mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
fixed recent/favorites list behaviour
'by series' library view
This commit is contained in:
parent
bc82f3abf6
commit
6d96924ac5
6 changed files with 42 additions and 42 deletions
|
@ -1,5 +1,7 @@
|
|||
===== 1.1.3 (Jul ??, 2011) =====
|
||||
* Library view: grouping books by first letter in title branch
|
||||
* Library view: books by series
|
||||
* Library view: load library in background
|
||||
* Local library search searches by file names too
|
||||
* 'invisible if pressed' issue for description in book information dialog has been fixed
|
||||
* LitRes: username forgetting issue has been fixed
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
<node name="byTitle" value="By title">
|
||||
<node name="summary" value="Books sorted by title"/>
|
||||
</node>
|
||||
<node name="bySeries" value="By series">
|
||||
<node name="summary" value="Books sorted by series"/>
|
||||
</node>
|
||||
<node name="byTag" value="By tag">
|
||||
<node name="summary" value="Books sorted by tag"/>
|
||||
</node>
|
||||
|
|
|
@ -33,16 +33,6 @@ public class AuthorTree extends LibraryTree {
|
|||
Author = author;
|
||||
}
|
||||
|
||||
SeriesTree getSeriesSubTree(String series) {
|
||||
final SeriesTree temp = new SeriesTree(series);
|
||||
int position = Collections.binarySearch(subTrees(), temp);
|
||||
if (position >= 0) {
|
||||
return (SeriesTree)subTrees().get(position);
|
||||
} else {
|
||||
return new SeriesTree(this, series, - position - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return
|
||||
|
|
|
@ -43,6 +43,7 @@ public final class Library {
|
|||
public static final String ROOT_RECENT = "recent";
|
||||
public static final String ROOT_BY_AUTHOR = "byAuthor";
|
||||
public static final String ROOT_BY_TITLE = "byTitle";
|
||||
public static final String ROOT_BY_SERIES = "bySeries";
|
||||
public static final String ROOT_BY_TAG = "byTag";
|
||||
public static final String ROOT_FILE_TREE = "fileTree";
|
||||
|
||||
|
@ -188,31 +189,6 @@ public final class Library {
|
|||
return fileList;
|
||||
}
|
||||
|
||||
private static class AuthorSeriesPair {
|
||||
private final Author myAuthor;
|
||||
private final String mySeries;
|
||||
|
||||
AuthorSeriesPair(Author author, String series) {
|
||||
myAuthor = author;
|
||||
mySeries = series;
|
||||
}
|
||||
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (!(object instanceof AuthorSeriesPair)) {
|
||||
return false;
|
||||
}
|
||||
AuthorSeriesPair pair = (AuthorSeriesPair)object;
|
||||
return ZLMiscUtil.equals(myAuthor, pair.myAuthor) && mySeries.equals(pair.mySeries);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Author.hashCode(myAuthor) + mySeries.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
private final List<?> myNullList = Collections.singletonList(null);
|
||||
|
||||
private LibraryTree getTagTree(Tag tag) {
|
||||
|
@ -236,13 +212,22 @@ public final class Library {
|
|||
if (seriesInfo == null) {
|
||||
authorTree.getBookSubTree(book, false);
|
||||
} else {
|
||||
final String series = seriesInfo.Name;
|
||||
final AuthorSeriesPair pair = new AuthorSeriesPair(a, series);
|
||||
final SeriesTree seriesTree = authorTree.getSeriesSubTree(series);
|
||||
seriesTree.getBookInSeriesSubTree(book);
|
||||
authorTree.getSeriesSubTree(seriesInfo.Name).getBookInSeriesSubTree(book);
|
||||
}
|
||||
}
|
||||
|
||||
if (seriesInfo != null) {
|
||||
FirstLevelTree seriesRoot = getFirstLevelTree(ROOT_BY_SERIES);
|
||||
if (seriesRoot == null) {
|
||||
seriesRoot = new FirstLevelTree(
|
||||
myRootTree,
|
||||
myRootTree.indexOf(getFirstLevelTree(ROOT_BY_TITLE)) + 1,
|
||||
ROOT_BY_SERIES
|
||||
);
|
||||
}
|
||||
seriesRoot.getSeriesSubTree(seriesInfo.Name).getBookInSeriesSubTree(book);
|
||||
}
|
||||
|
||||
if (myDoGroupTitlesByFirstLetter) {
|
||||
final String letter = TitleTree.firstTitleLetter(book);
|
||||
if (letter != null) {
|
||||
|
@ -288,14 +273,20 @@ public final class Library {
|
|||
|
||||
// Step 1: add "existing" books recent and favorites lists
|
||||
for (long id : db.loadRecentBookIds()) {
|
||||
final Book book = savedBooksByBookId.get(id);
|
||||
Book book = savedBooksByBookId.get(id);
|
||||
if (book == null) {
|
||||
book = Book.getById(id);
|
||||
}
|
||||
if (book != null) {
|
||||
new BookTree(getFirstLevelTree(ROOT_RECENT), book, true);
|
||||
}
|
||||
}
|
||||
|
||||
for (long id : db.loadFavoritesIds()) {
|
||||
final Book book = savedBooksByBookId.get(id);
|
||||
Book book = savedBooksByBookId.get(id);
|
||||
if (book == null) {
|
||||
book = Book.getById(id);
|
||||
}
|
||||
if (book != null) {
|
||||
getFirstLevelTree(ROOT_FAVORITES).getBookSubTree(book, true);
|
||||
}
|
||||
|
@ -349,7 +340,7 @@ public final class Library {
|
|||
|
||||
// Step 3: collect books from physical files; add new, update already added,
|
||||
// unmark orphaned as existing again, collect newly added
|
||||
final Map<Long,Book> orphanedBooksByFileId = db.loadBooks(fileInfos, true);
|
||||
final Map<Long,Book> orphanedBooksByFileId = db.loadBooks(fileInfos, false);
|
||||
final Set<Book> newBooks = new HashSet<Book>();
|
||||
|
||||
final List<ZLPhysicalFile> physicalFilesList = collectPhysicalFiles();
|
||||
|
|
|
@ -88,6 +88,16 @@ public abstract class LibraryTree extends FBTree {
|
|||
}
|
||||
}
|
||||
|
||||
SeriesTree getSeriesSubTree(String series) {
|
||||
final SeriesTree temp = new SeriesTree(series);
|
||||
int position = Collections.binarySearch(subTrees(), temp);
|
||||
if (position >= 0) {
|
||||
return (SeriesTree)subTrees().get(position);
|
||||
} else {
|
||||
return new SeriesTree(this, series, - position - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean removeBook(Book book) {
|
||||
final LinkedList<FBTree> toRemove = new LinkedList<FBTree>();
|
||||
for (FBTree tree : this) {
|
||||
|
|
|
@ -113,6 +113,10 @@ public abstract class FBTree extends ZLTree<FBTree> implements Comparable<FBTree
|
|||
return null;
|
||||
}
|
||||
|
||||
public int indexOf(FBTree tree) {
|
||||
return subTrees().indexOf(tree);
|
||||
}
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public String getTreeTitle() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue