android-ibc-forum

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

commit fb25405dd49bd497ffbe3b0f3a3d5744d99f3362
parent c83c057b5f293fda5aec8d684b9996a52e7d6b70
Author: Jan Dankert <devnull@localhost>
Date:   Sun, 12 Feb 2012 20:47:01 +0100

Den Tapatalk-Client als Instanzvariable halten, damit der Client nicht vom GC entfernt wird (und der Benutzer damit ausgeloggt wird), während die Activity läuft.

Diffstat:
src/de/mtbnews/android/ForumActivity.java | 19++++---------------
src/de/mtbnews/android/ForumOverviewActivity.java | 9++-------
src/de/mtbnews/android/ReplyMailActivity.java | 8++------
src/de/mtbnews/android/SubscriptionForenActivity.java | 5+++--
src/de/mtbnews/android/TopicActivity.java | 9+++------
5 files changed, 14 insertions(+), 36 deletions(-)

diff --git a/src/de/mtbnews/android/ForumActivity.java b/src/de/mtbnews/android/ForumActivity.java @@ -47,6 +47,8 @@ public class ForumActivity extends EndlessListActivity<Topic> private String forumId; private int topicMode = TapatalkClient.TOPIC_STANDARD; + private TapatalkClient client; + @Override protected void onCreate(Bundle savedInstanceState) { @@ -56,7 +58,7 @@ public class ForumActivity extends EndlessListActivity<Topic> prefs = PreferenceManager.getDefaultSharedPreferences(this); - TapatalkClient client = ((IBCApplication) getApplication()) + client = ((IBCApplication) getApplication()) .getTapatalkClient(); if (!client.loggedIn && prefs.getBoolean("auto_login", false)) @@ -143,8 +145,6 @@ public class ForumActivity extends EndlessListActivity<Topic> private void login() { - final TapatalkClient client = ((IBCApplication) getApplication()) - .getTapatalkClient(); new ServerAsyncTask(this, R.string.waitingfor_login) { @@ -172,9 +172,6 @@ public class ForumActivity extends EndlessListActivity<Topic> private void logout() { - final TapatalkClient client = ((IBCApplication) getApplication()) - .getTapatalkClient(); - new ServerAsyncTask(this, R.string.waitingfor_logout) { @@ -204,7 +201,7 @@ public class ForumActivity extends EndlessListActivity<Topic> super.onCreateOptionsMenu(menu); MenuInflater mi = new MenuInflater(getApplication()); - if (((IBCApplication) getApplication()).getTapatalkClient().loggedIn) + if (client.loggedIn) mi.inflate(R.menu.forum, menu); else mi.inflate(R.menu.forum_guest, menu); @@ -294,8 +291,6 @@ public class ForumActivity extends EndlessListActivity<Topic> throws IOException, TapatalkException { - TapatalkClient client = ((IBCApplication) getApplication()) - .getTapatalkClient(); client .subscribeForum(forumId, item - 1); @@ -322,8 +317,6 @@ public class ForumActivity extends EndlessListActivity<Topic> @Override protected void callServer() throws TapatalkException { - TapatalkClient client = ((IBCApplication) getApplication()) - .getTapatalkClient(); client.markForumAsRead(forumId); } @@ -343,8 +336,6 @@ public class ForumActivity extends EndlessListActivity<Topic> @Override protected void callServer() throws TapatalkException { - TapatalkClient client = ((IBCApplication) getApplication()) - .getTapatalkClient(); client.markForumAsRead(null); } @@ -398,8 +389,6 @@ public class ForumActivity extends EndlessListActivity<Topic> protected void callServer() throws TapatalkException { - TapatalkClient client = ((IBCApplication) getApplication()) - .getTapatalkClient(); this.forum = client.getForum(forumId, from, to, topicMode); totalSize = this.forum.topicCount; } diff --git a/src/de/mtbnews/android/ForumOverviewActivity.java b/src/de/mtbnews/android/ForumOverviewActivity.java @@ -39,6 +39,7 @@ public class ForumOverviewActivity extends ExpandableListActivity { private SharedPreferences prefs; private List<Forum> forumList; + private TapatalkClient client; @Override protected void onCreate(Bundle savedInstanceState) @@ -85,7 +86,7 @@ public class ForumOverviewActivity extends ExpandableListActivity private void loadForum() { - final TapatalkClient client = ((IBCApplication) getApplication()) + client = ((IBCApplication) getApplication()) .getTapatalkClient(); new ServerAsyncTask(this, R.string.waitingfor_forum) @@ -168,9 +169,6 @@ public class ForumOverviewActivity extends ExpandableListActivity menu.clear(); MenuInflater mi = new MenuInflater(getApplication()); - TapatalkClient client = ((IBCApplication) getApplication()) - .getTapatalkClient(); - if (client.loggedIn) mi.inflate(R.menu.forumoverview, menu); else @@ -256,7 +254,6 @@ public class ForumOverviewActivity extends ExpandableListActivity if (!TextUtils.isEmpty(prefs.getString("username", ""))) { - final TapatalkClient client = ((IBCApplication) getApplication()).getTapatalkClient(); new ServerAsyncTask(this, R.string.waitingfor_login) { @@ -297,8 +294,6 @@ public class ForumOverviewActivity extends ExpandableListActivity private void logout() { - final TapatalkClient client = ((IBCApplication) getApplication()).getTapatalkClient(); - new ServerAsyncTask(this, R.string.waitingfor_logout) { diff --git a/src/de/mtbnews/android/ReplyMailActivity.java b/src/de/mtbnews/android/ReplyMailActivity.java @@ -18,10 +18,12 @@ public class ReplyMailActivity extends Activity { private String boxId; private String messageId; + private TapatalkClient client; @Override protected void onCreate(Bundle savedInstanceState) { + client = ((IBCApplication) getApplication()).getTapatalkClient(); setContentView(R.layout.post); super.onCreate(savedInstanceState); @@ -38,13 +40,10 @@ public class ReplyMailActivity extends Activity new ServerAsyncTask(this, R.string.waitingfor_mailbox) { private Message message; - private TapatalkClient client; @Override protected void callServer() throws TapatalkException { - client = ((IBCApplication) getApplication()) - .getTapatalkClient(); message = client.getMessage(boxId, messageId); } @@ -80,9 +79,6 @@ public class ReplyMailActivity extends Activity protected void callServer() throws IOException, TapatalkException { - TapatalkClient client = ((IBCApplication) getApplication()) - .getTapatalkClient(); - client.createMessage(new String[] { recipient.getText() .toString() }, subject.getText().toString(), text.getText().toString()); diff --git a/src/de/mtbnews/android/SubscriptionForenActivity.java b/src/de/mtbnews/android/SubscriptionForenActivity.java @@ -38,12 +38,14 @@ import de.mtbnews.android.util.Utils; public class SubscriptionForenActivity extends ListActivity { private SharedPreferences prefs; + private TapatalkClient client; private final List<Forum> forumList = new ArrayList<Forum>(); @Override protected void onCreate(Bundle savedInstanceState) { + client = ((IBCApplication) getApplication()).getTapatalkClient(); super.onCreate(savedInstanceState); setContentView(R.layout.listing); @@ -95,7 +97,6 @@ public class SubscriptionForenActivity extends ListActivity @Override protected void callServer() throws IOException, TapatalkException { - TapatalkClient client = ((IBCApplication) getApplication()).getTapatalkClient(); // Login. if (Utils.loginExceeded(client)) @@ -156,7 +157,7 @@ public class SubscriptionForenActivity extends ListActivity super.onCreateOptionsMenu(menu); MenuInflater mi = new MenuInflater(getApplication()); - if (((IBCApplication) getApplication()).getTapatalkClient().loggedIn) + if (client.loggedIn) mi.inflate(R.menu.forum, menu); else mi.inflate(R.menu.forum_guest, menu); diff --git a/src/de/mtbnews/android/TopicActivity.java b/src/de/mtbnews/android/TopicActivity.java @@ -41,10 +41,12 @@ public class TopicActivity extends EndlessListActivity<Post> private String topicTitle; private int totalSize; + private TapatalkClient client; @Override protected void onCreate(Bundle savedInstanceState) { + client = ((IBCApplication) getApplication()).getTapatalkClient(); super.onCreate(savedInstanceState); topicId = TopicActivity.this.getIntent().getStringExtra(TOPIC_ID); @@ -99,7 +101,6 @@ public class TopicActivity extends EndlessListActivity<Post> @Override protected void callServer() throws TapatalkException { - TapatalkClient client = ((IBCApplication) getApplication()).getTapatalkClient(); topic = client.getTopic(topicId, from, to); @@ -144,7 +145,7 @@ public class TopicActivity extends EndlessListActivity<Post> case R.id.menu_bottom: getListView().setOnScrollListener(null); - getListView().setSelection( super.entries.size()-1); + getListView().setSelection(super.entries.size() - 1); getIntent().putExtra(LAST_POST, true); initialLoad(); return true; @@ -175,8 +176,6 @@ public class TopicActivity extends EndlessListActivity<Post> protected void callServer() throws TapatalkException { - TapatalkClient client = ((IBCApplication) getApplication()) - .getTapatalkClient(); client .subscribeTopic(topicId, item - 1); @@ -205,8 +204,6 @@ public class TopicActivity extends EndlessListActivity<Post> @Override protected void callServer() throws TapatalkException { - TapatalkClient client = ((IBCApplication) getApplication()) - .getTapatalkClient(); client.markTopicAsRead(topicId); } }.execute();