diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index be31a2ca27..d5ab6a9470 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -464,13 +464,13 @@ public class FragmentMessages extends FragmentEx { bottom_navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { - String[] pn = (String[]) bottom_navigation.getTag(); - String thread = (menuItem.getItemId() == R.id.action_prev ? pn[0] : pn[1]); + ViewModelMessages.AccountThread[] pn = (ViewModelMessages.AccountThread[]) bottom_navigation.getTag(); + ViewModelMessages.AccountThread target = (menuItem.getItemId() == R.id.action_prev ? pn[0] : pn[1]); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext()); lbm.sendBroadcast( new Intent(ActivityView.ACTION_VIEW_THREAD) - .putExtra("account", account) - .putExtra("thread", thread)); + .putExtra("account", target.account) + .putExtra("thread", target.thread)); return true; } }); @@ -587,7 +587,7 @@ public class FragmentMessages extends FragmentEx { if (viewType == AdapterMessage.ViewType.THREAD) { // Navigation ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class); - String[] pn = model.getPrevNext(thread); + ViewModelMessages.AccountThread[] pn = model.getPrevNext(thread); bottom_navigation.setTag(pn); bottom_navigation.getMenu().findItem(R.id.action_prev).setEnabled(pn[0] != null); bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(pn[1] != null); diff --git a/app/src/main/java/eu/faircode/email/ViewModelMessages.java b/app/src/main/java/eu/faircode/email/ViewModelMessages.java index baa22ee48c..c26b7fab62 100644 --- a/app/src/main/java/eu/faircode/email/ViewModelMessages.java +++ b/app/src/main/java/eu/faircode/email/ViewModelMessages.java @@ -10,9 +10,9 @@ public class ViewModelMessages extends ViewModel { this.messages = messages; } - String[] getPrevNext(String thread) { + AccountThread[] getPrevNext(String thread) { if (messages == null) - return new String[]{null, null}; + return new AccountThread[]{null, null}; boolean found = false; TupleMessageEx prev = null; @@ -31,6 +31,18 @@ public class ViewModelMessages extends ViewModel { else prev = item; } - return new String[]{prev == null ? null : prev.thread, next == null ? null : next.thread}; + return new AccountThread[]{ + prev == null ? null : new AccountThread(prev.account, prev.thread), + next == null ? null : new AccountThread(next.account, next.thread)}; + } + + class AccountThread { + long account; + String thread; + + AccountThread(long account, String thread) { + this.account = account; + this.thread = thread; + } } }