Skip to content

Commit 46be5da

Browse files
committed
version => 2.0.6
1 parent dc3f6de commit 46be5da

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<manifest
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
package="org.geometerplus.zlibrary.ui.android"
5-
android:versionCode="2000513"
6-
android:versionName="2.0.5.3"
5+
android:versionCode="2000610"
6+
android:versionName="2.0.6"
77
android:installLocation="auto"
88
>
99
<uses-sdk

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Fixed possible synchornisation crashes
55
* Fixed look for empty sync catalog
66
* Fixed work with files with ':' in name
7+
* Fixed using of books DB after finish of service
78

89
===== 2.0.5 (Aug 18, 2014) =====
910
* Fixed possible synchornisation crash

src/org/geometerplus/android/fbreader/libraryService/LibraryService.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
import org.geometerplus.android.fbreader.util.AndroidImageSynchronizer;
4545

4646
public class LibraryService extends Service {
47+
private static SQLiteBooksDatabase ourDatabase;
48+
private static final Object ourDatabaseLock = new Object();
49+
4750
static final String BOOK_EVENT_ACTION = "fbreader.library_service.book_event";
4851
static final String BUILD_EVENT_ACTION = "fbreader.library_service.build_event";
4952

@@ -96,8 +99,8 @@ public final class LibraryImplementation extends LibraryInterface.Stub {
9699
private final List<FileObserver> myFileObservers = new LinkedList<FileObserver>();
97100
private BookCollection myCollection;
98101

99-
LibraryImplementation() {
100-
myDatabase = new SQLiteBooksDatabase(LibraryService.this);
102+
LibraryImplementation(BooksDatabase db) {
103+
myDatabase = db;
101104
myCollection = new BookCollection(myDatabase, Paths.bookPath());
102105
reset(true);
103106
}
@@ -152,10 +155,6 @@ public void deactivate() {
152155
}
153156
}
154157

155-
public void close() {
156-
((SQLiteBooksDatabase)myDatabase).close();
157-
}
158-
159158
public String status() {
160159
return myCollection.status().toString();
161160
}
@@ -343,7 +342,12 @@ public IBinder onBind(Intent intent) {
343342
@Override
344343
public void onCreate() {
345344
super.onCreate();
346-
myLibrary = new LibraryImplementation();
345+
synchronized (ourDatabaseLock) {
346+
if (ourDatabase == null) {
347+
ourDatabase = new SQLiteBooksDatabase(LibraryService.this);
348+
}
349+
}
350+
myLibrary = new LibraryImplementation(ourDatabase);
347351
}
348352

349353
@Override
@@ -352,7 +356,6 @@ public void onDestroy() {
352356
final LibraryImplementation l = myLibrary;
353357
myLibrary = null;
354358
l.deactivate();
355-
l.close();
356359
}
357360
myImageSynchronizer.clear();
358361
super.onDestroy();

src/org/geometerplus/android/fbreader/libraryService/SQLiteBooksDatabase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ final class SQLiteBooksDatabase extends BooksDatabase {
5050
migrate();
5151
}
5252

53-
public void close() {
53+
@Override
54+
public void finalize() {
5455
myDatabase.close();
5556
}
5657

0 commit comments

Comments
 (0)