1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 10:49:24 +02:00

sporadic program freeze has been fixed

This commit is contained in:
Nikolay Pultsin 2011-04-11 17:53:11 +01:00
parent 34add4aec3
commit 692c749ef6
3 changed files with 44 additions and 88 deletions

View file

@ -43,7 +43,6 @@ public final class FBView extends ZLTextView {
} }
public void setModel(ZLTextModel model) { public void setModel(ZLTextModel model) {
myIsManualScrollingActive = false;
super.setModel(model); super.setModel(model);
if (myFooter != null) { if (myFooter != null) {
myFooter.resetTOCMarks(); myFooter.resetTOCMarks();
@ -52,7 +51,6 @@ public final class FBView extends ZLTextView {
private int myStartX; private int myStartX;
private int myStartY; private int myStartY;
private boolean myIsManualScrollingActive;
private boolean myIsBrightnessAdjustmentInProgress; private boolean myIsBrightnessAdjustmentInProgress;
private int myStartBrightness; private int myStartBrightness;
@ -77,10 +75,6 @@ public final class FBView extends ZLTextView {
return true; return true;
} }
if (isScrollingActive()) {
return false;
}
if (myReader.FooterIsSensitiveOption.getValue()) { if (myReader.FooterIsSensitiveOption.getValue()) {
Footer footer = getFooterArea(); Footer footer = getFooterArea();
if (footer != null && y > myContext.getHeight() - footer.getTapHeight()) { if (footer != null && y > myContext.getHeight() - footer.getTapHeight()) {
@ -128,10 +122,6 @@ public final class FBView extends ZLTextView {
return true; return true;
} }
if (isScrollingActive()) {
return false;
}
if (myReader.FooterIsSensitiveOption.getValue()) { if (myReader.FooterIsSensitiveOption.getValue()) {
Footer footer = getFooterArea(); Footer footer = getFooterArea();
if (footer != null && y > myContext.getHeight() - footer.getTapHeight()) { if (footer != null && y > myContext.getHeight() - footer.getTapHeight()) {
@ -158,8 +148,6 @@ public final class FBView extends ZLTextView {
fingerScrolling == ScrollingPreferences.FingerScrolling.byTapAndFlick) { fingerScrolling == ScrollingPreferences.FingerScrolling.byTapAndFlick) {
myStartX = x; myStartX = x;
myStartY = y; myStartY = y;
setScrollingActive(true);
myIsManualScrollingActive = true;
} }
} }
@ -180,7 +168,6 @@ public final class FBView extends ZLTextView {
} }
} }
if (isScrollingActive() && myIsManualScrollingActive) {
final boolean horizontal = ScrollingPreferences.Instance().HorizontalOption.getValue(); final boolean horizontal = ScrollingPreferences.Instance().HorizontalOption.getValue();
final int diff = horizontal ? x - myStartX : y - myStartY; final int diff = horizontal ? x - myStartX : y - myStartY;
final Direction direction = horizontal ? Direction.rightToLeft : Direction.up; final Direction direction = horizontal ? Direction.rightToLeft : Direction.up;
@ -201,12 +188,9 @@ public final class FBView extends ZLTextView {
myReader.scrollViewManually(myStartX, myStartY, x, y, direction); myReader.scrollViewManually(myStartX, myStartY, x, y, direction);
} }
} }
}
return true; return true;
} }
}
return false;
}
public boolean onFingerRelease(int x, int y) { public boolean onFingerRelease(int x, int y) {
if (super.onFingerRelease(x, y)) { if (super.onFingerRelease(x, y)) {
@ -215,9 +199,6 @@ public final class FBView extends ZLTextView {
synchronized (this) { synchronized (this) {
myIsBrightnessAdjustmentInProgress = false; myIsBrightnessAdjustmentInProgress = false;
if (isScrollingActive() && myIsManualScrollingActive) {
setScrollingActive(false);
myIsManualScrollingActive = false;
final boolean horizontal = ScrollingPreferences.Instance().HorizontalOption.getValue(); final boolean horizontal = ScrollingPreferences.Instance().HorizontalOption.getValue();
final int diff = horizontal ? x - myStartX : y - myStartY; final int diff = horizontal ? x - myStartX : y - myStartY;
boolean doScroll = false; boolean doScroll = false;
@ -244,11 +225,9 @@ public final class FBView extends ZLTextView {
: (diff < 0 ? PageIndex.next : PageIndex.previous); : (diff < 0 ? PageIndex.next : PageIndex.previous);
startAutoScrolling(pageIndex, horizontal ? Direction.rightToLeft : Direction.up, ScrollingPreferences.Instance().AnimationSpeedOption.getValue()); startAutoScrolling(pageIndex, horizontal ? Direction.rightToLeft : Direction.up, ScrollingPreferences.Instance().AnimationSpeedOption.getValue());
} }
}
return true; return true;
} }
}
return false;
}
public boolean onFingerLongPress(int x, int y) { public boolean onFingerLongPress(int x, int y) {
if (super.onFingerLongPress(x, y)) { if (super.onFingerLongPress(x, y)) {

View file

@ -67,7 +67,6 @@ public abstract class ZLTextView extends ZLTextViewBase {
myCurrentPage.reset(); myCurrentPage.reset();
myPreviousPage.reset(); myPreviousPage.reset();
myNextPage.reset(); myNextPage.reset();
setScrollingActive(false);
if (myModel != null) { if (myModel != null) {
final int paragraphsNumber = myModel.getParagraphsNumber(); final int paragraphsNumber = myModel.getParagraphsNumber();
if (paragraphsNumber > 0) { if (paragraphsNumber > 0) {
@ -195,35 +194,16 @@ public abstract class ZLTextView extends ZLTextViewBase {
return (myModel == null) || myModel.getMarks().isEmpty(); 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) { public final synchronized void startAutoScrolling(PageIndex pageIndex, Direction direction, int speed) {
if (isScrollingActive()) {
return;
}
setScrollingActive(true);
ZLApplication.Instance().startViewAutoScrolling(pageIndex, direction, speed); ZLApplication.Instance().startViewAutoScrolling(pageIndex, direction, speed);
} }
public final synchronized void startAutoScrolling(PageIndex pageIndex, Direction direction, int x, int y, int 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); ZLApplication.Instance().startViewAutoScrolling(pageIndex, direction, x, y, speed);
} }
@Override @Override
public synchronized void onScrollingFinished(PageIndex pageIndex) { public synchronized void onScrollingFinished(PageIndex pageIndex) {
setScrollingActive(false);
switch (pageIndex) { switch (pageIndex) {
case current: case current:
break; break;
@ -970,10 +950,6 @@ public abstract class ZLTextView extends ZLTextViewBase {
} }
public synchronized final void scrollPage(boolean forward, int scrollingMode, int value) { public synchronized final void scrollPage(boolean forward, int scrollingMode, int value) {
if (isScrollingActive()) {
return;
}
preparePaintInfo(myCurrentPage); preparePaintInfo(myCurrentPage);
myPreviousPage.reset(); myPreviousPage.reset();
myNextPage.reset(); myNextPage.reset();

View file

@ -190,6 +190,7 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
animator.startAutoScrolling(true, -3, direction, w, h, x, y, speed); animator.startAutoScrolling(true, -3, direction, w, h, x, y, speed);
break; break;
} }
animator.doStep();
postInvalidate(); postInvalidate();
} }