mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 19:42:17 +02:00
initialization actions were moved to time _after_ book opening
This commit is contained in:
parent
a4a0c036dd
commit
49ce990712
5 changed files with 27 additions and 15 deletions
|
@ -225,7 +225,7 @@ public class BookmarksActivity extends TabActivity implements MenuItem.OnMenuIte
|
|||
final Book book = Book.getById(bookId);
|
||||
if (book != null) {
|
||||
finish();
|
||||
fbreader.openBook(book, bookmark);
|
||||
fbreader.openBook(book, bookmark, null);
|
||||
} else {
|
||||
UIUtil.showErrorMessage(this, "cannotOpenBook");
|
||||
}
|
||||
|
|
|
@ -104,12 +104,21 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
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
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
DictionaryUtil.init(this);
|
||||
|
||||
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
|
||||
final ZLAndroidLibrary zlibrary = (ZLAndroidLibrary)ZLibrary.Instance();
|
||||
myFullScreenFlag =
|
||||
|
@ -245,7 +254,10 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
((PopupPanel)fbReader.getPopupById(TextSearchPopup.ID)).setPanelInfo(this, root);
|
||||
((PopupPanel)fbReader.getPopupById(NavigationPopup.ID)).setPanelInfo(this, root);
|
||||
((PopupPanel)fbReader.getPopupById(SelectionPopup.ID)).setPanelInfo(this, root);
|
||||
}
|
||||
|
||||
private void initPluginActions() {
|
||||
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
|
||||
synchronized (myPluginActions) {
|
||||
int index = 0;
|
||||
while (index < myPluginActions.size()) {
|
||||
|
@ -263,8 +275,6 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
null,
|
||||
null
|
||||
);
|
||||
|
||||
new TipRunner().start();
|
||||
}
|
||||
|
||||
private class TipRunner extends Thread {
|
||||
|
|
|
@ -135,7 +135,7 @@ public final class FBReaderApp extends ZLApplication {
|
|||
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 (Model == null) {
|
||||
book = Library.Instance().getRecentBook();
|
||||
|
@ -155,7 +155,7 @@ public final class FBReaderApp extends ZLApplication {
|
|||
final Book bookToOpen = book;
|
||||
runWithMessage("loadingBook", new Runnable() {
|
||||
public void run() {
|
||||
openBookInternal(bookToOpen, bookmark);
|
||||
openBookInternal(bookToOpen, bookmark, postAction);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ public final class FBReaderApp extends ZLApplication {
|
|||
Model.Book.reloadInfoFromDatabase();
|
||||
runWithMessage("loadingBook", new Runnable() {
|
||||
public void run() {
|
||||
openBookInternal(Model.Book, null);
|
||||
openBookInternal(Model.Book, null, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ public final class FBReaderApp extends ZLApplication {
|
|||
FootnoteView.clearCaches();
|
||||
}
|
||||
|
||||
synchronized void openBookInternal(Book book, Bookmark bookmark) {
|
||||
synchronized void openBookInternal(Book book, Bookmark bookmark, Runnable postAction) {
|
||||
if (book != null) {
|
||||
onViewChanged();
|
||||
|
||||
|
@ -300,8 +300,8 @@ public final class FBReaderApp extends ZLApplication {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void openFile(ZLFile file) {
|
||||
openBook(createBookForFile(file), null);
|
||||
public void openFile(ZLFile file, Runnable postAction) {
|
||||
openBook(createBookForFile(file), null, postAction);
|
||||
}
|
||||
|
||||
public void onWindowClosing() {
|
||||
|
@ -372,7 +372,7 @@ public final class FBReaderApp extends ZLApplication {
|
|||
final CancelActionDescription description = myCancelActionsList.get(index);
|
||||
switch (description.Type) {
|
||||
case previousBook:
|
||||
openBook(Library.Instance().getPreviousBook(), null);
|
||||
openBook(Library.Instance().getPreviousBook(), null, null);
|
||||
break;
|
||||
case returnTo:
|
||||
{
|
||||
|
|
|
@ -170,7 +170,7 @@ public abstract class ZLApplication {
|
|||
public void onWindowClosing() {
|
||||
}
|
||||
|
||||
public abstract void openFile(ZLFile file);
|
||||
public abstract void openFile(ZLFile file, Runnable postAction);
|
||||
|
||||
//Action
|
||||
static abstract public class ZLAction {
|
||||
|
|
|
@ -101,7 +101,7 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
|
||||
new Thread() {
|
||||
public void run() {
|
||||
ZLApplication.Instance().openFile(fileFromIntent(getIntent()));
|
||||
ZLApplication.Instance().openFile(fileFromIntent(getIntent()), getPostponedInitAction());
|
||||
ZLApplication.Instance().getViewWidget().repaint();
|
||||
}
|
||||
}.start();
|
||||
|
@ -109,6 +109,8 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
ZLApplication.Instance().getViewWidget().repaint();
|
||||
}
|
||||
|
||||
protected abstract Runnable getPostponedInitAction();
|
||||
|
||||
private PowerManager.WakeLock myWakeLock;
|
||||
private boolean myWakeLockToCreate;
|
||||
private boolean myStartTimer;
|
||||
|
@ -191,7 +193,7 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
ZLApplication.Instance().openFile(fileFromIntent(intent));
|
||||
ZLApplication.Instance().openFile(fileFromIntent(intent), null);
|
||||
}
|
||||
|
||||
private static ZLAndroidLibrary getLibrary() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue