mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
more methods in IBookCollection
This commit is contained in:
parent
50e5a7e299
commit
522d32a585
8 changed files with 166 additions and 36 deletions
|
@ -61,12 +61,45 @@ public class BookCollectionShadow implements IBookCollection, ServiceConnection
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized List<Book> books(String pattern) {
|
||||
if (myInterface == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
try {
|
||||
return SerializerUtil.deserializeBookList(myInterface.books(pattern));
|
||||
} catch (RemoteException e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized List<Book> recentBooks() {
|
||||
if (myInterface == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
try {
|
||||
return SerializerUtil.deserializeBookList(myInterface.recentBooks());
|
||||
} catch (RemoteException e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized List<Book> favorites() {
|
||||
if (myInterface == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
try {
|
||||
return SerializerUtil.deserializeBookList(myInterface.favorites());
|
||||
} catch (RemoteException e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized Book getRecentBook(int index) {
|
||||
if (myInterface == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return SerializerUtil.deserializeBook(myInterface.recentBook(index));
|
||||
return SerializerUtil.deserializeBook(myInterface.getRecentBook(index));
|
||||
} catch (RemoteException e) {
|
||||
return null;
|
||||
}
|
||||
|
@ -77,12 +110,39 @@ public class BookCollectionShadow implements IBookCollection, ServiceConnection
|
|||
return null;
|
||||
}
|
||||
try {
|
||||
return SerializerUtil.deserializeBook(myInterface.bookById(id));
|
||||
return SerializerUtil.deserializeBook(myInterface.getBookById(id));
|
||||
} catch (RemoteException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void removeBook(Book book, boolean deleteFromDisk) {
|
||||
if (myInterface != null) {
|
||||
try {
|
||||
myInterface.removeBook(SerializerUtil.serialize(book), deleteFromDisk);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void addBookToRecentList(Book book) {
|
||||
if (myInterface != null) {
|
||||
try {
|
||||
myInterface.addBookToRecentList(SerializerUtil.serialize(book));
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void setBookFavorite(Book book, boolean favorite) {
|
||||
if (myInterface != null) {
|
||||
try {
|
||||
myInterface.setBookFavorite(SerializerUtil.serialize(book), favorite);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized List<Bookmark> allBookmarks() {
|
||||
if (myInterface == null) {
|
||||
return Collections.emptyList();
|
||||
|
|
|
@ -8,8 +8,15 @@ import java.util.List;
|
|||
|
||||
interface LibraryInterface {
|
||||
int size();
|
||||
String bookById(in long id);
|
||||
String recentBook(in int index);
|
||||
List<String> books(String pattern);
|
||||
List<String> recentBooks();
|
||||
List<String> favorites();
|
||||
String getBookById(in long id);
|
||||
String getRecentBook(in int index);
|
||||
|
||||
void removeBook(in String book, in boolean deleteFromDisk);
|
||||
void addBookToRecentList(in String book);
|
||||
void setBookFavorite(in String book, in boolean favorite);
|
||||
|
||||
List<String> allBookmarks();
|
||||
String saveBookmark(in String bookmark);
|
||||
|
|
|
@ -125,16 +125,40 @@ public class LibraryService extends Service {
|
|||
return myCollection.size();
|
||||
}
|
||||
|
||||
public String recentBook(int index) {
|
||||
public List<String> books(String pattern) {
|
||||
return SerializerUtil.serializeBookList(myCollection.books(pattern));
|
||||
}
|
||||
|
||||
public List<String> recentBooks() {
|
||||
return SerializerUtil.serializeBookList(myCollection.recentBooks());
|
||||
}
|
||||
|
||||
public List<String> favorites() {
|
||||
return SerializerUtil.serializeBookList(myCollection.favorites());
|
||||
}
|
||||
|
||||
public String getRecentBook(int index) {
|
||||
return SerializerUtil.serialize(myCollection.getRecentBook(index));
|
||||
}
|
||||
|
||||
public String bookById(long id) {
|
||||
public String getBookById(long id) {
|
||||
return SerializerUtil.serialize(myCollection.getBookById(id));
|
||||
}
|
||||
|
||||
public void removeBook(String book, boolean deleteFromDisk) {
|
||||
myCollection.removeBook(SerializerUtil.deserializeBook(book), deleteFromDisk);
|
||||
}
|
||||
|
||||
public void addBookToRecentList(String book) {
|
||||
myCollection.addBookToRecentList(SerializerUtil.deserializeBook(book));
|
||||
}
|
||||
|
||||
public void setBookFavorite(String book, boolean favorite) {
|
||||
myCollection.setBookFavorite(SerializerUtil.deserializeBook(book), favorite);
|
||||
}
|
||||
|
||||
public List<String> allBookmarks() {
|
||||
return SerializerUtil.serialize(myCollection.allBookmarks());
|
||||
return SerializerUtil.serializeBookmarkList(myCollection.allBookmarks());
|
||||
}
|
||||
|
||||
public String saveBookmark(String serialized) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue