mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-19 23:12:12 +02:00
Use apply() instead of commit() to save preferences
This commit is contained in:
@@ -160,7 +160,7 @@ public class OpenScale {
|
||||
|
||||
public void selectScaleUser(int userId) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
prefs.edit().putInt("selectedUserId", userId).commit();
|
||||
prefs.edit().putInt("selectedUserId", userId).apply();
|
||||
|
||||
selectedScaleUser = null;
|
||||
}
|
||||
@@ -421,7 +421,7 @@ public class OpenScale {
|
||||
|
||||
public void clearScaleData(int userId) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
prefs.edit().putInt("uniqueNumber", 0x00).commit();
|
||||
prefs.edit().putInt("uniqueNumber", 0x00).apply();
|
||||
measurementDAO.deleteAll(userId);
|
||||
|
||||
updateScaleData();
|
||||
|
@@ -277,7 +277,7 @@ public class BluetoothMiScale extends BluetoothCommunication {
|
||||
Random r = new Random();
|
||||
uniqueNumber = r.nextInt(65535 - 100 + 1) + 100;
|
||||
|
||||
prefs.edit().putInt("uniqueNumber", uniqueNumber).commit();
|
||||
prefs.edit().putInt("uniqueNumber", uniqueNumber).apply();
|
||||
}
|
||||
|
||||
int userId = OpenScale.getInstance(context).getSelectedScaleUserId();
|
||||
|
@@ -248,7 +248,7 @@ public class BluetoothMiScale2 extends BluetoothCommunication {
|
||||
Random r = new Random();
|
||||
uniqueNumber = r.nextInt(65535 - 100 + 1) + 100;
|
||||
|
||||
prefs.edit().putInt("uniqueNumber", uniqueNumber).commit();
|
||||
prefs.edit().putInt("uniqueNumber", uniqueNumber).apply();
|
||||
}
|
||||
|
||||
int userId = OpenScale.getInstance(context).getSelectedScaleUserId();
|
||||
|
@@ -146,7 +146,7 @@ public class BluetoothYunmaiSE_Mini extends BluetoothCommunication {
|
||||
Random r = new Random();
|
||||
uniqueNumber = r.nextInt(65535 - 100 + 1) + 100;
|
||||
|
||||
prefs.edit().putInt("uniqueNumber", uniqueNumber).commit();
|
||||
prefs.edit().putInt("uniqueNumber", uniqueNumber).apply();
|
||||
}
|
||||
|
||||
int userId = OpenScale.getInstance(context).getSelectedScaleUserId();
|
||||
|
@@ -146,7 +146,7 @@ public class MainActivity extends BaseAppCompatActivity
|
||||
intent.putExtra(UserSettingsActivity.EXTRA_MODE, UserSettingsActivity.ADD_USER_REQUEST);
|
||||
startActivity(intent);
|
||||
|
||||
prefs.edit().putBoolean("firstStart", false).commit();
|
||||
prefs.edit().putBoolean("firstStart", false).apply();
|
||||
}
|
||||
|
||||
if(!valueOfCountModified){
|
||||
@@ -301,7 +301,7 @@ public class MainActivity extends BaseAppCompatActivity
|
||||
return;
|
||||
}
|
||||
|
||||
prefs.edit().putInt("lastFragmentId", menuItemId).commit();
|
||||
prefs.edit().putInt("lastFragmentId", menuItemId).apply();
|
||||
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
|
||||
|
@@ -188,10 +188,10 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
||||
case R.id.enableMonth:
|
||||
if (item.isChecked()) {
|
||||
item.setChecked(false);
|
||||
prefs.edit().putBoolean("showMonth", false).commit();
|
||||
prefs.edit().putBoolean("showMonth", false).apply();
|
||||
} else {
|
||||
item.setChecked(true);
|
||||
prefs.edit().putBoolean("showMonth", true).commit();
|
||||
prefs.edit().putBoolean("showMonth", true).apply();
|
||||
}
|
||||
|
||||
generateGraphs();
|
||||
@@ -199,10 +199,10 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
||||
case R.id.enableWeek:
|
||||
if (item.isChecked()) {
|
||||
item.setChecked(false);
|
||||
prefs.edit().putBoolean("showWeek", false).commit();
|
||||
prefs.edit().putBoolean("showWeek", false).apply();
|
||||
} else {
|
||||
item.setChecked(true);
|
||||
prefs.edit().putBoolean("showWeek", true).commit();
|
||||
prefs.edit().putBoolean("showWeek", true).apply();
|
||||
}
|
||||
|
||||
generateGraphs();
|
||||
|
@@ -154,7 +154,7 @@ public abstract class MeasurementView extends TableLayout {
|
||||
}
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit()
|
||||
.putString(PREF_MEASUREMENT_ORDER, TextUtils.join(",", order))
|
||||
.commit();
|
||||
.apply();
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
|
Reference in New Issue
Block a user