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

@ -31,12 +31,12 @@ public class SwipeListener implements View.OnTouchListener {
SwipeListener(final Context context, final ISwipeListener listener) { SwipeListener(final Context context, final ISwipeListener listener) {
final int width = context.getResources().getDisplayMetrics().widthPixels; final int width = context.getResources().getDisplayMetrics().widthPixels;
final int MOVE_THRESHOLD = width / 10; final int MOVE_THRESHOLD = width / 3;
final int SWIPE_THRESHOLD = width / 3; final int SPEED_THRESHOLD = width / 2;
gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override @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) if (me1 == null || me2 == null)
return false; return false;
if (me1.getPointerCount() > 1 || me2.getPointerCount() > 1) if (me1.getPointerCount() > 1 || me2.getPointerCount() > 1)
@ -45,39 +45,21 @@ public class SwipeListener implements View.OnTouchListener {
boolean consumed = false; boolean consumed = false;
int dx = Math.round(me2.getX() - me1.getX()); int dx = Math.round(me2.getX() - me1.getX());
int dy = Math.round(me2.getY() - me1.getY()); int dy = Math.round(me2.getY() - me1.getY());
if (Math.abs(dx) > Math.abs(dy)) { if (Math.abs(dx) > Math.abs(dy)) {
Log.i("Swipe dx=" + dx + "/" + SWIPE_THRESHOLD); Log.i("Swipe dx=" + dx + "/" + MOVE_THRESHOLD + " vx=" + vx + "/" + SPEED_THRESHOLD);
if (Math.abs(dx) > MOVE_THRESHOLD && Math.abs(vx) > SPEED_THRESHOLD)
try { try {
if (Math.abs(dx) > SWIPE_THRESHOLD) {
if (dx > 0)
consumed = listener.onSwipedRight();
else
consumed = listener.onSwipedLeft();
} else if (Math.abs(dx) > MOVE_THRESHOLD) {
if (dx > 0) if (dx > 0)
listener.onSwipingRight(); consumed = listener.onSwipeRight();
else else
listener.onSwipingLeft(); consumed = listener.onSwipeLeft();
}
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(ex); Log.e(ex);
} }
} }
return consumed; 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) { public boolean onTouch(@NonNull View view, @NonNull MotionEvent event) {
@ -85,14 +67,8 @@ public class SwipeListener implements View.OnTouchListener {
} }
interface ISwipeListener { interface ISwipeListener {
boolean onSwipedRight(); boolean onSwipeRight();
boolean onSwipedLeft();
void onSwipingLeft();
void onSwipingRight();
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:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/baseline_reply_24" /> 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 <ImageButton
android:id="@+id/ibDown" android:id="@+id/ibDown"
android:layout_width="wrap_content" android:layout_width="wrap_content"

Loading…
Cancel
Save