Improved error handling

pull/214/head
M66B 1 year ago
parent 58ee954993
commit a6cd53b98d

@ -320,56 +320,73 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (view.getId() == R.id.btnHelp) if (view.getId() == R.id.btnHelp) {
Helper.viewFAQ(context, 22);
else {
int pos = getAdapterPosition(); int pos = getAdapterPosition();
if (pos == RecyclerView.NO_POSITION) TupleAccountEx account = (pos == RecyclerView.NO_POSITION ? null : items.get(pos));
return; if (account == null)
Helper.viewFAQ(context, 22);
else {
Intent intent = new Intent(context, ActivityError.class);
intent.putExtra("title", "Test");
intent.putExtra("message", account.error);
intent.putExtra("provider", account.provider);
intent.putExtra("account", account.id);
intent.putExtra("protocol", account.protocol);
intent.putExtra("auth_type", account.auth_type);
intent.putExtra("personal", "personal");
intent.putExtra("address", "address");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
return;
}
TupleAccountEx account = items.get(pos); int pos = getAdapterPosition();
if (account.tbd != null) if (pos == RecyclerView.NO_POSITION)
return; return;
if (view.getId() == R.id.ibInbox) { TupleAccountEx account = items.get(pos);
Bundle args = new Bundle(); if (account.tbd != null)
args.putLong("id", account.id); return;
new SimpleTask<EntityFolder>() { if (view.getId() == R.id.ibInbox) {
@Override Bundle args = new Bundle();
protected EntityFolder onExecute(Context context, Bundle args) { args.putLong("id", account.id);
long id = args.getLong("id");
DB db = DB.getInstance(context); new SimpleTask<EntityFolder>() {
return db.folder().getFolderByType(id, EntityFolder.INBOX); @Override
} protected EntityFolder onExecute(Context context, Bundle args) {
long id = args.getLong("id");
@Override DB db = DB.getInstance(context);
protected void onExecuted(Bundle args, EntityFolder inbox) { return db.folder().getFolderByType(id, EntityFolder.INBOX);
if (inbox == null) }
return;
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context); @Override
lbm.sendBroadcast( protected void onExecuted(Bundle args, EntityFolder inbox) {
new Intent(ActivityView.ACTION_VIEW_MESSAGES) if (inbox == null)
.putExtra("account", inbox.account) return;
.putExtra("folder", inbox.id)
.putExtra("type", inbox.type));
} LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("account", inbox.account)
.putExtra("folder", inbox.id)
.putExtra("type", inbox.type));
@Override }
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex); @Override
} protected void onException(Bundle args, Throwable ex) {
}.execute(context, owner, args, "account:inbox"); Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
} else { }
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context); }.execute(context, owner, args, "account:inbox");
lbm.sendBroadcast( } else {
new Intent(settings ? ActivitySetup.ACTION_EDIT_ACCOUNT : ActivityView.ACTION_VIEW_FOLDERS) LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
.putExtra("id", account.id) lbm.sendBroadcast(
.putExtra("protocol", account.protocol)); new Intent(settings ? ActivitySetup.ACTION_EDIT_ACCOUNT : ActivityView.ACTION_VIEW_FOLDERS)
} .putExtra("id", account.id)
.putExtra("protocol", account.protocol));
} }
} }

Loading…
Cancel
Save