mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-31 22:26:06 +02:00
Observe operations
This commit is contained in:
@@ -21,7 +21,6 @@ package eu.faircode.email;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -33,6 +32,7 @@ import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.sun.mail.imap.IMAPFolder;
|
||||
@@ -46,7 +46,6 @@ import javax.mail.Session;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
public class FragmentFolder extends FragmentEx {
|
||||
private ViewGroup view;
|
||||
@@ -213,11 +212,33 @@ public class FragmentFolder extends FragmentEx {
|
||||
if (folder == null || !folder.name.equals(name))
|
||||
ServiceSynchronize.reload(getContext(), "save folder");
|
||||
else {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
||||
lbm.sendBroadcast(
|
||||
new Intent(ServiceSynchronize.ACTION_SYNCHRONIZE_FOLDER)
|
||||
.setType("account/" + folder.account)
|
||||
.putExtra("folder", folder.id));
|
||||
Bundle sargs = new Bundle();
|
||||
sargs.putLong("account", folder.account);
|
||||
sargs.putLong("folder", folder.id);
|
||||
|
||||
new SimpleTask<EntityAccount>() {
|
||||
@Override
|
||||
protected EntityAccount onLoad(Context context, Bundle args) {
|
||||
long account = args.getLong("account");
|
||||
long folder = args.getLong("folder");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
EntityOperation.sync(db, folder);
|
||||
|
||||
return db.account().getAccount(account);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLoaded(Bundle args, EntityAccount account) {
|
||||
if (!"connected".equals(account.state))
|
||||
Toast.makeText(getContext(), R.string.title_sync_queued, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
|
||||
}
|
||||
}.load(FragmentFolder.this, sargs);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user