@@ -1,5 +1,5 @@
|
||||
<manifest package="com.RickBarrette.osj.forum"
|
||||
android:versionCode="48"
|
||||
android:versionCode="49"
|
||||
android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
|
||||
|
||||
<uses-sdk
|
||||
|
||||
@@ -25,6 +25,10 @@ import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.view.MenuItem;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public class ForumDetailActivity extends FragmentActivity {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,10 @@ import android.support.v4.app.FragmentActivity;
|
||||
|
||||
import com.TwentyCodes.android.exception.ExceptionHandler;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public class ForumListActivity extends FragmentActivity implements ForumListFragment.Callbacks {
|
||||
|
||||
private boolean mTwoPane;
|
||||
|
||||
@@ -29,8 +29,11 @@ import android.widget.ListView;
|
||||
|
||||
import com.RickBarrette.osj.forum.content.ForumAdapter;
|
||||
import com.RickBarrette.osj.forum.content.ForumContent;
|
||||
import com.RickBarrette.osj.forum.dummy.DummyContent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public class ForumListFragment extends ListFragment {
|
||||
|
||||
public interface Callbacks {
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
*/
|
||||
package com.RickBarrette.osj.forum;
|
||||
|
||||
import android.R;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ListFragment;
|
||||
@@ -64,7 +63,7 @@ public class TopicListFragment extends ListFragment {
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setListAdapter(new ArrayAdapter<DummyContent.DummyItem>(getActivity(), R.layout.simple_list_item_activated_1, R.id.text1, DummyContent.ITEMS));
|
||||
setListAdapter(new ArrayAdapter<DummyContent.DummyItem>(getActivity(), android.R.layout.simple_list_item_activated_1, android.R.id.text1, DummyContent.ITEMS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,14 +42,15 @@ public class ForumAdapter extends BaseAdapter {
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates a new ForumAdapter
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public ForumAdapter(final Context context) {
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.widget.Adapter#getCount()
|
||||
*/
|
||||
@Override
|
||||
@@ -57,7 +58,8 @@ public class ForumAdapter extends BaseAdapter {
|
||||
return ForumContent.ITEMS.size();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.widget.Adapter#getItem(int)
|
||||
*/
|
||||
@Override
|
||||
@@ -65,7 +67,8 @@ public class ForumAdapter extends BaseAdapter {
|
||||
return ForumContent.ITEMS.get(position);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.widget.Adapter#getItemId(int)
|
||||
*/
|
||||
@Override
|
||||
@@ -73,7 +76,8 @@ public class ForumAdapter extends BaseAdapter {
|
||||
return position;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup)
|
||||
*/
|
||||
@Override
|
||||
@@ -112,4 +116,4 @@ public class ForumAdapter extends BaseAdapter {
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -32,30 +32,54 @@ import android.content.Context;
|
||||
import com.RickBarrette.osj.forum.R;
|
||||
|
||||
/**
|
||||
*
|
||||
* This
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public class ForumContent {
|
||||
|
||||
/**
|
||||
* This Forum Object
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static class ForumItem {
|
||||
|
||||
public String id;
|
||||
public HashMap<?, ?> content;
|
||||
|
||||
/**
|
||||
* Creates a new Forum Item
|
||||
* @param id
|
||||
* @param content
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public ForumItem(final String id, final HashMap<?, ?> content) {
|
||||
this.id = id;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this forum object
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return (String) content.get("forum_name");
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets all the categories and sub-forums
|
||||
* @return array of HashMap
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public Object[] getChildren(){
|
||||
return (Object[]) this.content.get("child");
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets all the topics for the current forum item
|
||||
* @param context
|
||||
* @return
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public Object[] getTopics(final Context context){
|
||||
final XMLRPCClient client = new XMLRPCClient((context.getString(R.string.server)));
|
||||
try {
|
||||
@@ -70,11 +94,21 @@ public class ForumContent {
|
||||
public static List<ForumItem> ITEMS = new ArrayList<ForumItem>();
|
||||
public static Map<String, ForumItem> ITEM_MAP = new HashMap<String, ForumItem>();
|
||||
|
||||
/**
|
||||
* Adds a new Forum Item to the list
|
||||
* @param item
|
||||
* @author ricky barrette
|
||||
*/
|
||||
private static void addItem(final ForumItem item) {
|
||||
ITEMS.add(item);
|
||||
ITEM_MAP.put(item.id, item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads the forum from the internet
|
||||
* @param context
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public static void getForum(Context context){
|
||||
final XMLRPCClient client = new XMLRPCClient((context.getString(R.string.server)));
|
||||
|
||||
@@ -88,7 +122,7 @@ public class ForumContent {
|
||||
if(result!= null){
|
||||
for(int i = 0; i < result.length; i++){
|
||||
HashMap<?, ?> contentHash = (HashMap<?, ?>) result[i];
|
||||
addItem(new ForumItem(new Integer(i).toString(), contentHash));
|
||||
addItem(new ForumItem(Integer.valueOf(i).toString(), contentHash));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import android.widget.TextView;
|
||||
import com.RickBarrette.osj.forum.R;
|
||||
|
||||
/**
|
||||
*
|
||||
* This adapter will be used to display sub-forums to the user
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public class SubForumAdapter extends BaseAdapter {
|
||||
@@ -52,7 +52,8 @@ public class SubForumAdapter extends BaseAdapter {
|
||||
mSubForums = ForumContent.ITEMS.get(position).getChildren();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.widget.Adapter#getCount()
|
||||
*/
|
||||
@Override
|
||||
@@ -63,7 +64,8 @@ public class SubForumAdapter extends BaseAdapter {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.widget.Adapter#getItem(int)
|
||||
*/
|
||||
@Override
|
||||
@@ -71,7 +73,8 @@ public class SubForumAdapter extends BaseAdapter {
|
||||
return (HashMap<?,?>) mSubForums[position];
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.widget.Adapter#getItemId(int)
|
||||
*/
|
||||
@Override
|
||||
@@ -79,7 +82,8 @@ public class SubForumAdapter extends BaseAdapter {
|
||||
return position;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup)
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -52,7 +52,8 @@ public class TopicAdapter extends BaseAdapter {
|
||||
mTopics = topics;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.widget.Adapter#getCount()
|
||||
*/
|
||||
@Override
|
||||
@@ -63,7 +64,8 @@ public class TopicAdapter extends BaseAdapter {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.widget.Adapter#getItem(int)
|
||||
*/
|
||||
@Override
|
||||
@@ -71,7 +73,8 @@ public class TopicAdapter extends BaseAdapter {
|
||||
return (HashMap<?,?>) mTopics[position];
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.widget.Adapter#getItemId(int)
|
||||
*/
|
||||
@Override
|
||||
@@ -79,7 +82,8 @@ public class TopicAdapter extends BaseAdapter {
|
||||
return position;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup)
|
||||
*/
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user