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

Merge branch 'master' into library-service

This commit is contained in:
Nikolay Pultsin 2013-02-02 10:02:29 +00:00
commit 94f6887476
4 changed files with 80 additions and 1 deletions

View file

@ -188,6 +188,42 @@ public class BookCollectionShadow extends AbstractBookCollection implements Serv
} }
} }
public synchronized List<Author> authors() {
if (myInterface == null) {
return Collections.emptyList();
}
//try {
// TODO: implement
return Collections.emptyList();
//} catch (RemoteException e) {
// return Collections.emptyList();
//}
}
public synchronized List<Tag> tags() {
if (myInterface == null) {
return Collections.emptyList();
}
//try {
// TODO: implement
return Collections.emptyList();
//} catch (RemoteException e) {
// return Collections.emptyList();
//}
}
public synchronized List<String> series() {
if (myInterface == null) {
return Collections.emptyList();
}
//try {
// TODO: implement
return Collections.emptyList();
//} catch (RemoteException e) {
// return Collections.emptyList();
//}
}
public synchronized boolean saveBook(Book book, boolean force) { public synchronized boolean saveBook(Book book, boolean force) {
if (myInterface == null) { if (myInterface == null) {
return false; return false;

View file

@ -19,7 +19,7 @@
package org.geometerplus.fbreader.book; package org.geometerplus.fbreader.book;
public final class Author { public final class Author implements Comparable<Author> {
public final String DisplayName; public final String DisplayName;
public final String SortKey; public final String SortKey;
@ -48,4 +48,10 @@ public final class Author {
public int hashCode() { public int hashCode() {
return SortKey.hashCode() + DisplayName.hashCode(); return SortKey.hashCode() + DisplayName.hashCode();
} }
@Override
public int compareTo(Author other) {
final int byKeys = SortKey.compareTo(other.SortKey);
return byKeys != 0 ? byKeys : DisplayName.compareTo(other.DisplayName);
}
} }

View file

@ -227,6 +227,39 @@ public class BookCollection extends AbstractBookCollection {
return bookList; return bookList;
} }
public List<Author> authors() {
final Set<Author> authors = new TreeSet<Author>();
synchronized (myBooksByFile) {
for (Book book : myBooksByFile.values()) {
authors.addAll(book.authors());
}
}
return new ArrayList<Author>(authors);
}
public List<Tag> tags() {
final Set<Tag> tags = new TreeSet<Tag>();
synchronized (myBooksByFile) {
for (Book book : myBooksByFile.values()) {
tags.addAll(book.tags());
}
}
return new ArrayList<Tag>(tags);
}
public List<String> series() {
final Set<String> series = new TreeSet<String>();
synchronized (myBooksByFile) {
for (Book book : myBooksByFile.values()) {
final SeriesInfo info = book.getSeriesInfo();
if (info != null) {
series.add(info.Title);
}
}
}
return new ArrayList<String>(series);
}
public Book getRecentBook(int index) { public Book getRecentBook(int index) {
List<Long> recentIds = myDatabase.loadRecentBookIds(); List<Long> recentIds = myDatabase.loadRecentBookIds();
return recentIds.size() > index ? getBookById(recentIds.get(index)) : null; return recentIds.size() > index ? getBookById(recentIds.get(index)) : null;

View file

@ -57,6 +57,10 @@ public interface IBookCollection {
Book getBookById(long id); Book getBookById(long id);
Book getRecentBook(int index); Book getRecentBook(int index);
List<Author> authors();
List<Tag> tags();
List<String> series();
boolean saveBook(Book book, boolean force); boolean saveBook(Book book, boolean force);
void removeBook(Book book, boolean deleteFromDisk); void removeBook(Book book, boolean deleteFromDisk);