mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Version 5.1.9-beta2. Optimize AppBarStateChangeListener.
This commit is contained in:
parent
3cae2b0dba
commit
cfd295aea8
@ -6,8 +6,8 @@ android {
|
|||||||
applicationId "ml.docilealligator.infinityforreddit"
|
applicationId "ml.docilealligator.infinityforreddit"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 94
|
versionCode 95
|
||||||
versionName "5.1.9-beta1"
|
versionName "5.1.9-beta2"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
javaCompileOptions {
|
javaCompileOptions {
|
||||||
annotationProcessorOptions {
|
annotationProcessorOptions {
|
||||||
|
@ -4,15 +4,21 @@ import com.google.android.material.appbar.AppBarLayout;
|
|||||||
|
|
||||||
public abstract class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener {
|
public abstract class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener {
|
||||||
private AppBarStateChangeListener.State mCurrentState = AppBarStateChangeListener.State.IDLE;
|
private AppBarStateChangeListener.State mCurrentState = AppBarStateChangeListener.State.IDLE;
|
||||||
|
private int lastOffset = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onOffsetChanged(AppBarLayout appBarLayout, int i) {
|
public final void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
|
||||||
if (i == 0) {
|
if (lastOffset == verticalOffset) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastOffset = verticalOffset;
|
||||||
|
|
||||||
|
if (verticalOffset == 0) {
|
||||||
if (mCurrentState != AppBarStateChangeListener.State.EXPANDED) {
|
if (mCurrentState != AppBarStateChangeListener.State.EXPANDED) {
|
||||||
onStateChanged(appBarLayout, AppBarStateChangeListener.State.EXPANDED);
|
onStateChanged(appBarLayout, AppBarStateChangeListener.State.EXPANDED);
|
||||||
}
|
}
|
||||||
mCurrentState = 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) {
|
if (mCurrentState != AppBarStateChangeListener.State.COLLAPSED) {
|
||||||
onStateChanged(appBarLayout, AppBarStateChangeListener.State.COLLAPSED);
|
onStateChanged(appBarLayout, AppBarStateChangeListener.State.COLLAPSED);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user