Fix worker
This commit is contained in:
parent
2b300ceae4
commit
b64fd393e9
|
@ -81,8 +81,8 @@ public class FetchHomeWorker extends Worker {
|
||||||
WorkManager.getInstance(context).cancelAllWorkByTag(Helper.WORKER_REFRESH_HOME + account.user_id + account.instance);
|
WorkManager.getInstance(context).cancelAllWorkByTag(Helper.WORKER_REFRESH_HOME + account.user_id + account.instance);
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
String value = prefs.getString(context.getString(R.string.SET_FETCH_HOME_DELAY_VALUE) + account.user_id + account.instance, "60");
|
String value = prefs.getString(context.getString(R.string.SET_FETCH_HOME_DELAY_VALUE) + account.user_id + account.instance, "60");
|
||||||
PeriodicWorkRequest notificationPeriodic = new PeriodicWorkRequest.Builder(NotificationsWorker.class, Long.parseLong(value), TimeUnit.MINUTES)
|
PeriodicWorkRequest notificationPeriodic = new PeriodicWorkRequest.Builder(FetchHomeWorker.class, Long.parseLong(value), TimeUnit.MINUTES)
|
||||||
.addTag(Helper.WORKER_REFRESH_NOTIFICATION)
|
.addTag(Helper.WORKER_REFRESH_HOME)
|
||||||
.build();
|
.build();
|
||||||
WorkManager.getInstance(context).enqueueUniquePeriodicWork(Helper.WORKER_REFRESH_HOME + account.user_id + account.instance, ExistingPeriodicWorkPolicy.REPLACE, notificationPeriodic);
|
WorkManager.getInstance(context).enqueueUniquePeriodicWork(Helper.WORKER_REFRESH_HOME + account.user_id + account.instance, ExistingPeriodicWorkPolicy.REPLACE, notificationPeriodic);
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ public class FetchHomeWorker extends Worker {
|
||||||
}
|
}
|
||||||
} catch (DBException e) {
|
} catch (DBException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
failed++;
|
failed = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Pagination pagination = MastodonHelper.getPagination(homeResponse.headers());
|
Pagination pagination = MastodonHelper.getPagination(homeResponse.headers());
|
||||||
|
@ -202,13 +202,18 @@ public class FetchHomeWorker extends Worker {
|
||||||
max_id = pagination.max_id;
|
max_id = pagination.max_id;
|
||||||
} else {
|
} else {
|
||||||
canContinue = false;
|
canContinue = false;
|
||||||
|
failed = 4;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
failed = 3;
|
||||||
canContinue = false;
|
canContinue = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
canContinue = false;
|
canContinue = false;
|
||||||
|
failed = 2;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
failed = 1;
|
||||||
}
|
}
|
||||||
//Pause between calls (1 second)
|
//Pause between calls (1 second)
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue