1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 18:29:23 +02:00

cleanup: some static calls have been removed

This commit is contained in:
Nikolay Pultsin 2010-11-23 08:05:03 +00:00
parent 141c313f9b
commit 4832d00472
5 changed files with 14 additions and 14 deletions

View file

@ -190,7 +190,7 @@ public final class FBReader extends ZLAndroidActivity {
protected ZLApplication createApplication(String fileName) {
if (SQLiteBooksDatabase.Instance() == null) {
new SQLiteBooksDatabase("READER");
new SQLiteBooksDatabase(this, "READER");
}
return new FBReaderApp(fileName);
}

View file

@ -85,7 +85,7 @@ public class LibraryTabActivity extends TabActivity implements MenuItem.OnMenuIt
Thread.setDefaultUncaughtExceptionHandler(new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));
if (SQLiteBooksDatabase.Instance() == null) {
new SQLiteBooksDatabase("LIBRARY");
new SQLiteBooksDatabase(this, "LIBRARY");
}
if (myLibrary == null) {

View file

@ -28,24 +28,24 @@ import android.database.SQLException;
import android.database.Cursor;
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
import org.geometerplus.zlibrary.core.dialogs.ZLDialogManager;
import org.geometerplus.zlibrary.core.options.ZLStringOption;
import org.geometerplus.zlibrary.core.options.ZLIntegerOption;
import org.geometerplus.zlibrary.core.config.ZLConfig;
import org.geometerplus.zlibrary.text.view.ZLTextPosition;
import org.geometerplus.zlibrary.text.view.ZLTextFixedPosition;
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
import org.geometerplus.fbreader.library.*;
import org.geometerplus.android.util.AndroidUtil;
public final class SQLiteBooksDatabase extends BooksDatabase {
private final String myInstanceId;
private final SQLiteDatabase myDatabase;
public SQLiteBooksDatabase(String instanceId) {
public SQLiteBooksDatabase(Context context, String instanceId) {
myInstanceId = instanceId;
myDatabase = ZLAndroidApplication.Instance().openOrCreateDatabase("books.db", Context.MODE_PRIVATE, null);
migrate();
myDatabase = context.openOrCreateDatabase("books.db", Context.MODE_PRIVATE, null);
migrate(context);
}
protected void executeAsATransaction(Runnable actions) {
@ -58,13 +58,13 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
}
}
private void migrate() {
private void migrate(Context context) {
final int version = myDatabase.getVersion();
final int currentVersion = 10;
if (version >= currentVersion) {
return;
}
ZLDialogManager.Instance().wait((version == 0) ? "creatingBooksDatabase" : "updatingBooksDatabase", new Runnable() {
AndroidUtil.wait((version == 0) ? "creatingBooksDatabase" : "updatingBooksDatabase", new Runnable() {
public void run() {
myDatabase.beginTransaction();
@ -96,7 +96,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
myDatabase.execSQL("VACUUM");
myDatabase.setVersion(currentVersion);
}
});
}, context);
}
private static void bindString(SQLiteStatement statement, int index, String value) {

View file

@ -98,7 +98,7 @@ public class BookInfoActivity extends ZLPreferenceActivity {
@Override
protected void init(Intent intent) {
if (SQLiteBooksDatabase.Instance() == null) {
new SQLiteBooksDatabase("LIBRARY");
new SQLiteBooksDatabase(this, "LIBRARY");
}
final String path = intent.getStringExtra(CURRENT_BOOK_PATH_KEY);

View file

@ -22,7 +22,7 @@ package org.geometerplus.android.util;
import java.util.Queue;
import java.util.LinkedList;
import android.app.Activity;
import android.content.Context;
import android.app.ProgressDialog;
import android.os.Handler;
import android.os.Message;
@ -58,12 +58,12 @@ public abstract class AndroidUtil {
}
}
};
public static void wait(String key, Runnable action, Activity activity) {
public static void wait(String key, Runnable action, Context context) {
synchronized (ourMonitor) {
final String message = ZLDialogManager.getWaitMessageText(key);
ourTaskQueue.offer(new Pair(action, message));
if (ourProgress == null) {
ourProgress = ProgressDialog.show(activity, null, message, true, false);
ourProgress = ProgressDialog.show(context, null, message, true, false);
} else {
return;
}