summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2014-10-28 00:15:42 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-10-28 00:15:42 +0000
commit09ae4aef52b4486b97ecc77feeb64307bcbd3993 (patch)
treed30d415de2c77e5ad20fa878ce14fa58b9861b11
parentbb4ae1d26a11a1211ce793278a878fa3cb224ff5 (diff)
parent9d219685c5f008ddfb0f72ef01831308d8a81c2e (diff)
downloadandroid_packages_apps_Trebuchet-09ae4aef52b4486b97ecc77feeb64307bcbd3993.zip
android_packages_apps_Trebuchet-09ae4aef52b4486b97ecc77feeb64307bcbd3993.tar.gz
android_packages_apps_Trebuchet-09ae4aef52b4486b97ecc77feeb64307bcbd3993.tar.bz2
Merge "Loading internal default layout if partner layout fails to load" into ub-now-queens
-rw-r--r--src/com/android/launcher3/LauncherProvider.java29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index f2d005e..fe9bc17 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -322,29 +322,34 @@ public class LauncherProvider extends ContentProvider {
}
}
+ final boolean usingExternallyProvidedLayout = loader != null;
if (loader == null) {
- loader = new DefaultLayoutParser(getContext(), mOpenHelper.mAppWidgetHost,
- mOpenHelper, getContext().getResources(), getDefaultWorkspaceResourceId());
+ loader = getDefaultLayoutParser();
}
-
// Populate favorites table with initial favorites
- SharedPreferences.Editor editor = sp.edit().remove(EMPTY_DATABASE_CREATED);
- mOpenHelper.loadFavorites(mOpenHelper.getWritableDatabase(), loader);
- editor.commit();
+ if ((mOpenHelper.loadFavorites(mOpenHelper.getWritableDatabase(), loader) <= 0)
+ && usingExternallyProvidedLayout) {
+ // Unable to load external layout. Cleanup and load the internal layout.
+ createEmptyDB();
+ mOpenHelper.loadFavorites(mOpenHelper.getWritableDatabase(),
+ getDefaultLayoutParser());
+ }
+ sp.edit().remove(EMPTY_DATABASE_CREATED).commit();
}
}
+ private DefaultLayoutParser getDefaultLayoutParser() {
+ int defaultLayout = LauncherAppState.getInstance()
+ .getDynamicGrid().getDeviceProfile().defaultLayoutId;
+ return new DefaultLayoutParser(getContext(), mOpenHelper.mAppWidgetHost,
+ mOpenHelper, getContext().getResources(), defaultLayout);
+ }
+
public void migrateLauncher2Shortcuts() {
mOpenHelper.migrateLauncher2Shortcuts(mOpenHelper.getWritableDatabase(),
Uri.parse(getContext().getString(R.string.old_launcher_provider_uri)));
}
- private static int getDefaultWorkspaceResourceId() {
- LauncherAppState app = LauncherAppState.getInstance();
- DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
- return grid.defaultLayoutId;
- }
-
private static interface ContentValuesCallback {
public void onRow(ContentValues values);
}