mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
library service in operation ;)
This commit is contained in:
parent
59a7c6b697
commit
9d9a30a7d1
2 changed files with 9 additions and 9 deletions
|
@ -28,6 +28,6 @@ public class FBReaderApplication extends ZLAndroidApplication {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
//bindService(new Intent(this, LibraryService.class), null, LibraryService.BIND_AUTO_CREATE);
|
startService(new Intent(this, LibraryService.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,13 +27,20 @@ import org.geometerplus.fbreader.library.*;
|
||||||
|
|
||||||
import org.geometerplus.android.fbreader.library.SQLiteBooksDatabase;
|
import org.geometerplus.android.fbreader.library.SQLiteBooksDatabase;
|
||||||
|
|
||||||
public class LibraryService extends Service implements Library.ChangeListener {
|
public class LibraryService extends Service {
|
||||||
public final class LibraryImplementation extends LibraryInterface.Stub {
|
public final class LibraryImplementation extends LibraryInterface.Stub {
|
||||||
LibraryImplementation() {
|
LibraryImplementation() {
|
||||||
BooksDatabase database = SQLiteBooksDatabase.Instance();
|
BooksDatabase database = SQLiteBooksDatabase.Instance();
|
||||||
if (database == null) {
|
if (database == null) {
|
||||||
database = new SQLiteBooksDatabase(LibraryService.this, "LIBRARY SERVICE");
|
database = new SQLiteBooksDatabase(LibraryService.this, "LIBRARY SERVICE");
|
||||||
}
|
}
|
||||||
|
final Library collection = Library.Instance();
|
||||||
|
collection.addChangeListener(new Library.ChangeListener() {
|
||||||
|
public void onLibraryChanged(final Code code) {
|
||||||
|
System.err.println("LibraryService.onLibraryChanged(" + code + ")");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
collection.startBuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUpToDate() {
|
public boolean isUpToDate() {
|
||||||
|
@ -66,19 +73,12 @@ public class LibraryService extends Service implements Library.ChangeListener {
|
||||||
System.err.println("LibraryService.onCreate()");
|
System.err.println("LibraryService.onCreate()");
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
myLibrary = new LibraryImplementation();
|
myLibrary = new LibraryImplementation();
|
||||||
//myLibrary.myBaseLibrary.addChangeListener(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
System.err.println("LibraryService.onDestroy()");
|
System.err.println("LibraryService.onDestroy()");
|
||||||
//myLibrary.myBaseLibrary.removeChangeListener(this);
|
|
||||||
myLibrary = null;
|
myLibrary = null;
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLibraryChanged(final Code code) {
|
|
||||||
// TODO: implement signal sending
|
|
||||||
System.err.println("LibraryService.onLibraryChanged(" + code + "): " + myLibrary.isUpToDate());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue