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); ivState.setImageResource(R.drawable.baseline_cloud_24);
else if ("connecting".equals(folder.state)) else if ("connecting".equals(folder.state))
ivState.setImageResource(R.drawable.baseline_cloud_queue_24); 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 else
ivState.setImageResource(R.drawable.baseline_cloud_off_24); ivState.setImageResource(R.drawable.baseline_cloud_off_24);
ivState.setVisibility(folder.synchronize || outbox ? View.VISIBLE : View.INVISIBLE); ivState.setVisibility(folder.synchronize || outbox ? View.VISIBLE : View.INVISIBLE);

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

Loading…
Cancel
Save