Bug 838398 - Make sure SyncType.onDestroy() is called when AboutHomePromoBox is removed. r=mfinkle
authorBrian Nicholson <bnicholson@mozilla.com>
Wed, 06 Feb 2013 10:45:19 -0800
changeset 130916 78a71db31dca4b1390e0119910f84925b32ca3ea
parent 130915 e65517972de2e638646cadb33d543c7061dfb2a6
child 130917 0b6163b1693fd4b56558d8f1c858175286770922
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs838398
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 838398 - Make sure SyncType.onDestroy() is called when AboutHomePromoBox is removed. r=mfinkle
mobile/android/base/AboutHomePromoBox.java
services/common/tests/unit/test_utils_json.js
--- a/mobile/android/base/AboutHomePromoBox.java
+++ b/mobile/android/base/AboutHomePromoBox.java
@@ -45,16 +45,24 @@ public class AboutHomePromoBox extends T
             text = aText;
             boldText = aBoldText;
             image = aImage;
         }
         public boolean canShow() {
             return true;
         }
         public void onClick(View v) { }
+        public void onDestroy() { }
+    }
+
+    @Override
+    protected void onDetachedFromWindow() {
+        for (Type type : mTypes) {
+            type.onDestroy();
+        }
     }
 
     private class SyncType extends Type {
         private OnAccountsUpdateListener mAccountListener;
         public SyncType(int aText, int aBoldText, int aImage) {
             super(aText, aBoldText, aImage);
             // The listener will run on the background thread (see 2nd argument)
             mAccountListener = new OnAccountsUpdateListener() {
@@ -70,16 +78,17 @@ public class AboutHomePromoBox extends T
         }
         @Override
         public void onClick(View v) {
             final Context context = v.getContext();
             final Intent intent = new Intent(context, SetupSyncActivity.class);
             context.startActivity(intent);
         }
 
+        @Override
         public void onDestroy() {
             if (mAccountListener != null) {
                 AccountManager.get(mContext).removeOnAccountsUpdatedListener(mAccountListener);
                 mAccountListener = null;
             }
         }
     }