From 9d9a30a7d1dc4f3934b3dede042d02a044c7c468 Mon Sep 17 00:00:00 2001 From: Nikolay Pultsin Date: Wed, 9 Jan 2013 01:31:22 +0000 Subject: [PATCH] library service in operation ;) --- .../android/fbreader/FBReaderApplication.java | 2 +- .../fbreader/libraryService/LibraryService.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/org/geometerplus/android/fbreader/FBReaderApplication.java b/src/org/geometerplus/android/fbreader/FBReaderApplication.java index 2a068049e..0753f92f5 100644 --- a/src/org/geometerplus/android/fbreader/FBReaderApplication.java +++ b/src/org/geometerplus/android/fbreader/FBReaderApplication.java @@ -28,6 +28,6 @@ public class FBReaderApplication extends ZLAndroidApplication { @Override public void onCreate() { super.onCreate(); - //bindService(new Intent(this, LibraryService.class), null, LibraryService.BIND_AUTO_CREATE); + startService(new Intent(this, LibraryService.class)); } } diff --git a/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java b/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java index 0c0323564..2d37183b1 100644 --- a/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java +++ b/src/org/geometerplus/android/fbreader/libraryService/LibraryService.java @@ -27,13 +27,20 @@ import org.geometerplus.fbreader.library.*; 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 { LibraryImplementation() { BooksDatabase database = SQLiteBooksDatabase.Instance(); if (database == null) { 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() { @@ -66,19 +73,12 @@ public class LibraryService extends Service implements Library.ChangeListener { System.err.println("LibraryService.onCreate()"); super.onCreate(); myLibrary = new LibraryImplementation(); - //myLibrary.myBaseLibrary.addChangeListener(this); } @Override public void onDestroy() { System.err.println("LibraryService.onDestroy()"); - //myLibrary.myBaseLibrary.removeChangeListener(this); myLibrary = null; super.onDestroy(); } - - public void onLibraryChanged(final Code code) { - // TODO: implement signal sending - System.err.println("LibraryService.onLibraryChanged(" + code + "): " + myLibrary.isUpToDate()); - } }