android-ibc-forum

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

commit 8d95d1d4602fed9f320fc7616b693caf3cd5ed3d
parent 072a57c297baaee76019ff48c65de5ddd2570972
Author: Jan Dankert <devnull@localhost>
Date:   Sun, 14 Oct 2012 12:17:00 +0200

Maximale Zeilenlänge von 80 auf 140 Zeichen erhöht.

Diffstat:
src/BBCodeTest.java | 3+--
src/de/mtbnews/android/Configuration.java | 44+++++++++++++++++---------------------------
src/de/mtbnews/android/CreateTopicActivity.java | 23+++++++++--------------
src/de/mtbnews/android/EndlessListActivity.java | 38+++++++++++++-------------------------
src/de/mtbnews/android/ForumActivity.java | 131++++++++++++++++++++++++++++++-------------------------------------------------
src/de/mtbnews/android/ForumOverviewActivity.java | 71++++++++++++++++++++++++-----------------------------------------------
src/de/mtbnews/android/IBCActivity.java | 57++++++++++++++++++---------------------------------------
src/de/mtbnews/android/IBCApplication.java | 18++++++------------
src/de/mtbnews/android/MailActivity.java | 47+++++++++++++++++------------------------------
src/de/mtbnews/android/MailboxActivity.java | 41++++++++++++++---------------------------
src/de/mtbnews/android/MessageActivity.java | 13+++++--------
src/de/mtbnews/android/NewsDetailActivity.java | 12++++--------
src/de/mtbnews/android/PhotoActivity.java | 6++----
src/de/mtbnews/android/ReplyMailActivity.java | 26+++++++++-----------------
src/de/mtbnews/android/ReplyPostActivity.java | 18++++++------------
src/de/mtbnews/android/SearchActivity.java | 40++++++++++++++--------------------------
src/de/mtbnews/android/SubscriptionForenActivity.java | 41++++++++++++++---------------------------
src/de/mtbnews/android/SubscriptionTopicsActivity.java | 48++++++++++++++++++------------------------------
src/de/mtbnews/android/TopicActivity.java | 70+++++++++++++++++++++++++++-------------------------------------------
src/de/mtbnews/android/adapter/BBCodeConverter.java | 41+++++++++++++----------------------------
src/de/mtbnews/android/adapter/ExpandableForumContentAdapter.java | 10++++------
src/de/mtbnews/android/adapter/ListEntryContentAdapter.java | 36++++++++++++------------------------
src/de/mtbnews/android/adapter/RSSContentAdapter.java | 10+++-------
src/de/mtbnews/android/receiver/NetworkStateReceiver.java | 6++----
src/de/mtbnews/android/service/SubscriptionService.java | 120++++++++++++++++++++++++++++++-------------------------------------------------
src/de/mtbnews/android/tapatalk/TapatalkClient.java | 194+++++++++++++++++++++++++++++--------------------------------------------------
src/de/mtbnews/android/tapatalk/TapatalkException.java | 3+--
src/de/mtbnews/android/tapatalk/wrapper/Forum.java | 5++---
src/de/mtbnews/android/tapatalk/wrapper/ListEntry.java | 4++--
src/de/mtbnews/android/tapatalk/wrapper/ListHolder.java | 2+-
src/de/mtbnews/android/tapatalk/wrapper/Message.java | 4+---
src/de/mtbnews/android/tapatalk/wrapper/Post.java | 1-
src/de/mtbnews/android/tapatalk/wrapper/Topic.java | 5++---
src/de/mtbnews/android/util/IBCException.java | 9+++++----
src/de/mtbnews/android/util/ServerAsyncTask.java | 29++++++++++++-----------------
src/de/mtbnews/android/util/Utils.java | 3+--
36 files changed, 444 insertions(+), 785 deletions(-)

diff --git a/src/BBCodeTest.java b/src/BBCodeTest.java @@ -33,7 +33,7 @@ public class BBCodeTest extends TestCase String in = "[url]http://example.com/image.png[/url]."; String out = "<a href=\"http://example.com/image.png\">http://example.com/image.png</a>."; testInOut(in, out); - + in = "[url=http://example.com/image.png]haha[/url]."; out = "<a href=\"http://example.com/image.png\">haha</a>."; testInOut(in, out); @@ -47,7 +47,6 @@ public class BBCodeTest extends TestCase testInOut(in, out); } - private void testInOut(String in, String out) throws Exception { BBCodeConverter bbCodeConverter = new BBCodeConverter(); diff --git a/src/de/mtbnews/android/Configuration.java b/src/de/mtbnews/android/Configuration.java @@ -11,38 +11,30 @@ import de.mtbnews.android.service.SubscriptionService; public class Configuration extends PreferenceActivity { - private SharedPreferences prefs; @Override protected void onCreate(Bundle savedInstanceState) { setTheme(R.style.Default); - prefs = PreferenceManager.getDefaultSharedPreferences(this); OnSharedPreferenceChangeListener listener = new SharedPreferences.OnSharedPreferenceChangeListener() { - public void onSharedPreferenceChanged(SharedPreferences prefs, - String key) + public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { if (key.equals("autostart_subscription_service")) { - if (prefs.getBoolean("autostart_subscription_service", - false)) + if (prefs.getBoolean("autostart_subscription_service", false)) { - startService(new Intent(getApplicationContext(), - SubscriptionService.class)); - Toast.makeText(Configuration.this, - R.string.subscription_service_started, - Toast.LENGTH_SHORT).show(); + startService(new Intent(getApplicationContext(), SubscriptionService.class)); + Toast.makeText(Configuration.this, R.string.subscription_service_started, Toast.LENGTH_SHORT) + .show(); } else { - stopService(new Intent(getApplicationContext(), - SubscriptionService.class)); - Toast.makeText(Configuration.this, - R.string.subscription_service_stopped, - Toast.LENGTH_SHORT).show(); + stopService(new Intent(getApplicationContext(), SubscriptionService.class)); + Toast.makeText(Configuration.this, R.string.subscription_service_stopped, Toast.LENGTH_SHORT) + .show(); } } @@ -50,17 +42,13 @@ public class Configuration extends PreferenceActivity // starten. if (key.equals("subscription_service_interval")) { - if (prefs.getBoolean("autostart_subscription_service", - false)) + if (prefs.getBoolean("autostart_subscription_service", false)) { // Restart - stopService(new Intent(getApplicationContext(), - SubscriptionService.class)); - startService(new Intent(getApplicationContext(), - SubscriptionService.class)); - Toast.makeText(Configuration.this, - R.string.subscription_service_started, - Toast.LENGTH_SHORT).show(); + stopService(new Intent(getApplicationContext(), SubscriptionService.class)); + startService(new Intent(getApplicationContext(), SubscriptionService.class)); + Toast.makeText(Configuration.this, R.string.subscription_service_started, Toast.LENGTH_SHORT) + .show(); } } @@ -73,12 +61,14 @@ public class Configuration extends PreferenceActivity else application.setTheme(android.R.style.Theme); - Toast.makeText(Configuration.this, R.string.theme_changed, - Toast.LENGTH_SHORT).show(); + Toast.makeText(Configuration.this, R.string.theme_changed, Toast.LENGTH_SHORT).show(); } } }; + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + + // Den Listener setzen. prefs.registerOnSharedPreferenceChangeListener(listener); super.onCreate(savedInstanceState); diff --git a/src/de/mtbnews/android/CreateTopicActivity.java b/src/de/mtbnews/android/CreateTopicActivity.java @@ -25,17 +25,17 @@ public class CreateTopicActivity extends Activity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + setTheme(((IBCApplication) getApplication()).themeResId); setContentView(R.layout.post); - + prefs = PreferenceManager.getDefaultSharedPreferences(this); forumId = getIntent().getStringExtra("forum_id"); final TextView recipient = (TextView) findViewById(R.id.recipient); recipient.setText(""); recipient.setVisibility(View.INVISIBLE); - + final TextView label = (TextView) findViewById(R.id.recipient_label); label.setVisibility(View.INVISIBLE); @@ -55,25 +55,20 @@ public class CreateTopicActivity extends Activity { @Override - protected void callServer() throws IOException, - TapatalkException + protected void callServer() throws IOException, TapatalkException { - TapatalkClient client = ((IBCApplication) getApplication()) - .getTapatalkClient(); - + TapatalkClient client = ((IBCApplication) getApplication()).getTapatalkClient(); + // Login. if (Utils.loginExceeded(client)) - client.login(prefs.getString("username", ""), prefs - .getString("password", "")); + client.login(prefs.getString("username", ""), prefs.getString("password", "")); - client.createTopic(forumId, subject.getText() - .toString(), text.getText().toString()); + client.createTopic(forumId, subject.getText().toString(), text.getText().toString()); } protected void doOnSuccess() { - Toast.makeText(CreateTopicActivity.this, - R.string.sent_ok, Toast.LENGTH_LONG); + Toast.makeText(CreateTopicActivity.this, R.string.sent_ok, Toast.LENGTH_LONG); CreateTopicActivity.this.finish(); } }.execute(); diff --git a/src/de/mtbnews/android/EndlessListActivity.java b/src/de/mtbnews/android/EndlessListActivity.java @@ -100,8 +100,7 @@ public abstract class EndlessListActivity<T> extends ListActivity { entries.clear(); entries.addAll(list); - ((BaseAdapter) getListAdapter()) - .notifyDataSetChanged(); + ((BaseAdapter) getListAdapter()).notifyDataSetChanged(); displayFrom = start; displayTo = end; @@ -151,8 +150,8 @@ public abstract class EndlessListActivity<T> extends ListActivity * @param firstLoad * @return gelandene Elemente */ - abstract protected void loadEntries(OnListLoadedListener<T> onListLoaded, - final int from, final int to, boolean firstLoad); + abstract protected void loadEntries(OnListLoadedListener<T> onListLoaded, final int from, final int to, + boolean firstLoad); /** * @param onListLoaded @@ -161,8 +160,7 @@ public abstract class EndlessListActivity<T> extends ListActivity * @param firstLoad * @return gelandene Elemente */ - private void loadEntries(OnListLoadedListener<T> onListLoaded, int from, - int to) + private void loadEntries(OnListLoadedListener<T> onListLoaded, int from, int to) { loadEntries(onListLoaded, from, to, firstLoad); firstLoad = false; @@ -201,8 +199,8 @@ public abstract class EndlessListActivity<T> extends ListActivity * int, int, int) */ @Override - public void onScroll(AbsListView view, final int firstVisibleItem, - final int visibleItemCount, final int totalItemCount) + public void onScroll(AbsListView view, final int firstVisibleItem, final int visibleItemCount, + final int totalItemCount) { // Letztes Item, dass angezeigt wird. @@ -212,14 +210,11 @@ public abstract class EndlessListActivity<T> extends ListActivity { // Sind wir am oberen Rand der Liste und die Liste ist noch // nicht vollständig geladen? - if (firstVisibleItem == 0 && displayFrom > 0 - && !loadingInProgress) + if (firstVisibleItem == 0 && displayFrom > 0 && !loadingInProgress) { loadingInProgress = true; - int start = Math.max(0, displayFrom - - Integer.parseInt(prefs.getString("num_load", - "10"))); + int start = Math.max(0, displayFrom - Integer.parseInt(prefs.getString("num_load", "10"))); int end = displayFrom - 1; @@ -236,14 +231,12 @@ public abstract class EndlessListActivity<T> extends ListActivity entries.clear(); entries.addAll(list); - ((BaseAdapter) getListAdapter()) - .notifyDataSetChanged(); + ((BaseAdapter) getListAdapter()).notifyDataSetChanged(); // Zur gleichen Position springen (die jetzt // aber etwas weiter nach hinten verschoben // ist). - getListView().setSelection( - firstVisibleItem + loadedSize); + getListView().setSelection(firstVisibleItem + loadedSize); loadingInProgress = false; } @@ -254,16 +247,12 @@ public abstract class EndlessListActivity<T> extends ListActivity else { // Sind wir am unterenRand der Liste? - if ((lastInScreen == totalItemCount) - && (totalItemCount < getTotalSize()) - && !(loadingInProgress)) + if ((lastInScreen == totalItemCount) && (totalItemCount < getTotalSize()) && !(loadingInProgress)) { loadingInProgress = true; int start = displayTo + 1; - int end = start - + Integer.parseInt(prefs.getString("num_load", - "10")) - 1; + int end = start + Integer.parseInt(prefs.getString("num_load", "10")) - 1; loadEntries(new OnListLoadedListener<T>() { @@ -275,8 +264,7 @@ public abstract class EndlessListActivity<T> extends ListActivity displayTo += loadedSize; - ((BaseAdapter) getListAdapter()) - .notifyDataSetChanged(); + ((BaseAdapter) getListAdapter()).notifyDataSetChanged(); loadingInProgress = false; } diff --git a/src/de/mtbnews/android/ForumActivity.java b/src/de/mtbnews/android/ForumActivity.java @@ -81,8 +81,7 @@ public class ForumActivity extends EndlessListActivity<Topic> forumId = getIntent().getStringExtra(FORUM_ID); Log.d(IBC.TAG, "Loading forum #" + forumId); - ListAdapter adapter = new ListEntryContentAdapter(ForumActivity.this, - entries); + ListAdapter adapter = new ListEntryContentAdapter(ForumActivity.this, entries); setListAdapter(adapter); initialLoad(); @@ -92,8 +91,7 @@ public class ForumActivity extends EndlessListActivity<Topic> { @Override - public void onCreateContextMenu(ContextMenu menu, View v, - ContextMenuInfo menuInfo) + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { if (topicMode == TapatalkClient.TOPIC_ANNOUNCEMENT) return; @@ -106,15 +104,13 @@ public class ForumActivity extends EndlessListActivity<Topic> list.setOnItemClickListener(new OnItemClickListener() { @Override - public void onItemClick(AdapterView<?> parent, View view, - int position, long id) + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (topicMode == TapatalkClient.TOPIC_ANNOUNCEMENT) return; // int aktPosition = displayFrom + position + 1; - final Intent intent = new Intent(ForumActivity.this, - TopicActivity.class); + final Intent intent = new Intent(ForumActivity.this, TopicActivity.class); Topic topic = ForumActivity.super.entries.get(position); intent.putExtra(TopicActivity.TOPIC_ID, topic.getId()); startActivity(intent); @@ -126,27 +122,22 @@ public class ForumActivity extends EndlessListActivity<Topic> @Override public boolean onContextItemSelected(MenuItem item) { - AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item - .getMenuInfo(); + AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.menu_goto_top: - final Intent intent = new Intent(ForumActivity.this, - TopicActivity.class); - intent.putExtra("topic_id", super.entries - .get(menuInfo.position).getId()); + final Intent intent = new Intent(ForumActivity.this, TopicActivity.class); + intent.putExtra("topic_id", super.entries.get(menuInfo.position).getId()); intent.putExtra("first_post", true); startActivity(intent); return true; case R.id.menu_goto_bottom: - final Intent intent2 = new Intent(ForumActivity.this, - TopicActivity.class); - intent2.putExtra("topic_id", super.entries.get( - menuInfo.position).getId()); + final Intent intent2 = new Intent(ForumActivity.this, TopicActivity.class); + intent2.putExtra("topic_id", super.entries.get(menuInfo.position).getId()); intent2.putExtra("last_post", true); startActivity(intent2); return true; @@ -161,20 +152,17 @@ public class ForumActivity extends EndlessListActivity<Topic> { @Override - protected synchronized void callServer() throws IOException, - IBCException + protected synchronized void callServer() throws IOException, IBCException { try { - client.login(prefs.getString("username", ""), prefs - .getString("password", "")); + client.login(prefs.getString("username", ""), prefs.getString("password", "")); } catch (TapatalkException e) { - throw new IBCException(R.string.login_failed, e - .getMessage(), e); + throw new IBCException(R.string.login_failed, e.getMessage(), e); } } @@ -188,8 +176,7 @@ public class ForumActivity extends EndlessListActivity<Topic> { @Override - protected synchronized void callServer() throws IOException, - IBCException + protected synchronized void callServer() throws IOException, IBCException { try @@ -249,8 +236,7 @@ public class ForumActivity extends EndlessListActivity<Topic> case R.id.menu_participated_topics: Intent intent = new Intent(this, SearchActivity.class); - intent - .setAction(SearchActivity.ACTION_SEARCH_PARTICIPATED_TOPICS); + intent.setAction(SearchActivity.ACTION_SEARCH_PARTICIPATED_TOPICS); startActivity(intent); return true; @@ -273,9 +259,7 @@ public class ForumActivity extends EndlessListActivity<Topic> if (TextUtils.isEmpty(prefs.getString("username", ""))) { - Toast - .makeText(this, R.string.nousername, - Toast.LENGTH_LONG).show(); + Toast.makeText(this, R.string.nousername, Toast.LENGTH_LONG).show(); Intent intent4 = new Intent(this, Configuration.class); startActivity(intent4); @@ -288,9 +272,7 @@ public class ForumActivity extends EndlessListActivity<Topic> } else { - Toast - .makeText(this, R.string.nousername, - Toast.LENGTH_LONG).show(); + Toast.makeText(this, R.string.nousername, Toast.LENGTH_LONG).show(); } return true; @@ -299,43 +281,35 @@ public class ForumActivity extends EndlessListActivity<Topic> AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.subscribe_forum); - builder.setItems(R.array.subscription_modes, - new DialogInterface.OnClickListener() + builder.setItems(R.array.subscription_modes, new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface dialog, final int item) + { + + new ServerAsyncTask(ForumActivity.this, R.string.subscribe_forum) { - public void onClick(DialogInterface dialog, - final int item) + + @Override + protected void callServer() throws IOException, TapatalkException { + client.subscribeForum(forumId, item - 1); + } - new ServerAsyncTask(ForumActivity.this, - R.string.subscribe_forum) - { - - @Override - protected void callServer() - throws IOException, - TapatalkException - { - client - .subscribeForum(forumId, - item - 1); - } - - @Override - protected void doOnSuccess() - { - Toast.makeText(getApplicationContext(), - R.string.subscription_saved, + @Override + protected void doOnSuccess() + { + Toast + .makeText(getApplicationContext(), R.string.subscription_saved, Toast.LENGTH_SHORT).show(); - } - }.execute(); } - }); + }.execute(); + } + }); builder.create().show(); return true; case R.id.menu_mark_read: - new ServerAsyncTask(ForumActivity.this, - R.string.mark_forum_read) + new ServerAsyncTask(ForumActivity.this, R.string.mark_forum_read) { @Override @@ -354,8 +328,7 @@ public class ForumActivity extends EndlessListActivity<Topic> case R.id.menu_mark_all_read: - new ServerAsyncTask(ForumActivity.this, - R.string.mark_forum_read) + new ServerAsyncTask(ForumActivity.this, R.string.mark_forum_read) { @Override protected void callServer() throws TapatalkException @@ -376,17 +349,15 @@ public class ForumActivity extends EndlessListActivity<Topic> // Den Topic-Mode ändern (Standard,Wichtig,Ankündigungen) AlertDialog.Builder builder2 = new AlertDialog.Builder(this); builder2.setTitle(R.string.mode); - builder2.setItems(R.array.topic_modes, - new DialogInterface.OnClickListener() - { + builder2.setItems(R.array.topic_modes, new DialogInterface.OnClickListener() + { - public void onClick(DialogInterface dialog, - final int item) - { - topicMode = item + 1; - initialLoad(); - } - }); + public void onClick(DialogInterface dialog, final int item) + { + topicMode = item + 1; + initialLoad(); + } + }); builder2.create().show(); return true; } @@ -400,8 +371,7 @@ public class ForumActivity extends EndlessListActivity<Topic> } @Override - protected void loadEntries( - final de.mtbnews.android.EndlessListActivity.OnListLoadedListener<Topic> onListLoaded, + protected void loadEntries(final de.mtbnews.android.EndlessListActivity.OnListLoadedListener<Topic> onListLoaded, final int from, final int to, final boolean firstLoad) { @@ -413,9 +383,8 @@ public class ForumActivity extends EndlessListActivity<Topic> protected void callServer() throws TapatalkException { if (Utils.loginExceeded(client)) - client.login(prefs.getString("username", ""), prefs - .getString("password", "")); - + client.login(prefs.getString("username", ""), prefs.getString("password", "")); + this.forum = client.getForum(forumId, from, to, topicMode); totalSize = this.forum.topicCount; } @@ -427,9 +396,7 @@ public class ForumActivity extends EndlessListActivity<Topic> if (firstLoad) if (prefs.getBoolean("show_hints", true)) - Toast.makeText(ForumActivity.this, - R.string.hint_press_long, Toast.LENGTH_SHORT) - .show(); + Toast.makeText(ForumActivity.this, R.string.hint_press_long, Toast.LENGTH_SHORT).show(); } }.execute(); diff --git a/src/de/mtbnews/android/ForumOverviewActivity.java b/src/de/mtbnews/android/ForumOverviewActivity.java @@ -103,8 +103,7 @@ public class ForumOverviewActivity extends ExpandableListActivity // Login. if (prefs.getBoolean("auto_login", false)) if (Utils.loginExceeded(client)) - client.login(prefs.getString("username", ""), prefs - .getString("password", "")); + client.login(prefs.getString("username", ""), prefs.getString("password", "")); forumList = client.getAllForum(); ((IBCApplication) getApplication()).setForumList(forumList); @@ -115,8 +114,7 @@ public class ForumOverviewActivity extends ExpandableListActivity protected void doOnSuccess() { - ExpandableListAdapter adapter = new ExpandableForumContentAdapter( - ForumOverviewActivity.this, forumList); + ExpandableListAdapter adapter = new ExpandableForumContentAdapter(ForumOverviewActivity.this, forumList); setListAdapter(adapter); } @@ -128,33 +126,27 @@ public class ForumOverviewActivity extends ExpandableListActivity { @Override - public boolean onChildClick(ExpandableListView arg0, View arg1, - int groupPosition, int childPosition, long rowId) + public boolean onChildClick(ExpandableListView arg0, View arg1, int groupPosition, int childPosition, + long rowId) { - Forum forum = forumList.get(groupPosition).subForen - .get(childPosition); + Forum forum = forumList.get(groupPosition).subForen.get(childPosition); if (forum.subOnly) { - Toast.makeText(ForumOverviewActivity.this, - R.string.sub_only, Toast.LENGTH_SHORT).show(); + Toast.makeText(ForumOverviewActivity.this, R.string.sub_only, Toast.LENGTH_SHORT).show(); } else if (!TextUtils.isEmpty(forum.url)) { - if (!Intent.ACTION_CREATE_SHORTCUT.equals(getIntent() - .getAction())) + if (!Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())) { - startActivity(new Intent(Intent.ACTION_VIEW, Uri - .parse(forum.url))); + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(forum.url))); } } else { - if (Intent.ACTION_CREATE_SHORTCUT.equals(getIntent() - .getAction())) + if (Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())) { - Intent shortcutIntent = new Intent( - ForumOverviewActivity.this, ForumActivity.class); + Intent shortcutIntent = new Intent(ForumOverviewActivity.this, ForumActivity.class); // Intent shortcutIntent = new // Intent(Intent.ACTION_MAIN); // shortcutIntent.setClassName(ForumActivity.class.getPackage().getName(), @@ -167,15 +159,11 @@ public class ForumOverviewActivity extends ExpandableListActivity // the caller) Intent intent = new Intent(); - intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, - shortcutIntent); - intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, forum - .getTitle()); - Parcelable iconResource = Intent.ShortcutIconResource - .fromContext(ForumOverviewActivity.this, - R.drawable.ibc_icon); - intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, - iconResource); + intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); + intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, forum.getTitle()); + Parcelable iconResource = Intent.ShortcutIconResource.fromContext(ForumOverviewActivity.this, + R.drawable.ibc_icon); + intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); // Now, return the result to the launcher @@ -185,8 +173,7 @@ public class ForumOverviewActivity extends ExpandableListActivity } else { - final Intent intent = new Intent( - ForumOverviewActivity.this, ForumActivity.class); + final Intent intent = new Intent(ForumOverviewActivity.this, ForumActivity.class); intent.putExtra("forum_id", forum.getId()); startActivity(intent); } @@ -259,8 +246,7 @@ public class ForumOverviewActivity extends ExpandableListActivity case R.id.menu_participated_topics: Intent intent = new Intent(this, SearchActivity.class); - intent - .setAction(SearchActivity.ACTION_SEARCH_PARTICIPATED_TOPICS); + intent.setAction(SearchActivity.ACTION_SEARCH_PARTICIPATED_TOPICS); startActivity(intent); return true; @@ -292,9 +278,7 @@ public class ForumOverviewActivity extends ExpandableListActivity if (TextUtils.isEmpty(prefs.getString("username", ""))) { - Toast - .makeText(this, R.string.nousername, - Toast.LENGTH_LONG).show(); + Toast.makeText(this, R.string.nousername, Toast.LENGTH_LONG).show(); Intent intent4 = new Intent(this, Configuration.class); startActivity(intent4); @@ -307,11 +291,9 @@ public class ForumOverviewActivity extends ExpandableListActivity { @Override - protected void callServer() throws IOException, - TapatalkException + protected void callServer() throws IOException, TapatalkException { - client.login(prefs.getString("username", ""), prefs - .getString("password", "")); + client.login(prefs.getString("username", ""), prefs.getString("password", "")); } @@ -319,8 +301,7 @@ public class ForumOverviewActivity extends ExpandableListActivity protected void doOnSuccess() { Log.d("IBC", "login success"); - Toast.makeText(ForumOverviewActivity.this, - R.string.login_success, Toast.LENGTH_SHORT) + Toast.makeText(ForumOverviewActivity.this, R.string.login_success, Toast.LENGTH_SHORT) .show(); forumList = null; loadForum(); @@ -331,9 +312,7 @@ public class ForumOverviewActivity extends ExpandableListActivity } else { - Toast - .makeText(this, R.string.nousername, - Toast.LENGTH_LONG).show(); + Toast.makeText(this, R.string.nousername, Toast.LENGTH_LONG).show(); } return true; @@ -347,8 +326,7 @@ public class ForumOverviewActivity extends ExpandableListActivity { @Override - protected synchronized void callServer() throws IOException, - TapatalkException + protected synchronized void callServer() throws IOException, TapatalkException { client.logout(); } @@ -356,8 +334,7 @@ public class ForumOverviewActivity extends ExpandableListActivity @Override protected void doOnSuccess() { - Toast.makeText(ForumOverviewActivity.this, R.string.logout, - Toast.LENGTH_SHORT).show(); + Toast.makeText(ForumOverviewActivity.this, R.string.logout, Toast.LENGTH_SHORT).show(); } }.executeSynchronized(); diff --git a/src/de/mtbnews/android/IBCActivity.java b/src/de/mtbnews/android/IBCActivity.java @@ -18,9 +18,6 @@ */ package de.mtbnews.android; -import java.io.IOException; - -import org.apache.http.client.ClientProtocolException; import org.mcsoxford.rss.RSSFault; import org.mcsoxford.rss.RSSFeed; import org.mcsoxford.rss.RSSReader; @@ -66,8 +63,7 @@ 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)); } }); @@ -85,11 +81,9 @@ public class IBCActivity extends ListActivity { @Override - public void onItemClick(AdapterView<?> parent, View view, - int position, long id) + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { - final Intent intent = new Intent(IBCActivity.this, - NewsDetailActivity.class); + final Intent intent = new Intent(IBCActivity.this, NewsDetailActivity.class); intent.putExtra("itemid", position); startActivity(intent); } @@ -102,8 +96,7 @@ public class IBCActivity extends ListActivity @Override protected void callServer() throws IBCException { - final RSSFeed oldFeed = ((IBCApplication) getApplication()) - .getNewsFeed(); + final RSSFeed oldFeed = ((IBCApplication) getApplication()).getNewsFeed(); if (oldFeed != null) { @@ -120,13 +113,11 @@ public class IBCActivity extends ListActivity } catch (RSSReaderException e) { - throw new IBCException(R.string.error_io, e - .getMessage(), e); + throw new IBCException(R.string.error_io, e.getMessage(), e); } catch (RSSFault e) { - throw new IBCException(R.string.error_io, e - .getMessage(), e); + throw new IBCException(R.string.error_io, e.getMessage(), e); } } } @@ -135,8 +126,7 @@ public class IBCActivity extends ListActivity { IBCActivity.this.setTitle(feed.getTitle()); - ListAdapter adapter = new ListEntryContentAdapter( - IBCActivity.this, this.feed.getItems(), false, true); + ListAdapter adapter = new ListEntryContentAdapter(IBCActivity.this, this.feed.getItems(), false, true); setListAdapter(adapter); } }.execute(); @@ -163,49 +153,38 @@ public class IBCActivity extends ListActivity startActivity(new Intent(IBCActivity.this, PhotoActivity.class)); return true; case R.id.menu_mailbox: - startActivity(new Intent(IBCActivity.this, - MailboxActivity.class)); + startActivity(new Intent(IBCActivity.this, MailboxActivity.class)); return true; case R.id.www_bikemarkt: - startActivity(new Intent(Intent.ACTION_VIEW, Uri - .parse("http://bikemarkt.mtb-news.de/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/"))); + 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/"))); + 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/"))); + 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/"))); + 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/"))); + 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/"))); + 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/"))); + 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/"))); + 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/"))); + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://videos.mtb-news.de/"))); return true; } diff --git a/src/de/mtbnews/android/IBCApplication.java b/src/de/mtbnews/android/IBCApplication.java @@ -31,21 +31,18 @@ public class IBCApplication extends Application * Speichert eine Referenz auf den Tapatalk-Client. Dieser Client kann vom * GC jederzeit entfernt werden, wenn der Speicherverbrauch zu hoch ist. */ - private SoftReference<TapatalkClient> tapatalkClientRef = new SoftReference<TapatalkClient>( - null); + private SoftReference<TapatalkClient> tapatalkClientRef = new SoftReference<TapatalkClient>(null); /** * Speichert eine Referenz auf den RSSFeed. Dieser Feed kann vom GC * jederzeit entfernt werden, wenn der Speicherverbrauch zu hoch ist. */ - private SoftReference<RSSFeed> newsFeedRef = new SoftReference<RSSFeed>( - null); + private SoftReference<RSSFeed> newsFeedRef = new SoftReference<RSSFeed>(null); /** * Speichert eine Referenz auf die Forum-Liste. Diese Liste kann vom GC * jederzeit entfernt werden, wenn der Speicherverbrauch zu hoch ist. */ - private SoftReference<List<Forum>> listForumRef = new SoftReference<List<Forum>>( - null);; + private SoftReference<List<Forum>> listForumRef = new SoftReference<List<Forum>>(null);; public SharedPreferences prefs; @@ -62,13 +59,11 @@ public class IBCApplication extends Application Log.d(IBC.TAG, "starting main application"); prefs = PreferenceManager.getDefaultSharedPreferences(this); - themeResId = (prefs.getBoolean("ibc_theme", true)) ? R.style.IBC - : R.style.Default; + themeResId = (prefs.getBoolean("ibc_theme", true)) ? R.style.IBC : R.style.Default; if (prefs.getBoolean("autostart_subscription_service", false)) { - startService(new Intent(getApplicationContext(), - SubscriptionService.class)); + startService(new Intent(getApplicationContext(), SubscriptionService.class)); } super.onCreate(); @@ -117,8 +112,7 @@ public class IBCApplication extends Application Log.d(IBC.TAG, "Creating a new tapatalk client"); client = new TapatalkClient(IBC.IBC_FORUM_CONNECTOR_URL); - client.setUserAgent( - "Mozilla/5.0 (compatible; Android)"); + client.setUserAgent("Mozilla/5.0 (compatible; Android)"); tapatalkClientRef = new SoftReference<TapatalkClient>(client); return client; } diff --git a/src/de/mtbnews/android/MailActivity.java b/src/de/mtbnews/android/MailActivity.java @@ -26,6 +26,7 @@ public class MailActivity extends EndlessListActivity<Message> private int totalMessageCount; private String boxId; private SharedPreferences prefs; + /** * Diese Liste immer von oben beginnen. * @@ -47,8 +48,7 @@ public class MailActivity extends EndlessListActivity<Message> prefs = PreferenceManager.getDefaultSharedPreferences(this); boxId = getIntent().getStringExtra("box_id"); - ListAdapter adapter = new ListEntryContentAdapter(MailActivity.this, - super.entries); + ListAdapter adapter = new ListEntryContentAdapter(MailActivity.this, super.entries); setListAdapter(adapter); initialLoad(); @@ -59,27 +59,22 @@ public class MailActivity extends EndlessListActivity<Message> { @Override - public void onItemClick(AdapterView<?> parent, View view, - int position, long id) + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent i = new Intent(MailActivity.this, MessageActivity.class); i.putExtra("box_id", boxId); - i.putExtra("message_id", MailActivity.super.entries - .get(position).id); + i.putExtra("message_id", MailActivity.super.entries.get(position).id); startActivity(i); } }); list.setOnItemLongClickListener(new OnItemLongClickListener() { @Override - public boolean onItemLongClick(AdapterView<?> arg0, View arg1, - int arg2, long arg3) + public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { - Intent i = new Intent(MailActivity.this, - ReplyMailActivity.class); + Intent i = new Intent(MailActivity.this, ReplyMailActivity.class); i.putExtra("box_id", boxId); - i.putExtra("message_id", - MailActivity.super.entries.get(arg2).id); + i.putExtra("message_id", MailActivity.super.entries.get(arg2).id); startActivity(i); return true; } @@ -87,9 +82,6 @@ public class MailActivity extends EndlessListActivity<Message> } - - - @Override public boolean onCreateOptionsMenu(Menu menu) { @@ -113,8 +105,6 @@ public class MailActivity extends EndlessListActivity<Message> return false; } - - @Override protected int getTotalSize() { @@ -122,9 +112,8 @@ public class MailActivity extends EndlessListActivity<Message> } @Override - protected void loadEntries( - final OnListLoadedListener<Message> onListLoaded, final int from, - final int to, boolean firstLoad) + protected void loadEntries(final OnListLoadedListener<Message> onListLoaded, final int from, final int to, + boolean firstLoad) { new ServerAsyncTask(this, R.string.waitingforcontent) @@ -135,16 +124,14 @@ public class MailActivity extends EndlessListActivity<Message> @Override protected void callServer() throws TapatalkException { - TapatalkClient client = ((IBCApplication) getApplication()) - .getTapatalkClient(); - - if (Utils.loginExceeded(client)) - client.login(prefs.getString("username", ""), prefs - .getString("password", "")); - - mailbox = client.getBoxContent(boxId, from, to); - - totalMessageCount = mailbox.countAll; + TapatalkClient client = ((IBCApplication) getApplication()).getTapatalkClient(); + + if (Utils.loginExceeded(client)) + client.login(prefs.getString("username", ""), prefs.getString("password", "")); + + mailbox = client.getBoxContent(boxId, from, to); + + totalMessageCount = mailbox.countAll; } protected void doOnSuccess() diff --git a/src/de/mtbnews/android/MailboxActivity.java b/src/de/mtbnews/android/MailboxActivity.java @@ -1,6 +1,5 @@ package de.mtbnews.android; -import java.io.IOException; import java.util.List; import android.app.ListActivity; @@ -33,7 +32,7 @@ public class MailboxActivity extends ListActivity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + setTheme(((IBCApplication) getApplication()).themeResId); setContentView(R.layout.listing); @@ -45,13 +44,11 @@ public class MailboxActivity extends ListActivity @Override protected void callServer() throws TapatalkException { - TapatalkClient client = ((IBCApplication) getApplication()) - .getTapatalkClient(); + TapatalkClient client = ((IBCApplication) getApplication()).getTapatalkClient(); // Login. if (Utils.loginExceeded(client)) - client.login(prefs.getString("username", ""), prefs - .getString("password", "")); + client.login(prefs.getString("username", ""), prefs.getString("password", "")); mailboxList = client.getMailbox(); @@ -59,8 +56,7 @@ public class MailboxActivity extends ListActivity protected void doOnSuccess() { - ListAdapter adapter = new ListEntryContentAdapter( - MailboxActivity.this, mailboxList); + ListAdapter adapter = new ListEntryContentAdapter(MailboxActivity.this, mailboxList); // IBCActivity.this.setTitle(feed.getTitle()); setListAdapter(adapter); } @@ -73,35 +69,27 @@ public class MailboxActivity extends ListActivity { @Override - public void onItemClick(AdapterView<?> parent, View view, - int position, long id) + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final Mailbox mailbox = mailboxList.get(position); - if (Intent.ACTION_CREATE_SHORTCUT.equals(getIntent() - .getAction())) + if (Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())) { - Intent shortcutIntent = new Intent(MailboxActivity.this, - MailActivity.class); + Intent shortcutIntent = new Intent(MailboxActivity.this, MailActivity.class); // Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); - shortcutIntent.setClassName(MailboxActivity.this, - MailActivity.class.getName()); + shortcutIntent.setClassName(MailboxActivity.this, MailActivity.class.getName()); shortcutIntent.putExtra("box_id", mailbox.getId()); // Then, set up the container intent (the response to the // caller) Intent intent = new Intent(); - intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, - shortcutIntent); - intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, mailbox - .getTitle()); - Parcelable iconResource = Intent.ShortcutIconResource - .fromContext(MailboxActivity.this, - R.drawable.ibc_icon); - intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, - iconResource); + intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); + intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, mailbox.getTitle()); + Parcelable iconResource = Intent.ShortcutIconResource.fromContext(MailboxActivity.this, + R.drawable.ibc_icon); + intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); // Now, return the result to the launcher @@ -112,8 +100,7 @@ public class MailboxActivity extends ListActivity else { - Intent i = new Intent(MailboxActivity.this, - MailActivity.class); + Intent i = new Intent(MailboxActivity.this, MailActivity.class); i.putExtra("box_id", mailbox.getId()); startActivity(i); } diff --git a/src/de/mtbnews/android/MessageActivity.java b/src/de/mtbnews/android/MessageActivity.java @@ -42,13 +42,11 @@ public class MessageActivity extends Activity @Override protected void callServer() throws TapatalkException { - client = ((IBCApplication) getApplication()) - .getTapatalkClient(); - + client = ((IBCApplication) getApplication()).getTapatalkClient(); + if (Utils.loginExceeded(client)) - client.login(prefs.getString("username", ""), prefs - .getString("password", "")); - + client.login(prefs.getString("username", ""), prefs.getString("password", "")); + message = client.getMessage(boxId, messageId); } @@ -59,8 +57,7 @@ public class MessageActivity extends Activity MessageActivity.this.setTitle(message.getTitle()); TextView datum = (TextView) findViewById(R.id.item_date); - datum.setText(DateFormat.getTimeFormat(MessageActivity.this) - .format(message.getDate())); + datum.setText(DateFormat.getTimeFormat(MessageActivity.this).format(message.getDate())); // TextView name = (TextView) findViewById(R.id.item_title); // name.setText(item.getTitle()); diff --git a/src/de/mtbnews/android/NewsDetailActivity.java b/src/de/mtbnews/android/NewsDetailActivity.java @@ -40,8 +40,7 @@ public class NewsDetailActivity extends Activity @Override protected void callServer() throws IOException { - final RSSFeed oldFeed = ((IBCApplication) getApplication()) - .getNewsFeed(); + final RSSFeed oldFeed = ((IBCApplication) getApplication()).getNewsFeed(); if (oldFeed != null) { @@ -69,15 +68,12 @@ public class NewsDetailActivity extends Activity protected void doOnSuccess() { - final RSSItem item = feed.getItems().get( - getIntent().getIntExtra("itemid", 0)); + final RSSItem item = feed.getItems().get(getIntent().getIntExtra("itemid", 0)); final String html = item.getFullContent(); - webView.getSettings().setLoadsImagesAutomatically( - prefs.getBoolean("load_images", false)); - webView.loadDataWithBaseURL(IBC.IBC_NEWS_RSS_URL, html, - "text/html", "UTF-8", null); + webView.getSettings().setLoadsImagesAutomatically(prefs.getBoolean("load_images", false)); + webView.loadDataWithBaseURL(IBC.IBC_NEWS_RSS_URL, html, "text/html", "UTF-8", null); setTitle(item.getTitle()); } diff --git a/src/de/mtbnews/android/PhotoActivity.java b/src/de/mtbnews/android/PhotoActivity.java @@ -62,8 +62,7 @@ public class PhotoActivity extends ListActivity protected void doOnSuccess() { - ListAdapter adapter = new RSSContentAdapter(PhotoActivity.this, - feed); + ListAdapter adapter = new RSSContentAdapter(PhotoActivity.this, feed); PhotoActivity.this.setTitle(feed.getTitle()); setListAdapter(adapter); @@ -76,8 +75,7 @@ public class PhotoActivity extends ListActivity { @Override - public void onItemClick(AdapterView<?> parent, View view, - int position, long id) + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { RSSItem item = (RSSItem) getListAdapter().getItem(position); diff --git a/src/de/mtbnews/android/ReplyMailActivity.java b/src/de/mtbnews/android/ReplyMailActivity.java @@ -53,8 +53,7 @@ public class ReplyMailActivity extends Activity protected void callServer() throws TapatalkException { if (Utils.loginExceeded(client)) - client.login(prefs.getString("username", ""), prefs - .getString("password", "")); + client.login(prefs.getString("username", ""), prefs.getString("password", "")); message = client.getMessage(boxId, messageId); } @@ -67,11 +66,9 @@ public class ReplyMailActivity extends Activity // TextView name = (TextView) findViewById(R.id.item_title); // name.setText(item.getTitle()); - subject.setText(message.subject.startsWith("Re: ") ? "" - : "Re: " + message.subject); + subject.setText(message.subject.startsWith("Re: ") ? "" : "Re: " + message.subject); - text.setText("[quote]" + message.getContent() - + "[/quote]\n\n"); + text.setText("[quote]" + message.getContent() + "[/quote]\n\n"); } }.execute(); @@ -87,26 +84,21 @@ public class ReplyMailActivity extends Activity @Override public void onClick(View v) { - new ServerAsyncTask(ReplyMailActivity.this, - R.string.waitingfor_sending) + new ServerAsyncTask(ReplyMailActivity.this, R.string.waitingfor_sending) { @Override - protected void callServer() throws IOException, - TapatalkException + protected void callServer() throws IOException, TapatalkException { if (Utils.loginExceeded(client)) - client.login(prefs.getString("username", ""), prefs - .getString("password", "")); + client.login(prefs.getString("username", ""), prefs.getString("password", "")); - client.createMessage(new String[] { recipient.getText() - .toString() }, subject.getText().toString(), - text.getText().toString()); + client.createMessage(new String[] { recipient.getText().toString() }, subject.getText() + .toString(), text.getText().toString()); } protected void doOnSuccess() { - Toast.makeText(ReplyMailActivity.this, - R.string.sent_ok, Toast.LENGTH_LONG); + Toast.makeText(ReplyMailActivity.this, R.string.sent_ok, Toast.LENGTH_LONG); ReplyMailActivity.this.finish(); } }.execute(); diff --git a/src/de/mtbnews/android/ReplyPostActivity.java b/src/de/mtbnews/android/ReplyPostActivity.java @@ -26,7 +26,7 @@ public class ReplyPostActivity extends Activity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + setTheme(((IBCApplication) getApplication()).themeResId); setContentView(R.layout.post); prefs = PreferenceManager.getDefaultSharedPreferences(this); @@ -44,9 +44,7 @@ public class ReplyPostActivity extends Activity label.setVisibility(View.INVISIBLE); final TextView subject = (TextView) findViewById(R.id.subject); - subject - .setText(ReplyPostActivity.this.subject != null ? ReplyPostActivity.this.subject - : ""); + subject.setText(ReplyPostActivity.this.subject != null ? ReplyPostActivity.this.subject : ""); final TextView text = (TextView) findViewById(R.id.content); text.setText(quote != null ? "[quote]" + quote + "[/quote]" : ""); @@ -64,22 +62,18 @@ public class ReplyPostActivity extends Activity @Override protected void callServer() throws TapatalkException { - TapatalkClient client = ((IBCApplication) getApplication()) - .getTapatalkClient(); + TapatalkClient client = ((IBCApplication) getApplication()).getTapatalkClient(); // Login. if (Utils.loginExceeded(client)) - client.login(prefs.getString("username", ""), prefs - .getString("password", "")); + client.login(prefs.getString("username", ""), prefs.getString("password", "")); - client.createReply(forumId, topicId, subject.getText() - .toString(), text.getText().toString()); + client.createReply(forumId, topicId, subject.getText().toString(), text.getText().toString()); } protected void doOnSuccess() { - Toast.makeText(ReplyPostActivity.this, - R.string.sent_ok, Toast.LENGTH_LONG); + Toast.makeText(ReplyPostActivity.this, R.string.sent_ok, Toast.LENGTH_LONG); ReplyPostActivity.this.finish(); } }.execute(); diff --git a/src/de/mtbnews/android/SearchActivity.java b/src/de/mtbnews/android/SearchActivity.java @@ -99,12 +99,10 @@ public class SearchActivity extends EndlessListActivity<Topic> // Das kann nur ein Programmfehler sein, daher RTE werfen und damit // hoffen, dass der Benutzer einen Bericht sendet. - throw new RuntimeException("Unknown search action: " - + intent.getAction()); + throw new RuntimeException("Unknown search action: " + intent.getAction()); } - ListAdapter adapter = new ListEntryContentAdapter(SearchActivity.this, - entries); + ListAdapter adapter = new ListEntryContentAdapter(SearchActivity.this, entries); setListAdapter(adapter); initialLoad(); @@ -114,8 +112,7 @@ public class SearchActivity extends EndlessListActivity<Topic> { @Override - public void onCreateContextMenu(ContextMenu menu, View v, - ContextMenuInfo menuInfo) + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { MenuInflater menuInflater = new MenuInflater(getApplication()); menuInflater.inflate(R.menu.topic_context, menu); @@ -125,12 +122,10 @@ public class SearchActivity extends EndlessListActivity<Topic> list.setOnItemClickListener(new OnItemClickListener() { @Override - public void onItemClick(AdapterView<?> parent, View view, - int position, long id) + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // int aktPosition = displayFrom + position + 1; - final Intent intent = new Intent(SearchActivity.this, - TopicActivity.class); + final Intent intent = new Intent(SearchActivity.this, TopicActivity.class); Topic topic = SearchActivity.super.entries.get(position); intent.putExtra(TopicActivity.TOPIC_ID, topic.getId()); startActivity(intent); @@ -148,27 +143,22 @@ public class SearchActivity extends EndlessListActivity<Topic> @Override public boolean onContextItemSelected(MenuItem item) { - AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item - .getMenuInfo(); + AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.menu_goto_top: - final Intent intent = new Intent(SearchActivity.this, - TopicActivity.class); - intent.putExtra(TopicActivity.TOPIC_ID, super.entries.get( - menuInfo.position).getId()); + final Intent intent = new Intent(SearchActivity.this, TopicActivity.class); + intent.putExtra(TopicActivity.TOPIC_ID, super.entries.get(menuInfo.position).getId()); intent.putExtra("first_post", true); startActivity(intent); return true; case R.id.menu_goto_bottom: - final Intent intent2 = new Intent(SearchActivity.this, - TopicActivity.class); - intent2.putExtra(TopicActivity.TOPIC_ID, super.entries.get( - menuInfo.position).getId()); + final Intent intent2 = new Intent(SearchActivity.this, TopicActivity.class); + intent2.putExtra(TopicActivity.TOPIC_ID, super.entries.get(menuInfo.position).getId()); intent2.putExtra("last_post", true); startActivity(intent2); return true; @@ -178,8 +168,8 @@ public class SearchActivity extends EndlessListActivity<Topic> } @Override - protected void loadEntries(final OnListLoadedListener<Topic> onListLoaded, - final int from, final int to, boolean firstLoad) + protected void loadEntries(final OnListLoadedListener<Topic> onListLoaded, final int from, final int to, + boolean firstLoad) { new ServerAsyncTask(SearchActivity.this, R.string.waitingfor_loadmore) { @@ -188,11 +178,9 @@ public class SearchActivity extends EndlessListActivity<Topic> @Override protected void callServer() throws TapatalkException { - TapatalkClient client = ((IBCApplication) getApplication()) - .getTapatalkClient(); + TapatalkClient client = ((IBCApplication) getApplication()).getTapatalkClient(); - search = client.searchTopics(searchType, query, username, from, - to, searchId); + search = client.searchTopics(searchType, query, username, from, to, searchId); totalSize = search.topicCount; searchId = search.searchId; diff --git a/src/de/mtbnews/android/SubscriptionForenActivity.java b/src/de/mtbnews/android/SubscriptionForenActivity.java @@ -53,8 +53,7 @@ public class SubscriptionForenActivity extends ListActivity client = ((IBCApplication) getApplication()).getTapatalkClient(); prefs = PreferenceManager.getDefaultSharedPreferences(this); - ListAdapter adapter = new ListEntryContentAdapter( - SubscriptionForenActivity.this, forumList); + ListAdapter adapter = new ListEntryContentAdapter(SubscriptionForenActivity.this, forumList); setListAdapter(adapter); ListView list = getListView(); @@ -62,8 +61,7 @@ public class SubscriptionForenActivity extends ListActivity { @Override - public void onCreateContextMenu(ContextMenu menu, View v, - ContextMenuInfo menuInfo) + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { MenuInflater menuInflater = new MenuInflater(getApplication()); menuInflater.inflate(R.menu.topic_context, menu); @@ -74,13 +72,10 @@ public class SubscriptionForenActivity extends ListActivity list.setOnItemClickListener(new OnItemClickListener() { @Override - public void onItemClick(AdapterView<?> parent, View view, - int position, long id) + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { - final Intent intent = new Intent( - SubscriptionForenActivity.this, ForumActivity.class); - intent.putExtra(ForumActivity.FORUM_ID, forumList.get(position) - .getId()); + final Intent intent = new Intent(SubscriptionForenActivity.this, ForumActivity.class); + intent.putExtra(ForumActivity.FORUM_ID, forumList.get(position).getId()); startActivity(intent); } }); @@ -101,8 +96,7 @@ public class SubscriptionForenActivity extends ListActivity // Login. if (Utils.loginExceeded(client)) - client.login(prefs.getString("username", ""), prefs - .getString("password", "")); + client.login(prefs.getString("username", ""), prefs.getString("password", "")); newForumList = client.getSubscribedForum(false); } @@ -114,8 +108,7 @@ public class SubscriptionForenActivity extends ListActivity forumList.clear(); forumList.addAll(newForumList); - ((BaseAdapter) SubscriptionForenActivity.this.getListAdapter()) - .notifyDataSetChanged(); + ((BaseAdapter) SubscriptionForenActivity.this.getListAdapter()).notifyDataSetChanged(); } }.executeSynchronized(); @@ -124,27 +117,22 @@ public class SubscriptionForenActivity extends ListActivity @Override public boolean onContextItemSelected(MenuItem item) { - AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item - .getMenuInfo(); + AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.menu_goto_top: - final Intent intent = new Intent( - SubscriptionForenActivity.this, ForumActivity.class); - intent.putExtra("forum_id", forumList.get(menuInfo.position) - .getId()); + final Intent intent = new Intent(SubscriptionForenActivity.this, ForumActivity.class); + intent.putExtra("forum_id", forumList.get(menuInfo.position).getId()); intent.putExtra("first_post", true); startActivity(intent); return true; case R.id.menu_goto_bottom: - final Intent intent2 = new Intent( - SubscriptionForenActivity.this, ForumActivity.class); - intent2.putExtra("forum_id", forumList.get(menuInfo.position) - .getId()); + final Intent intent2 = new Intent(SubscriptionForenActivity.this, ForumActivity.class); + intent2.putExtra("forum_id", forumList.get(menuInfo.position).getId()); intent2.putExtra("last_post", true); startActivity(intent2); return true; @@ -165,15 +153,14 @@ public class SubscriptionForenActivity extends ListActivity case R.id.menu_preferences: startActivity(new Intent(this, Configuration.class)); return true; - + case R.id.menu_mailbox: startActivity(new Intent(this, MailboxActivity.class)); return true; case R.id.menu_participated_topics: Intent intent = new Intent(this, SearchActivity.class); - intent - .setAction(SearchActivity.ACTION_SEARCH_PARTICIPATED_TOPICS); + intent.setAction(SearchActivity.ACTION_SEARCH_PARTICIPATED_TOPICS); startActivity(intent); return true; diff --git a/src/de/mtbnews/android/SubscriptionTopicsActivity.java b/src/de/mtbnews/android/SubscriptionTopicsActivity.java @@ -38,6 +38,7 @@ public class SubscriptionTopicsActivity extends EndlessListActivity<Topic> { private int totalSize; private SharedPreferences prefs; + /** * Diese Liste immer von oben beginnen. * @@ -48,6 +49,7 @@ public class SubscriptionTopicsActivity extends EndlessListActivity<Topic> { return false; } + @Override protected void onCreate(Bundle savedInstanceState) { @@ -57,8 +59,7 @@ public class SubscriptionTopicsActivity extends EndlessListActivity<Topic> setTheme(((IBCApplication) getApplication()).themeResId); setContentView(R.layout.listing); - ListAdapter adapter = new ListEntryContentAdapter( - SubscriptionTopicsActivity.this, entries); + ListAdapter adapter = new ListEntryContentAdapter(SubscriptionTopicsActivity.this, entries); setListAdapter(adapter); initialLoad(); @@ -68,8 +69,7 @@ public class SubscriptionTopicsActivity extends EndlessListActivity<Topic> { @Override - public void onCreateContextMenu(ContextMenu menu, View v, - ContextMenuInfo menuInfo) + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { MenuInflater menuInflater = new MenuInflater(getApplication()); menuInflater.inflate(R.menu.topic_context, menu); @@ -79,14 +79,11 @@ public class SubscriptionTopicsActivity extends EndlessListActivity<Topic> list.setOnItemClickListener(new OnItemClickListener() { @Override - public void onItemClick(AdapterView<?> parent, View view, - int position, long id) + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // int aktPosition = displayFrom + position + 1; - final Intent intent = new Intent( - SubscriptionTopicsActivity.this, TopicActivity.class); - Topic topic = SubscriptionTopicsActivity.super.entries - .get(position); + final Intent intent = new Intent(SubscriptionTopicsActivity.this, TopicActivity.class); + Topic topic = SubscriptionTopicsActivity.super.entries.get(position); intent.putExtra(TopicActivity.TOPIC_ID, topic.getId()); startActivity(intent); } @@ -97,27 +94,22 @@ public class SubscriptionTopicsActivity extends EndlessListActivity<Topic> @Override public boolean onContextItemSelected(MenuItem item) { - AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item - .getMenuInfo(); + AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.menu_goto_top: - final Intent intent = new Intent( - SubscriptionTopicsActivity.this, TopicActivity.class); - intent.putExtra(TopicActivity.TOPIC_ID, super.entries.get( - menuInfo.position).getId()); + final Intent intent = new Intent(SubscriptionTopicsActivity.this, TopicActivity.class); + intent.putExtra(TopicActivity.TOPIC_ID, super.entries.get(menuInfo.position).getId()); intent.putExtra(EndlessListActivity.FIRST_POST, true); startActivity(intent); return true; case R.id.menu_goto_bottom: - final Intent intent2 = new Intent( - SubscriptionTopicsActivity.this, TopicActivity.class); - intent2.putExtra(TopicActivity.TOPIC_ID, super.entries.get( - menuInfo.position).getId()); + final Intent intent2 = new Intent(SubscriptionTopicsActivity.this, TopicActivity.class); + intent2.putExtra(TopicActivity.TOPIC_ID, super.entries.get(menuInfo.position).getId()); intent2.putExtra(EndlessListActivity.LAST_POST, true); startActivity(intent2); return true; @@ -133,13 +125,11 @@ public class SubscriptionTopicsActivity extends EndlessListActivity<Topic> } @Override - protected void loadEntries( - final OnListLoadedListener<Topic> onListLoadedListener, - final int from, final int to, final boolean firstLoad) + protected void loadEntries(final OnListLoadedListener<Topic> onListLoadedListener, final int from, final int to, + final boolean firstLoad) { - new ServerAsyncTask(SubscriptionTopicsActivity.this, - firstLoad ? R.string.waitingfor_subscription_topics - : R.string.waitingfor_loadmore) + new ServerAsyncTask(SubscriptionTopicsActivity.this, firstLoad ? R.string.waitingfor_subscription_topics + : R.string.waitingfor_loadmore) { private ListHolder<Topic> topicHolder; @@ -150,8 +140,7 @@ public class SubscriptionTopicsActivity extends EndlessListActivity<Topic> // Login. if (Utils.loginExceeded(client)) - client.login(prefs.getString("username", ""), prefs - .getString("password", "")); + client.login(prefs.getString("username", ""), prefs.getString("password", "")); topicHolder = client.getSubscribedTopics(from, to, false); @@ -165,8 +154,7 @@ public class SubscriptionTopicsActivity extends EndlessListActivity<Topic> if (firstLoad) if (prefs.getBoolean("show_hints", true)) - Toast.makeText(SubscriptionTopicsActivity.this, - R.string.hint_press_long, Toast.LENGTH_SHORT) + Toast.makeText(SubscriptionTopicsActivity.this, R.string.hint_press_long, Toast.LENGTH_SHORT) .show(); } diff --git a/src/de/mtbnews/android/TopicActivity.java b/src/de/mtbnews/android/TopicActivity.java @@ -12,12 +12,8 @@ import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; -import android.view.View; -import android.widget.AdapterView; import android.widget.ListAdapter; -import android.widget.ListView; import android.widget.Toast; -import android.widget.AdapterView.OnItemClickListener; import de.mtbnews.android.adapter.ListEntryContentAdapter; import de.mtbnews.android.tapatalk.TapatalkClient; import de.mtbnews.android.tapatalk.TapatalkException; @@ -55,16 +51,14 @@ public class TopicActivity extends EndlessListActivity<Post> topicId = TopicActivity.this.getIntent().getStringExtra(TOPIC_ID); // forumId = TopicActivity.this.getIntent().getStringExtra("forum_id"); - ListAdapter adapter = new ListEntryContentAdapter(TopicActivity.this, - entries, true, false); + ListAdapter adapter = new ListEntryContentAdapter(TopicActivity.this, entries, true, false); setListAdapter(adapter); initialLoad(); - final ListView list = getListView(); - /* - * list.setOnItemClickListener(new OnItemClickListener() { + * final ListView list = getListView(); list.setOnItemClickListener(new + * OnItemClickListener() { * * @Override public void onItemClick(AdapterView<?> parent, View view, * int position, long id) { int aktPosition = displayFrom + position + @@ -84,13 +78,10 @@ public class TopicActivity extends EndlessListActivity<Post> } @Override - protected void loadEntries( - final OnListLoadedListener<Post> onListLoadedListener, - final int from, final int to, boolean firstLoad) + protected void loadEntries(final OnListLoadedListener<Post> onListLoadedListener, final int from, final int to, + boolean firstLoad) { - new ServerAsyncTask(TopicActivity.this, - firstLoad ? R.string.waitingfor_topic - : R.string.waitingfor_loadmore) + new ServerAsyncTask(TopicActivity.this, firstLoad ? R.string.waitingfor_topic : R.string.waitingfor_loadmore) { private List<Post> posts; private Topic topic; @@ -134,7 +125,7 @@ public class TopicActivity extends EndlessListActivity<Post> case R.id.menu_preferences: startActivity(new Intent(this, Configuration.class)); return true; - + case R.id.menu_top: getListView().setOnScrollListener(null); @@ -163,43 +154,36 @@ public class TopicActivity extends EndlessListActivity<Post> AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.subscribe_topic); - builder.setItems(R.array.subscription_modes, - new DialogInterface.OnClickListener() + builder.setItems(R.array.subscription_modes, new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface dialog, final int item) + { + new ServerAsyncTask(TopicActivity.this, R.string.subscribe_topic) { - public void onClick(DialogInterface dialog, - final int item) + + @Override + protected void callServer() throws TapatalkException { - new ServerAsyncTask(TopicActivity.this, - R.string.subscribe_topic) - { - - @Override - protected void callServer() - throws TapatalkException - { - client - .subscribeTopic(topicId, - item - 1); - } - - @Override - protected void doOnSuccess() - { - Toast.makeText(getApplicationContext(), - R.string.subscription_saved, + client.subscribeTopic(topicId, item - 1); + } + + @Override + protected void doOnSuccess() + { + Toast + .makeText(getApplicationContext(), R.string.subscription_saved, Toast.LENGTH_SHORT).show(); - } - }.execute(); } - }); + }.execute(); + } + }); builder.create().show(); return true; case R.id.menu_mark_read: // TODO: In Tapatalk-API-Version 3 nicht verfügbar! - new ServerAsyncTask(TopicActivity.this, - R.string.mark_topic_read) + new ServerAsyncTask(TopicActivity.this, R.string.mark_topic_read) { @Override diff --git a/src/de/mtbnews/android/adapter/BBCodeConverter.java b/src/de/mtbnews/android/adapter/BBCodeConverter.java @@ -19,29 +19,22 @@ public class BBCodeConverter { string = string.replaceAll("(\r\n|\n\r|\n|\r)", "<br />"); - string = processTag(string, - "\\[color=['\"]?(.*?[^'\"])['\"]?\\](.*?)\\[/color\\]", + string = processTag(string, "\\[color=['\"]?(.*?[^'\"])['\"]?\\](.*?)\\[/color\\]", "<span style='color:$1'>$2</span>"); - string = processTag(string, "\\[quote[^\\[]*\\](.*?)\\[/quote\\]", - "<blockquote>$1</blockquote>"); + string = processTag(string, "\\[quote[^\\[]*\\](.*?)\\[/quote\\]", "<blockquote>$1</blockquote>"); - string = processTag(string, - "\\[list=['\"]?(.*?[^'\"])['\"]?\\](.*?)\\[/list\\]", - "<ul>$2</ul>"); + string = processTag(string, "\\[list=['\"]?(.*?[^'\"])['\"]?\\](.*?)\\[/list\\]", "<ul>$2</ul>"); // str = str.replaceAll("(\r\n|\n\r|\n|\r)", "<br>"); // [color] // [size] - string = processTag(string, - "\\[size=['\"]?([0-9]|[1-2][0-9])['\"]?\\](.*?)\\[/size\\]", + string = processTag(string, "\\[size=['\"]?([0-9]|[1-2][0-9])['\"]?\\](.*?)\\[/size\\]", "<span style='font-size:$1px'>$2</span>"); - string = processTag(string, - "\\[mention=['\"]?([0-9]+)['\"]?\\](.*?)\\[/mention\\]", - "<a href=\"" + IBC.IBC_FORUM_URL - + "member.php?u=$1\">&rarr;$2</a>"); + string = processTag(string, "\\[mention=['\"]?([0-9]+)['\"]?\\](.*?)\\[/mention\\]", "<a href=\"" + + IBC.IBC_FORUM_URL + "member.php?u=$1\">&rarr;$2</a>"); // [b][u][i] string = processTag(string, "\\[b\\](.*?)\\[/b\\]", "<b>$1</b>"); @@ -54,37 +47,29 @@ public class BBCodeConverter string = processTag(string, "[*]", "&bull;"); // [img] - string = processTag(string, "\\[img\\](.*?)\\[/img\\]", - "<a href=\"$1\">Bild anzeigen</a>"); + string = processTag(string, "\\[img\\](.*?)\\[/img\\]", "<a href=\"$1\">Bild anzeigen</a>"); // [url] - string = processTag(string, "\\[url\\](.*?)\\[/url\\]", - "<a href=\"$1\">$1</a>"); - string = processTag(string, - "\\[url=['\"]?(.*?[^'\"])['\"]?\\](.*?)\\[/url\\]", - "<a href=\"$1\">$2</a>"); + string = processTag(string, "\\[url\\](.*?)\\[/url\\]", "<a href=\"$1\">$1</a>"); + string = processTag(string, "\\[url=['\"]?(.*?[^'\"])['\"]?\\](.*?)\\[/url\\]", "<a href=\"$1\">$2</a>"); string = processTag(string, "\\[yt.*\\](.*?)\\[/yt\\]", "<a href=\"http://www.youtube.com/watch?v=$2\">Video bei Youtube anzeigen</a>"); // [email] - string = processTag(string, "\\[email\\](.*?)\\[/email\\]", - "<a href='mailto:$1'>$1</a>"); + string = processTag(string, "\\[email\\](.*?)\\[/email\\]", "<a href='mailto:$1'>$1</a>"); return string; } - private static String processTag(String text, String pattern, - String replaceWith) + private static String processTag(String text, String pattern, String replaceWith) { try { - return Pattern.compile(pattern, Pattern.CASE_INSENSITIVE).matcher( - text).replaceAll(replaceWith); + return Pattern.compile(pattern, Pattern.CASE_INSENSITIVE).matcher(text).replaceAll(replaceWith); } catch (Exception e) { - Log.d(IBC.TAG, "Error while processing '" + pattern + "': " - + e.getMessage(), e); + Log.d(IBC.TAG, "Error while processing '" + pattern + "': " + e.getMessage(), e); return text; } } diff --git a/src/de/mtbnews/android/adapter/ExpandableForumContentAdapter.java b/src/de/mtbnews/android/adapter/ExpandableForumContentAdapter.java @@ -31,8 +31,7 @@ public class ExpandableForumContentAdapter extends BaseExpandableListAdapter public ExpandableForumContentAdapter(Context context, List<Forum> forumList) { - inflator = (LayoutInflater) context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + inflator = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); this.forumList = forumList; } @@ -51,8 +50,8 @@ public class ExpandableForumContentAdapter extends BaseExpandableListAdapter } @Override - public View getChildView(int groupPosition, int childPosition, - boolean isLastChild, View convertView, ViewGroup parent) + public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, + ViewGroup parent) { Forum e = forumList.get(groupPosition).subForen.get(childPosition); @@ -96,8 +95,7 @@ public class ExpandableForumContentAdapter extends BaseExpandableListAdapter } @Override - public View getGroupView(int groupPosition, boolean isExpanded, - View convertView, ViewGroup parent) + public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { final Forum forum = forumList.get(groupPosition); diff --git a/src/de/mtbnews/android/adapter/ListEntryContentAdapter.java b/src/de/mtbnews/android/adapter/ListEntryContentAdapter.java @@ -42,22 +42,18 @@ public class ListEntryContentAdapter extends BaseAdapter private boolean containsBBCode; private boolean containsHtml; - public ListEntryContentAdapter(Context context, - List<? extends ListEntry> list) + public ListEntryContentAdapter(Context context, List<? extends ListEntry> list) { mContext = context; - inflator = (LayoutInflater) context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + inflator = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); this.list = list; } - public ListEntryContentAdapter(Context context, - List<? extends ListEntry> list, boolean containsBBCode, + public ListEntryContentAdapter(Context context, List<? extends ListEntry> list, boolean containsBBCode, boolean containsHtml) { mContext = context; - inflator = (LayoutInflater) context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + inflator = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); this.list = list; this.containsBBCode = containsBBCode; this.containsHtml = containsHtml; @@ -105,14 +101,10 @@ public class ListEntryContentAdapter extends BaseAdapter viewHolder = new ViewHolder(); - viewHolder.datum = (TextView) convertView - .findViewById(R.id.item_date); - viewHolder.name = (TextView) convertView - .findViewById(R.id.item_name); - viewHolder.title = (TextView) convertView - .findViewById(R.id.item_title); - viewHolder.desc = (TextView) convertView - .findViewById(R.id.item_description); + viewHolder.datum = (TextView) convertView.findViewById(R.id.item_date); + viewHolder.name = (TextView) convertView.findViewById(R.id.item_name); + viewHolder.title = (TextView) convertView.findViewById(R.id.item_title); + viewHolder.desc = (TextView) convertView.findViewById(R.id.item_description); convertView.setTag(viewHolder); } else @@ -121,11 +113,8 @@ public class ListEntryContentAdapter extends BaseAdapter } if (e.getDate() != null) - viewHolder.datum.setText(DateFormat.getDateFormat( - parent.getContext()).format(e.getDate()) - + " " - + DateFormat.getTimeFormat(parent.getContext()).format( - e.getDate())); + viewHolder.datum.setText(DateFormat.getDateFormat(parent.getContext()).format(e.getDate()) + " " + + DateFormat.getTimeFormat(parent.getContext()).format(e.getDate())); else // viewHolder.datum.setEnabled(false); viewHolder.datum.setText(""); @@ -148,8 +137,7 @@ public class ListEntryContentAdapter extends BaseAdapter if (e.getContent() != null) { - SharedPreferences prefs = ((IBCApplication) ((Activity) mContext) - .getApplication()).prefs; + SharedPreferences prefs = ((IBCApplication) ((Activity) mContext).getApplication()).prefs; if (containsBBCode && prefs.getBoolean("parse_bbcode", false)) { String html; @@ -168,7 +156,7 @@ public class ListEntryContentAdapter extends BaseAdapter // imageGetter, null)); viewHolder.desc.setText(Html.fromHtml(html)); viewHolder.desc.setMovementMethod(LinkMovementMethod.getInstance()); - //viewHolder.desc.setAutoLinkMask(Linkify.ALL); + // viewHolder.desc.setAutoLinkMask(Linkify.ALL); } else if (containsHtml) { diff --git a/src/de/mtbnews/android/adapter/RSSContentAdapter.java b/src/de/mtbnews/android/adapter/RSSContentAdapter.java @@ -37,8 +37,7 @@ public class RSSContentAdapter extends BaseAdapter public RSSContentAdapter(Context context, RSSFeed feed) { mContext = context; - inflator = (LayoutInflater) context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + inflator = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); this.feed = feed; } @@ -72,11 +71,8 @@ public class RSSContentAdapter extends BaseAdapter final View view = inflator.inflate(R.layout.rss_item, null); TextView datum = (TextView) view.findViewById(R.id.item_date); - datum.setText(DateFormat.getDateFormat(parent.getContext()).format( - e.getPubDate()) - + " " - + DateFormat.getTimeFormat(parent.getContext()).format( - e.getPubDate())); + datum.setText(DateFormat.getDateFormat(parent.getContext()).format(e.getPubDate()) + " " + + DateFormat.getTimeFormat(parent.getContext()).format(e.getPubDate())); TextView name = (TextView) view.findViewById(R.id.item_title); name.setText(e.getTitle()); diff --git a/src/de/mtbnews/android/receiver/NetworkStateReceiver.java b/src/de/mtbnews/android/receiver/NetworkStateReceiver.java @@ -34,15 +34,13 @@ public class NetworkStateReceiver extends BroadcastReceiver public void onReceive(Context context, Intent intent) { // Feststellen, ob die Verbindung besteht. - final boolean connectionAvailable = !intent.getBooleanExtra( - ConnectivityManager.EXTRA_NO_CONNECTIVITY, false); + final boolean connectionAvailable = !intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false); if (connectionAvailable) { // Datenverbindung vorhanden Log.d("IBC", "Connection established, (re-)starting service"); - context - .startService(new Intent(context, SubscriptionService.class)); + context.startService(new Intent(context, SubscriptionService.class)); } else { diff --git a/src/de/mtbnews/android/service/SubscriptionService.java b/src/de/mtbnews/android/service/SubscriptionService.java @@ -84,8 +84,7 @@ public class SubscriptionService extends Service prefs = PreferenceManager.getDefaultSharedPreferences(this); // Intervall in Minuten (Default = 3 Stunden) - int intervalInMinutes = Integer.parseInt(prefs.getString( - "subscription_service_interval", "180")); + int intervalInMinutes = Integer.parseInt(prefs.getString("subscription_service_interval", "180")); // Prüfen, ob Service laufen soll und ein Benutzername vorhanden ist if (prefs.getBoolean("autostart_subscription_service", false) @@ -93,8 +92,7 @@ public class SubscriptionService extends Service { Log.d(IBC.TAG, "Creating the timer"); timer = new Timer(); - timer.scheduleAtFixedRate(new SubscriptionTask(), 2000, - intervalInMinutes * 60 * 1000); + timer.scheduleAtFixedRate(new SubscriptionTask(), 2000, intervalInMinutes * 60 * 1000); } else { @@ -126,39 +124,32 @@ public class SubscriptionService extends Service // Tapatalk-Client durch den GC weggeräum werden kann. Dieser // Hintergrundprozess wird dadurch deutlich weniger // speicherintensiv. - final TapatalkClient client = new TapatalkClient( - IBC.IBC_FORUM_CONNECTOR_URL); + final TapatalkClient client = new TapatalkClient(IBC.IBC_FORUM_CONNECTOR_URL); // Anzeigen einer Notification, damit der Benutzer weiß, dass neue // Nachrichten ab final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - final PendingIntent emptyIntent = PendingIntent.getActivity( - getApplicationContext(), 0, new Intent(), 0); + final PendingIntent emptyIntent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0); - final String tickerText1 = getResources().getString( - R.string.checking_new); + final String tickerText1 = getResources().getString(R.string.checking_new); if (prefs.getBoolean("show_hints", false)) { - final Notification notificationRunning = new Notification( - R.drawable.ibc_logo, tickerText1, System - .currentTimeMillis()); + final Notification notificationRunning = new Notification(R.drawable.ibc_logo, tickerText1, System + .currentTimeMillis()); - notificationRunning.setLatestEventInfo(getApplicationContext(), - getResources().getString(R.string.checking_new), "", - emptyIntent); + notificationRunning.setLatestEventInfo(getApplicationContext(), getResources().getString( + R.string.checking_new), "", emptyIntent); notificationRunning.defaults = 0; - notificationRunning.flags = Notification.FLAG_ONGOING_EVENT - | Notification.FLAG_NO_CLEAR; + notificationRunning.flags = Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR; nm.notify(NOTIFICATION_EVENT_RUNNING, notificationRunning); } try { // Zuerst Login - client.login(prefs.getString("username", ""), prefs.getString( - "password", "")); + client.login(prefs.getString("username", ""), prefs.getString("password", "")); List<Forum> subscribedForum = client.getSubscribedForum(true); @@ -169,26 +160,20 @@ public class SubscriptionService extends Service } if (!forumNameList.isEmpty()) { - final Intent notificationIntent = new Intent( - SubscriptionService.this, + final Intent notificationIntent = new Intent(SubscriptionService.this, SubscriptionForenActivity.class); - final PendingIntent contentIntent = PendingIntent - .getActivity(SubscriptionService.this, 0, - notificationIntent, 0); - - final String tickerText = getResources().getString( - R.string.unread_forum) - + "\n" + TextUtils.join("\n", forumNameList); - - final Notification notification = createNotification( - tickerText, R.string.unread_forum, "(" - + subscribedForum.size() + ")", TextUtils - .join(", ", forumNameList), contentIntent); + final PendingIntent contentIntent = PendingIntent.getActivity(SubscriptionService.this, 0, + notificationIntent, 0); + + final String tickerText = getResources().getString(R.string.unread_forum) + "\n" + + TextUtils.join("\n", forumNameList); + + final Notification notification = createNotification(tickerText, R.string.unread_forum, "(" + + subscribedForum.size() + ")", TextUtils.join(", ", forumNameList), contentIntent); nm.notify(NOTIFICATION_FORUM, notification); } - ListHolder<Topic> subscribedTopic = client.getSubscribedTopics( - 0, 10, true); + ListHolder<Topic> subscribedTopic = client.getSubscribedTopics(0, 10, true); final List<String> topicNameList = new ArrayList<String>(); for (Topic topic : subscribedTopic.getChildren()) { @@ -197,21 +182,16 @@ public class SubscriptionService extends Service if (!topicNameList.isEmpty()) { - final Intent notificationIntent = new Intent( - SubscriptionService.this, + final Intent notificationIntent = new Intent(SubscriptionService.this, SubscriptionTopicsActivity.class); - final PendingIntent contentIntent = PendingIntent - .getActivity(SubscriptionService.this, 0, - notificationIntent, 0); - - final String tickerText = getResources().getString( - R.string.unread_topic) - + "\n" + TextUtils.join("\n", topicNameList); - - final Notification notification = createNotification( - tickerText, R.string.unread_topic, "(" - + subscribedTopic.getChildren().size() - + ")", TextUtils.join(", ", topicNameList), + final PendingIntent contentIntent = PendingIntent.getActivity(SubscriptionService.this, 0, + notificationIntent, 0); + + final String tickerText = getResources().getString(R.string.unread_topic) + "\n" + + TextUtils.join("\n", topicNameList); + + final Notification notification = createNotification(tickerText, R.string.unread_topic, "(" + + subscribedTopic.getChildren().size() + ")", TextUtils.join(", ", topicNameList), contentIntent); nm.notify(NOTIFICATION_TOPIC, notification); @@ -234,20 +214,15 @@ public class SubscriptionService extends Service if (unreadCount > 0) { - final Intent notificationIntent = new Intent( - SubscriptionService.this, MailboxActivity.class); - final PendingIntent contentIntent = PendingIntent - .getActivity(SubscriptionService.this, 0, - notificationIntent, 0); - - final String tickerText = getResources().getString( - R.string.unread_messages) - + "\n" + TextUtils.join("\n", unreadBoxNames); - - final Notification notification = createNotification( - tickerText, R.string.unread_messages, "(" - + unreadCount + ")", TextUtils.join(", ", - unreadBoxNames), contentIntent); + final Intent notificationIntent = new Intent(SubscriptionService.this, MailboxActivity.class); + final PendingIntent contentIntent = PendingIntent.getActivity(SubscriptionService.this, 0, + notificationIntent, 0); + + final String tickerText = getResources().getString(R.string.unread_messages) + "\n" + + TextUtils.join("\n", unreadBoxNames); + + final Notification notification = createNotification(tickerText, R.string.unread_messages, "(" + + unreadCount + ")", TextUtils.join(", ", unreadBoxNames), contentIntent); nm.notify(NOTIFICATION_MESSAGES, notification); } } @@ -323,17 +298,13 @@ public class SubscriptionService extends Service * Auszulösender Intent * @return */ - private Notification createNotification(String tickerText, int titleResId, - String titleExtra, String content, PendingIntent intent) + private Notification createNotification(String tickerText, int titleResId, String titleExtra, String content, + PendingIntent intent) { - final Notification notification = new Notification(R.drawable.ibc_logo, - tickerText, System.currentTimeMillis()); - notification - .setLatestEventInfo(getApplicationContext(), getResources() - .getString(titleResId) - + (titleExtra != null ? " " + titleExtra : ""), - content, intent); + final Notification notification = new Notification(R.drawable.ibc_logo, tickerText, System.currentTimeMillis()); + notification.setLatestEventInfo(getApplicationContext(), getResources().getString(titleResId) + + (titleExtra != null ? " " + titleExtra : ""), content, intent); notification.defaults = Notification.DEFAULT_LIGHTS; @@ -348,8 +319,7 @@ public class SubscriptionService extends Service if (prefs.getBoolean("use_vibration", false)) notification.defaults |= Notification.DEFAULT_VIBRATE; - notification.flags = Notification.FLAG_AUTO_CANCEL - | Notification.FLAG_ONLY_ALERT_ONCE; + notification.flags = Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONLY_ALERT_ONCE; return notification; } diff --git a/src/de/mtbnews/android/tapatalk/TapatalkClient.java b/src/de/mtbnews/android/tapatalk/TapatalkClient.java @@ -48,18 +48,15 @@ public class TapatalkClient * @param password * @throws TapatalkException */ - public void login(String username, String password) - throws TapatalkException + public void login(String username, String password) throws TapatalkException { this.loggedIn = false; this.loginTime = -1L; if (TextUtils.isEmpty(username)) - throw new TapatalkException("Username empty", - TapatalkErrorCode.NO_USERNAME); + throw new TapatalkException("Username empty", TapatalkErrorCode.NO_USERNAME); - final Object[] params = new Object[] { username.getBytes(), - password.getBytes() }; + final Object[] params = new Object[] { username.getBytes(), password.getBytes() }; try { @@ -70,8 +67,7 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException("Login failed" + ": " + e.getMessage(), - e, TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Login failed" + ": " + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); } } @@ -87,9 +83,7 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException( - "Logout failed" + ": " + e.getMessage(), e, - TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Logout failed" + ": " + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); } } @@ -106,8 +100,7 @@ public class TapatalkClient * @throws TapatalkException */ @SuppressWarnings("unchecked") - public Topic getTopic(String topicId, int start, int end) - throws TapatalkException + public Topic getTopic(String topicId, int start, int end) throws TapatalkException { try { @@ -120,17 +113,15 @@ public class TapatalkClient int postCount = toInt(map.get("total_post_num")); List<Post> posts = new ArrayList<Post>(); - Topic topic = new Topic(id, posts, title, null, null, null, - postCount); + Topic topic = new Topic(id, posts, title, null, null, null, postCount); topic.forumId = (String) map.get("forum_id"); for (Object o1 : (Object[]) map.get("posts")) { Map postMap = (Map) o1; - Post post = new Post((Date) postMap.get("post_time"), - byteArrayToString(postMap.get("post_title")), - byteArrayToString(postMap.get("post_content")), - byteArrayToString(postMap.get("post_author_name"))); + Post post = new Post((Date) postMap.get("post_time"), byteArrayToString(postMap.get("post_title")), + byteArrayToString(postMap.get("post_content")), byteArrayToString(postMap + .get("post_author_name"))); posts.add(post); } @@ -138,8 +129,7 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException("Could not load Topic " + topicId, e, - TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Could not load Topic " + topicId, e, TapatalkErrorCode.XMLRPC_ERROR); } } @@ -157,8 +147,7 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException("Could not load Forum structure", e, - TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Could not load Forum structure", e, TapatalkErrorCode.XMLRPC_ERROR); } } @@ -178,8 +167,7 @@ public class TapatalkClient public final static int TOPIC_ANNOUNCEMENT = 3; @SuppressWarnings("unchecked") - public Forum getForum(String forumId, int from, int to, int mode) - throws TapatalkException + public Forum getForum(String forumId, int from, int to, int mode) throws TapatalkException { try { @@ -209,14 +197,11 @@ public class TapatalkClient for (Object o1 : (Object[]) map.get("topics")) { Map topicMap = (Map) o1; - Topic topic = new Topic( - (String) topicMap.get("topic_id"), - posts, // + Topic topic = new Topic((String) topicMap.get("topic_id"), posts, // byteArrayToString(topicMap.get("topic_title")),// (Date) topicMap.get("last_reply_time"), // byteArrayToString(topicMap.get("short_content")),// - byteArrayToString(topicMap.get("topic_author_name")), - 0); + byteArrayToString(topicMap.get("topic_author_name")), 0); topic.unread = (Boolean) topicMap.get("new_post"); topics.add(topic); } @@ -226,14 +211,13 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException("Could not load Forum " + forumId - + ": " + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Could not load Forum " + forumId + ": " + e.getMessage(), e, + TapatalkErrorCode.XMLRPC_ERROR); } } @SuppressWarnings("unchecked") - public ListHolder<Topic> getSubscribedTopics(int from, int to, - boolean onlyUnread) throws TapatalkException + public ListHolder<Topic> getSubscribedTopics(int from, int to, boolean onlyUnread) throws TapatalkException { try { @@ -250,33 +234,28 @@ public class TapatalkClient if (!onlyUnread || (Boolean) topicMap.get("new_post")) { - Topic topic = new Topic( - (String) topicMap.get("topic_id"), - new ArrayList<Post>(), // + Topic topic = new Topic((String) topicMap.get("topic_id"), new ArrayList<Post>(), // byteArrayToString(topicMap.get("topic_title")),// (Date) topicMap.get("post_time"), // byteArrayToString(topicMap.get("short_content")),// - byteArrayToString(topicMap.get("post_author_name")), - 0); + byteArrayToString(topicMap.get("post_author_name")), 0); topic.unread = (Boolean) topicMap.get("new_post"); topics.add(topic); } } - ListHolder<Topic> topicHolder = new ListHolder<Topic>(topics, - topicCount, from, to); + ListHolder<Topic> topicHolder = new ListHolder<Topic>(topics, topicCount, from, to); return topicHolder; } catch (XMLRPCException e) { - throw new TapatalkException("Could not load subscribe topics" - + ": " + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Could not load subscribe topics" + ": " + e.getMessage(), e, + TapatalkErrorCode.XMLRPC_ERROR); } } @SuppressWarnings("unchecked") - public List<Forum> getSubscribedForum(boolean onlyUnread) - throws TapatalkException + public List<Forum> getSubscribedForum(boolean onlyUnread) throws TapatalkException { try { @@ -294,8 +273,7 @@ public class TapatalkClient { String id = (String) map2.get("forum_id"); String name = byteArrayToString(map2.get("forum_name")); - Forum forum = new Forum(id, new ArrayList<Topic>(), name, - null, null); + Forum forum = new Forum(id, new ArrayList<Topic>(), name, null, null); forum.unread = (Boolean) map2.get("new_post"); forums.add(forum); @@ -306,8 +284,8 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException("Could not load subscribe topics" - + ": " + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Could not load subscribe topics" + ": " + e.getMessage(), e, + TapatalkErrorCode.XMLRPC_ERROR); } } @@ -335,8 +313,7 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException("XMLRPC-Error: " + e.getMessage(), e, - TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("XMLRPC-Error: " + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); } } @@ -358,8 +335,7 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException("Marking topics read: " - + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Marking topics read: " + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); } } @@ -378,8 +354,7 @@ public class TapatalkClient * One of the SUBSCRIBE_*-constants * @throws TapatalkException */ - public void subscribeForum(String forumId, int mode) - throws TapatalkException + public void subscribeForum(String forumId, int mode) throws TapatalkException { try { @@ -397,8 +372,8 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException("Could not load subscribe topics" - + ": " + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Could not load subscribe topics" + ": " + e.getMessage(), e, + TapatalkErrorCode.XMLRPC_ERROR); } } @@ -411,8 +386,7 @@ public class TapatalkClient * One of the SUBSCRIBE_*-constants * @throws TapatalkException */ - public void subscribeTopic(String topicId, int mode) - throws TapatalkException + public void subscribeTopic(String topicId, int mode) throws TapatalkException { try { @@ -430,8 +404,8 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException("Could not load subscribe topics" - + ": " + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Could not load subscribe topics" + ": " + e.getMessage(), e, + TapatalkErrorCode.XMLRPC_ERROR); } } @@ -440,8 +414,8 @@ public class TapatalkClient public static final int SEARCHTYPE_PARTICIPATED = 3; public static final int SEARCHTYPE_UNREAD = 4; - public Search searchTopics(int searchType, String query, String username, - int start, int end, String searchId) throws TapatalkException + public Search searchTopics(int searchType, String query, String username, int start, int end, String searchId) + throws TapatalkException { try { @@ -455,8 +429,7 @@ public class TapatalkClient if (searchId == null) params = new Object[] { query.getBytes(), start, end }; else - params = new Object[] { "".getBytes(), start, end, - searchId }; + params = new Object[] { "".getBytes(), start, end, searchId }; break; case SEARCHTYPE_LATEST: method = "get_latest_topic"; @@ -470,8 +443,7 @@ public class TapatalkClient if (searchId == null) params = new Object[] { username.getBytes(), start, end }; else - params = new Object[] { username.getBytes(), start, - end, searchId }; + params = new Object[] { username.getBytes(), start, end, searchId }; break; case SEARCHTYPE_UNREAD: method = "get_unread_topic"; @@ -494,8 +466,7 @@ public class TapatalkClient for (Object o1 : (Object[]) map.get("topics")) { Map topicMap = toMap(o1); - Topic topic = new Topic((String) topicMap.get("topic_id"), - posts, // + Topic topic = new Topic((String) topicMap.get("topic_id"), posts, // byteArrayToString(topicMap.get("topic_title")),// (Date) topicMap.get("post_time"), // byteArrayToString(topicMap.get("short_content")),// @@ -508,8 +479,7 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException("Could not search" + ": " - + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Could not search" + ": " + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); } } @@ -533,8 +503,7 @@ public class TapatalkClient for (Object o1 : (Object[]) map.get("list")) { Map mapMap = toMap(o1); - Mailbox box = new Mailbox((String) mapMap.get("box_id"), - byteArrayToString(mapMap.get("box_name")),// + Mailbox box = new Mailbox((String) mapMap.get("box_id"), byteArrayToString(mapMap.get("box_name")),// (Integer) mapMap.get("msg_count"), // (Integer) mapMap.get("unread_count")); boxList.add(box); @@ -545,8 +514,8 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException("Could not read mailbox" + ": " - + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Could not read mailbox" + ": " + e.getMessage(), e, + TapatalkErrorCode.XMLRPC_ERROR); } } @@ -559,16 +528,14 @@ public class TapatalkClient * @return * @throws TapatalkException */ - public Mailbox getBoxContent(String boxId, int start, int end) - throws TapatalkException + public Mailbox getBoxContent(String boxId, int start, int end) throws TapatalkException { try { Object[] params = new Object[] { boxId, start, end }; Map map = toMap(client.callEx("get_box", params)); - Mailbox mailbox = new Mailbox(boxId, "", (Integer) map - .get("total_message_count"), (Integer) map + Mailbox mailbox = new Mailbox(boxId, "", (Integer) map.get("total_message_count"), (Integer) map .get("total_unread_count")); final List<Message> messageList = new ArrayList<Message>(); @@ -581,11 +548,10 @@ public class TapatalkClient Object[] objects = (Object[]) msgMap.get("msg_to"); String[] msgTo = new String[objects.length]; for (int j = 0; j < objects.length; j++) - msgTo[j] = byteArrayToString((toMap(objects[j]) - .get("username"))); + msgTo[j] = byteArrayToString((toMap(objects[j]).get("username"))); - Message message = new Message((String) msgMap.get("msg_id"), - ((Integer) msgMap.get("msg_state")).equals(1), // + Message message = new Message((String) msgMap.get("msg_id"), ((Integer) msgMap.get("msg_state")) + .equals(1), // (Date) msgMap.get("sent_date"),// byteArrayToString(msgMap.get("msg_from")),// msgTo,// @@ -598,8 +564,8 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException("Could not read mailbox " + boxId - + ": " + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Could not read mailbox " + boxId + ": " + e.getMessage(), e, + TapatalkErrorCode.XMLRPC_ERROR); } } @@ -612,15 +578,13 @@ public class TapatalkClient * @return * @throws TapatalkException */ - public Message getMessage(String boxId, String messageId) - throws TapatalkException + public Message getMessage(String boxId, String messageId) throws TapatalkException { try { final Object[] params = new Object[] { messageId, boxId }; - Map<String, Object> mapMap = toMap(client.callEx("get_message", - params)); + Map<String, Object> mapMap = toMap(client.callEx("get_message", params)); Object[] objects = (Object[]) mapMap.get("msg_to"); String[] msgTo = new String[objects.length]; @@ -638,8 +602,7 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException("Could not read message " + boxId + "," - + messageId + ": " + e.getMessage(), e, + throw new TapatalkException("Could not read message " + boxId + "," + messageId + ": " + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); } } @@ -652,13 +615,11 @@ public class TapatalkClient * @param content * @throws TapatalkException */ - public void createTopic(String forumId, String subject, String content) - throws TapatalkException + public void createTopic(String forumId, String subject, String content) throws TapatalkException { try { - final Object[] params = new Object[] { forumId, subject.getBytes(), - content.getBytes() }; + final Object[] params = new Object[] { forumId, subject.getBytes(), content.getBytes() }; Map<?, ?> map = toMap(client.callEx("new_topic", params)); @@ -668,8 +629,8 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException("Could not create the topic: " - + e.getMessage(), e, TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Could not create the topic: " + e.getMessage(), e, + TapatalkErrorCode.XMLRPC_ERROR); } } @@ -682,13 +643,11 @@ public class TapatalkClient * @return * @throws TapatalkException */ - public void createReply(String forumId, String topicId, String subject, - String content) throws TapatalkException + public void createReply(String forumId, String topicId, String subject, String content) throws TapatalkException { try { - final Object[] params = new Object[] { forumId, topicId, - subject.getBytes(), content.getBytes() }; + final Object[] params = new Object[] { forumId, topicId, subject.getBytes(), content.getBytes() }; Map<?, ?> map = toMap(client.callEx("reply_post", params)); @@ -697,8 +656,7 @@ public class TapatalkClient } catch (XMLRPCException e) { - throw new TapatalkException("Could not reply", e, - TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Could not reply", e, TapatalkErrorCode.XMLRPC_ERROR); } } @@ -711,13 +669,11 @@ public class TapatalkClient * @return * @throws TapatalkException */ - public void createMessage(String[] to, String subject, String content) - throws TapatalkException + public void createMessage(String[] to, String subject, String content) throws TapatalkException { try { - final Object[] params = new Object[] { to, subject.getBytes(), - content.getBytes() }; + final Object[] params = new Object[] { to, subject.getBytes(), content.getBytes() }; Object result = client.callEx("create_message", params); @@ -728,8 +684,7 @@ public class TapatalkClient final Boolean ok = (Boolean) result; if (!ok) { - throw new TapatalkException("sending message failed", - TapatalkErrorCode.SEND_MESSAGE_FAILED); + throw new TapatalkException("sending message failed", TapatalkErrorCode.SEND_MESSAGE_FAILED); } } else @@ -742,25 +697,22 @@ public class TapatalkClient } catch (TapatalkException e) { - throw new TapatalkException("sending message failed: " - + e.getMessage(), + throw new TapatalkException("sending message failed: " + e.getMessage(), TapatalkErrorCode.SEND_MESSAGE_FAILED); } } } catch (XMLRPCException e) { - throw new TapatalkException("Could not create the message", e, - TapatalkErrorCode.XMLRPC_ERROR); + throw new TapatalkException("Could not create the message", e, TapatalkErrorCode.XMLRPC_ERROR); } } - public void setUserAgent( String agent) + public void setUserAgent(String agent) { client.setUserAgent(agent); } - private static String byteArrayToString(Object object) { byte[] byteArray = (byte[]) object; @@ -793,8 +745,7 @@ public class TapatalkClient { if (!(o instanceof Map)) { - throw new TapatalkException("no map: " + o.toString() + " (" - + o.getClass() + ")", + throw new TapatalkException("no map: " + o.toString() + " (" + o.getClass() + ")", TapatalkErrorCode.UNKNOWN_SERVER_RESPONSE); } Map<String, Object> map = (Map<String, Object>) o; @@ -805,8 +756,7 @@ public class TapatalkClient boolean ok = (Boolean) object; if (!ok) - throw new TapatalkException(byteArrayToString(map - .get("result_text")), + throw new TapatalkException(byteArrayToString(map.get("result_text")), TapatalkErrorCode.UNKNOWN_SERVER_RESPONSE); return map; } @@ -821,14 +771,12 @@ public class TapatalkClient 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); + Forum forum = new Forum(id, new ArrayList<Topic>(), name, null, content); forum.url = (String) map.get("url"); list.add(forum); forum.subOnly = (Boolean) map.get("sub_only"); if (map.containsKey(childName)) - forum.subForen = createSubForen(castToMapArray((Object[]) map - .get(childName)), childName); + forum.subForen = createSubForen(castToMapArray((Object[]) map.get(childName)), childName); } return list; diff --git a/src/de/mtbnews/android/tapatalk/TapatalkException.java b/src/de/mtbnews/android/tapatalk/TapatalkException.java @@ -22,8 +22,7 @@ public class TapatalkException extends Exception * @param errorCode * TODO */ - public TapatalkException(String detailMessage, Throwable throwable, - TapatalkErrorCode errorCode) + public TapatalkException(String detailMessage, Throwable throwable, TapatalkErrorCode errorCode) { super(detailMessage, throwable); diff --git a/src/de/mtbnews/android/tapatalk/wrapper/Forum.java b/src/de/mtbnews/android/tapatalk/wrapper/Forum.java @@ -19,7 +19,7 @@ public class Forum implements ListEntry public boolean subOnly; public boolean unread; public String url; - + @Override public boolean isUnread() { @@ -34,8 +34,7 @@ public class Forum implements ListEntry * @param content * @param postCount */ - public Forum(String id, List<Topic> topics, String title, Date date, - String content) + public Forum(String id, List<Topic> topics, String title, Date date, String content) { super(); this.id = id; diff --git a/src/de/mtbnews/android/tapatalk/wrapper/ListEntry.java b/src/de/mtbnews/android/tapatalk/wrapper/ListEntry.java @@ -10,8 +10,8 @@ public interface ListEntry String getContent(); Date getDate(); - + String getName(); - + boolean isUnread(); } diff --git a/src/de/mtbnews/android/tapatalk/wrapper/ListHolder.java b/src/de/mtbnews/android/tapatalk/wrapper/ListHolder.java @@ -19,7 +19,7 @@ public class ListHolder<T> public ListHolder(List<T> children, int totalCount, int from, int to) { super(); - this.children= children; + this.children = children; this.totalCount = totalCount; this.from = from; this.to = to; diff --git a/src/de/mtbnews/android/tapatalk/wrapper/Message.java b/src/de/mtbnews/android/tapatalk/wrapper/Message.java @@ -12,7 +12,6 @@ public class Message implements ListEntry public String content; public boolean unread; - @Override public boolean isUnread() { @@ -28,8 +27,7 @@ public class Message implements ListEntry * @param subject * @param content */ - public Message(String id, boolean unread, Date date, String from, String[] to, - String subject, String content) + public Message(String id, boolean unread, Date date, String from, String[] to, String subject, String content) { super(); this.id = id; diff --git a/src/de/mtbnews/android/tapatalk/wrapper/Post.java b/src/de/mtbnews/android/tapatalk/wrapper/Post.java @@ -63,5 +63,4 @@ public class Post implements ListEntry return name; } - } diff --git a/src/de/mtbnews/android/tapatalk/wrapper/Topic.java b/src/de/mtbnews/android/tapatalk/wrapper/Topic.java @@ -15,7 +15,7 @@ public class Topic implements ListEntry private String content; private String name; private int postCount; - + public String forumId; public boolean unread; @@ -34,8 +34,7 @@ public class Topic implements ListEntry * @param name * @param postCount */ - public Topic(String id, List<Post> posts, String title, Date date, - String content, String name, int postCount) + public Topic(String id, List<Post> posts, String title, Date date, String content, String name, int postCount) { super(); this.id = id; diff --git a/src/de/mtbnews/android/util/IBCException.java b/src/de/mtbnews/android/util/IBCException.java @@ -6,7 +6,7 @@ package de.mtbnews.android.util; /** * * @author dankert - * + * */ public class IBCException extends Exception { @@ -14,7 +14,8 @@ public class IBCException extends Exception private int errorResId; /** - * @param errorResId Resource-Id der Fehlermeldung + * @param errorResId + * Resource-Id der Fehlermeldung * @param detailMessage * @param cause */ @@ -22,9 +23,9 @@ public class IBCException extends Exception { super(detailMessage, cause); this.errorResId = errorResId; - + } - + /** * @return */ diff --git a/src/de/mtbnews/android/util/ServerAsyncTask.java b/src/de/mtbnews/android/util/ServerAsyncTask.java @@ -57,25 +57,22 @@ public abstract class ServerAsyncTask extends AsyncTask<Void, Void, Void> this.progressDialog = new ProgressDialog(context); // progressDialog.setTitle(R.string.loading); - progressDialog.setMessage(context.getResources().getString(message) - + " ..."); + progressDialog.setMessage(context.getResources().getString(message) + " ..."); } @Override final protected void onPreExecute() { progressDialog.setCancelable(true); - progressDialog - .setOnCancelListener(new DialogInterface.OnCancelListener() - { - @Override - public void onCancel(DialogInterface dialog) - { - ServerAsyncTask.this.cancel(true); - Toast.makeText(context, R.string.canceled, - Toast.LENGTH_SHORT).show(); - } - }); + progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() + { + @Override + public void onCancel(DialogInterface dialog) + { + ServerAsyncTask.this.cancel(true); + Toast.makeText(context, R.string.canceled, Toast.LENGTH_SHORT).show(); + } + }); progressDialog.show(); } @@ -158,8 +155,7 @@ public abstract class ServerAsyncTask extends AsyncTask<Void, Void, Void> catch (TapatalkException e) { Log.w(this.getClass().getName(), e.getMessage(), e); - error = new IBCException(Utils.getResId(e.getErrorCode()), e - .getMessage(), e); + error = new IBCException(Utils.getResId(e.getErrorCode()), e.getMessage(), e); } catch (IBCException e) { @@ -195,8 +191,7 @@ public abstract class ServerAsyncTask extends AsyncTask<Void, Void, Void> * @throws IOException * Vom Server erzeugte Fehler */ - protected abstract void callServer() throws IOException, TapatalkException, - IBCException; + protected abstract void callServer() throws IOException, TapatalkException, IBCException; /** * diff --git a/src/de/mtbnews/android/util/Utils.java b/src/de/mtbnews/android/util/Utils.java @@ -41,7 +41,6 @@ public final class Utils */ public static final boolean loginExceeded(TapatalkClient client) { - return !client.loggedIn - || System.currentTimeMillis() - client.loginTime > IBC.LOGIN_TIMEOUT * 60 * 1000; + return !client.loggedIn || System.currentTimeMillis() - client.loginTime > IBC.LOGIN_TIMEOUT * 60 * 1000; } }