am ec8345a1: When the launcher is paused and we reload stuff in the background, we need to re-re-load it in onResume.
This commit is contained in:
@@ -195,6 +195,7 @@ public final class Launcher extends Activity
|
|||||||
private boolean mPaused = true;
|
private boolean mPaused = true;
|
||||||
private boolean mRestoring;
|
private boolean mRestoring;
|
||||||
private boolean mWaitingForResult;
|
private boolean mWaitingForResult;
|
||||||
|
private boolean mOnResumeNeedsLoad;
|
||||||
|
|
||||||
private Bundle mSavedInstanceState;
|
private Bundle mSavedInstanceState;
|
||||||
|
|
||||||
@@ -585,19 +586,19 @@ public final class Launcher extends Activity
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
mPaused = false;
|
mPaused = false;
|
||||||
|
if (mRestoring || mOnResumeNeedsLoad) {
|
||||||
if (mRestoring) {
|
|
||||||
mWorkspaceLoading = true;
|
mWorkspaceLoading = true;
|
||||||
mModel.startLoader(this, true);
|
mModel.startLoader(this, true);
|
||||||
mRestoring = false;
|
mRestoring = false;
|
||||||
|
mOnResumeNeedsLoad = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
mPaused = true;
|
||||||
dismissPreview(mPreviousView);
|
dismissPreview(mPreviousView);
|
||||||
dismissPreview(mNextView);
|
dismissPreview(mNextView);
|
||||||
mDragController.cancelDrag();
|
mDragController.cancelDrag();
|
||||||
@@ -2126,6 +2127,30 @@ public final class Launcher extends Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the activity is currently paused, signal that we need to re-run the loader
|
||||||
|
* in onResume.
|
||||||
|
*
|
||||||
|
* This needs to be called from incoming places where resources might have been loaded
|
||||||
|
* while we are paused. That is becaues the Configuration might be wrong
|
||||||
|
* when we're not running, and if it comes back to what it was when we
|
||||||
|
* were paused, we are not restarted.
|
||||||
|
*
|
||||||
|
* Implementation of the method from LauncherModel.Callbacks.
|
||||||
|
*
|
||||||
|
* @return true if we are currently paused. The caller might be able to
|
||||||
|
* skip some work in that case since we will come back again.
|
||||||
|
*/
|
||||||
|
public boolean setLoadOnResume() {
|
||||||
|
if (mPaused) {
|
||||||
|
Log.i(TAG, "setLoadOnResume");
|
||||||
|
mOnResumeNeedsLoad = true;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the method from LauncherModel.Callbacks.
|
* Implementation of the method from LauncherModel.Callbacks.
|
||||||
*/
|
*/
|
||||||
@@ -2170,6 +2195,8 @@ public final class Launcher extends Activity
|
|||||||
*/
|
*/
|
||||||
public void bindItems(ArrayList<ItemInfo> shortcuts, int start, int end) {
|
public void bindItems(ArrayList<ItemInfo> shortcuts, int start, int end) {
|
||||||
|
|
||||||
|
setLoadOnResume();
|
||||||
|
|
||||||
final Workspace workspace = mWorkspace;
|
final Workspace workspace = mWorkspace;
|
||||||
|
|
||||||
for (int i=start; i<end; i++) {
|
for (int i=start; i<end; i++) {
|
||||||
@@ -2207,6 +2234,7 @@ public final class Launcher extends Activity
|
|||||||
* Implementation of the method from LauncherModel.Callbacks.
|
* Implementation of the method from LauncherModel.Callbacks.
|
||||||
*/
|
*/
|
||||||
public void bindFolders(HashMap<Long, FolderInfo> folders) {
|
public void bindFolders(HashMap<Long, FolderInfo> folders) {
|
||||||
|
setLoadOnResume();
|
||||||
sFolders.clear();
|
sFolders.clear();
|
||||||
sFolders.putAll(folders);
|
sFolders.putAll(folders);
|
||||||
}
|
}
|
||||||
@@ -2217,6 +2245,8 @@ public final class Launcher extends Activity
|
|||||||
* Implementation of the method from LauncherModel.Callbacks.
|
* Implementation of the method from LauncherModel.Callbacks.
|
||||||
*/
|
*/
|
||||||
public void bindAppWidget(LauncherAppWidgetInfo item) {
|
public void bindAppWidget(LauncherAppWidgetInfo item) {
|
||||||
|
setLoadOnResume();
|
||||||
|
|
||||||
final long start = DEBUG_WIDGETS ? SystemClock.uptimeMillis() : 0;
|
final long start = DEBUG_WIDGETS ? SystemClock.uptimeMillis() : 0;
|
||||||
if (DEBUG_WIDGETS) {
|
if (DEBUG_WIDGETS) {
|
||||||
Log.d(TAG, "bindAppWidget: " + item);
|
Log.d(TAG, "bindAppWidget: " + item);
|
||||||
@@ -2253,6 +2283,8 @@ public final class Launcher extends Activity
|
|||||||
* Implementation of the method from LauncherModel.Callbacks.
|
* Implementation of the method from LauncherModel.Callbacks.
|
||||||
*/
|
*/
|
||||||
public void finishBindingItems() {
|
public void finishBindingItems() {
|
||||||
|
setLoadOnResume();
|
||||||
|
|
||||||
if (mSavedState != null) {
|
if (mSavedState != null) {
|
||||||
if (!mWorkspace.hasFocus()) {
|
if (!mWorkspace.hasFocus()) {
|
||||||
mWorkspace.getChildAt(mWorkspace.getCurrentScreen()).requestFocus();
|
mWorkspace.getChildAt(mWorkspace.getCurrentScreen()).requestFocus();
|
||||||
@@ -2298,6 +2330,7 @@ public final class Launcher extends Activity
|
|||||||
* Implementation of the method from LauncherModel.Callbacks.
|
* Implementation of the method from LauncherModel.Callbacks.
|
||||||
*/
|
*/
|
||||||
public void bindAppsAdded(ArrayList<ApplicationInfo> apps) {
|
public void bindAppsAdded(ArrayList<ApplicationInfo> apps) {
|
||||||
|
setLoadOnResume();
|
||||||
removeDialog(DIALOG_CREATE_SHORTCUT);
|
removeDialog(DIALOG_CREATE_SHORTCUT);
|
||||||
mAllAppsGrid.addApps(apps);
|
mAllAppsGrid.addApps(apps);
|
||||||
}
|
}
|
||||||
@@ -2308,6 +2341,7 @@ public final class Launcher extends Activity
|
|||||||
* Implementation of the method from LauncherModel.Callbacks.
|
* Implementation of the method from LauncherModel.Callbacks.
|
||||||
*/
|
*/
|
||||||
public void bindAppsUpdated(ArrayList<ApplicationInfo> apps) {
|
public void bindAppsUpdated(ArrayList<ApplicationInfo> apps) {
|
||||||
|
setLoadOnResume();
|
||||||
removeDialog(DIALOG_CREATE_SHORTCUT);
|
removeDialog(DIALOG_CREATE_SHORTCUT);
|
||||||
mWorkspace.updateShortcuts(apps);
|
mWorkspace.updateShortcuts(apps);
|
||||||
mAllAppsGrid.updateApps(apps);
|
mAllAppsGrid.updateApps(apps);
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
private Bitmap mDefaultIcon;
|
private Bitmap mDefaultIcon;
|
||||||
|
|
||||||
public interface Callbacks {
|
public interface Callbacks {
|
||||||
|
public boolean setLoadOnResume();
|
||||||
public int getCurrentWorkspaceScreen();
|
public int getCurrentWorkspaceScreen();
|
||||||
public void startBinding();
|
public void startBinding();
|
||||||
public void bindItems(ArrayList<ItemInfo> shortcuts, int start, int end);
|
public void bindItems(ArrayList<ItemInfo> shortcuts, int start, int end);
|
||||||
@@ -349,7 +350,19 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
|
String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
|
||||||
enqueuePackageUpdated(new PackageUpdatedTask(PackageUpdatedTask.OP_ADD, packages));
|
enqueuePackageUpdated(new PackageUpdatedTask(PackageUpdatedTask.OP_ADD, packages));
|
||||||
// Then, rebind everything.
|
// Then, rebind everything.
|
||||||
startLoader(mApp, false);
|
boolean runLoader = true;
|
||||||
|
if (mCallbacks != null) {
|
||||||
|
Callbacks callbacks = mCallbacks.get();
|
||||||
|
if (callbacks != null) {
|
||||||
|
// If they're paused, we can skip loading, because they'll do it again anyway
|
||||||
|
if (callbacks.setLoadOnResume()) {
|
||||||
|
runLoader = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (runLoader) {
|
||||||
|
startLoader(mApp, false);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) {
|
} else if (Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) {
|
||||||
String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
|
String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
|
||||||
|
|||||||
Reference in New Issue
Block a user