summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuobin Zhang <guobin.zhang@intel.com>2012-09-12 00:07:18 +0800
committerGuobin Zhang <guobin.zhang@intel.com>2014-04-28 11:09:57 +0800
commit8e317f9f98cdcfc4955c483e20b5a620849ff2dc (patch)
tree3a0c5df46cc3ebe5f75079ca60b7daa0d5c4761b
parent80c20b369e24adbcdcb1387923182bbaa917dba0 (diff)
downloadMms-8e317f9f98cdcfc4955c483e20b5a620849ff2dc.tar.gz
Avoid ConversationList/ComposeMessage activity leaks
First, ConversationList activity leak, Contact.mListeners are only unbound when ListItemViews are recycled, without considering the activity exit case or message delete case. Second, ComposeMessage activity leak: use SoftReferences instead of HardReferences for the slideshow cache. Change-Id: Ic235b31403b26aba16bf6b8b51bff7b4c6f68d98 Signed-off-by: Guobin Zhang <guobin.zhang@intel.com>
-rw-r--r--src/com/android/mms/ui/ConversationList.java18
-rw-r--r--src/com/android/mms/util/PduLoaderManager.java2
2 files changed, 19 insertions, 1 deletions
diff --git a/src/com/android/mms/ui/ConversationList.java b/src/com/android/mms/ui/ConversationList.java
index afbc456a..12a9e5fc 100644
--- a/src/com/android/mms/ui/ConversationList.java
+++ b/src/com/android/mms/ui/ConversationList.java
@@ -410,6 +410,7 @@ public class ConversationList extends ListActivity implements DraftCache.OnDraft
DraftCache.getInstance().removeOnDraftChangedListener(this);
+ unbindListeners(null);
// Simply setting the choice mode causes the previous choice mode to finish and we exit
// multi-select mode (if we're in it) and remove all the selections.
getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
@@ -424,6 +425,20 @@ public class ConversationList extends ListActivity implements DraftCache.OnDraft
mListAdapter.changeCursor(null);
}
+ private void unbindListeners(final Collection<Long> threadIds) {
+ for (int i = 0; i < getListView().getChildCount(); i++) {
+ View view = getListView().getChildAt(i);
+ if (view instanceof ConversationListItem) {
+ ConversationListItem item = (ConversationListItem)view;
+ if (threadIds == null) {
+ item.unbind();
+ } else if (threadIds.contains(item.getConversation().getThreadId())) {
+ item.unbind();
+ }
+ }
+ }
+ }
+
@Override
public void onDraftChanged(final long threadId, final boolean hasDraft) {
// Run notifyDataSetChanged() on the main thread.
@@ -821,6 +836,9 @@ public class ConversationList extends ListActivity implements DraftCache.OnDraft
@Override
public void run() {
int token = DELETE_CONVERSATION_TOKEN;
+ if (mContext instanceof ConversationList) {
+ ((ConversationList)mContext).unbindListeners(mThreadIds);
+ }
if (mThreadIds == null) {
Conversation.startDeleteAll(mHandler, token, mDeleteLockedMessages);
DraftCache.getInstance().refresh();
diff --git a/src/com/android/mms/util/PduLoaderManager.java b/src/com/android/mms/util/PduLoaderManager.java
index 6ebcd307..4730b57f 100644
--- a/src/com/android/mms/util/PduLoaderManager.java
+++ b/src/com/android/mms/util/PduLoaderManager.java
@@ -65,7 +65,7 @@ public class PduLoaderManager extends BackgroundLoaderManager {
public PduLoaderManager(final Context context) {
super(context);
- mSlideshowCache = new SimpleCache<Uri, SlideshowModel>(8, 16, 0.75f, true);
+ mSlideshowCache = new SimpleCache<Uri, SlideshowModel>(8, 16, 0.75f, false);
mPduCache = PduCache.getInstance();
mPduPersister = PduPersister.getPduPersister(context);
mContext = context;