fix lint warning: CommitPrefEdits: use apply() instead of commit()
"Consider using apply() instead; commit writes its data to persistent storage immediately, whereas apply will handle it in the background" commit() is only useful if the code actually checks the return value.
This commit is contained in:
parent
c67a60271d
commit
c3b47ecd5a
@ -40,7 +40,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
if (preferences.getString(PREF_LOCAL_REPO_NAME, null) == null) {
|
||||
preferences.edit()
|
||||
.putString(PREF_LOCAL_REPO_NAME, getDefaultLocalRepoName())
|
||||
.commit();
|
||||
.apply();
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
}
|
||||
|
||||
public void setPrivilegedInstallerEnabled(boolean enable) {
|
||||
preferences.edit().putBoolean(PREF_PRIVILEGED_INSTALLER, enable).commit();
|
||||
preferences.edit().putBoolean(PREF_PRIVILEGED_INSTALLER, enable).apply();
|
||||
}
|
||||
|
||||
public boolean isFirstTime() {
|
||||
@ -121,7 +121,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
}
|
||||
|
||||
public void setFirstTime(boolean firstTime) {
|
||||
preferences.edit().putBoolean(PREF_FIRST_TIME, firstTime).commit();
|
||||
preferences.edit().putBoolean(PREF_FIRST_TIME, firstTime).apply();
|
||||
}
|
||||
|
||||
public boolean isPostPrivilegedInstall() {
|
||||
@ -129,7 +129,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
}
|
||||
|
||||
public void setPostPrivilegedInstall(boolean postInstall) {
|
||||
preferences.edit().putBoolean(PREF_POST_PRIVILEGED_INSTALL, postInstall).commit();
|
||||
preferences.edit().putBoolean(PREF_POST_PRIVILEGED_INSTALL, postInstall).apply();
|
||||
}
|
||||
|
||||
public boolean shouldCacheApks() {
|
||||
@ -149,7 +149,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
}
|
||||
|
||||
public void setShowNfcDuringSwap(boolean show) {
|
||||
preferences.edit().putBoolean(PREF_SHOW_NFC_DURING_SWAP, show).commit();
|
||||
preferences.edit().putBoolean(PREF_SHOW_NFC_DURING_SWAP, show).apply();
|
||||
}
|
||||
|
||||
public boolean expertMode() {
|
||||
|
@ -406,7 +406,7 @@ public class UpdateService extends IntentService implements ProgressListener {
|
||||
|
||||
SharedPreferences.Editor e = prefs.edit();
|
||||
e.putLong(Preferences.PREF_UPD_LAST, System.currentTimeMillis());
|
||||
e.commit();
|
||||
e.apply();
|
||||
|
||||
if (errorRepos == 0) {
|
||||
if (changes) {
|
||||
|
@ -141,7 +141,7 @@ public abstract class AppListFragment extends ListFragment implements
|
||||
boolean hasTriedEmptyUpdate = prefs.getBoolean(triedEmptyUpdate, false);
|
||||
if (!hasTriedEmptyUpdate) {
|
||||
Utils.debugLog(TAG, "Empty app list, and we haven't done an update yet. Forcing repo update.");
|
||||
prefs.edit().putBoolean(triedEmptyUpdate, true).commit();
|
||||
prefs.edit().putBoolean(triedEmptyUpdate, true).apply();
|
||||
UpdateService.updateNow(getActivity());
|
||||
return true;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ public class AvailableAppsFragment extends AppListFragment implements
|
||||
Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor e = p.edit();
|
||||
e.putString(CATEGORY_KEY, currentCategory);
|
||||
e.commit();
|
||||
e.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -204,13 +204,13 @@ public class PreferencesFragment extends PreferenceFragment
|
||||
// privileged permission are granted, i.e. the extension is installed correctly
|
||||
SharedPreferences.Editor editor = pref.getSharedPreferences().edit();
|
||||
editor.putBoolean(Preferences.PREF_PRIVILEGED_INSTALLER, true);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
pref.setChecked(true);
|
||||
} else {
|
||||
// privileged permission not available
|
||||
SharedPreferences.Editor editor = pref.getSharedPreferences().edit();
|
||||
editor.putBoolean(Preferences.PREF_PRIVILEGED_INSTALLER, false);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
pref.setChecked(false);
|
||||
|
||||
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getActivity());
|
||||
@ -248,7 +248,7 @@ public class PreferencesFragment extends PreferenceFragment
|
||||
} else {
|
||||
SharedPreferences.Editor editor = pref.getSharedPreferences().edit();
|
||||
editor.putBoolean(Preferences.PREF_PRIVILEGED_INSTALLER, false);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
pref.setChecked(false);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user