Simplification

pull/184/head
M66B 5 years ago
parent 6314e66c03
commit 24b6da0598

@ -195,14 +195,15 @@ public class FragmentAccounts extends FragmentBase {
@Override @Override
protected void onExecuted(Bundle args, EntityFolder drafts) { protected void onExecuted(Bundle args, EntityFolder drafts) {
if (drafts != null) { if (drafts == null)
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext()); return;
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES) LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
.putExtra("account", drafts.account) lbm.sendBroadcast(
.putExtra("folder", drafts.id) new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("type", drafts.type)); .putExtra("account", drafts.account)
} .putExtra("folder", drafts.id)
.putExtra("type", drafts.type));
} }
@Override @Override

@ -207,14 +207,26 @@ public class FragmentFolders extends FragmentBase {
fabCompose.setOnLongClickListener(new View.OnLongClickListener() { fabCompose.setOnLongClickListener(new View.OnLongClickListener() {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
Bundle args = new Bundle();
args.putLong("account", account);
new SimpleTask<EntityFolder>() { new SimpleTask<EntityFolder>() {
@Override @Override
protected EntityFolder onExecute(Context context, Bundle args) { protected EntityFolder onExecute(Context context, Bundle args) {
return DB.getInstance(context).folder().getPrimaryDrafts(); long account = args.getLong("account");
DB db = DB.getInstance(context);
if (account < 0)
return db.folder().getPrimaryDrafts();
else
return db.folder().getFolderByType(account, EntityFolder.DRAFTS);
} }
@Override @Override
protected void onExecuted(Bundle args, EntityFolder drafts) { protected void onExecuted(Bundle args, EntityFolder drafts) {
if (drafts == null)
return;
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext()); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast( lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES) new Intent(ActivityView.ACTION_VIEW_MESSAGES)
@ -227,7 +239,7 @@ public class FragmentFolders extends FragmentBase {
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex); Log.unexpectedError(getParentFragmentManager(), ex);
} }
}.execute(FragmentFolders.this, new Bundle(), "folders:drafts"); }.execute(FragmentFolders.this, args, "folders:drafts");
return true; return true;
} }

@ -987,16 +987,14 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
@Override @Override
protected void onExecuted(Bundle args, EntityFolder drafts) { protected void onExecuted(Bundle args, EntityFolder drafts) {
if (drafts == null) if (drafts == null)
Snackbar.make(view, R.string.title_no_drafts, Snackbar.LENGTH_LONG) return;
.setGestureInsetBottomIgnored(true).show();
else { LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext()); lbm.sendBroadcast(
lbm.sendBroadcast( new Intent(ActivityView.ACTION_VIEW_MESSAGES)
new Intent(ActivityView.ACTION_VIEW_MESSAGES) .putExtra("account", drafts.account)
.putExtra("account", drafts.account) .putExtra("folder", drafts.id)
.putExtra("folder", drafts.id) .putExtra("type", drafts.type));
.putExtra("type", drafts.type));
}
} }
@Override @Override

Loading…
Cancel
Save