1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 02:39:23 +02:00

library -> by authors tree new implementation (events are not fully supported yet)

This commit is contained in:
Nikolay Pultsin 2013-02-06 00:29:03 +00:00
parent c4308ade41
commit 6c3b9028a1
11 changed files with 177 additions and 42 deletions

View file

@ -121,6 +121,19 @@ public class BookCollectionShadow extends AbstractBookCollection implements Serv
}
}
public synchronized List<Book> books(Author author) {
if (myInterface == null) {
return Collections.emptyList();
}
try {
return SerializerUtil.deserializeBookList(
myInterface.booksForAuthor(Util.authorToString(author))
);
} catch (RemoteException e) {
return Collections.emptyList();
}
}
public synchronized List<Book> books(String pattern) {
if (myInterface == null) {
return Collections.emptyList();
@ -195,10 +208,7 @@ public class BookCollectionShadow extends AbstractBookCollection implements Serv
final List<String> strings = myInterface.authors();
final List<Author> authors = new ArrayList<Author>(strings.size());
for (String s : strings) {
final String[] splited = s.split("\000");
if (splited.length == 2) {
authors.add(new Author(splited[0], splited[1]));
}
authors.add(Util.stringToAuthor(s));
}
return authors;
} catch (RemoteException e) {

View file

@ -11,6 +11,7 @@ interface LibraryInterface {
int size();
List<String> books();
List<String> booksForPattern(in String pattern);
List<String> booksForAuthor(in String author);
List<String> recentBooks();
List<String> favorites();
String getBookByFile(in String file);

View file

@ -124,6 +124,10 @@ public class LibraryService extends Service {
return SerializerUtil.serializeBookList(myCollection.books());
}
public List<String> booksForAuthor(String author) {
return SerializerUtil.serializeBookList(myCollection.books(Util.stringToAuthor(author)));
}
public List<String> booksForPattern(String pattern) {
return SerializerUtil.serializeBookList(myCollection.books(pattern));
}
@ -152,12 +156,7 @@ public class LibraryService extends Service {
final List<Author> authors = myCollection.authors();
final List<String> strings = new ArrayList<String>(authors.size());
for (Author a : authors) {
strings.add(
new StringBuilder(a.DisplayName)
.append('\000')
.append(a.SortKey)
.toString()
);
strings.add(Util.authorToString(a));
}
return strings;
}