1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-06 03:50:19 +02:00

more "architecture" around book serialization

This commit is contained in:
Nikolay Pultsin 2013-01-10 05:54:40 +04:00
parent ea45b239a1
commit 4d4a495b7c
8 changed files with 134 additions and 19 deletions

View file

@ -19,6 +19,9 @@
package org.geometerplus.android.fbreader.libraryService;
import java.util.Collections;
import java.util.List;
import android.content.*;
import android.os.IBinder;
import android.os.RemoteException;
@ -46,12 +49,23 @@ public class BookCollectionShadow implements IBookCollection, ServiceConnection
return null;
}
try {
return BookSerializerUtil.deserialize(myInterface.bookById(id));
return SerializerUtil.deserializeBook(myInterface.bookById(id));
} catch (RemoteException e) {
return null;
}
}
public synchronized List<Bookmark> allBookmarks() {
if (myInterface == null) {
return Collections.emptyList();
}
try {
return SerializerUtil.deserializeBookmarkList(myInterface.allBookmarks());
} catch (RemoteException e) {
return Collections.emptyList();
}
}
// method from ServiceConnection interface
public synchronized void onServiceConnected(ComponentName name, IBinder service) {
myInterface = LibraryInterface.Stub.asInterface(service);

View file

@ -4,6 +4,9 @@
package org.geometerplus.android.fbreader.libraryService;
import java.util.List;
interface LibraryInterface {
String bookById(in long id);
List<String> allBookmarks();
}

View file

@ -19,6 +19,8 @@
package org.geometerplus.android.fbreader.libraryService;
import java.util.List;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
@ -68,7 +70,11 @@ public class LibraryService extends Service {
}
public String bookById(long id) {
return BookSerializerUtil.serialize(myCollection.getBookById(id));
return SerializerUtil.serialize(myCollection.getBookById(id));
}
public List<String> allBookmarks() {
return SerializerUtil.serialize(myCollection.allBookmarks());
}
}