Show syncing folder state

pull/72/head
M66B 6 years ago
parent 07f263419b
commit fe17a18d24

@ -113,6 +113,10 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
ivState.setImageResource(R.drawable.baseline_cloud_24);
else if ("connecting".equals(folder.state))
ivState.setImageResource(R.drawable.baseline_cloud_queue_24);
else if ("closing".equals(folder.state))
ivState.setImageResource(R.drawable.baseline_close_24);
else if ("syncing".equals(folder.state))
ivState.setImageResource(R.drawable.baseline_sync_24);
else
ivState.setImageResource(R.drawable.baseline_cloud_off_24);
ivState.setVisibility(folder.synchronize || outbox ? View.VISIBLE : View.INVISIBLE);

@ -764,6 +764,8 @@ public class ServiceSynchronize extends LifecycleService {
// Close store
Log.i(Helper.TAG, account.name + " closing");
db.account().setAccountState(account.id, "closing");
for (EntityFolder folder : folders.keySet())
db.folder().setFolderState(folder.id, "closing");
try {
// This can take some time
istore.close();
@ -1173,10 +1175,11 @@ public class ServiceSynchronize extends LifecycleService {
}
private void synchronizeMessages(EntityAccount account, EntityFolder folder, IMAPFolder ifolder, ServiceState state) throws MessagingException, IOException {
DB db = DB.getInstance(this);
try {
Log.v(Helper.TAG, folder.name + " start sync after=" + folder.after);
DB db = DB.getInstance(this);
db.folder().setFolderState(folder.id, "syncing");
// Get reference times
Calendar cal = Calendar.getInstance();
@ -1283,6 +1286,7 @@ public class ServiceSynchronize extends LifecycleService {
Log.w(Helper.TAG, folder.name + " statistics added=" + added + " updated=" + updated + " unchanged=" + unchanged);
} finally {
Log.v(Helper.TAG, folder.name + " end sync");
db.folder().setFolderState(folder.id, ifolder.isOpen() ? "connected" : "disconnected");
}
}
@ -1579,20 +1583,23 @@ public class ServiceSynchronize extends LifecycleService {
private BroadcastReceiver outboxReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
public void onReceive(final Context context, Intent intent) {
Log.v(Helper.TAG, outbox.name + " run operations");
executor.submit(new Runnable() {
@Override
public void run() {
DB db = DB.getInstance(context);
try {
Log.i(Helper.TAG, outbox.name + " start operations");
db.folder().setFolderState(outbox.id, "syncing");
processOperations(outbox, null, null, null);
} catch (Throwable ex) {
Log.e(Helper.TAG, outbox.name + " " + ex + "\n" + Log.getStackTraceString(ex));
reportError(null, outbox.name, ex);
} finally {
Log.i(Helper.TAG, outbox.name + " end operations");
db.folder().setFolderState(outbox.id, "connected");
}
}
});

Loading…
Cancel
Save