mirror of https://github.com/M66B/FairEmail.git
Update new messages every 15 seconds during sync
This commit is contained in:
parent
d24e641bcb
commit
82e7334ab8
|
@ -135,6 +135,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
static final int DEFAULT_BACKOFF_POWER = 3; // 2^3=8 seconds (totally 8+2x20=48 seconds)
|
||||
|
||||
private static final long MSG_DELAY = 15 * 1000L; // milliseconds
|
||||
private static final long BACKUP_DELAY = 30 * 1000L; // milliseconds
|
||||
private static final long PURGE_DELAY = 30 * 1000L; // milliseconds
|
||||
private static final int QUIT_DELAY = 10; // seconds
|
||||
|
@ -737,6 +738,15 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
final TwoStateOwner cowner = new TwoStateOwner(this, "liveSynchronizing");
|
||||
|
||||
final Runnable updateNew = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.i("Update new messages");
|
||||
cowner.restart();
|
||||
getMainHandler().postDelayed(this, MSG_DELAY);
|
||||
}
|
||||
};
|
||||
|
||||
db.folder().liveSynchronizing().observe(this, new Observer<List<TupleFolderSync>>() {
|
||||
private List<Long> lastAccounts = new ArrayList<>();
|
||||
private List<Long> lastFolders = new ArrayList<>();
|
||||
|
@ -776,10 +786,13 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
" folders=" + folders.size() +
|
||||
" accounts=" + accounts.size());
|
||||
|
||||
if (syncing == 0)
|
||||
if (syncing == 0) {
|
||||
getMainHandler().removeCallbacks(updateNew);
|
||||
cowner.start();
|
||||
else
|
||||
} else {
|
||||
cowner.stop();
|
||||
getMainHandler().postDelayed(updateNew, MSG_DELAY);
|
||||
}
|
||||
|
||||
if (!changed)
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue