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

SQLiteBooksDatabase intialization with no waiting messages

This commit is contained in:
Nikolay Pultsin 2013-02-10 01:45:33 +04:00
parent 7fcbdf37a3
commit fbe214aa18

View file

@ -38,7 +38,6 @@ import org.geometerplus.zlibrary.text.view.ZLTextFixedPosition;
import org.geometerplus.fbreader.book.*;
import org.geometerplus.fbreader.library.*;
import org.geometerplus.android.util.UIUtil;
import org.geometerplus.android.util.SQLiteUtil;
public final class SQLiteBooksDatabase extends BooksDatabase {
@ -48,7 +47,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
public SQLiteBooksDatabase(Context context, String instanceId) {
myInstanceId = instanceId;
myDatabase = context.openOrCreateDatabase("books.db", Context.MODE_PRIVATE, null);
migrate(context);
migrate();
}
protected void executeAsTransaction(Runnable actions) {
@ -70,14 +69,13 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
}
}
private void migrate(Context context) {
private void migrate() {
final int version = myDatabase.getVersion();
final int currentVersion = 20;
if (version >= currentVersion) {
return;
}
UIUtil.wait(version == 0 ? "creatingBooksDatabase" : "updatingBooksDatabase", new Runnable() {
public void run() {
myDatabase.beginTransaction();
switch (myDatabase.getVersion()) {
@ -128,8 +126,6 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
myDatabase.execSQL("VACUUM");
}
}, context);
}
@Override
protected Book loadBook(long bookId) {