summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrace Kloba <klobag@google.com>2009-08-27 11:53:36 -0700
committerGrace Kloba <klobag@google.com>2009-08-27 11:53:36 -0700
commitb8a9cb0e2b3b2a1bb250853a79b8ea2046ff3d6e (patch)
tree286b6bcc45a0ad7f2749efdb326f90762feadc71
parent9f0d27c82baa6d838147afabdf6f0764bf265a21 (diff)
downloadBrowser-android-1.6_r1.5.tar.gz
The IconListenerSet inside CombinedBookmarkHistoryActivity is static. So when the activity is destroyed, it needs to remove its listener to avoid leak.
-rw-r--r--src/com/android/browser/BrowserHistoryPage.java7
-rw-r--r--src/com/android/browser/CombinedBookmarkHistoryActivity.java3
-rw-r--r--src/com/android/browser/MostVisitedActivity.java12
3 files changed, 21 insertions, 1 deletions
diff --git a/src/com/android/browser/BrowserHistoryPage.java b/src/com/android/browser/BrowserHistoryPage.java
index 42ca8480..4a0f8c52 100644
--- a/src/com/android/browser/BrowserHistoryPage.java
+++ b/src/com/android/browser/BrowserHistoryPage.java
@@ -137,6 +137,13 @@ public class BrowserHistoryPage extends ExpandableListActivity {
}
@Override
+ protected void onDestroy() {
+ super.onDestroy();
+ CombinedBookmarkHistoryActivity.getIconListenerSet(getContentResolver())
+ .removeListener(mIconReceiver);
+ }
+
+ @Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
diff --git a/src/com/android/browser/CombinedBookmarkHistoryActivity.java b/src/com/android/browser/CombinedBookmarkHistoryActivity.java
index 963f1792..5678b442 100644
--- a/src/com/android/browser/CombinedBookmarkHistoryActivity.java
+++ b/src/com/android/browser/CombinedBookmarkHistoryActivity.java
@@ -59,6 +59,9 @@ public class CombinedBookmarkHistoryActivity extends TabActivity
public void addListener(IconListener listener) {
mListeners.add(listener);
}
+ public void removeListener(IconListener listener) {
+ mListeners.remove(listener);
+ }
public Bitmap getFavicon(String url) {
return (Bitmap) mUrlsToIcons.get(url);
}
diff --git a/src/com/android/browser/MostVisitedActivity.java b/src/com/android/browser/MostVisitedActivity.java
index 704ee279..83342a18 100644
--- a/src/com/android/browser/MostVisitedActivity.java
+++ b/src/com/android/browser/MostVisitedActivity.java
@@ -42,12 +42,15 @@ public class MostVisitedActivity extends ListActivity {
private MyAdapter mAdapter;
+ // Instance of IconReceiver
+ private final IconReceiver mIconReceiver = new IconReceiver();
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mAdapter = new MyAdapter();
CombinedBookmarkHistoryActivity.getIconListenerSet(getContentResolver())
- .addListener(new IconReceiver());
+ .addListener(mIconReceiver);
setListAdapter(mAdapter);
ListView list = getListView();
LayoutInflater factory = LayoutInflater.from(this);
@@ -57,6 +60,13 @@ public class MostVisitedActivity extends ListActivity {
list.setEmptyView(v);
}
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ CombinedBookmarkHistoryActivity.getIconListenerSet(getContentResolver())
+ .removeListener(mIconReceiver);
+ }
+
private class IconReceiver implements IconListener {
public void onReceivedIcon(String url, Bitmap icon) {
setListAdapter(mAdapter);