Long click account to go to inbox

This commit is contained in:
M66B 2018-11-13 14:44:57 +01:00
parent 124f97bf56
commit 691eb212b4
1 changed files with 40 additions and 0 deletions

View File

@ -204,6 +204,20 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
drawerLayout.closeDrawer(drawerList);
}
});
drawerList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
DrawerItem item = (DrawerItem) parent.getAdapter().getItem(position);
switch (item.getId()) {
case -1:
drawerLayout.closeDrawer(drawerList);
onMenuInbox((long) item.getData());
return true;
default:
return false;
}
}
});
getSupportFragmentManager().addOnBackStackChangedListener(this);
@ -707,6 +721,32 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
fragmentTransaction.commit();
}
private void onMenuInbox(long account) {
Bundle args = new Bundle();
args.putLong("account", account);
new SimpleTask<Long>() {
@Override
protected Long onLoad(Context context, Bundle args) throws Throwable {
long account = args.getLong("account");
return DB.getInstance(context).folder().getFolderByType(account, EntityFolder.INBOX).id;
}
@Override
protected void onLoaded(Bundle args, Long folder) {
long account = args.getLong("account");
getSupportFragmentManager().popBackStack("unified", 0);
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(ActivityView.this);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("account", account)
.putExtra("folder", folder));
}
}.load(this, args);
}
private void onMenuSetup() {
startActivity(new Intent(ActivityView.this, ActivitySetup.class));
}