mirror of https://github.com/M66B/FairEmail.git
Disable poll outside of schedule
This commit is contained in:
parent
f5306720e1
commit
4f7917d8bf
|
@ -132,9 +132,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
||||||
if (value != current) {
|
if (value != current) {
|
||||||
adapterView.setTag(value);
|
adapterView.setTag(value);
|
||||||
prefs.edit().putInt("poll_interval", value).apply();
|
prefs.edit().putInt("poll_interval", value).apply();
|
||||||
if (value == 0)
|
ServiceSynchronize.reschedule(getContext());
|
||||||
ServiceSynchronize.eval(getContext(), "poll_interval");
|
|
||||||
WorkerPoll.init(getContext());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,8 +140,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
||||||
public void onNothingSelected(AdapterView<?> adapterView) {
|
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||||
adapterView.setTag(null);
|
adapterView.setTag(null);
|
||||||
prefs.edit().remove("poll_interval").apply();
|
prefs.edit().remove("poll_interval").apply();
|
||||||
ServiceSynchronize.eval(getContext(), "poll_interval");
|
ServiceSynchronize.reschedule(getContext());
|
||||||
WorkerPoll.init(getContext());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1528,7 +1528,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||||
|
|
||||||
AlarmManagerCompat.setAndAllowWhileIdle(am, AlarmManager.RTC_WAKEUP, next, pi);
|
AlarmManagerCompat.setAndAllowWhileIdle(am, AlarmManager.RTC_WAKEUP, next, pi);
|
||||||
|
|
||||||
WorkerPoll.init(context);
|
WorkerPoll.init(context, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long[] getSchedule(Context context) {
|
private static long[] getSchedule(Context context) {
|
||||||
|
|
|
@ -50,10 +50,9 @@ public class WorkerPoll extends Worker {
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init(Context context) {
|
static void init(Context context, boolean enabled) {
|
||||||
try {
|
try {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
boolean enabled = prefs.getBoolean("enabled", true);
|
|
||||||
int pollInterval = prefs.getInt("poll_interval", 0);
|
int pollInterval = prefs.getInt("poll_interval", 0);
|
||||||
if (enabled && pollInterval > 0) {
|
if (enabled && pollInterval > 0) {
|
||||||
Log.i("Queuing " + getName() + " every " + pollInterval + " minutes");
|
Log.i("Queuing " + getName() + " every " + pollInterval + " minutes");
|
||||||
|
|
Loading…
Reference in New Issue