Simplified boot/init

pull/160/head
M66B 6 years ago
parent 2fda4ebd35
commit 6f47a2e22c

@ -83,7 +83,7 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
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.boot(ActivityMain.this); ServiceSynchronize.init(ActivityMain.this);
ServiceSend.boot(ActivityMain.this); ServiceSend.boot(ActivityMain.this);
} else } else
startActivity(new Intent(ActivityMain.this, ActivitySetup.class)); startActivity(new Intent(ActivityMain.this, ActivitySetup.class));

@ -433,9 +433,6 @@ public class ServiceSend extends ServiceBase {
} }
static void boot(final Context context) { static void boot(final Context context) {
if (!booted) {
booted = true;
Thread thread = new Thread(new Runnable() { Thread thread = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -452,7 +449,6 @@ public class ServiceSend extends ServiceBase {
thread.setPriority(THREAD_PRIORITY_BACKGROUND); thread.setPriority(THREAD_PRIORITY_BACKGROUND);
thread.start(); thread.start();
} }
}
static void start(Context context) { static void start(Context context) {
ContextCompat.startForegroundService(context, ContextCompat.startForegroundService(context,

@ -1418,9 +1418,6 @@ public class ServiceSynchronize extends ServiceBase {
}; };
static void boot(final Context context) { static void boot(final Context context) {
if (!booted) {
booted = true;
Thread thread = new Thread(new Runnable() { Thread thread = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -1443,9 +1440,7 @@ 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)
ContextCompat.startForegroundService(context, init(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);
@ -1463,6 +1458,11 @@ public class ServiceSynchronize extends ServiceBase {
thread.setPriority(THREAD_PRIORITY_BACKGROUND); thread.setPriority(THREAD_PRIORITY_BACKGROUND);
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) {

Loading…
Cancel
Save