From 97e6ad8557fe0da3c31a2f5da9f3e1a3ae04d4fa Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 8 Jul 2020 08:52:45 +0200 Subject: [PATCH] Refactoring --- .../eu/faircode/email/FragmentMessages.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 9e53bcead5..4e74bc9e3f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -4893,14 +4893,14 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. return (up && onReply(context)); case KeyEvent.KEYCODE_PAGE_UP: case KeyEvent.KEYCODE_DPAD_UP: - if (up) - rvMessage.scrollBy(0, -context.getResources().getDisplayMetrics().heightPixels / 2); - return up; + if (viewType == AdapterMessage.ViewType.THREAD) + return (up && onScroll(context, true)); + break; case KeyEvent.KEYCODE_PAGE_DOWN: case KeyEvent.KEYCODE_DPAD_DOWN: - if (up) - rvMessage.scrollBy(0, context.getResources().getDisplayMetrics().heightPixels / 2); - return up; + if (viewType == AdapterMessage.ViewType.THREAD) + return (up && onScroll(context, false)); + break; } if (!up) @@ -5009,6 +5009,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. fabMore.performClick(); return true; } + + private boolean onScroll(Context context, boolean up) { + rvMessage.scrollBy(0, (up ? -1 : 1) * + context.getResources().getDisplayMetrics().heightPixels / 2); + return true; + } }; @Override