Updated comments and implemented basic log filtering
Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<manifest package="com.RickBarrette.osj.forum"
|
||||
android:versionCode="170"
|
||||
android:versionCode="178"
|
||||
android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
|
||||
|
||||
<uses-sdk
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
<string name="title_topic_list">Topics</string>
|
||||
<string name="title_forum_detail">Forum Detail</string>
|
||||
<string name="title_forum_list">Forums</string>
|
||||
<string name="server">http://rickbarrette.org/forum/mobiquo/mobiquo.php</string>
|
||||
<string name="test_server">http://rickbarrette.org/forum/mobiquo/mobiquo.php</string>
|
||||
<string name="title">Title</string>
|
||||
<string name="description">Decription</string>
|
||||
<string name="post">Post</string>
|
||||
<string name="user">User</string>
|
||||
<string name="latest_post">Lastest Post</string>
|
||||
<string name="new_posts">New Posts</string>
|
||||
<string name="username">test</string>
|
||||
<string name="password">Test1</string>
|
||||
<string name="test_username">test</string>
|
||||
<string name="test_password">Test1</string>
|
||||
<string name="osj_server">https://oceanstatejeepsters.ipower.com</string>
|
||||
</resources>
|
||||
@@ -19,10 +19,6 @@
|
||||
*/
|
||||
package com.RickBarrette.osj.forum;
|
||||
|
||||
import org.xmlrpc.android.XMLRPCClient;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* This class will be used to house the constraints of this application
|
||||
* @author ricky barrette
|
||||
@@ -30,12 +26,37 @@ import android.content.Context;
|
||||
public class Constraints {
|
||||
|
||||
/**
|
||||
* Creates an XML RPC Client
|
||||
* @param Context
|
||||
* @return
|
||||
* @author ricky barrette
|
||||
* Set this boolean to true to use the test server
|
||||
*/
|
||||
public static XMLRPCClient getClient(Context context) {
|
||||
return new XMLRPCClient(context.getString(R.string.server), context.getString(R.string.username), context.getString(R.string.password));
|
||||
}
|
||||
public static final boolean TESTING = true;
|
||||
|
||||
/**
|
||||
* Set this boolean to true to enable debug logging
|
||||
*/
|
||||
public static final boolean DEBUG = true;
|
||||
|
||||
/**
|
||||
* Set this boolean to true to enable error logging
|
||||
*/
|
||||
public static final boolean ERROR = true;
|
||||
|
||||
/**
|
||||
* Set this boolean to true to enable info logging
|
||||
*/
|
||||
public static final boolean INFO = true;
|
||||
|
||||
/**
|
||||
* Set this boolean to true to enable verbose logging
|
||||
*/
|
||||
public static final boolean VERBOSE = true;
|
||||
|
||||
/**
|
||||
* Set this boolean to true to enable warning logging
|
||||
*/
|
||||
public static final boolean WARNING = true;
|
||||
|
||||
/**
|
||||
* Set this boolean to true to enable wtf logging
|
||||
*/
|
||||
public static final boolean WTF = true;
|
||||
}
|
||||
165
OSJ Forum/src/com/RickBarrette/osj/forum/Log.java
Normal file
165
OSJ Forum/src/com/RickBarrette/osj/forum/Log.java
Normal file
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* Log.java
|
||||
* @date Sep 14, 2012
|
||||
* @author ricky barrette
|
||||
*
|
||||
* Copyright 2012 Richard Barrette
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
*/
|
||||
package com.RickBarrette.osj.forum;
|
||||
|
||||
/**
|
||||
* A convince class for logging with log level constraints
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public class Log {
|
||||
|
||||
/**
|
||||
* Send a DEBUG log message
|
||||
* @param tag
|
||||
* @param log
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static void d(String tag, String log){
|
||||
if(Constraints.DEBUG)
|
||||
android.util.Log.d(tag, log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a DEBUG log message and log the exception.
|
||||
* @param tag
|
||||
* @param log
|
||||
* @param e
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static void d(String tag, String log, Throwable e){
|
||||
if(Constraints.DEBUG)
|
||||
android.util.Log.d(tag, log, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a ERROR log message
|
||||
* @param tag
|
||||
* @param log
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static void e(String tag, String log){
|
||||
if(Constraints.ERROR)
|
||||
android.util.Log.e(tag, log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a ERROR log message and log the exception.
|
||||
* @param tag
|
||||
* @param log
|
||||
* @param e
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static void e(String tag, String log, Throwable e){
|
||||
if(Constraints.ERROR)
|
||||
android.util.Log.e(tag, log, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a INFO log message
|
||||
* @param tag
|
||||
* @param log
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static void i(String tag, String log){
|
||||
if(Constraints.INFO)
|
||||
android.util.Log.i(tag, log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a INFO log message and log the exception.
|
||||
* @param tag
|
||||
* @param log
|
||||
* @param e
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static void i(String tag, String log, Throwable e){
|
||||
if(Constraints.INFO)
|
||||
android.util.Log.i(tag, log, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a VERBOSE log message
|
||||
* @param tag
|
||||
* @param log
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static void v(String tag, String log){
|
||||
if(Constraints.VERBOSE)
|
||||
android.util.Log.v(tag, log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a VERBOSE log message and log the exception.
|
||||
* @param tag
|
||||
* @param log
|
||||
* @param e
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static void v(String tag, String log, Throwable e){
|
||||
if(Constraints.VERBOSE)
|
||||
android.util.Log.v(tag, log, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a WARNING log message
|
||||
* @param tag
|
||||
* @param log
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static void w(String tag, String log){
|
||||
if(Constraints.WARNING)
|
||||
android.util.Log.w(tag, log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a WARNING log message and log the exception.
|
||||
* @param tag
|
||||
* @param log
|
||||
* @param e
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static void w(String tag, String log, Throwable e){
|
||||
if(Constraints.WARNING)
|
||||
android.util.Log.w(tag, log, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a WTF log message
|
||||
* @param tag
|
||||
* @param log
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static void wtf(String tag, String log){
|
||||
if(Constraints.WTF)
|
||||
android.util.Log.wtf(tag, log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a WTF log message and log the exception.
|
||||
* @param tag
|
||||
* @param log
|
||||
* @param e
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static void wtf(String tag, String log, Throwable e){
|
||||
if(Constraints.WTF)
|
||||
android.util.Log.wtf(tag, log, e);
|
||||
}
|
||||
}
|
||||
@@ -28,12 +28,11 @@ import org.xmlrpc.android.XMLRPCClient;
|
||||
import org.xmlrpc.android.XMLRPCException;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.RickBarrette.osj.forum.R;
|
||||
import com.RickBarrette.osj.forum.Log;
|
||||
|
||||
/**
|
||||
* This class is used to maintian the forum's content data
|
||||
* This class is used to maintain an instance of a forum's content data
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public class ForumContent {
|
||||
@@ -59,7 +58,7 @@ public class ForumContent {
|
||||
this.content = content;
|
||||
|
||||
for(Object key: content.keySet())
|
||||
Log.d(TAG, key.toString());
|
||||
Log.v(TAG, key.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +102,7 @@ public class ForumContent {
|
||||
ITEMS.clear();
|
||||
ITEM_MAP.clear();
|
||||
|
||||
final XMLRPCClient client = new XMLRPCClient((context.getString(R.string.server)));
|
||||
final XMLRPCClient client = XMLRPCClient.getClient(context);
|
||||
|
||||
Object[] result = null;
|
||||
try {
|
||||
|
||||
@@ -22,7 +22,6 @@ package com.RickBarrette.osj.forum.content;
|
||||
import java.util.HashMap;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -33,7 +32,7 @@ import android.widget.TextView;
|
||||
import com.RickBarrette.osj.forum.R;
|
||||
|
||||
/**
|
||||
*
|
||||
* This adapter will be used to populte a list view with post from a thread
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public class ThreadAdapter extends BaseAdapter {
|
||||
@@ -45,13 +44,10 @@ public class ThreadAdapter extends BaseAdapter {
|
||||
QuickContactBadge badage;
|
||||
}
|
||||
|
||||
private static final String TAG = "TopicAdapter";
|
||||
|
||||
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates a new ThreadAdapter
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public ThreadAdapter(Context context) {
|
||||
@@ -132,8 +128,6 @@ public class ThreadAdapter extends BaseAdapter {
|
||||
holder.user.setText(new String((byte[]) getItem(position).get("post_author_name")));
|
||||
holder.post.setText(new String((byte[]) getItem(position).get("post_content")));
|
||||
|
||||
for (Object key : getItem(position).keySet())
|
||||
Log.d(TAG, key.toString());
|
||||
return convertView;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,11 @@ import org.xmlrpc.android.XMLRPCClient;
|
||||
import org.xmlrpc.android.XMLRPCException;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.RickBarrette.osj.forum.Constraints;
|
||||
import com.RickBarrette.osj.forum.Log;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is used to maintain an instance of a thread's data content
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public class ThreadContent {
|
||||
@@ -43,7 +42,7 @@ public class ThreadContent {
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static class ThreadItem {
|
||||
private static final String TAG = "TopicItem";
|
||||
private static final String TAG = "ThreadItem";
|
||||
public String id;
|
||||
public HashMap<?, ?> content;
|
||||
|
||||
@@ -58,7 +57,7 @@ public class ThreadContent {
|
||||
this.content = content;
|
||||
|
||||
for(Object key: content.keySet())
|
||||
Log.d(TAG, key.toString());
|
||||
Log.v(TAG, key.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +83,7 @@ public class ThreadContent {
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static void getThread(String topicId, int startNumber, int lastNumber, final Context context){
|
||||
final XMLRPCClient client = Constraints.getClient(context);
|
||||
final XMLRPCClient client = XMLRPCClient.getClient(context);
|
||||
|
||||
ITEMS.clear();
|
||||
ITEM_MAP.clear();
|
||||
|
||||
@@ -22,7 +22,6 @@ package com.RickBarrette.osj.forum.content;
|
||||
import java.util.HashMap;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -46,8 +45,6 @@ public class TopicAdapter extends BaseAdapter {
|
||||
QuickContactBadge badage;
|
||||
}
|
||||
|
||||
private static final String TAG = "TopicAdapter";
|
||||
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
/**
|
||||
@@ -130,8 +127,6 @@ public class TopicAdapter extends BaseAdapter {
|
||||
holder.lastestPost.setText(new String((byte[]) getItem(position).get("short_content")));
|
||||
holder.newPosts.setVisibility(((Boolean) getItem(position).get("new_post") ? View.VISIBLE : View.GONE));
|
||||
|
||||
for(Object key: getItem(position).keySet())
|
||||
Log.d(TAG, key.toString());
|
||||
return convertView;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,11 @@ import org.xmlrpc.android.XMLRPCClient;
|
||||
import org.xmlrpc.android.XMLRPCException;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.RickBarrette.osj.forum.Constraints;
|
||||
import com.RickBarrette.osj.forum.Log;
|
||||
|
||||
/**
|
||||
* This class is used to maintain a topic's content data
|
||||
* This class is used to maintain an instance of a topic's content data
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public class TopicContent {
|
||||
@@ -58,7 +57,7 @@ public class TopicContent {
|
||||
this.content = content;
|
||||
|
||||
for(Object key: content.keySet())
|
||||
Log.d(TAG, key.toString());
|
||||
Log.v(TAG, key.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +81,7 @@ public class TopicContent {
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static void getTopics(String forumId, final Context context){
|
||||
final XMLRPCClient client = Constraints.getClient(context);
|
||||
final XMLRPCClient client = XMLRPCClient.getClient(context);
|
||||
|
||||
ITEMS.clear();
|
||||
ITEM_MAP.clear();
|
||||
|
||||
@@ -29,6 +29,11 @@ import org.apache.http.params.HttpProtocolParams;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.RickBarrette.osj.forum.Constraints;
|
||||
import com.RickBarrette.osj.forum.R;
|
||||
|
||||
/**
|
||||
* XMLRPCClient allows to call remote XMLRPC method.
|
||||
*
|
||||
@@ -420,4 +425,17 @@ public class XMLRPCClient extends XMLRPCCommon {
|
||||
public Object call(String method, Object... params) throws XMLRPCException {
|
||||
return callEx(method, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an XML RPC Client
|
||||
* @param Context
|
||||
* @return XMLRPCClient
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static XMLRPCClient getClient(Context context) {
|
||||
if(Constraints.TESTING)
|
||||
return new XMLRPCClient(context.getString(R.string.test_server), context.getString(R.string.test_username), context.getString(R.string.test_password));
|
||||
else
|
||||
return new XMLRPCClient(context.getString(R.string.osj_server), context.getString(R.string.test_username), context.getString(R.string.test_password));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user