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

initialization actions were moved to time _after_ book opening

This commit is contained in:
Nikolay Pultsin 2012-02-26 00:10:38 +00:00
parent a4a0c036dd
commit 49ce990712
5 changed files with 27 additions and 15 deletions

View file

@ -225,7 +225,7 @@ public class BookmarksActivity extends TabActivity implements MenuItem.OnMenuIte
final Book book = Book.getById(bookId); final Book book = Book.getById(bookId);
if (book != null) { if (book != null) {
finish(); finish();
fbreader.openBook(book, bookmark); fbreader.openBook(book, bookmark, null);
} else { } else {
UIUtil.showErrorMessage(this, "cannotOpenBook"); UIUtil.showErrorMessage(this, "cannotOpenBook");
} }

View file

@ -104,12 +104,21 @@ public final class FBReader extends ZLAndroidActivity {
return filePath != null ? ZLFile.createFileByPath(filePath) : null; return filePath != null ? ZLFile.createFileByPath(filePath) : null;
} }
@Override
protected Runnable getPostponedInitAction() {
return new Runnable() {
public void run() {
initPluginActions();
new TipRunner().start();
DictionaryUtil.init(FBReader.this);
}
};
}
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
DictionaryUtil.init(this);
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance(); final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
final ZLAndroidLibrary zlibrary = (ZLAndroidLibrary)ZLibrary.Instance(); final ZLAndroidLibrary zlibrary = (ZLAndroidLibrary)ZLibrary.Instance();
myFullScreenFlag = myFullScreenFlag =
@ -245,7 +254,10 @@ public final class FBReader extends ZLAndroidActivity {
((PopupPanel)fbReader.getPopupById(TextSearchPopup.ID)).setPanelInfo(this, root); ((PopupPanel)fbReader.getPopupById(TextSearchPopup.ID)).setPanelInfo(this, root);
((PopupPanel)fbReader.getPopupById(NavigationPopup.ID)).setPanelInfo(this, root); ((PopupPanel)fbReader.getPopupById(NavigationPopup.ID)).setPanelInfo(this, root);
((PopupPanel)fbReader.getPopupById(SelectionPopup.ID)).setPanelInfo(this, root); ((PopupPanel)fbReader.getPopupById(SelectionPopup.ID)).setPanelInfo(this, root);
}
private void initPluginActions() {
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
synchronized (myPluginActions) { synchronized (myPluginActions) {
int index = 0; int index = 0;
while (index < myPluginActions.size()) { while (index < myPluginActions.size()) {
@ -263,8 +275,6 @@ public final class FBReader extends ZLAndroidActivity {
null, null,
null null
); );
new TipRunner().start();
} }
private class TipRunner extends Thread { private class TipRunner extends Thread {

View file

@ -135,7 +135,7 @@ public final class FBReaderApp extends ZLApplication {
setView(BookTextView); setView(BookTextView);
} }
public void openBook(Book book, final Bookmark bookmark) { public void openBook(Book book, final Bookmark bookmark, final Runnable postAction) {
if (book == null) { if (book == null) {
if (Model == null) { if (Model == null) {
book = Library.Instance().getRecentBook(); book = Library.Instance().getRecentBook();
@ -155,7 +155,7 @@ public final class FBReaderApp extends ZLApplication {
final Book bookToOpen = book; final Book bookToOpen = book;
runWithMessage("loadingBook", new Runnable() { runWithMessage("loadingBook", new Runnable() {
public void run() { public void run() {
openBookInternal(bookToOpen, bookmark); openBookInternal(bookToOpen, bookmark, postAction);
} }
}); });
} }
@ -165,7 +165,7 @@ public final class FBReaderApp extends ZLApplication {
Model.Book.reloadInfoFromDatabase(); Model.Book.reloadInfoFromDatabase();
runWithMessage("loadingBook", new Runnable() { runWithMessage("loadingBook", new Runnable() {
public void run() { public void run() {
openBookInternal(Model.Book, null); openBookInternal(Model.Book, null, null);
} }
}); });
} }
@ -219,7 +219,7 @@ public final class FBReaderApp extends ZLApplication {
FootnoteView.clearCaches(); FootnoteView.clearCaches();
} }
synchronized void openBookInternal(Book book, Bookmark bookmark) { synchronized void openBookInternal(Book book, Bookmark bookmark, Runnable postAction) {
if (book != null) { if (book != null) {
onViewChanged(); onViewChanged();
@ -300,8 +300,8 @@ public final class FBReaderApp extends ZLApplication {
} }
@Override @Override
public void openFile(ZLFile file) { public void openFile(ZLFile file, Runnable postAction) {
openBook(createBookForFile(file), null); openBook(createBookForFile(file), null, postAction);
} }
public void onWindowClosing() { public void onWindowClosing() {
@ -372,7 +372,7 @@ public final class FBReaderApp extends ZLApplication {
final CancelActionDescription description = myCancelActionsList.get(index); final CancelActionDescription description = myCancelActionsList.get(index);
switch (description.Type) { switch (description.Type) {
case previousBook: case previousBook:
openBook(Library.Instance().getPreviousBook(), null); openBook(Library.Instance().getPreviousBook(), null, null);
break; break;
case returnTo: case returnTo:
{ {

View file

@ -170,7 +170,7 @@ public abstract class ZLApplication {
public void onWindowClosing() { public void onWindowClosing() {
} }
public abstract void openFile(ZLFile file); public abstract void openFile(ZLFile file, Runnable postAction);
//Action //Action
static abstract public class ZLAction { static abstract public class ZLAction {

View file

@ -101,7 +101,7 @@ public abstract class ZLAndroidActivity extends Activity {
new Thread() { new Thread() {
public void run() { public void run() {
ZLApplication.Instance().openFile(fileFromIntent(getIntent())); ZLApplication.Instance().openFile(fileFromIntent(getIntent()), getPostponedInitAction());
ZLApplication.Instance().getViewWidget().repaint(); ZLApplication.Instance().getViewWidget().repaint();
} }
}.start(); }.start();
@ -109,6 +109,8 @@ public abstract class ZLAndroidActivity extends Activity {
ZLApplication.Instance().getViewWidget().repaint(); ZLApplication.Instance().getViewWidget().repaint();
} }
protected abstract Runnable getPostponedInitAction();
private PowerManager.WakeLock myWakeLock; private PowerManager.WakeLock myWakeLock;
private boolean myWakeLockToCreate; private boolean myWakeLockToCreate;
private boolean myStartTimer; private boolean myStartTimer;
@ -191,7 +193,7 @@ public abstract class ZLAndroidActivity extends Activity {
@Override @Override
protected void onNewIntent(Intent intent) { protected void onNewIntent(Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
ZLApplication.Instance().openFile(fileFromIntent(intent)); ZLApplication.Instance().openFile(fileFromIntent(intent), null);
} }
private static ZLAndroidLibrary getLibrary() { private static ZLAndroidLibrary getLibrary() {