mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2025-01-15 21:57:31 +01:00
Only apply preferences when they actually changed
This commit is contained in:
parent
da9a3e714d
commit
a2afbe07fd
@ -67,7 +67,9 @@ public class CheckinPrefs implements SharedPreferences.OnSharedPreferenceChangeL
|
||||
}
|
||||
|
||||
public static void setEnabled(Context context, boolean newStatus) {
|
||||
boolean changed = CheckinPrefs.get(context).isEnabled() != newStatus;
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(PREF_ENABLE_CHECKIN, newStatus).commit();
|
||||
if (!changed) return;
|
||||
if (newStatus) {
|
||||
context.sendOrderedBroadcast(new Intent(context, TriggerReceiver.class), null);
|
||||
}
|
||||
|
@ -218,7 +218,9 @@ public class GcmPrefs implements SharedPreferences.OnSharedPreferenceChangeListe
|
||||
}
|
||||
|
||||
public static void setEnabled(Context context, boolean newStatus) {
|
||||
boolean changed = GcmPrefs.get(context).isEnabled() != newStatus;
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(GcmPrefs.PREF_ENABLE_GCM, newStatus).commit();
|
||||
if (!changed) return;
|
||||
if (!newStatus) {
|
||||
McsService.stop(context);
|
||||
} else {
|
||||
|
@ -25,7 +25,9 @@ class ExposurePreferences(private val context: Context) {
|
||||
var enabled
|
||||
get() = preferences.getBoolean(PREF_SCANNER_ENABLED, false)
|
||||
set(newStatus) {
|
||||
val changed = enabled != newStatus
|
||||
preferences.edit().putBoolean(PREF_SCANNER_ENABLED, newStatus).commit()
|
||||
if (!changed) return
|
||||
if (newStatus) {
|
||||
context.sendOrderedBroadcast(Intent(context, ServiceTrigger::class.java), null)
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user