mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
bookmark serialization; used in BookmarksActivity
This commit is contained in:
parent
4d4a495b7c
commit
024adf0509
5 changed files with 283 additions and 69 deletions
|
@ -31,12 +31,14 @@ import org.geometerplus.fbreader.library.*;
|
|||
public class BookCollectionShadow implements IBookCollection, ServiceConnection {
|
||||
private final Context myContext;
|
||||
private volatile LibraryInterface myInterface;
|
||||
private Runnable myOnBindAction;
|
||||
|
||||
public BookCollectionShadow(Context context) {
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
public void bindToService() {
|
||||
public void bindToService(Runnable onBindAction) {
|
||||
myOnBindAction = onBindAction;
|
||||
myContext.bindService(
|
||||
new Intent(myContext, LibraryService.class),
|
||||
this,
|
||||
|
@ -44,6 +46,10 @@ public class BookCollectionShadow implements IBookCollection, ServiceConnection
|
|||
);
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
myContext.unbindService(this);
|
||||
}
|
||||
|
||||
public synchronized Book getBookById(long id) {
|
||||
if (myInterface == null) {
|
||||
return null;
|
||||
|
@ -69,6 +75,9 @@ public class BookCollectionShadow implements IBookCollection, ServiceConnection
|
|||
// method from ServiceConnection interface
|
||||
public synchronized void onServiceConnected(ComponentName name, IBinder service) {
|
||||
myInterface = LibraryInterface.Stub.asInterface(service);
|
||||
if (myOnBindAction != null) {
|
||||
myOnBindAction.run();
|
||||
}
|
||||
}
|
||||
|
||||
// method from ServiceConnection interface
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue