mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
TagTree on-the-fly
This commit is contained in:
parent
4e95e802a2
commit
147236cce3
14 changed files with 231 additions and 75 deletions
|
@ -134,6 +134,19 @@ public class BookCollectionShadow extends AbstractBookCollection implements Serv
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized List<Book> books(Tag tag) {
|
||||
if (myInterface == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
try {
|
||||
return SerializerUtil.deserializeBookList(
|
||||
myInterface.booksForTag(Util.tagToString(tag))
|
||||
);
|
||||
} catch (RemoteException e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized List<Book> books(String pattern) {
|
||||
if (myInterface == null) {
|
||||
return Collections.emptyList();
|
||||
|
@ -220,12 +233,16 @@ public class BookCollectionShadow extends AbstractBookCollection implements Serv
|
|||
if (myInterface == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
//try {
|
||||
// TODO: implement
|
||||
try {
|
||||
final List<String> strings = myInterface.tags();
|
||||
final List<Tag> tags = new ArrayList<Tag>(strings.size());
|
||||
for (String s : strings) {
|
||||
tags.add(Util.stringToTag(s));
|
||||
}
|
||||
return tags;
|
||||
} catch (RemoteException e) {
|
||||
return Collections.emptyList();
|
||||
//} catch (RemoteException e) {
|
||||
// return Collections.emptyList();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized List<String> series() {
|
||||
|
|
|
@ -11,6 +11,7 @@ interface LibraryInterface {
|
|||
int size();
|
||||
List<String> books();
|
||||
List<String> booksForAuthor(in String author);
|
||||
List<String> booksForTag(in String tag);
|
||||
List<String> booksForPattern(in String pattern);
|
||||
List<String> recentBooks();
|
||||
List<String> favorites();
|
||||
|
@ -19,6 +20,8 @@ interface LibraryInterface {
|
|||
String getRecentBook(in int index);
|
||||
|
||||
List<String> authors();
|
||||
List<String> series();
|
||||
List<String> tags();
|
||||
|
||||
boolean saveBook(in String book, in boolean force);
|
||||
void removeBook(in String book, in boolean deleteFromDisk);
|
||||
|
|
|
@ -123,6 +123,10 @@ public class LibraryService extends Service {
|
|||
return SerializerUtil.serializeBookList(myCollection.books(Util.stringToAuthor(author)));
|
||||
}
|
||||
|
||||
public List<String> booksForTag(String tag) {
|
||||
return SerializerUtil.serializeBookList(myCollection.books(Util.stringToTag(tag)));
|
||||
}
|
||||
|
||||
public List<String> booksForPattern(String pattern) {
|
||||
return SerializerUtil.serializeBookList(myCollection.books(pattern));
|
||||
}
|
||||
|
@ -156,6 +160,19 @@ public class LibraryService extends Service {
|
|||
return strings;
|
||||
}
|
||||
|
||||
public List<String> series() {
|
||||
return myCollection.series();
|
||||
}
|
||||
|
||||
public List<String> tags() {
|
||||
final List<Tag> tags = myCollection.tags();
|
||||
final List<String> strings = new ArrayList<String>(tags.size());
|
||||
for (Tag t : tags) {
|
||||
strings.add(Util.tagToString(t));
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
|
||||
public boolean saveBook(String book, boolean force) {
|
||||
return myCollection.saveBook(SerializerUtil.deserializeBook(book), force);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.geometerplus.android.fbreader.libraryService;
|
||||
|
||||
import org.geometerplus.fbreader.book.Author;
|
||||
import org.geometerplus.fbreader.book.Tag;
|
||||
|
||||
abstract class Util {
|
||||
static String authorToString(Author author) {
|
||||
|
@ -34,4 +35,17 @@ abstract class Util {
|
|||
return Author.NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static String tagToString(Tag tag) {
|
||||
return tag.toString("\000");
|
||||
}
|
||||
|
||||
static Tag stringToTag(String string) {
|
||||
final String[] splitted = string.split("\000");
|
||||
if (splitted.length > 0) {
|
||||
return Tag.getTag(splitted);
|
||||
} else {
|
||||
return Tag.NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue