Merge "Using SharedPrefenrece.apply instead of commit to prevent disk IO on main thread" into ub-launcher3-burnaby-polish

This commit is contained in:
Sunny Goyal
2015-12-18 22:38:52 +00:00
committed by Android (Google) Code Review
6 changed files with 12 additions and 13 deletions

View File

@@ -471,7 +471,7 @@ public class WallpaperCropActivity extends BaseActivity implements Handler.Callb
editor.remove(WALLPAPER_WIDTH_KEY);
editor.remove(WALLPAPER_HEIGHT_KEY);
}
editor.commit();
editor.apply();
WallpaperUtils.suggestWallpaperDimension(getResources(),
sp, getWindowManager(), WallpaperManager.getInstance(getContext()), true);
}

View File

@@ -82,7 +82,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
strings = new HashSet<String>(strings);
}
strings.add(encoded);
sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, strings).commit();
sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, strings).apply();
}
}
}
@@ -110,7 +110,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
newStringsIter.remove();
}
}
sp.edit().putStringSet(APPS_PENDING_INSTALL, newStrings).commit();
sp.edit().putStringSet(APPS_PENDING_INSTALL, newStrings).apply();
}
}
}
@@ -131,7 +131,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
infos.add(info);
}
}
sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, new HashSet<String>()).commit();
sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, new HashSet<String>()).apply();
return infos;
}
}

View File

@@ -3672,7 +3672,7 @@ public class Launcher extends Activity
mSharedPrefs.edit()
.putInt(QSB_WIDGET_ID, widgetId)
.putString(QSB_WIDGET_PROVIDER, searchProvider.provider.flattenToString())
.commit();
.apply();
}
mAppWidgetHost.setQsbWidgetId(widgetId);

View File

@@ -30,7 +30,7 @@ import java.io.IOException;
public class LauncherBackupAgentHelper extends BackupAgentHelper {
private static final String TAG = "LauncherBackupAgentHelper";
private static final String TAG = "LauncherBAHelper";
private static final String LAUNCHER_DATA_PREFIX = "L";
@@ -91,7 +91,7 @@ public class LauncherBackupAgentHelper extends BackupAgentHelper {
if (hasData && mHelper.restoreSuccessful) {
LauncherAppState.getLauncherProvider().clearFlagEmptyDbCreated();
LauncherClings.synchonouslyMarkFirstRunClingDismissed(this);
LauncherClings.markFirstRunClingDismissed(this);
// Rank was added in v4.
if (mHelper.restoredBackupVersion <= 3) {

View File

@@ -251,9 +251,9 @@ class LauncherClings implements OnClickListener {
!sharedPrefs.getBoolean(MIGRATION_CLING_DISMISSED_KEY, false);
}
public static void synchonouslyMarkFirstRunClingDismissed(Context ctx) {
SharedPreferences.Editor editor = Utilities.getPrefs(ctx).edit();
editor.putBoolean(WORKSPACE_CLING_DISMISSED_KEY, true);
editor.commit();
public static void markFirstRunClingDismissed(Context ctx) {
Utilities.getPrefs(ctx).edit()
.putBoolean(WORKSPACE_CLING_DISMISSED_KEY, true)
.apply();
}
}

View File

@@ -57,7 +57,6 @@ import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.util.ManagedProfileHeuristic;
import com.android.launcher3.util.Thunk;
import java.io.File;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
@@ -686,7 +685,7 @@ public class LauncherProvider extends ContentProvider {
// available (tablet users). Because one of the possible cling flows (migration)
// is very destructive (wipes out workspaces), we want to prevent this from showing
// until clear data. We do so by marking that the clings have been shown.
LauncherClings.synchonouslyMarkFirstRunClingDismissed(mContext);
LauncherClings.markFirstRunClingDismissed(mContext);
}
case 17: {
// No-op