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