diff --git a/src/org/geometerplus/fbreader/fbreader/FBView.java b/src/org/geometerplus/fbreader/fbreader/FBView.java index b8365cde2..7a825f5a1 100644 --- a/src/org/geometerplus/fbreader/fbreader/FBView.java +++ b/src/org/geometerplus/fbreader/fbreader/FBView.java @@ -43,7 +43,6 @@ public final class FBView extends ZLTextView { } public void setModel(ZLTextModel model) { - myIsManualScrollingActive = false; super.setModel(model); if (myFooter != null) { myFooter.resetTOCMarks(); @@ -52,7 +51,6 @@ public final class FBView extends ZLTextView { private int myStartX; private int myStartY; - private boolean myIsManualScrollingActive; private boolean myIsBrightnessAdjustmentInProgress; private int myStartBrightness; @@ -77,10 +75,6 @@ public final class FBView extends ZLTextView { return true; } - if (isScrollingActive()) { - return false; - } - if (myReader.FooterIsSensitiveOption.getValue()) { Footer footer = getFooterArea(); if (footer != null && y > myContext.getHeight() - footer.getTapHeight()) { @@ -128,10 +122,6 @@ public final class FBView extends ZLTextView { return true; } - if (isScrollingActive()) { - return false; - } - if (myReader.FooterIsSensitiveOption.getValue()) { Footer footer = getFooterArea(); if (footer != null && y > myContext.getHeight() - footer.getTapHeight()) { @@ -158,8 +148,6 @@ public final class FBView extends ZLTextView { fingerScrolling == ScrollingPreferences.FingerScrolling.byTapAndFlick) { myStartX = x; myStartY = y; - setScrollingActive(true); - myIsManualScrollingActive = true; } } @@ -180,32 +168,28 @@ public final class FBView extends ZLTextView { } } - if (isScrollingActive() && myIsManualScrollingActive) { - final boolean horizontal = ScrollingPreferences.Instance().HorizontalOption.getValue(); - final int diff = horizontal ? x - myStartX : y - myStartY; - final Direction direction = horizontal ? Direction.rightToLeft : Direction.up; - if (diff >= 0) { - final ZLTextWordCursor cursor = getStartCursor(); - if (cursor == null || cursor.isNull()) { - return false; - } - if (!cursor.isStartOfParagraph() || !cursor.getParagraphCursor().isFirst()) { - myReader.scrollViewManually(myStartX, myStartY, x, y, direction); - } - } else { - final ZLTextWordCursor cursor = getEndCursor(); - if (cursor == null || cursor.isNull()) { - return false; - } - if (!cursor.isEndOfParagraph() || !cursor.getParagraphCursor().isLast()) { - myReader.scrollViewManually(myStartX, myStartY, x, y, direction); - } + final boolean horizontal = ScrollingPreferences.Instance().HorizontalOption.getValue(); + final int diff = horizontal ? x - myStartX : y - myStartY; + final Direction direction = horizontal ? Direction.rightToLeft : Direction.up; + if (diff >= 0) { + final ZLTextWordCursor cursor = getStartCursor(); + if (cursor == null || cursor.isNull()) { + return false; + } + if (!cursor.isStartOfParagraph() || !cursor.getParagraphCursor().isFirst()) { + myReader.scrollViewManually(myStartX, myStartY, x, y, direction); + } + } else { + final ZLTextWordCursor cursor = getEndCursor(); + if (cursor == null || cursor.isNull()) { + return false; + } + if (!cursor.isEndOfParagraph() || !cursor.getParagraphCursor().isLast()) { + myReader.scrollViewManually(myStartX, myStartY, x, y, direction); } - return true; } } - - return false; + return true; } public boolean onFingerRelease(int x, int y) { @@ -215,39 +199,34 @@ public final class FBView extends ZLTextView { synchronized (this) { myIsBrightnessAdjustmentInProgress = false; - if (isScrollingActive() && myIsManualScrollingActive) { - setScrollingActive(false); - myIsManualScrollingActive = false; - final boolean horizontal = ScrollingPreferences.Instance().HorizontalOption.getValue(); - final int diff = horizontal ? x - myStartX : y - myStartY; - boolean doScroll = false; - if (diff > 0) { - ZLTextWordCursor cursor = getStartCursor(); - if (cursor != null && !cursor.isNull()) { - doScroll = !cursor.isStartOfParagraph() || !cursor.getParagraphCursor().isFirst(); - } - } else if (diff < 0) { - ZLTextWordCursor cursor = getEndCursor(); - if (cursor != null && !cursor.isNull()) { - doScroll = !cursor.isEndOfParagraph() || !cursor.getParagraphCursor().isLast(); - } + final boolean horizontal = ScrollingPreferences.Instance().HorizontalOption.getValue(); + final int diff = horizontal ? x - myStartX : y - myStartY; + boolean doScroll = false; + if (diff > 0) { + ZLTextWordCursor cursor = getStartCursor(); + if (cursor != null && !cursor.isNull()) { + doScroll = !cursor.isStartOfParagraph() || !cursor.getParagraphCursor().isFirst(); } - if (doScroll) { - final int h = myContext.getHeight(); - final int w = myContext.getWidth(); - final int minDiff = horizontal ? - (w > h ? w / 4 : w / 3) : - (h > w ? h / 4 : h / 3); - final PageIndex pageIndex = - Math.abs(diff) < minDiff - ? PageIndex.current - : (diff < 0 ? PageIndex.next : PageIndex.previous); - startAutoScrolling(pageIndex, horizontal ? Direction.rightToLeft : Direction.up, ScrollingPreferences.Instance().AnimationSpeedOption.getValue()); + } else if (diff < 0) { + ZLTextWordCursor cursor = getEndCursor(); + if (cursor != null && !cursor.isNull()) { + doScroll = !cursor.isEndOfParagraph() || !cursor.getParagraphCursor().isLast(); } - return true; + } + if (doScroll) { + final int h = myContext.getHeight(); + final int w = myContext.getWidth(); + final int minDiff = horizontal ? + (w > h ? w / 4 : w / 3) : + (h > w ? h / 4 : h / 3); + final PageIndex pageIndex = + Math.abs(diff) < minDiff + ? PageIndex.current + : (diff < 0 ? PageIndex.next : PageIndex.previous); + startAutoScrolling(pageIndex, horizontal ? Direction.rightToLeft : Direction.up, ScrollingPreferences.Instance().AnimationSpeedOption.getValue()); } } - return false; + return true; } public boolean onFingerLongPress(int x, int y) { diff --git a/src/org/geometerplus/zlibrary/text/view/ZLTextView.java b/src/org/geometerplus/zlibrary/text/view/ZLTextView.java index f4b618f64..bf0833617 100644 --- a/src/org/geometerplus/zlibrary/text/view/ZLTextView.java +++ b/src/org/geometerplus/zlibrary/text/view/ZLTextView.java @@ -67,7 +67,6 @@ public abstract class ZLTextView extends ZLTextViewBase { myCurrentPage.reset(); myPreviousPage.reset(); myNextPage.reset(); - setScrollingActive(false); if (myModel != null) { final int paragraphsNumber = myModel.getParagraphsNumber(); if (paragraphsNumber > 0) { @@ -195,35 +194,16 @@ public abstract class ZLTextView extends ZLTextViewBase { return (myModel == null) || myModel.getMarks().isEmpty(); } - private volatile boolean myScrollingIsActive; - protected boolean isScrollingActive() { - return myScrollingIsActive; - } - protected void setScrollingActive(boolean active) { - myScrollingIsActive = active; - } - public final synchronized void startAutoScrolling(PageIndex pageIndex, Direction direction, int speed) { - if (isScrollingActive()) { - return; - } - - setScrollingActive(true); ZLApplication.Instance().startViewAutoScrolling(pageIndex, direction, speed); } public final synchronized void startAutoScrolling(PageIndex pageIndex, Direction direction, int x, int y, int speed) { - if (isScrollingActive()) { - return; - } - - setScrollingActive(true); ZLApplication.Instance().startViewAutoScrolling(pageIndex, direction, x, y, speed); } @Override public synchronized void onScrollingFinished(PageIndex pageIndex) { - setScrollingActive(false); switch (pageIndex) { case current: break; @@ -970,10 +950,6 @@ public abstract class ZLTextView extends ZLTextViewBase { } public synchronized final void scrollPage(boolean forward, int scrollingMode, int value) { - if (isScrollingActive()) { - return; - } - preparePaintInfo(myCurrentPage); myPreviousPage.reset(); myNextPage.reset(); diff --git a/src/org/geometerplus/zlibrary/ui/android/view/ZLAndroidWidget.java b/src/org/geometerplus/zlibrary/ui/android/view/ZLAndroidWidget.java index 200fbce50..b587062dd 100644 --- a/src/org/geometerplus/zlibrary/ui/android/view/ZLAndroidWidget.java +++ b/src/org/geometerplus/zlibrary/ui/android/view/ZLAndroidWidget.java @@ -190,6 +190,7 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener { animator.startAutoScrolling(true, -3, direction, w, h, x, y, speed); break; } + animator.doStep(); postInvalidate(); }