mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 19:09:17 +01:00
Now tap on edges of webtoon reader scrolls by 3/4 screen
This commit is contained in:
parent
486f129e62
commit
a3ec057384
@ -68,7 +68,7 @@ public class PagerReaderFragment extends BaseFragment {
|
|||||||
imageView.setMinimumScaleType(parentFragment.scaleType);
|
imageView.setMinimumScaleType(parentFragment.scaleType);
|
||||||
imageView.setRegionDecoderClass(parentFragment.getRegionDecoderClass());
|
imageView.setRegionDecoderClass(parentFragment.getRegionDecoderClass());
|
||||||
imageView.setBitmapDecoderClass(parentFragment.getBitmapDecoderClass());
|
imageView.setBitmapDecoderClass(parentFragment.getBitmapDecoderClass());
|
||||||
imageView.setVerticalScroll(parentFragment instanceof VerticalReader);
|
imageView.setVerticalScrollingParent(parentFragment instanceof VerticalReader);
|
||||||
imageView.setOnTouchListener((v, motionEvent) -> parentFragment.onImageTouch(motionEvent));
|
imageView.setOnTouchListener((v, motionEvent) -> parentFragment.onImageTouch(motionEvent));
|
||||||
imageView.setOnImageEventListener(new SubsamplingScaleImageView.DefaultOnImageEventListener() {
|
imageView.setOnImageEventListener(new SubsamplingScaleImageView.DefaultOnImageEventListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -187,8 +187,8 @@ public class PagerReaderFragment extends BaseFragment {
|
|||||||
|
|
||||||
final AtomicInteger currentValue = new AtomicInteger(-1);
|
final AtomicInteger currentValue = new AtomicInteger(-1);
|
||||||
|
|
||||||
progressSubscription = Observable.interval(75, TimeUnit.MILLISECONDS, Schedulers.newThread())
|
progressSubscription = Observable.interval(100, TimeUnit.MILLISECONDS, Schedulers.newThread())
|
||||||
.onBackpressureDrop()
|
.onBackpressureLatest()
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(tick -> {
|
.subscribe(tick -> {
|
||||||
// Refresh UI only if progress change
|
// Refresh UI only if progress change
|
||||||
|
@ -38,7 +38,7 @@ public class WebtoonHolder extends RecyclerView.ViewHolder {
|
|||||||
imageView.setMaxScale(10);
|
imageView.setMaxScale(10);
|
||||||
imageView.setRegionDecoderClass(adapter.getReader().getRegionDecoderClass());
|
imageView.setRegionDecoderClass(adapter.getReader().getRegionDecoderClass());
|
||||||
imageView.setBitmapDecoderClass(adapter.getReader().getBitmapDecoderClass());
|
imageView.setBitmapDecoderClass(adapter.getReader().getBitmapDecoderClass());
|
||||||
imageView.setVerticalScroll(true);
|
imageView.setVerticalScrollingParent(true);
|
||||||
imageView.setOnTouchListener(touchListener);
|
imageView.setOnTouchListener(touchListener);
|
||||||
imageView.setOnImageEventListener(new SubsamplingScaleImageView.DefaultOnImageEventListener() {
|
imageView.setOnImageEventListener(new SubsamplingScaleImageView.DefaultOnImageEventListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,11 +29,20 @@ public class WebtoonReader extends BaseReader {
|
|||||||
private Subscription decoderSubscription;
|
private Subscription decoderSubscription;
|
||||||
private GestureDetector gestureDetector;
|
private GestureDetector gestureDetector;
|
||||||
|
|
||||||
|
private int scrollDistance;
|
||||||
|
|
||||||
|
private static final float LEFT_REGION = 0.33f;
|
||||||
|
private static final float RIGHT_REGION = 0.66f;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
|
||||||
adapter = new WebtoonAdapter(this);
|
adapter = new WebtoonAdapter(this);
|
||||||
|
|
||||||
|
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||||
|
scrollDistance = screenHeight * 3 / 4;
|
||||||
|
|
||||||
layoutManager = new PreCachingLayoutManager(getActivity());
|
layoutManager = new PreCachingLayoutManager(getActivity());
|
||||||
layoutManager.setExtraLayoutSpace(getResources().getDisplayMetrics().heightPixels / 2);
|
layoutManager.setExtraLayoutSpace(screenHeight / 2);
|
||||||
|
|
||||||
recycler = new RecyclerView(getActivity());
|
recycler = new RecyclerView(getActivity());
|
||||||
recycler.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
|
recycler.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
|
||||||
@ -48,10 +57,18 @@ public class WebtoonReader extends BaseReader {
|
|||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.subscribe(v -> recycler.setAdapter(adapter));
|
.subscribe(v -> recycler.setAdapter(adapter));
|
||||||
|
|
||||||
gestureDetector = new GestureDetector(getActivity(), new SimpleOnGestureListener() {
|
gestureDetector = new GestureDetector(recycler.getContext(), new SimpleOnGestureListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onSingleTapConfirmed(MotionEvent e) {
|
public boolean onSingleTapConfirmed(MotionEvent e) {
|
||||||
getReaderActivity().onCenterSingleTap();
|
final float positionX = e.getX();
|
||||||
|
|
||||||
|
if (positionX < recycler.getWidth() * LEFT_REGION) {
|
||||||
|
recycler.smoothScrollBy(0, -scrollDistance);
|
||||||
|
} else if (positionX > recycler.getWidth() * RIGHT_REGION) {
|
||||||
|
recycler.smoothScrollBy(0, scrollDistance);
|
||||||
|
} else {
|
||||||
|
getReaderActivity().onCenterSingleTap();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -206,7 +206,7 @@ public class SubsamplingScaleImageView extends View {
|
|||||||
private int maxBitmapDimensions;
|
private int maxBitmapDimensions;
|
||||||
|
|
||||||
// Vertical pagers/scrollers should enable this
|
// Vertical pagers/scrollers should enable this
|
||||||
private boolean isVerticalScroll;
|
private boolean isVerticalScrollingParent;
|
||||||
|
|
||||||
// Is two-finger zooming in progress
|
// Is two-finger zooming in progress
|
||||||
private boolean isZooming;
|
private boolean isZooming;
|
||||||
@ -758,7 +758,7 @@ public class SubsamplingScaleImageView extends View {
|
|||||||
float lastX = vTranslate.x;
|
float lastX = vTranslate.x;
|
||||||
float lastY = vTranslate.y;
|
float lastY = vTranslate.y;
|
||||||
fitToBounds(true);
|
fitToBounds(true);
|
||||||
if (!isVerticalScroll) {
|
if (!isVerticalScrollingParent) {
|
||||||
boolean atXEdge = lastX != vTranslate.x;
|
boolean atXEdge = lastX != vTranslate.x;
|
||||||
boolean edgeXSwipe = atXEdge && dx > dy && !isPanning;
|
boolean edgeXSwipe = atXEdge && dx > dy && !isPanning;
|
||||||
boolean yPan = lastY == vTranslate.y && dy > 15;
|
boolean yPan = lastY == vTranslate.y && dy > 15;
|
||||||
@ -779,7 +779,7 @@ public class SubsamplingScaleImageView extends View {
|
|||||||
if (!edgeYSwipe && (!atYEdge || xPan || isPanning)) {
|
if (!edgeYSwipe && (!atYEdge || xPan || isPanning)) {
|
||||||
isPanning = true;
|
isPanning = true;
|
||||||
} else if (dy > 5) {
|
} else if (dy > 5) {
|
||||||
// Haven't panned the image, and we're at the left or right edge. Switch to page swipe.
|
// Haven't panned the image, and we're at the top or bottom edge. Switch to page swipe.
|
||||||
maxTouchCount = 0;
|
maxTouchCount = 0;
|
||||||
handler.removeMessages(MESSAGE_LONG_CLICK);
|
handler.removeMessages(MESSAGE_LONG_CLICK);
|
||||||
getParent().requestDisallowInterceptTouchEvent(false);
|
getParent().requestDisallowInterceptTouchEvent(false);
|
||||||
@ -2502,8 +2502,8 @@ public class SubsamplingScaleImageView extends View {
|
|||||||
/**
|
/**
|
||||||
* Set vertical scroll mode to fix gestures
|
* Set vertical scroll mode to fix gestures
|
||||||
*/
|
*/
|
||||||
public void setVerticalScroll(boolean isVerticalScroll) {
|
public void setVerticalScrollingParent(boolean isVerticalScrollingParent) {
|
||||||
this.isVerticalScroll = isVerticalScroll;
|
this.isVerticalScrollingParent = isVerticalScrollingParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user