aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDocile-Alligator <chineseperson5@gmail.com>2022-03-14 06:15:44 +0000
committerDocile-Alligator <chineseperson5@gmail.com>2022-03-14 06:15:44 +0000
commitcfd295aea8a5a1f6ba460fa25f972c1e4cc523e5 (patch)
tree6956c2038edeb78bfde19ec97350ae5141c5e9fc /app
parent3cae2b0dbadfcc109f8e7f52170722c664638d1f (diff)
downloadinfinity-for-reddit-cfd295aea8a5a1f6ba460fa25f972c1e4cc523e5.tar
infinity-for-reddit-cfd295aea8a5a1f6ba460fa25f972c1e4cc523e5.tar.gz
infinity-for-reddit-cfd295aea8a5a1f6ba460fa25f972c1e4cc523e5.tar.bz2
infinity-for-reddit-cfd295aea8a5a1f6ba460fa25f972c1e4cc523e5.tar.lz
infinity-for-reddit-cfd295aea8a5a1f6ba460fa25f972c1e4cc523e5.tar.xz
infinity-for-reddit-cfd295aea8a5a1f6ba460fa25f972c1e4cc523e5.tar.zst
infinity-for-reddit-cfd295aea8a5a1f6ba460fa25f972c1e4cc523e5.zip
Version 5.1.9-beta2. Optimize AppBarStateChangeListener.
Diffstat (limited to '')
-rw-r--r--app/build.gradle4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppBarStateChangeListener.java12
2 files changed, 11 insertions, 5 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 779678fc..0cf2ae1c 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -6,8 +6,8 @@ android {
applicationId "ml.docilealligator.infinityforreddit"
minSdkVersion 21
targetSdkVersion 30
- versionCode 94
- versionName "5.1.9-beta1"
+ versionCode 95
+ versionName "5.1.9-beta2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppBarStateChangeListener.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppBarStateChangeListener.java
index dffd958c..43e11941 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppBarStateChangeListener.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppBarStateChangeListener.java
@@ -4,15 +4,21 @@ import com.google.android.material.appbar.AppBarLayout;
public abstract class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener {
private AppBarStateChangeListener.State mCurrentState = AppBarStateChangeListener.State.IDLE;
+ private int lastOffset = -1;
@Override
- public final void onOffsetChanged(AppBarLayout appBarLayout, int i) {
- if (i == 0) {
+ public final void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
+ if (lastOffset == verticalOffset) {
+ return;
+ }
+ lastOffset = verticalOffset;
+
+ if (verticalOffset == 0) {
if (mCurrentState != AppBarStateChangeListener.State.EXPANDED) {
onStateChanged(appBarLayout, AppBarStateChangeListener.State.EXPANDED);
}
mCurrentState = AppBarStateChangeListener.State.EXPANDED;
- } else if (Math.abs(i) >= appBarLayout.getTotalScrollRange()) {
+ } else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
if (mCurrentState != AppBarStateChangeListener.State.COLLAPSED) {
onStateChanged(appBarLayout, AppBarStateChangeListener.State.COLLAPSED);
}