mirror of https://github.com/M66B/FairEmail.git
Improved error handling
This commit is contained in:
parent
58ee954993
commit
a6cd53b98d
|
@ -320,56 +320,73 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view.getId() == R.id.btnHelp)
|
||||
Helper.viewFAQ(context, 22);
|
||||
else {
|
||||
if (view.getId() == R.id.btnHelp) {
|
||||
int pos = getAdapterPosition();
|
||||
if (pos == RecyclerView.NO_POSITION)
|
||||
return;
|
||||
|
||||
TupleAccountEx account = items.get(pos);
|
||||
if (account.tbd != null)
|
||||
return;
|
||||
|
||||
if (view.getId() == R.id.ibInbox) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", account.id);
|
||||
|
||||
new SimpleTask<EntityFolder>() {
|
||||
@Override
|
||||
protected EntityFolder onExecute(Context context, Bundle args) {
|
||||
long id = args.getLong("id");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
return db.folder().getFolderByType(id, EntityFolder.INBOX);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, EntityFolder inbox) {
|
||||
if (inbox == null)
|
||||
return;
|
||||
|
||||
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);
|
||||
}
|
||||
}.execute(context, owner, args, "account:inbox");
|
||||
} else {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
||||
lbm.sendBroadcast(
|
||||
new Intent(settings ? ActivitySetup.ACTION_EDIT_ACCOUNT : ActivityView.ACTION_VIEW_FOLDERS)
|
||||
.putExtra("id", account.id)
|
||||
.putExtra("protocol", account.protocol));
|
||||
TupleAccountEx account = (pos == RecyclerView.NO_POSITION ? null : items.get(pos));
|
||||
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;
|
||||
}
|
||||
|
||||
int pos = getAdapterPosition();
|
||||
if (pos == RecyclerView.NO_POSITION)
|
||||
return;
|
||||
|
||||
TupleAccountEx account = items.get(pos);
|
||||
if (account.tbd != null)
|
||||
return;
|
||||
|
||||
if (view.getId() == R.id.ibInbox) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", account.id);
|
||||
|
||||
new SimpleTask<EntityFolder>() {
|
||||
@Override
|
||||
protected EntityFolder onExecute(Context context, Bundle args) {
|
||||
long id = args.getLong("id");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
return db.folder().getFolderByType(id, EntityFolder.INBOX);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, EntityFolder inbox) {
|
||||
if (inbox == null)
|
||||
return;
|
||||
|
||||
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);
|
||||
}
|
||||
}.execute(context, owner, args, "account:inbox");
|
||||
} else {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
||||
lbm.sendBroadcast(
|
||||
new Intent(settings ? ActivitySetup.ACTION_EDIT_ACCOUNT : ActivityView.ACTION_VIEW_FOLDERS)
|
||||
.putExtra("id", account.id)
|
||||
.putExtra("protocol", account.protocol));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue