summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2014-10-31 18:48:25 (GMT)
committerDanesh M <daneshm90@gmail.com>2015-09-28 02:11:07 (GMT)
commit0b5f4e2b91f7fc2d8a42fbb96ef84036a92662cd (patch)
tree3dd54ae322eefbb7ef44bcfa9b92f32f50ad45dd
parent7dfa47353bacd2149a61cc2261c9a60f2e22825f (diff)
downloadandroid_packages_apps_Trebuchet-0b5f4e2b91f7fc2d8a42fbb96ef84036a92662cd.zip
android_packages_apps_Trebuchet-0b5f4e2b91f7fc2d8a42fbb96ef84036a92662cd.tar.gz
android_packages_apps_Trebuchet-0b5f4e2b91f7fc2d8a42fbb96ef84036a92662cd.tar.bz2
Adding a couple memory optimizations to Launcher
-> Always dispose of widget page views when leaving the activity. These pages hold onto many bitmaps. -> Clear database cache when leaving the activity. Bug: 17967108 Change-Id: I10ebaaed14e7cd86f09a9afcabd73043705f21b8
-rw-r--r--src/com/android/launcher3/AppsCustomizePagedView.java1
-rw-r--r--src/com/android/launcher3/AppsCustomizeTabHost.java8
-rw-r--r--src/com/android/launcher3/Launcher.java19
-rw-r--r--src/com/android/launcher3/PagedViewWithDraggableItems.java4
4 files changed, 22 insertions, 10 deletions
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java
index 5af1179..8c6d117 100644
--- a/src/com/android/launcher3/AppsCustomizePagedView.java
+++ b/src/com/android/launcher3/AppsCustomizePagedView.java
@@ -1921,6 +1921,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
public void reset() {
+ super.reset();
// If we have reset, then we should not continue to restore the previous state
mSaveInstanceStateItemIndex = -1;
diff --git a/src/com/android/launcher3/AppsCustomizeTabHost.java b/src/com/android/launcher3/AppsCustomizeTabHost.java
index 9a516fd..df65cba 100644
--- a/src/com/android/launcher3/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher3/AppsCustomizeTabHost.java
@@ -141,14 +141,6 @@ public class AppsCustomizeTabHost extends FrameLayout implements LauncherTransit
mPagedView.loadAssociatedPages(mPagedView.getCurrentPage());
}
}
-
- public void onTrimMemory() {
- mContent.setVisibility(GONE);
- // Clear the widget pages of all their subviews - this will trigger the widget previews
- // to delete their bitmaps
- mPagedView.clearAllWidgetPages();
- }
-
@Override
public ViewGroup getContent() {
return mPagedView;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 75131cb..e3b4f95 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -56,6 +56,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.ContentObserver;
+import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
@@ -4112,6 +4113,9 @@ public class Launcher extends Activity
if (mSearchDropTargetBar != null) {
mSearchDropTargetBar.hideSearchBar(false);
}
+
+ // This can hold unnecessary references to views.
+ mStateAnimation = null;
}
});
@@ -4441,6 +4445,9 @@ public class Launcher extends Activity
}
mAppsCustomizeContent.updateCurrentPageScroll();
+
+ // This can hold unnecessary references to views.
+ mStateAnimation = null;
}
});
@@ -4489,8 +4496,16 @@ public class Launcher extends Activity
@Override
public void onTrimMemory(int level) {
super.onTrimMemory(level);
- if (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE) {
- mAppsCustomizeTabHost.onTrimMemory();
+ if (level >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
+ // The widget preview db can result in holding onto over
+ // 3MB of memory for caching which isn't necessary.
+ SQLiteDatabase.releaseMemory();
+
+ // We reset the apps customize tray in order to
+ // to free all the memory associated with widget previews
+ if (mAppsCustomizeTabHost != null) {
+ mAppsCustomizeTabHost.reset();
+ }
}
}
diff --git a/src/com/android/launcher3/PagedViewWithDraggableItems.java b/src/com/android/launcher3/PagedViewWithDraggableItems.java
index 2a29c33..7f4a3a0 100644
--- a/src/com/android/launcher3/PagedViewWithDraggableItems.java
+++ b/src/com/android/launcher3/PagedViewWithDraggableItems.java
@@ -91,6 +91,10 @@ public abstract class PagedViewWithDraggableItems extends PagedView
return super.onTouchEvent(ev);
}
+ public void reset() {
+ mLastTouchedItem = null;
+ }
+
@Override
public boolean onTouch(View v, MotionEvent event) {
mLastTouchedItem = v;