diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/com/wireguard/android/widget/CustomRecyclerViewScrollListener.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/app/src/main/java/com/wireguard/android/widget/CustomRecyclerViewScrollListener.java b/app/src/main/java/com/wireguard/android/widget/CustomRecyclerViewScrollListener.java index 2660179f..dfdfd513 100644 --- a/app/src/main/java/com/wireguard/android/widget/CustomRecyclerViewScrollListener.java +++ b/app/src/main/java/com/wireguard/android/widget/CustomRecyclerViewScrollListener.java @@ -8,21 +8,26 @@ package com.wireguard.android.widget; import android.support.v7.widget.RecyclerView; +import com.wireguard.android.R; + public abstract class CustomRecyclerViewScrollListener extends RecyclerView.OnScrollListener { private int scrollDist; private boolean isVisible = true; - private static final float FLING_THRESHOLD = 25; + private static int flingThreshold; @Override public void onScrolled(final RecyclerView recyclerView, final int dx, final int dy) { super.onScrolled(recyclerView, dx, dy); - if (isVisible && scrollDist > FLING_THRESHOLD) { + if (flingThreshold == 0) + flingThreshold = recyclerView.getResources().getDimensionPixelSize(R.dimen.design_fab_size_normal) / 2; + + if (isVisible && scrollDist >= flingThreshold) { hide(); scrollDist = 0; isVisible = false; - } else if (!isVisible && scrollDist < -FLING_THRESHOLD) { + } else if (!isVisible && scrollDist <= -flingThreshold) { show(); scrollDist = 0; isVisible = true; |