summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2014-11-25 15:12:13 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-11-25 15:12:13 +0000
commitc0809125914256df4cbb1414348fed7699f6a53d (patch)
tree4bb8b7987f8f9d2377623f8b6bf17d0ba4b04921 /src/com/android
parent593d501724232ff9cb256a140a12e9b6a1710859 (diff)
parentb02e611d15bd6fbb05814adaa804dd68181c556c (diff)
downloadandroid_packages_apps_Trebuchet-c0809125914256df4cbb1414348fed7699f6a53d.tar.gz
android_packages_apps_Trebuchet-c0809125914256df4cbb1414348fed7699f6a53d.tar.bz2
android_packages_apps_Trebuchet-c0809125914256df4cbb1414348fed7699f6a53d.zip
am b02e611d: Don\'t try to create an app state instance during restore.
* commit 'b02e611d15bd6fbb05814adaa804dd68181c556c': Don't try to create an app state instance during restore.
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher3/LauncherAppState.java17
-rw-r--r--src/com/android/launcher3/LauncherBackupHelper.java13
2 files changed, 15 insertions, 15 deletions
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index ec914d873..b7c45a340 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -195,6 +195,13 @@ public class LauncherAppState implements DeviceProfile.DeviceProfileCallbacks {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
DeviceProfile initDynamicGrid(Context context) {
+ mDynamicGrid = createDynamicGrid(context, mDynamicGrid);
+ mDynamicGrid.getDeviceProfile().addCallback(this);
+ return mDynamicGrid.getDeviceProfile();
+ }
+
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
+ static DynamicGrid createDynamicGrid(Context context, DynamicGrid dynamicGrid) {
// Determine the dynamic grid properties
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
@@ -204,27 +211,27 @@ public class LauncherAppState implements DeviceProfile.DeviceProfileCallbacks {
DisplayMetrics dm = new DisplayMetrics();
display.getMetrics(dm);
- if (mDynamicGrid == null) {
+ if (dynamicGrid == null) {
Point smallestSize = new Point();
Point largestSize = new Point();
display.getCurrentSizeRange(smallestSize, largestSize);
- mDynamicGrid = new DynamicGrid(context,
+ dynamicGrid = new DynamicGrid(context,
context.getResources(),
Math.min(smallestSize.x, smallestSize.y),
Math.min(largestSize.x, largestSize.y),
realSize.x, realSize.y,
dm.widthPixels, dm.heightPixels);
- mDynamicGrid.getDeviceProfile().addCallback(this);
}
// Update the icon size
- DeviceProfile grid = mDynamicGrid.getDeviceProfile();
+ DeviceProfile grid = dynamicGrid.getDeviceProfile();
grid.updateFromConfiguration(context, context.getResources(),
realSize.x, realSize.y,
dm.widthPixels, dm.heightPixels);
- return grid;
+ return dynamicGrid;
}
+
public DynamicGrid getDynamicGrid() {
return mDynamicGrid;
}
diff --git a/src/com/android/launcher3/LauncherBackupHelper.java b/src/com/android/launcher3/LauncherBackupHelper.java
index c260fbc33..437434748 100644
--- a/src/com/android/launcher3/LauncherBackupHelper.java
+++ b/src/com/android/launcher3/LauncherBackupHelper.java
@@ -371,16 +371,9 @@ public class LauncherBackupHelper implements BackupHelper {
if (mCurrentProfile != null) {
return mCurrentProfile;
}
- LauncherAppState.setApplicationContext(mContext.getApplicationContext());
- LauncherAppState app = LauncherAppState.getInstance();
-
- DeviceProfile profile;
- if (app.getDynamicGrid() == null) {
- // Initialize the grid
- profile = app.initDynamicGrid(mContext);
- } else {
- profile = app.getDynamicGrid().getDeviceProfile();
- }
+ final Context applicationContext = mContext.getApplicationContext();
+ DeviceProfile profile = LauncherAppState.createDynamicGrid(applicationContext, null)
+ .getDeviceProfile();
mCurrentProfile = new DeviceProfieData();
mCurrentProfile.desktopRows = profile.numRows;