mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-06 18:57:26 +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"
|
||||
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 {
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user