Fixed manual poll in some circumstances

pull/160/head
M66B 5 years ago
parent d2d20dd6ee
commit 68d03fac18

@ -81,11 +81,9 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
@Override @Override
protected void onExecuted(Bundle args, Boolean hasAccounts) { protected void onExecuted(Bundle args, Boolean hasAccounts) {
if (hasAccounts) { if (hasAccounts)
startActivity(new Intent(ActivityMain.this, ActivityView.class)); startActivity(new Intent(ActivityMain.this, ActivityView.class));
ServiceSynchronize.init(ActivityMain.this); else
ServiceSend.boot(ActivityMain.this);
} else
startActivity(new Intent(ActivityMain.this, ActivitySetup.class)); startActivity(new Intent(ActivityMain.this, ActivitySetup.class));
finish(); finish();
} }

@ -1446,7 +1446,9 @@ public class ServiceSynchronize extends ServiceBase {
int pollInterval = prefs.getInt("poll_interval", 0); int pollInterval = prefs.getInt("poll_interval", 0);
int accounts = db.account().getSynchronizingAccounts().size(); int accounts = db.account().getSynchronizingAccounts().size();
if (enabled && pollInterval == 0 && accounts > 0) if (enabled && pollInterval == 0 && accounts > 0)
init(context); ContextCompat.startForegroundService(context,
new Intent(context, ServiceSynchronize.class)
.setAction("init"));
else { else {
for (EntityAccount account : db.account().getAccounts()) for (EntityAccount account : db.account().getAccounts())
db.account().setAccountState(account.id, null); db.account().setAccountState(account.id, null);
@ -1465,12 +1467,6 @@ public class ServiceSynchronize extends ServiceBase {
thread.start(); thread.start();
} }
static void init(Context context) {
ContextCompat.startForegroundService(context,
new Intent(context, ServiceSynchronize.class)
.setAction("init"));
}
private static void schedule(Context context) { private static void schedule(Context context) {
Intent alarm = new Intent(context, ServiceSynchronize.class); Intent alarm = new Intent(context, ServiceSynchronize.class);
alarm.setAction("alarm"); alarm.setAction("alarm");

Loading…
Cancel
Save