android-ibc-forum

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit ef64447a860b1db32b5decff71038733ed89f74e
parent fc35375232a80641b650537a7368e76afa579ad6
Author: Jan Dankert <devnull@localhost>
Date:   Wed, 25 Jan 2012 22:41:28 +0100

Für die Forenübersicht einen ausklappbare Listview benutzen (ExpandableListView).

Diffstat:
res/layout/exp_listing.xml | 18++++++++++++++++++
res/layout/rss_item.xml | 20++++++++++++++++++++
res/menu/main.xml | 27+++++++++++++++++++++++++++
res/values/strings.xml | 42+++++++++++++++++++++++++++---------------
src/de/mtbnews/android/ForumOverviewActivity.java | 292-------------------------------------------------------------------------------
src/de/mtbnews/android/IBCActivity.java | 46+++++++++++++++++++++++++++++++++++++++++++++-
src/de/mtbnews/android/adapter/ExpandableForumContentAdapter.java | 152+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/de/mtbnews/android/adapter/MapContentAdapter.java | 10+++++++---
src/de/mtbnews/android/adapter/MapExpandableContentAdapter.java | 114-------------------------------------------------------------------------------
src/de/mtbnews/android/tapatalk/TapatalkClient.java | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
src/de/mtbnews/android/tapatalk/wrapper/Forum.java | 4++++
11 files changed, 351 insertions(+), 425 deletions(-)

diff --git a/res/layout/exp_listing.xml b/res/layout/exp_listing.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" android:layout_height="wrap_content" + android:orientation="vertical"> + + <ImageView android:id="@+id/listimage" android:layout_width="wrap_content" + android:layout_height="wrap_content" android:visibility="invisible" /> + + <TextView android:id="@+id/listtitle" android:textSize="14sp" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:visibility="invisible" /> + + <ExpandableListView android:id="@id/android:list" android:textSize="25sp" + android:layout_width="fill_parent" android:layout_height="wrap_content"> + </ExpandableListView> + + +</LinearLayout> diff --git a/res/layout/rss_item.xml b/res/layout/rss_item.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" android:layout_width="fill_parent" + android:layout_height="wrap_content" android:layout_margin="8sp" + android:padding="5sp" style="@style/textbox"> + + + <TextView android:layout_width="wrap_content" + android:layout_height="wrap_content" android:id="@+id/item_date" + style="@style/normalText"></TextView> + + <TextView android:text="@+id/TextView03" android:layout_width="fill_parent" + android:layout_height="wrap_content" android:id="@+id/item_title" + style="@style/titleText"></TextView> + + <TextView android:text="@+id/TextView01" android:layout_width="wrap_content" + android:layout_height="wrap_content" android:id="@+id/item_description" + style="@style/normalText"></TextView> +</LinearLayout> diff --git a/res/menu/main.xml b/res/menu/main.xml @@ -1,5 +1,32 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:id="@+id/menu_preferences" android:title="@string/preferences" android:icon="@android:drawable/ic_menu_preferences"></item> + + <item android:id="@+id/menu_links" android:title="@string/links" + android:icon="@android:drawable/ic_menu_info_details"> + <menu> + <item android:id="@+id/www_bikemarkt" android:title="@string/bikemarkt" + android:icon="@android:drawable/ic_menu_info_details"></item> + <item android:id="@+id/www_forum" android:title="@string/forum" + android:icon="@android:drawable/ic_menu_info_details"></item> + <item android:id="@+id/www_news" android:title="@string/news" + android:icon="@android:drawable/ic_menu_info_details"></item> + <item android:id="@+id/www_fotos" android:title="@string/photos" + android:icon="@android:drawable/ic_menu_info_details"></item> + <item android:id="@+id/www_shop" android:title="@string/shop" + android:icon="@android:drawable/ic_menu_info_details"></item> + <item android:id="@+id/www_gewichte" android:title="@string/gewichte" + android:icon="@android:drawable/ic_menu_info_details"></item> + <item android:id="@+id/www_lmb" android:title="@string/lmb" + android:icon="@android:drawable/ic_menu_info_details"></item> + <item android:id="@+id/www_biketest" android:title="@string/biketest" + android:icon="@android:drawable/ic_menu_info_details"></item> + <item android:id="@+id/www_video" android:title="@string/video" + android:icon="@android:drawable/ic_menu_info_details"></item> + <item android:id="@+id/www_blog" android:title="@string/blog" + android:icon="@android:drawable/ic_menu_info_details"></item> + </menu> + </item> </menu> \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - + <string name="sub_only">Forum enthält keine Themen</string> <string name="app_name">IBC</string> <string name="search_for_topics">Suche nach Themen</string> @@ -28,7 +28,7 @@ </string-array> <string name="writable">Schreibzugriff</string> <string name="version_summary">Server-Version</string> - + <string name="publish">Veröffentlichen</string> <string name="properties">Eigenschaften</string> <string name="loading">Warten auf Server</string> @@ -54,23 +54,26 @@ <string name="upload_file">Datei hochladen</string> <string name="upload_image">Bild hochladen</string> <string name="upload_ok">Hochladevorgang abgeschlossen</string> - <string name="upload_ok_long">Die Datei wurde erfolgreich auf den Server geladen</string> + <string name="upload_ok_long">Die Datei wurde erfolgreich auf den Server geladen + </string> <string name="upload_fail">Hochladevorgang fehlerhaft</string> - <string name="upload_fail_long">Die Datei konnte nicht auf den Server geladen werden</string> + <string name="upload_fail_long">Die Datei konnte nicht auf den Server geladen + werden</string> <string name="publish_long">Die Veröffentlichung wurde gestartet</string> <string name="publish_ok">Wurde veröffentlicht</string> <string name="publish_ok_long">Erfolgreich veröffentlicht</string> <string name="publish_fail">Veröffentlichung nicht erfolgreich</string> - <string name="publish_fail_long">Leider konnte die Datei nicht veröffentlicht werden</string> + <string name="publish_fail_long">Leider konnte die Datei nicht veröffentlicht werden + </string> <string name="delete">Löschen</string> <string name="name">Name</string> <string name="filename">Dateiname</string> <string name="template">Vorlage</string> <string name="save">Speichern</string> - - - - + + + + <string name="description">Inhalt</string> <string name="editor">Inhalt</string> <string name="error_timeout">Zeitablauf</string> @@ -88,7 +91,8 @@ <string name="databaseid_desc">Datenbank-Id aus der Server-Konfiguration</string> <string name="saved">Gespeichert</string> <string name="release">Freigeben</string> - <string name="noserver">Es ist noch kein Server konfiguriert. Über die Menütaste können Sie einen neuen Server anlegen.</string> + <string name="noserver">Es ist noch kein Server konfiguriert. Über die + Menütaste können Sie einen neuen Server anlegen.</string> <string name="nousername">Es ist noch kein Benutzername konfiguriert</string> <string name="www">Zur Webseite</string> <string name="scroll_down">Immer an das Ende scrollen</string> @@ -103,9 +107,17 @@ <item>20</item> <item>50</item> </string-array> - - -<string name="forum">Forum</string> -<string name="news">News</string> -<string name="photos">Fotos</string> + + + <string name="forum">Forum</string> + <string name="news">News</string> + <string name="photos">Fotos</string> + <string name="bikemarkt">Bikemarkt</string> + <string name="shop">Shopping</string> + <string name="gewichte">Gewichte</string> + <string name="lmb">Fahrgemeinschaften</string> + <string name="biketest">Biketest</string> + <string name="video">Videos</string> + <string name="blog">Blog</string> + <string name="links">Links</string> </resources> diff --git a/src/de/mtbnews/android/ForumOverviewActivity.java b/src/de/mtbnews/android/ForumOverviewActivity.java @@ -1,292 +0,0 @@ -/** - * - */ -package de.mtbnews.android; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.xmlrpc.android.XMLRPCClient; -import org.xmlrpc.android.XMLRPCException; - -import android.app.ExpandableListActivity; -import android.app.ListActivity; -import android.content.Intent; -import android.content.SharedPreferences; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.text.TextUtils; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.widget.AdapterView; -import android.widget.ExpandableListView; -import android.widget.ListAdapter; -import android.widget.ListView; -import android.widget.Toast; -import android.widget.AdapterView.OnItemClickListener; -import de.mtbnews.android.adapter.MapContentAdapter; -import de.mtbnews.android.tapatalk.TapatalkClient; -import de.mtbnews.android.tapatalk.TapatalkException; -import de.mtbnews.android.util.AppData; -import de.mtbnews.android.util.IBC; -import de.mtbnews.android.util.ServerAsyncTask; - -/** - * @author dankert - * - */ -public class ForumOverviewActivity extends ListActivity -{ - private SharedPreferences prefs; - - private List<Map<String, Object>> list; - - @Override - protected void onCreate(Bundle savedInstanceState) - { - if (AppData.client == null) - AppData.client = new TapatalkClient(IBC.IBC_FORUM_CONNECTOR_URL); - - super.onCreate(savedInstanceState); - - setContentView(R.layout.listing); - - prefs = PreferenceManager.getDefaultSharedPreferences(this); - - if (prefs.getBoolean("auto_login", false)) - { - login(); - } - - loadForum(); - } - - private void login() - { - final TapatalkClient client = AppData.client; - new ServerAsyncTask(this, R.string.waitingfor_login) - { - - @Override - protected void callServer() throws IOException - { - - // add 2 to 4 - - try - { - Map<String, Object> map = client.login(prefs.getString( - "username", ""), prefs.getString("password", "")); - - } - catch (TapatalkException e) - { - e.printStackTrace(); - throw new RuntimeException(e); - } - - } - - }.execute(); - } - - private void loadForum() - { - final XMLRPCClient client = AppData.client.getXMLRPCClient(); - - new ServerAsyncTask(this, R.string.waitingfor_forum) - { - - private Object[] forumList; - - @Override - protected void callServer() throws IOException - { - - try - { - Object l = client.call("get_forum"); - - this.forumList = (Object[]) l; - } - catch (XMLRPCException e) - { - e.printStackTrace(); - throw new RuntimeException(e); - } - - } - - protected void doOnSuccess() - { - list = flattenArrayMap(this.forumList, "child"); - - ListAdapter adapter = new MapContentAdapter( - ForumOverviewActivity.this, list, null, "forum_name", - "description"); - // IBCActivity.this.setTitle(feed.getTitle()); - setListAdapter(adapter); - - } - - }.execute(); - final ListView list = getListView(); - - list.setOnItemClickListener(new OnItemClickListener() - { - - @Override - public void onItemClick(AdapterView<?> parent, View view, - int position, long id) - { - - Map<String, Object> map = ForumOverviewActivity.this.list - .get(position); - - boolean subOnly = (Boolean) map.get("sub_only"); - if (subOnly) - { - Toast.makeText(ForumOverviewActivity.this, - R.string.sub_only, Toast.LENGTH_SHORT).show(); - } - else - { - final Intent intent = new Intent( - ForumOverviewActivity.this, ForumActivity.class); - intent.putExtra("forum_id", (String) map.get("forum_id")); - startActivity(intent); - } - } - }); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) - { - super.onCreateOptionsMenu(menu); - MenuInflater mi = new MenuInflater(getApplication()); - mi.inflate(R.menu.forum, menu); - - return true; - } - - /** - * {@inheritDoc} - * - * @see android.app.Activity#onSearchRequested() - */ - @Override - public boolean onSearchRequested() - { - return super.onSearchRequested(); - } - - public boolean onOptionsItemSelected(MenuItem item) - { - switch (item.getItemId()) - { - case R.id.menu_mailbox: - startActivity(new Intent(this, MailboxActivity.class)); - return true; - - case R.id.menu_participated_topics: - Intent intent = new Intent(this, ForumActivity.class); - intent.putExtra("participated", true); - startActivity(intent); - return true; - - case R.id.menu_latest_topics: - Intent intent2 = new Intent(this, ForumActivity.class); - intent2.putExtra("latest", true); - startActivity(intent2); - return true; - case R.id.menu_unread_topics: - Intent intent3 = new Intent(this, ForumActivity.class); - intent3.putExtra("unread", true); - startActivity(intent3); - return true; - - case R.id.menu_logout: - logout(); - return true; - - case R.id.menu_login: - - if (TextUtils.isEmpty(prefs.getString("username", ""))) - { - Toast.makeText(this,R.string.nousername,Toast.LENGTH_LONG).show(); - - Intent intent4 = new Intent(this, Configuration.class); - startActivity(intent4); - } - // Evtl. gibt es jetzt einen Benutzernamen ... - - if (!TextUtils.isEmpty(prefs.getString("username", ""))) - { - login(); - } - else { - Toast.makeText(this,R.string.nousername,Toast.LENGTH_LONG).show(); - } - - - return true; - } - return false; - } - - private List<Map<String, Object>> flattenArrayMap(Object[] objects, - String childName) - { - - List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); - - for (Object object : objects) - { - Map map = (Map) object; - list.add(map); - - if (map.containsKey(childName)) - { - list.addAll(flattenArrayMap((Object[]) map.get(childName), - childName)); - } - } - return list; - - } - - - private void logout() - { - final TapatalkClient client = AppData.client; - - new ServerAsyncTask(this, R.string.waitingfor_logout) - { - - @Override - protected synchronized void callServer() throws IOException - { - - try - { - client.logout(); - - } - catch (TapatalkException e) - { - e.printStackTrace(); - throw new RuntimeException(e); - } - - } - - }.executeSynchronized(); - } - - -} diff --git a/src/de/mtbnews/android/IBCActivity.java b/src/de/mtbnews/android/IBCActivity.java @@ -19,6 +19,7 @@ package de.mtbnews.android; import java.io.IOException; +import java.net.URI; import org.apache.http.client.ClientProtocolException; import org.mcsoxford.rss.RSSFeed; @@ -29,6 +30,7 @@ import android.app.AlertDialog; import android.app.ListActivity; import android.content.Intent; import android.content.SharedPreferences; +import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; import android.view.Menu; @@ -78,7 +80,8 @@ public class IBCActivity extends ListActivity @Override public void onClick(View v) { - startActivity(new Intent(IBCActivity.this, ForumOverviewActivity.class)); + startActivity(new Intent(IBCActivity.this, + ForumOverviewActivity.class)); } }); @@ -172,6 +175,47 @@ public class IBCActivity extends ListActivity startActivity(new Intent(this, Configuration.class)); return true; + case R.id.www_bikemarkt: + startActivity(new Intent(Intent.ACTION_VIEW, Uri + .parse("http://bikemarkt.mtb-news.de/bikemarkt/"))); + return true; + case R.id.www_biketest: + startActivity(new Intent(Intent.ACTION_VIEW, Uri + .parse("http://www.mtb-news.de/biketest/"))); + return true; + case R.id.www_blog: + startActivity(new Intent(Intent.ACTION_VIEW, Uri + .parse("http://schaltwerk.mtb-news.de/"))); + return true; + case R.id.www_forum: + startActivity(new Intent(Intent.ACTION_VIEW, Uri + .parse("http://www.mtb-news.de/forum/"))); + return true; + case R.id.www_fotos: + startActivity(new Intent(Intent.ACTION_VIEW, Uri + .parse("http://fotos.mtb-news.de/"))); + return true; + case R.id.www_gewichte: + startActivity(new Intent(Intent.ACTION_VIEW, Uri + .parse("http://gewichte.mtb-news.de/"))); + return true; + case R.id.www_lmb: + startActivity(new Intent(Intent.ACTION_VIEW, Uri + .parse("http://www.mtb-news.de/lmb/"))); + return true; + case R.id.www_news: + startActivity(new Intent(Intent.ACTION_VIEW, Uri + .parse("http://www.mtb-news.de/"))); + return true; + case R.id.www_shop: + startActivity(new Intent(Intent.ACTION_VIEW, Uri + .parse("http://shop.mtb-news.de/"))); + return true; + case R.id.www_video: + startActivity(new Intent(Intent.ACTION_VIEW, Uri + .parse("http://videos.mtb-news.de/"))); + return true; + } return false; } diff --git a/src/de/mtbnews/android/adapter/ExpandableForumContentAdapter.java b/src/de/mtbnews/android/adapter/ExpandableForumContentAdapter.java @@ -0,0 +1,152 @@ +/** + * + */ +package de.mtbnews.android.adapter; + +import java.util.List; + +import android.content.Context; +import android.graphics.Color; +import android.opengl.Visibility; +import android.util.Log; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseExpandableListAdapter; +import android.widget.TextView; +import de.mtbnews.android.R; +import de.mtbnews.android.tapatalk.wrapper.Forum; + +/** + * @author dankert + * + */ +public class ExpandableForumContentAdapter extends BaseExpandableListAdapter +{ + + private static final int IBC_GELB = Color.parseColor("#FFCC66"); + + /** Remember our context so we can use it when constructing views. */ + private Context mContext; + + /** + * Hold onto a copy of the entire Contact List. + */ + + private LayoutInflater inflator; + private List<Forum> forumList; + + public ExpandableForumContentAdapter(Context context, List<Forum> forumList) + { + mContext = context; + inflator = (LayoutInflater) context + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + + this.forumList = forumList; + Log.d("IBC", "" + this.forumList.size()); + Log.d("IBC", this.forumList.toString()); + } + + @Override + public Object getChild(int arg0, int arg1) + { + Forum e = forumList.get(arg0).subForen.get(arg1); + return e; + } + + @Override + public long getChildId(int groupPosition, int childPosition) + { + return childPosition; + } + + @Override + public View getChildView(int groupPosition, int childPosition, + boolean isLastChild, View convertView, ViewGroup parent) + { + Forum e = forumList.get(groupPosition).subForen.get(childPosition); + + final View view = inflator.inflate(R.layout.rss_item, null); + + TextView datum = (TextView) view.findViewById(R.id.item_date); + datum.setVisibility(View.INVISIBLE); + + TextView name = (TextView) view.findViewById(R.id.item_title); + name.setText(e.getTitle()); + + TextView desc = (TextView) view.findViewById(R.id.item_description); + + desc.setText(e.getContent()); + + return view; + } + + @Override + public int getChildrenCount(int groupPosition) + { + return forumList.get(groupPosition).subForen.size(); + } + + @Override + public Object getGroup(int groupPosition) + { + return forumList.get(groupPosition); + } + + @Override + public int getGroupCount() + { + return forumList.size(); + } + + @Override + public long getGroupId(int groupPosition) + { + // TODO Auto-generated method stub + return groupPosition; + } + + @Override + public View getGroupView(int groupPosition, boolean isExpanded, + View convertView, ViewGroup parent) + { + Forum e = forumList.get(groupPosition); + + final View view = inflator.inflate(R.layout.rss_item, null); + view.setBackgroundColor(IBC_GELB); + + TextView datum = (TextView) view.findViewById(R.id.item_date); + datum.setVisibility(View.INVISIBLE); + + TextView name = (TextView) view.findViewById(R.id.item_title); + name.setGravity( Gravity.CENTER); + name.setBackgroundColor(IBC_GELB); + name.setText(e.getTitle()); + + TextView desc = (TextView) view.findViewById(R.id.item_description); + desc.setVisibility(View.INVISIBLE); + // desc.setText(e.getContent()); + + return view; + } + + @Override + public boolean hasStableIds() + { + return true; + } + + @Override + public boolean isChildSelectable(int groupPosition, int childPosition) + { + return true; + } + + @Override + public boolean areAllItemsEnabled() + { + return true; + } + +} diff --git a/src/de/mtbnews/android/adapter/MapContentAdapter.java b/src/de/mtbnews/android/adapter/MapContentAdapter.java @@ -19,8 +19,9 @@ import de.mtbnews.android.R; /** * @author dankert - * + * @Deprecated use ListEntryContentAdapter */ +@Deprecated public class MapContentAdapter extends BaseAdapter { @@ -129,10 +130,13 @@ public class MapContentAdapter extends BaseAdapter { if (e.get(descriptionKey) != null) - viewHolder.desc.setText(new String((byte[]) e.get(descriptionKey))); + viewHolder.desc.setText(new String((byte[]) e + .get(descriptionKey))); else viewHolder.desc.setText(""); - } else { + } + else + { viewHolder.desc.setText(""); } diff --git a/src/de/mtbnews/android/adapter/MapExpandableContentAdapter.java b/src/de/mtbnews/android/adapter/MapExpandableContentAdapter.java @@ -1,114 +0,0 @@ -/** - * - */ -package de.mtbnews.android.adapter; - -import java.util.List; -import java.util.Map; - -import org.mcsoxford.rss.RSSItem; - -import android.content.Context; -import android.text.format.DateFormat; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.TextView; -import de.mtbnews.android.R; - -/** - * @author dankert - * - */ -public class MapExpandableContentAdapter extends BaseAdapter -{ - - /** Remember our context so we can use it when constructing views. */ - private Context mContext; - - /** - * Hold onto a copy of the entire Contact List. - */ - - private LayoutInflater inflator; - - private String dateKey; - private String titleKey; - private String descriptionKey; - - private List<Map<String, Object>> map; - - public MapExpandableContentAdapter(Context context, List<Map<String, Object>> map, - String dateKey, String titleKey, String descriptionKey) - { - mContext = context; - inflator = (LayoutInflater) context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - this.map = map; - this.dateKey = dateKey; - this.titleKey = titleKey; - this.descriptionKey = descriptionKey; - } - - public int getCount() - { - return map.size(); - } - - public Object getItem(int position) - { - return map.get(position); - } - - /** Use the array index as a unique id. */ - public long getItemId(int position) - { - return position; - - } - - /** - * @param convertView - * The old view to overwrite, if one is passed - * @returns a ContactEntryView that holds wraps around an ContactEntry - */ - public View getView(int position, View convertView, ViewGroup parent) - { - - Map<String, Object> e = map.get(position); - - final View view = inflator.inflate(R.layout.rss_item, null); - - if (dateKey != null) - { - TextView datum = (TextView) view.findViewById(R.id.item_date); - datum.setText(DateFormat.getDateFormat(parent.getContext()).format( - e.get(dateKey)) - + " " - + DateFormat.getTimeFormat(parent.getContext()).format( - e.get(dateKey))); - } - - if (titleKey != null) - { - - TextView name = (TextView) view.findViewById(R.id.item_title); - name.setText(new String((byte[]) e.get(titleKey))); - } - - if (descriptionKey != null) - { - TextView desc = (TextView) view.findViewById(R.id.item_description); - - if (e.get(descriptionKey) != null) - desc.setText(new String((byte[]) e.get(descriptionKey)) - + " ..."); - else - desc.setText(""); - } - - return view; - } - -} diff --git a/src/de/mtbnews/android/tapatalk/TapatalkClient.java b/src/de/mtbnews/android/tapatalk/TapatalkClient.java @@ -118,6 +118,35 @@ public class TapatalkClient } } + public List<Forum> getAllForum() throws TapatalkException + { + try + { + Object l = client.call("get_forum"); + Object[] arr = (Object[]) l; + Map[] mapArr = castToMapArray(arr); + + List<Forum> forum = createSubForen(mapArr, "child"); + + return forum; + } + catch (XMLRPCException e) + { + throw new TapatalkException("Could not load Forum structure", e); + } + } + + private Map[] castToMapArray(Object[] arr) + { + Map[] mapArr = new Map[arr.length]; + int i = 0; + for (Object object : arr) + { + mapArr[i] = (Map) arr[i++]; + } + return mapArr; + } + @SuppressWarnings("unchecked") public Forum getForum(String forumId) throws TapatalkException { @@ -314,4 +343,26 @@ public class TapatalkClient return map; } + private List<Forum> createSubForen(Map[] mapArray, String childName) + { + + final List<Forum> list = new ArrayList<Forum>(); + + for (Map map : mapArray) + { + String name = byteArrayToString(map.get("forum_name")); + String content = byteArrayToString(map.get("description")); + String id = (String) map.get("forum_id"); + Forum forum = new Forum(id, new ArrayList<Topic>(), name, null, + content); + list.add(forum); + forum.subOnly = (Boolean) map.get("sub_only"); + if (map.containsKey(childName)) + forum.subForen = createSubForen(castToMapArray((Object[])map.get(childName)), + childName); + } + return list; + + } + } diff --git a/src/de/mtbnews/android/tapatalk/wrapper/Forum.java b/src/de/mtbnews/android/tapatalk/wrapper/Forum.java @@ -13,6 +13,10 @@ public class Forum implements ListEntry private String title; private Date date; private String content; + + public List<Forum> subForen; + public boolean subOnly; + /** * @param id