mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
on-timer footer update has been added
This commit is contained in:
parent
501ab4d764
commit
ab00a735cb
4 changed files with 82 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
|||
===== 0.7.12 (??? ??, 2010) =====
|
||||
* On-timer footer update has been added
|
||||
|
||||
===== 0.7.11 (Oct 24, 2010) =====
|
||||
* Several craches have been fixed
|
||||
|
||||
===== 0.7.10 (Oct 24, 2010) =====
|
||||
* Resources have been updated
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ public final class FBView extends ZLTextView {
|
|||
}
|
||||
|
||||
if (myReader.FooterIsSensitive.getValue()) {
|
||||
Footer footer = (Footer)getFooterArea();
|
||||
Footer footer = getFooterArea();
|
||||
if (footer != null && y > myContext.getHeight() - footer.getTapHeight()) {
|
||||
footer.setProgress(x);
|
||||
return true;
|
||||
|
@ -287,6 +287,12 @@ public final class FBView extends ZLTextView {
|
|||
}
|
||||
|
||||
private class Footer implements FooterArea {
|
||||
private Runnable UpdateTask = new Runnable() {
|
||||
public void run() {
|
||||
ZLApplication.Instance().repaintView();
|
||||
}
|
||||
};
|
||||
|
||||
public int getHeight() {
|
||||
return myReader.FooterHeightOption.getValue();
|
||||
}
|
||||
|
@ -379,16 +385,18 @@ public final class FBView extends ZLTextView {
|
|||
}
|
||||
}
|
||||
|
||||
private FooterArea myFooter;
|
||||
private Footer myFooter;
|
||||
|
||||
@Override
|
||||
public FooterArea getFooterArea() {
|
||||
public Footer getFooterArea() {
|
||||
if (myReader.ScrollbarTypeOption.getValue() == SCROLLBAR_SHOW_AS_FOOTER) {
|
||||
if (myFooter == null) {
|
||||
myFooter = new Footer();
|
||||
ZLApplication.Instance().addTimerTask(myFooter.UpdateTask, 15000);
|
||||
}
|
||||
} else {
|
||||
if (myFooter != null) {
|
||||
ZLApplication.Instance().removeTimerTask(myFooter.UpdateTask);
|
||||
myFooter = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -359,4 +359,59 @@ public abstract class ZLApplication {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private Timer myTimer;
|
||||
private final HashMap<Runnable,Long> myTimerTaskPeriods = new HashMap<Runnable,Long>();
|
||||
private final HashMap<Runnable,TimerTask> myTimerTasks = new HashMap<Runnable,TimerTask>();
|
||||
private static class MyTimerTask extends TimerTask {
|
||||
private final Runnable myRunnable;
|
||||
|
||||
MyTimerTask(Runnable runnable) {
|
||||
myRunnable = runnable;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
myRunnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
private void addTimerTaskInternal(Runnable runnable, long periodMilliseconds) {
|
||||
final TimerTask task = new MyTimerTask(runnable);
|
||||
myTimer.schedule(task, periodMilliseconds / 2, periodMilliseconds);
|
||||
myTimerTasks.put(runnable, task);
|
||||
}
|
||||
|
||||
public final synchronized void startTimer() {
|
||||
if (myTimer == null) {
|
||||
myTimer = new Timer();
|
||||
for (Map.Entry<Runnable,Long> entry : myTimerTaskPeriods.entrySet()) {
|
||||
addTimerTaskInternal(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final synchronized void stopTimer() {
|
||||
if (myTimer != null) {
|
||||
myTimer.cancel();
|
||||
myTimer = null;
|
||||
myTimerTasks.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public final synchronized void addTimerTask(Runnable runnable, long periodMilliseconds) {
|
||||
removeTimerTask(runnable);
|
||||
myTimerTaskPeriods.put(runnable, periodMilliseconds);
|
||||
if (myTimer != null) {
|
||||
addTimerTaskInternal(runnable, periodMilliseconds);
|
||||
}
|
||||
}
|
||||
|
||||
public final synchronized void removeTimerTask(Runnable runnable) {
|
||||
TimerTask task = myTimerTasks.get(runnable);
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
myTimerTasks.remove(runnable);
|
||||
}
|
||||
myTimerTaskPeriods.remove(runnable);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,6 +126,7 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
|
||||
private PowerManager.WakeLock myWakeLock;
|
||||
private boolean myWakeLockToCreate;
|
||||
private boolean myStartTimer;
|
||||
|
||||
public final void createWakeLock() {
|
||||
if (myWakeLockToCreate) {
|
||||
|
@ -139,6 +140,10 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (myStartTimer) {
|
||||
ZLApplication.Instance().startTimer();
|
||||
myStartTimer = false;
|
||||
}
|
||||
}
|
||||
|
||||
private final void switchWakeLock(boolean on) {
|
||||
|
@ -161,10 +166,11 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
myWakeLockToCreate =
|
||||
switchWakeLock(
|
||||
ZLAndroidApplication.Instance().BatteryLevelToTurnScreenOffOption.getValue() <
|
||||
ZLApplication.Instance().getBatteryLevel();
|
||||
switchWakeLock(true);
|
||||
ZLApplication.Instance().getBatteryLevel()
|
||||
);
|
||||
myStartTimer = true;
|
||||
|
||||
registerReceiver(myBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
}
|
||||
|
@ -172,6 +178,7 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
@Override
|
||||
public void onPause() {
|
||||
unregisterReceiver(myBatteryInfoReceiver);
|
||||
ZLApplication.Instance().stopTimer();
|
||||
switchWakeLock(false);
|
||||
ZLApplication.Instance().onWindowClosing();
|
||||
super.onPause();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue