mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
navigaion code has been simplified
This commit is contained in:
parent
dfb63f1961
commit
142b5c06eb
7 changed files with 9 additions and 61 deletions
|
@ -47,7 +47,7 @@ import org.geometerplus.fbreader.fbreader.ActionCode;
|
||||||
import org.geometerplus.fbreader.library.Library;
|
import org.geometerplus.fbreader.library.Library;
|
||||||
|
|
||||||
public final class FBReader extends ZLAndroidActivity {
|
public final class FBReader extends ZLAndroidActivity {
|
||||||
static FBReader Instance;
|
public static FBReader Instance;
|
||||||
|
|
||||||
private int myFullScreenFlag;
|
private int myFullScreenFlag;
|
||||||
|
|
||||||
|
@ -203,31 +203,13 @@ public final class FBReader extends ZLAndroidActivity {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void navigate() {
|
public void navigate() {
|
||||||
final ZLTextView textView = (ZLTextView) ZLApplication.Instance().getCurrentView();
|
final ZLTextView textView = (ZLTextView)ZLApplication.Instance().getCurrentView();
|
||||||
myNavigatePanel.NavigateDragging = false;
|
myNavigatePanel.NavigateDragging = false;
|
||||||
myNavigatePanel.StartPosition = new ZLTextFixedPosition(textView.getStartCursor());
|
myNavigatePanel.StartPosition = new ZLTextFixedPosition(textView.getStartCursor());
|
||||||
myNavigatePanel.show(true);
|
myNavigatePanel.show(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public final boolean canNavigate() {
|
|
||||||
final org.geometerplus.fbreader.fbreader.FBReader fbreader =
|
|
||||||
(org.geometerplus.fbreader.fbreader.FBReader)ZLApplication.Instance();
|
|
||||||
final ZLView view = fbreader.getCurrentView();
|
|
||||||
if (!(view instanceof ZLTextView)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final ZLTextModel textModel = ((ZLTextView) view).getModel();
|
|
||||||
if (textModel == null || textModel.getParagraphsNumber() == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final BookModel bookModel = fbreader.Model;
|
|
||||||
return bookModel != null && bookModel.Book != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final void createNavigation(View layout) {
|
private final void createNavigation(View layout) {
|
||||||
final SeekBar slider = (SeekBar) layout.findViewById(R.id.book_position_slider);
|
final SeekBar slider = (SeekBar) layout.findViewById(R.id.book_position_slider);
|
||||||
final TextView text = (TextView) layout.findViewById(R.id.book_position_text);
|
final TextView text = (TextView) layout.findViewById(R.id.book_position_text);
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
|
|
||||||
package org.geometerplus.fbreader.fbreader;
|
package org.geometerplus.fbreader.fbreader;
|
||||||
|
|
||||||
|
import org.geometerplus.zlibrary.text.model.ZLTextModel;
|
||||||
|
import org.geometerplus.zlibrary.text.view.ZLTextView;
|
||||||
|
|
||||||
class ShowNavigationAction extends FBAction {
|
class ShowNavigationAction extends FBAction {
|
||||||
ShowNavigationAction(FBReader fbreader) {
|
ShowNavigationAction(FBReader fbreader) {
|
||||||
super(fbreader);
|
super(fbreader);
|
||||||
|
@ -26,10 +29,12 @@ class ShowNavigationAction extends FBAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
return Reader.canNavigate();
|
final ZLTextView view = (ZLTextView)Reader.getCurrentView();
|
||||||
|
final ZLTextModel textModel = view.getModel();
|
||||||
|
return textModel != null && textModel.getParagraphsNumber() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
Reader.navigate();
|
org.geometerplus.android.fbreader.FBReader.Instance.navigate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,19 +144,6 @@ public abstract class ZLApplication {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void navigate() {
|
|
||||||
if (myWindow != null) {
|
|
||||||
myWindow.navigate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canNavigate() {
|
|
||||||
if (myWindow != null) {
|
|
||||||
return myWindow.canNavigate();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void rotateScreen() {
|
public void rotateScreen() {
|
||||||
if (myWindow != null) {
|
if (myWindow != null) {
|
||||||
myWindow.rotate();
|
myWindow.rotate();
|
||||||
|
|
|
@ -44,8 +44,6 @@ abstract public class ZLApplicationWindow {
|
||||||
|
|
||||||
abstract protected void rotate();
|
abstract protected void rotate();
|
||||||
abstract protected boolean canRotate();
|
abstract protected boolean canRotate();
|
||||||
abstract protected void navigate();
|
|
||||||
abstract protected boolean canNavigate();
|
|
||||||
|
|
||||||
abstract protected void close();
|
abstract protected void close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,14 +125,6 @@ public final class ZLAndroidApplicationWindow extends ZLApplicationWindow {
|
||||||
return !ZLAndroidApplication.Instance().AutoOrientationOption.getValue();
|
return !ZLAndroidApplication.Instance().AutoOrientationOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void navigate() {
|
|
||||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).navigate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canNavigate() {
|
|
||||||
return ((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).canNavigate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).finish();
|
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,4 @@ public abstract class ZLAndroidActivity extends Activity {
|
||||||
myChangeCounter = 0;
|
myChangeCounter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected void navigate();
|
|
||||||
abstract protected boolean canNavigate();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,19 +59,6 @@ public final class ZLAndroidLibrary extends ZLibrary {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void navigate() {
|
|
||||||
if (myActivity != null) {
|
|
||||||
myActivity.navigate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canNavigate() {
|
|
||||||
if (myActivity != null) {
|
|
||||||
return myActivity.canNavigate();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void finish() {
|
public void finish() {
|
||||||
if ((myActivity != null) && !myActivity.isFinishing()) {
|
if ((myActivity != null) && !myActivity.isFinishing()) {
|
||||||
myActivity.finish();
|
myActivity.finish();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue