Revert "Scroll instead of fling"

This reverts commit 3c324e3de9.
pull/172/head
M66B 5 years ago
parent fea48a2556
commit 73cc48ddb7

@ -76,7 +76,6 @@ import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.Spinner;
import android.widget.TextView;
@ -193,8 +192,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private FixedRecyclerView rvMessage;
private View vwAnchor;
private SeekBar sbThread;
private ImageView ivLeft;
private ImageView ivRight;
private ImageButton ibDown;
private ImageButton ibUp;
private ImageButton ibSeen;
@ -384,8 +381,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
rvMessage = view.findViewById(R.id.rvMessage);
vwAnchor = view.findViewById(R.id.vwAnchor);
sbThread = view.findViewById(R.id.sbThread);
ivLeft = view.findViewById(R.id.ivLeft);
ivRight = view.findViewById(R.id.ivRight);
ibDown = view.findViewById(R.id.ibDown);
ibUp = view.findViewById(R.id.ibUp);
ibSeen = view.findViewById(R.id.ibSeen);
@ -987,8 +982,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
tvNoEmail.setVisibility(View.GONE);
tvNoEmailHint.setVisibility(View.GONE);
sbThread.setVisibility(View.GONE);
ivLeft.setVisibility(View.GONE);
ivRight.setVisibility(View.GONE);
ibDown.setVisibility(View.GONE);
ibUp.setVisibility(View.GONE);
ibSeen.setVisibility(View.GONE);
@ -1059,7 +1052,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
final SwipeListener swipeListener = new SwipeListener(getContext(), new SwipeListener.ISwipeListener() {
@Override
public boolean onSwipedRight() {
public boolean onSwipeRight() {
if (prev == null) {
Animation bounce = AnimationUtils.loadAnimation(getContext(), R.anim.bounce_right);
view.startAnimation(bounce);
@ -1070,7 +1063,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
@Override
public boolean onSwipedLeft() {
public boolean onSwipeLeft() {
if (next == null) {
Animation bounce = AnimationUtils.loadAnimation(getContext(), R.anim.bounce_left);
view.startAnimation(bounce);
@ -1079,24 +1072,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return (next != null);
}
@Override
public void onSwipingLeft() {
ivLeft.setVisibility(View.VISIBLE);
ivRight.setVisibility(View.GONE);
}
@Override
public void onSwipingRight() {
ivLeft.setVisibility(View.GONE);
ivRight.setVisibility(View.VISIBLE);
}
@Override
public void onCancel() {
ivLeft.setVisibility(View.GONE);
ivRight.setVisibility(View.GONE);
}
});
rvMessage.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {

@ -31,12 +31,12 @@ public class SwipeListener implements View.OnTouchListener {
SwipeListener(final Context context, final ISwipeListener listener) {
final int width = context.getResources().getDisplayMetrics().widthPixels;
final int MOVE_THRESHOLD = width / 10;
final int SWIPE_THRESHOLD = width / 3;
final int MOVE_THRESHOLD = width / 3;
final int SPEED_THRESHOLD = width / 2;
gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onScroll(MotionEvent me1, MotionEvent me2, float distanceX, float distanceY) {
public boolean onFling(MotionEvent me1, MotionEvent me2, float vx, float vy) {
if (me1 == null || me2 == null)
return false;
if (me1.getPointerCount() > 1 || me2.getPointerCount() > 1)
@ -45,39 +45,21 @@ public class SwipeListener implements View.OnTouchListener {
boolean consumed = false;
int dx = Math.round(me2.getX() - me1.getX());
int dy = Math.round(me2.getY() - me1.getY());
if (Math.abs(dx) > Math.abs(dy)) {
Log.i("Swipe dx=" + dx + "/" + SWIPE_THRESHOLD);
try {
if (Math.abs(dx) > SWIPE_THRESHOLD) {
if (dx > 0)
consumed = listener.onSwipedRight();
else
consumed = listener.onSwipedLeft();
} else if (Math.abs(dx) > MOVE_THRESHOLD) {
Log.i("Swipe dx=" + dx + "/" + MOVE_THRESHOLD + " vx=" + vx + "/" + SPEED_THRESHOLD);
if (Math.abs(dx) > MOVE_THRESHOLD && Math.abs(vx) > SPEED_THRESHOLD)
try {
if (dx > 0)
listener.onSwipingRight();
consumed = listener.onSwipeRight();
else
listener.onSwipingLeft();
consumed = listener.onSwipeLeft();
} catch (Throwable ex) {
Log.e(ex);
}
} catch (Throwable ex) {
Log.e(ex);
}
}
return consumed;
}
}) {
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_UP)
try {
listener.onCancel();
} catch (Throwable ex) {
Log.e(ex);
}
return super.onTouchEvent(ev);
}
};
});
}
public boolean onTouch(@NonNull View view, @NonNull MotionEvent event) {
@ -85,14 +67,8 @@ public class SwipeListener implements View.OnTouchListener {
}
interface ISwipeListener {
boolean onSwipedRight();
boolean onSwipedLeft();
void onSwipingLeft();
void onSwipingRight();
boolean onSwipeRight();
void onCancel();
boolean onSwipeLeft();
}
}

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M15.41,16.59L10.83,12l4.58,-4.59L14,6l-6,6 6,6 1.41,-1.41z"/>
</vector>

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M8.59,16.59L13.17,12 8.59,7.41 10,6l6,6 -6,6 -1.41,-1.41z"/>
</vector>

@ -200,30 +200,6 @@
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/baseline_reply_24" />
<ImageView
android:id="@+id/ivLeft"
android:layout_width="60dp"
android:layout_height="60dp"
android:padding="12dp"
android:tint="?attr/colorSeparator"
app:layout_constraintBottom_toTopOf="@+id/sbThread"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/baseline_keyboard_arrow_left_24" />
<ImageView
android:id="@+id/ivRight"
android:layout_width="60dp"
android:layout_height="60dp"
android:padding="12dp"
android:tint="?attr/colorSeparator"
app:layout_constraintBottom_toTopOf="@+id/sbThread"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/baseline_keyboard_arrow_right_24" />
<ImageButton
android:id="@+id/ibDown"
android:layout_width="wrap_content"

Loading…
Cancel
Save