* commit '81927a4d459e01d06c880002dcec978a6e446c59': Unload widget previews when launcher is not visible
This commit is contained in:
commit
ee951cc512
5 files changed
+59
-4
No files matched your search
@@ -393,15 +393,17 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
|||||||
mWidgetSpacingLayout.measure(widthSpec, heightSpec);
|
mWidgetSpacingLayout.measure(widthSpec, heightSpec);
|
||||||
mContentWidth = mWidgetSpacingLayout.getContentWidth();
|
mContentWidth = mWidgetSpacingLayout.getContentWidth();
|
||||||
|
|
||||||
|
AppsCustomizeTabHost host = (AppsCustomizeTabHost) getTabHost();
|
||||||
|
final boolean hostIsTransitioning = host.isTransitioning();
|
||||||
|
|
||||||
// Restore the page
|
// Restore the page
|
||||||
int page = getPageForComponent(mSaveInstanceStateItemIndex);
|
int page = getPageForComponent(mSaveInstanceStateItemIndex);
|
||||||
invalidatePageData(Math.max(0, page));
|
invalidatePageData(Math.max(0, page), hostIsTransitioning);
|
||||||
|
|
||||||
// Show All Apps cling if we are finished transitioning, otherwise, we will try again when
|
// Show All Apps cling if we are finished transitioning, otherwise, we will try again when
|
||||||
// the transition completes in AppsCustomizeTabHost (otherwise the wrong offsets will be
|
// the transition completes in AppsCustomizeTabHost (otherwise the wrong offsets will be
|
||||||
// returned while animating)
|
// returned while animating)
|
||||||
AppsCustomizeTabHost host = (AppsCustomizeTabHost) getTabHost();
|
if (!hostIsTransitioning) {
|
||||||
if (!host.isTransitioning()) {
|
|
||||||
post(new Runnable() {
|
post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -662,6 +664,18 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
|||||||
cancelAllTasks();
|
cancelAllTasks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearAllWidgetPages() {
|
||||||
|
cancelAllTasks();
|
||||||
|
int count = getChildCount();
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
View v = getPageAt(i);
|
||||||
|
if (v instanceof PagedViewGridLayout) {
|
||||||
|
((PagedViewGridLayout) v).removeAllViewsOnPage();
|
||||||
|
mDirtyPageContent.set(i, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void cancelAllTasks() {
|
private void cancelAllTasks() {
|
||||||
// Clean up all the async tasks
|
// Clean up all the async tasks
|
||||||
Iterator<AppsCustomizeAsyncTask> iter = mRunningTasks.iterator();
|
Iterator<AppsCustomizeAsyncTask> iter = mRunningTasks.iterator();
|
||||||
|
|||||||
@@ -366,6 +366,11 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
|||||||
}
|
}
|
||||||
mContent.setVisibility(VISIBLE);
|
mContent.setVisibility(VISIBLE);
|
||||||
|
|
||||||
|
if (!toWorkspace) {
|
||||||
|
// Make sure the current page is loaded (we start loading the side pages after the
|
||||||
|
// transition to prevent slowing down the animation)
|
||||||
|
mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage(), true);
|
||||||
|
}
|
||||||
if (animated && !delayLauncherTransitionUntilLayout) {
|
if (animated && !delayLauncherTransitionUntilLayout) {
|
||||||
enableAndBuildHardwareLayer();
|
enableAndBuildHardwareLayer();
|
||||||
}
|
}
|
||||||
@@ -391,6 +396,9 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
|||||||
// Dismiss the workspace cling and show the all apps cling (if not already shown)
|
// Dismiss the workspace cling and show the all apps cling (if not already shown)
|
||||||
l.dismissWorkspaceCling(null);
|
l.dismissWorkspaceCling(null);
|
||||||
mAppsCustomizePane.showAllAppsCling();
|
mAppsCustomizePane.showAllAppsCling();
|
||||||
|
// Make sure adjacent pages are loaded (we wait until after the transition to
|
||||||
|
// prevent slowing down the animation)
|
||||||
|
mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage());
|
||||||
|
|
||||||
if (!LauncherApplication.isScreenLarge()) {
|
if (!LauncherApplication.isScreenLarge()) {
|
||||||
mAppsCustomizePane.hideScrollingIndicator(false);
|
mAppsCustomizePane.hideScrollingIndicator(false);
|
||||||
@@ -398,6 +406,23 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onResume() {
|
||||||
|
if (getVisibility() == VISIBLE) {
|
||||||
|
mContent.setVisibility(VISIBLE);
|
||||||
|
// We unload the widget previews when the UI is hidden, so need to reload pages
|
||||||
|
// Load the current page synchronously, and the neighboring pages asynchronously
|
||||||
|
mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage(), true);
|
||||||
|
mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.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
|
||||||
|
mAppsCustomizePane.clearAllWidgetPages();
|
||||||
|
}
|
||||||
|
|
||||||
boolean isTransitioning() {
|
boolean isTransitioning() {
|
||||||
return mInTransition;
|
return mInTransition;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import android.content.ActivityNotFoundException;
|
|||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
import android.content.ClipDescription;
|
import android.content.ClipDescription;
|
||||||
|
import android.content.ComponentCallbacks2;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -563,6 +564,7 @@ public final class Launcher extends Activity
|
|||||||
// When we resume Launcher, a different Activity might be responsible for the app
|
// When we resume Launcher, a different Activity might be responsible for the app
|
||||||
// market intent, so refresh the icon
|
// market intent, so refresh the icon
|
||||||
updateAppMarketIcon();
|
updateAppMarketIcon();
|
||||||
|
mAppsCustomizeTabHost.onResume();
|
||||||
if (!mWorkspaceLoading) {
|
if (!mWorkspaceLoading) {
|
||||||
final ViewTreeObserver observer = mWorkspace.getViewTreeObserver();
|
final ViewTreeObserver observer = mWorkspace.getViewTreeObserver();
|
||||||
final Workspace workspace = mWorkspace;
|
final Workspace workspace = mWorkspace;
|
||||||
@@ -2397,6 +2399,14 @@ public final class Launcher extends Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTrimMemory(int level) {
|
||||||
|
super.onTrimMemory(level);
|
||||||
|
if (level == ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
|
||||||
|
mAppsCustomizeTabHost.onTrimMemory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void showWorkspace(boolean animated) {
|
void showWorkspace(boolean animated) {
|
||||||
Resources res = getResources();
|
Resources res = getResources();
|
||||||
int stagger = res.getInteger(R.integer.config_appsCustomizeWorkspaceAnimationStagger);
|
int stagger = res.getInteger(R.integer.config_appsCustomizeWorkspaceAnimationStagger);
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public abstract class PagedView extends ViewGroup {
|
|||||||
|
|
||||||
private PageSwitchListener mPageSwitchListener;
|
private PageSwitchListener mPageSwitchListener;
|
||||||
|
|
||||||
private ArrayList<Boolean> mDirtyPageContent;
|
protected ArrayList<Boolean> mDirtyPageContent;
|
||||||
|
|
||||||
// choice modes
|
// choice modes
|
||||||
protected static final int CHOICE_MODE_NONE = 0;
|
protected static final int CHOICE_MODE_NONE = 0;
|
||||||
|
|||||||
@@ -68,6 +68,12 @@ public class PagedViewGridLayout extends GridLayout implements Page {
|
|||||||
heightMeasureSpec);
|
heightMeasureSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDetachedFromWindow() {
|
||||||
|
super.onDetachedFromWindow();
|
||||||
|
mOnLayoutListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
public void setOnLayoutListener(Runnable r) {
|
public void setOnLayoutListener(Runnable r) {
|
||||||
mOnLayoutListener = r;
|
mOnLayoutListener = r;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user