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

Merge branch 'master' into library-service

Conflicts:
	src/org/geometerplus/fbreader/library/Library.java
This commit is contained in:
Nikolay Pultsin 2013-02-09 14:28:32 +04:00
commit 83e5045a09
14 changed files with 231 additions and 59 deletions

View file

@ -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() {

View file

@ -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);

View file

@ -128,6 +128,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));
}
@ -161,6 +165,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);
}

View file

@ -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;
}
}
}