Fixed overscoll invalid zero offset

This commit is contained in:
M66B 2023-04-24 17:37:33 +02:00
parent b95947d079
commit ea4297f729
1 changed files with 17 additions and 7 deletions

View File

@ -239,6 +239,8 @@ import biweekly.Biweekly;
import biweekly.ICalendar;
import biweekly.component.VEvent;
import me.everything.android.ui.overscroll.IOverScrollDecor;
import me.everything.android.ui.overscroll.IOverScrollState;
import me.everything.android.ui.overscroll.IOverScrollStateListener;
import me.everything.android.ui.overscroll.IOverScrollUpdateListener;
import me.everything.android.ui.overscroll.VerticalOverScrollBounceEffectDecorator;
import me.everything.android.ui.overscroll.adapters.RecyclerViewOverScrollDecorAdapter;
@ -2093,26 +2095,25 @@ public class FragmentMessages extends FragmentBase
DEFAULT_TOUCH_DRAG_MOVE_RATIO_BCK,
DEFAULT_DECELERATE_FACTOR
);
decor.setOverScrollUpdateListener(new IOverScrollUpdateListener() {
private boolean triggered = false;
ObjectHolder<Boolean> otriggered = new ObjectHolder<>(false);
decor.setOverScrollUpdateListener(new IOverScrollUpdateListener() {
@Override
public void onOverScrollUpdate(IOverScrollDecor decor, int state, float offset) {
float height = decor.getView().getHeight();
if (height == 0)
return;
if (offset == 0)
triggered = false;
else if (!triggered) {
if (!otriggered.value) {
float dx = Math.abs(offset * DEFAULT_TOUCH_DRAG_MOVE_RATIO_FWD);
if (offset > 0 && dx > height / 4) {
triggered = true;
otriggered.value = true;
handleAutoClose();
}
if (offset < 0 && dx > height / 8) {
triggered = true;
otriggered.value = true;
Bundle args = new Bundle();
args.putInt("icon", R.drawable.twotone_drive_file_move_24);
@ -2131,6 +2132,15 @@ public class FragmentMessages extends FragmentBase
}
}
});
decor.setOverScrollStateListener(new IOverScrollStateListener() {
@Override
public void onOverScrollStateChange(IOverScrollDecor decor, int oldState, int newState) {
// offset is unreliable
if (newState == IOverScrollState.STATE_IDLE)
otriggered.value = false;
}
});
} catch (Throwable ex) {
/*
java.lang.NoClassDefFoundError: Failed resolution of: Lme/a/a/a/a/a/b$1;