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:
parent
7fcbdf37a3
commit
fbe214aa18
1 changed files with 50 additions and 54 deletions
|
@ -38,7 +38,6 @@ import org.geometerplus.zlibrary.text.view.ZLTextFixedPosition;
|
||||||
import org.geometerplus.fbreader.book.*;
|
import org.geometerplus.fbreader.book.*;
|
||||||
import org.geometerplus.fbreader.library.*;
|
import org.geometerplus.fbreader.library.*;
|
||||||
|
|
||||||
import org.geometerplus.android.util.UIUtil;
|
|
||||||
import org.geometerplus.android.util.SQLiteUtil;
|
import org.geometerplus.android.util.SQLiteUtil;
|
||||||
|
|
||||||
public final class SQLiteBooksDatabase extends BooksDatabase {
|
public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
|
@ -48,7 +47,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
public SQLiteBooksDatabase(Context context, String instanceId) {
|
public SQLiteBooksDatabase(Context context, String instanceId) {
|
||||||
myInstanceId = instanceId;
|
myInstanceId = instanceId;
|
||||||
myDatabase = context.openOrCreateDatabase("books.db", Context.MODE_PRIVATE, null);
|
myDatabase = context.openOrCreateDatabase("books.db", Context.MODE_PRIVATE, null);
|
||||||
migrate(context);
|
migrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void executeAsTransaction(Runnable actions) {
|
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 version = myDatabase.getVersion();
|
||||||
final int currentVersion = 20;
|
final int currentVersion = 20;
|
||||||
if (version >= currentVersion) {
|
if (version >= currentVersion) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UIUtil.wait(version == 0 ? "creatingBooksDatabase" : "updatingBooksDatabase", new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
myDatabase.beginTransaction();
|
myDatabase.beginTransaction();
|
||||||
|
|
||||||
switch (myDatabase.getVersion()) {
|
switch (myDatabase.getVersion()) {
|
||||||
|
@ -128,8 +126,6 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
|
|
||||||
myDatabase.execSQL("VACUUM");
|
myDatabase.execSQL("VACUUM");
|
||||||
}
|
}
|
||||||
}, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Book loadBook(long bookId) {
|
protected Book loadBook(long bookId) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue