From eb9012933c4791b294df90b841204e0f7939c3bb Mon Sep 17 00:00:00 2001 From: Nikolay Pultsin Date: Thu, 8 May 2008 15:42:41 +0000 Subject: [PATCH] text selection: added 'scrolling in selection mode' plucker plugin is temporary commented git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@857 6a642e6f-84f6-412e-ac94-c4a38d5a04b0 --- .../fbreader/formats/PluginCollection.java | 2 +- .../text/view/impl/ZLTextSelectionModel.java | 33 ++++++++++++++++--- .../text/view/impl/ZLTextViewImpl.java | 2 +- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/org/geometerplus/fbreader/formats/PluginCollection.java b/src/org/geometerplus/fbreader/formats/PluginCollection.java index 0e73515fd..42c7289d2 100644 --- a/src/org/geometerplus/fbreader/formats/PluginCollection.java +++ b/src/org/geometerplus/fbreader/formats/PluginCollection.java @@ -40,7 +40,7 @@ public class PluginCollection { if (ourInstance == null) { ourInstance = new PluginCollection(); ourInstance.myPlugins.add(new FB2Plugin()); - ourInstance.myPlugins.add(new PluckerPlugin()); + //ourInstance.myPlugins.add(new PluckerPlugin()); //ourInstance->myPlugins.push_back(new DocBookPlugin()); //ourInstance.myPlugins.add(new HtmlPlugin()); /*ourInstance.myPlugins.add(new TxtPlugin()); diff --git a/src/org/geometerplus/zlibrary/text/view/impl/ZLTextSelectionModel.java b/src/org/geometerplus/zlibrary/text/view/impl/ZLTextSelectionModel.java index c835ec946..a4aa60b7b 100644 --- a/src/org/geometerplus/zlibrary/text/view/impl/ZLTextSelectionModel.java +++ b/src/org/geometerplus/zlibrary/text/view/impl/ZLTextSelectionModel.java @@ -22,6 +22,7 @@ package org.geometerplus.zlibrary.text.view.impl; import java.util.*; import org.geometerplus.zlibrary.core.application.ZLApplication; +import org.geometerplus.zlibrary.text.view.ZLTextView; final class ZLTextSelectionModel { final static class BoundElement { @@ -145,11 +146,11 @@ final class ZLTextSelectionModel { myStoredY = y; if (!mySecondBound.Before.Exists) { - //startSelectionScrolling(false); + startSelectionScrolling(false); } else if (!mySecondBound.After.Exists) { - //startSelectionScrolling(true); + startSelectionScrolling(true); } else { - //stopSelectionScrolling(); + stopSelectionScrolling(); } if (!oldRange.Left.equalsTo(newRange.Left) || !oldRange.Right.equalsTo(newRange.Right)) { @@ -173,13 +174,13 @@ final class ZLTextSelectionModel { } void deactivate() { - //stopSelectionScrolling(); + stopSelectionScrolling(); myIsActive = false; myDoUpdate = false; } void clear() { - //stopSelectionScrolling(); + stopSelectionScrolling(); myIsEmpty = true; myIsActive = false; myDoUpdate = false; @@ -270,4 +271,26 @@ final class ZLTextSelectionModel { bound.After.Exists = false; } } + + private final Timer myTimer = new Timer(); + private TimerTask myScrollingTask; + + private void startSelectionScrolling(final boolean forward) { + stopSelectionScrolling(); + myScrollingTask = new TimerTask() { + public void run() { + myView.scrollPage(forward, ZLTextView.ScrollingMode.SCROLL_LINES, 1); + myDoUpdate = true; + myView.Application.refreshWindow(); + } + }; + myTimer.schedule(myScrollingTask, 200, 400); + } + + private void stopSelectionScrolling() { + if (myScrollingTask != null) { + myScrollingTask.cancel(); + } + myScrollingTask = null; + } } diff --git a/src/org/geometerplus/zlibrary/text/view/impl/ZLTextViewImpl.java b/src/org/geometerplus/zlibrary/text/view/impl/ZLTextViewImpl.java index ffbf56413..ac66f496b 100644 --- a/src/org/geometerplus/zlibrary/text/view/impl/ZLTextViewImpl.java +++ b/src/org/geometerplus/zlibrary/text/view/impl/ZLTextViewImpl.java @@ -360,7 +360,7 @@ public abstract class ZLTextViewImpl extends ZLTextView { } } - public void paint() { + public synchronized void paint() { //android.os.Debug.startMethodTracing("/tmp/paint"); preparePaintInfo();