diff options
author | Michael Jurka <mikejurka@google.com> | 2010-12-14 18:02:21 -0800 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2010-12-14 18:37:56 -0800 |
commit | e7bf83b0a3250d73ef2c4c2dfa9d7fafb6847985 (patch) | |
tree | 81cc5d2d63e472941a6163e0df18d5d7432ae465 /src/com/android/launcher2/Launcher.java | |
parent | c3f9f4fcbd3fba3753335d5c9671c0893393b164 (diff) | |
download | android_packages_apps_Trebuchet-e7bf83b0a3250d73ef2c4c2dfa9d7fafb6847985.tar.gz android_packages_apps_Trebuchet-e7bf83b0a3250d73ef2c4c2dfa9d7fafb6847985.tar.bz2 android_packages_apps_Trebuchet-e7bf83b0a3250d73ef2c4c2dfa9d7fafb6847985.zip |
fix potential leak of Activities
- cache ConstantStates instead of Drawables
Change-Id: Iea1cf23c845b9128ea1c12dffc32265f8d7db933
Diffstat (limited to 'src/com/android/launcher2/Launcher.java')
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 455b130c1..992c506d5 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -261,9 +261,9 @@ public final class Launcher extends Activity new HashMap<View, AppWidgetProviderInfo>(); // External icons saved in case of resource changes, orientation, etc. - private static Drawable sGlobalSearchIcon; - private static Drawable sVoiceSearchIcon; - private static Drawable sAppMarketIcon; + private static Drawable.ConstantState sGlobalSearchIcon; + private static Drawable.ConstantState sVoiceSearchIcon; + private static Drawable.ConstantState sAppMarketIcon; @Override protected void onCreate(Bundle savedInstanceState) { @@ -2998,7 +2998,7 @@ public final class Launcher extends Activity } // if successful in getting icon, return it; otherwise, set button to use default drawable - private Drawable updateButtonWithIconFromExternalActivity( + private Drawable.ConstantState updateButtonWithIconFromExternalActivity( int buttonId, ComponentName activityName, int fallbackDrawableId) { ImageView button = (ImageView) findViewById(buttonId); Drawable toolbarIcon = null; @@ -3023,13 +3023,13 @@ public final class Launcher extends Activity return null; } else { button.setImageDrawable(toolbarIcon); - return toolbarIcon; + return toolbarIcon.getConstantState(); } } - private void updateButtonWithDrawable(int buttonId, Drawable d) { + private void updateButtonWithDrawable(int buttonId, Drawable.ConstantState d) { ImageView button = (ImageView) findViewById(buttonId); - button.setImageDrawable(d); + button.setImageDrawable(d.newDrawable(getResources())); } private void updateGlobalSearchIcon() { @@ -3046,7 +3046,7 @@ public final class Launcher extends Activity } } - private void updateGlobalSearchIcon(Drawable d) { + private void updateGlobalSearchIcon(Drawable.ConstantState d) { updateButtonWithDrawable(R.id.search_button, d); } @@ -3063,7 +3063,7 @@ public final class Launcher extends Activity } } - private void updateVoiceSearchIcon(Drawable d) { + private void updateVoiceSearchIcon(Drawable.ConstantState d) { updateButtonWithDrawable(R.id.voice_button, d); } @@ -3084,7 +3084,7 @@ public final class Launcher extends Activity } } - private void updateAppMarketIcon(Drawable d) { + private void updateAppMarketIcon(Drawable.ConstantState d) { updateButtonWithDrawable(R.id.market_button, d); } |