From e1b4d70543d9a7a92b1d308b5345820c97748f62 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 21 Oct 2018 08:49:03 +0000 Subject: [PATCH] Swa previous/next --- .../eu/faircode/email/FragmentMessages.java | 6 +++--- .../eu/faircode/email/ViewModelMessages.java | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 627912c8..35a221f4 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -464,8 +464,8 @@ public class FragmentMessages extends FragmentEx { bottom_navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { - ViewModelMessages.AccountThread[] pn = (ViewModelMessages.AccountThread[]) bottom_navigation.getTag(); - ViewModelMessages.AccountThread target = (menuItem.getItemId() == R.id.action_prev ? pn[0] : pn[1]); + ViewModelMessages.Target[] pn = (ViewModelMessages.Target[]) bottom_navigation.getTag(); + ViewModelMessages.Target target = (menuItem.getItemId() == R.id.action_prev ? pn[0] : pn[1]); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext()); lbm.sendBroadcast( new Intent(ActivityView.ACTION_VIEW_THREAD) @@ -587,7 +587,7 @@ public class FragmentMessages extends FragmentEx { if (viewType == AdapterMessage.ViewType.THREAD) { // Navigation ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class); - ViewModelMessages.AccountThread[] pn = model.getPrevNext(thread); + ViewModelMessages.Target[] 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 c26b7fab..148b7190 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; } - AccountThread[] getPrevNext(String thread) { + Target[] getPrevNext(String thread) { if (messages == null) - return new AccountThread[]{null, null}; + return new Target[]{null, null}; boolean found = false; TupleMessageEx prev = null; @@ -22,25 +22,25 @@ public class ViewModelMessages extends ViewModel { if (item == null) continue; if (found) { - next = item; + prev = item; messages.loadAround(i); break; } if (thread.equals(item.thread)) found = true; else - prev = item; + next = item; } - return new AccountThread[]{ - prev == null ? null : new AccountThread(prev.account, prev.thread), - next == null ? null : new AccountThread(next.account, next.thread)}; + return new Target[]{ + prev == null ? null : new Target(prev.account, prev.thread), + next == null ? null : new Target(next.account, next.thread)}; } - class AccountThread { + class Target { long account; String thread; - AccountThread(long account, String thread) { + Target(long account, String thread) { this.account = account; this.thread = thread; }