mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
more methods in IBookCollection
This commit is contained in:
parent
a72943e2dd
commit
40b4953f83
4 changed files with 36 additions and 2 deletions
|
@ -50,6 +50,28 @@ public class BookCollectionShadow implements IBookCollection, ServiceConnection
|
||||||
myContext.unbindService(this);
|
myContext.unbindService(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized int size() {
|
||||||
|
if (myInterface == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return myInterface.size();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized Book getRecentBook(int index) {
|
||||||
|
if (myInterface == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return SerializerUtil.deserializeBook(myInterface.recentBook(index));
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized Book getBookById(long id) {
|
public synchronized Book getBookById(long id) {
|
||||||
if (myInterface == null) {
|
if (myInterface == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -72,7 +94,7 @@ public class BookCollectionShadow implements IBookCollection, ServiceConnection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveBookmark(Bookmark bookmark) {
|
public synchronized void saveBookmark(Bookmark bookmark) {
|
||||||
if (myInterface != null) {
|
if (myInterface != null) {
|
||||||
try {
|
try {
|
||||||
bookmark.update(SerializerUtil.deserializeBookmark(
|
bookmark.update(SerializerUtil.deserializeBookmark(
|
||||||
|
@ -83,7 +105,7 @@ public class BookCollectionShadow implements IBookCollection, ServiceConnection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteBookmark(Bookmark bookmark) {
|
public synchronized void deleteBookmark(Bookmark bookmark) {
|
||||||
if (myInterface != null) {
|
if (myInterface != null) {
|
||||||
try {
|
try {
|
||||||
myInterface.deleteBookmark(SerializerUtil.serialize(bookmark));
|
myInterface.deleteBookmark(SerializerUtil.serialize(bookmark));
|
||||||
|
|
|
@ -7,7 +7,9 @@ package org.geometerplus.android.fbreader.libraryService;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
interface LibraryInterface {
|
interface LibraryInterface {
|
||||||
|
int size();
|
||||||
String bookById(in long id);
|
String bookById(in long id);
|
||||||
|
String recentBook(in int index);
|
||||||
|
|
||||||
List<String> allBookmarks();
|
List<String> allBookmarks();
|
||||||
String saveBookmark(in String bookmark);
|
String saveBookmark(in String bookmark);
|
||||||
|
|
|
@ -69,6 +69,14 @@ public class LibraryService extends Service {
|
||||||
myCollection.startBuild();
|
myCollection.startBuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return myCollection.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String recentBook(int index) {
|
||||||
|
return SerializerUtil.serialize(myCollection.getRecentBook(index));
|
||||||
|
}
|
||||||
|
|
||||||
public String bookById(long id) {
|
public String bookById(long id) {
|
||||||
return SerializerUtil.serialize(myCollection.getBookById(id));
|
return SerializerUtil.serialize(myCollection.getBookById(id));
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,9 @@ package org.geometerplus.fbreader.library;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface IBookCollection {
|
public interface IBookCollection {
|
||||||
|
int size();
|
||||||
Book getBookById(long id);
|
Book getBookById(long id);
|
||||||
|
Book getRecentBook(int index);
|
||||||
|
|
||||||
List<Bookmark> allBookmarks();
|
List<Bookmark> allBookmarks();
|
||||||
void saveBookmark(Bookmark bookmark);
|
void saveBookmark(Bookmark bookmark);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue