mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
Merge branch 'master' into library-service
This commit is contained in:
commit
94f6887476
4 changed files with 80 additions and 1 deletions
|
@ -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) {
|
||||
if (myInterface == null) {
|
||||
return false;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
package org.geometerplus.fbreader.book;
|
||||
|
||||
public final class Author {
|
||||
public final class Author implements Comparable<Author> {
|
||||
public final String DisplayName;
|
||||
public final String SortKey;
|
||||
|
||||
|
@ -48,4 +48,10 @@ public final class Author {
|
|||
public int 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -227,6 +227,39 @@ public class BookCollection extends AbstractBookCollection {
|
|||
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) {
|
||||
List<Long> recentIds = myDatabase.loadRecentBookIds();
|
||||
return recentIds.size() > index ? getBookById(recentIds.get(index)) : null;
|
||||
|
|
|
@ -57,6 +57,10 @@ public interface IBookCollection {
|
|||
Book getBookById(long id);
|
||||
Book getRecentBook(int index);
|
||||
|
||||
List<Author> authors();
|
||||
List<Tag> tags();
|
||||
List<String> series();
|
||||
|
||||
boolean saveBook(Book book, boolean force);
|
||||
void removeBook(Book book, boolean deleteFromDisk);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue