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

fixed recent/favorites list behaviour

'by series' library view
This commit is contained in:
Nikolay Pultsin 2011-07-18 00:10:20 +01:00
parent bc82f3abf6
commit 6d96924ac5
6 changed files with 42 additions and 42 deletions

View file

@ -1,5 +1,7 @@
===== 1.1.3 (Jul ??, 2011) ===== ===== 1.1.3 (Jul ??, 2011) =====
* Library view: grouping books by first letter in title branch * 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 * Local library search searches by file names too
* 'invisible if pressed' issue for description in book information dialog has been fixed * 'invisible if pressed' issue for description in book information dialog has been fixed
* LitRes: username forgetting issue has been fixed * LitRes: username forgetting issue has been fixed

View file

@ -11,6 +11,9 @@
<node name="byTitle" value="By title"> <node name="byTitle" value="By title">
<node name="summary" value="Books sorted by title"/> <node name="summary" value="Books sorted by title"/>
</node> </node>
<node name="bySeries" value="By series">
<node name="summary" value="Books sorted by series"/>
</node>
<node name="byTag" value="By tag"> <node name="byTag" value="By tag">
<node name="summary" value="Books sorted by tag"/> <node name="summary" value="Books sorted by tag"/>
</node> </node>

View file

@ -33,16 +33,6 @@ public class AuthorTree extends LibraryTree {
Author = author; 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 @Override
public String getName() { public String getName() {
return return

View file

@ -43,6 +43,7 @@ public final class Library {
public static final String ROOT_RECENT = "recent"; public static final String ROOT_RECENT = "recent";
public static final String ROOT_BY_AUTHOR = "byAuthor"; public static final String ROOT_BY_AUTHOR = "byAuthor";
public static final String ROOT_BY_TITLE = "byTitle"; 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_BY_TAG = "byTag";
public static final String ROOT_FILE_TREE = "fileTree"; public static final String ROOT_FILE_TREE = "fileTree";
@ -188,31 +189,6 @@ public final class Library {
return fileList; 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 final List<?> myNullList = Collections.singletonList(null);
private LibraryTree getTagTree(Tag tag) { private LibraryTree getTagTree(Tag tag) {
@ -236,13 +212,22 @@ public final class Library {
if (seriesInfo == null) { if (seriesInfo == null) {
authorTree.getBookSubTree(book, false); authorTree.getBookSubTree(book, false);
} else { } else {
final String series = seriesInfo.Name; authorTree.getSeriesSubTree(seriesInfo.Name).getBookInSeriesSubTree(book);
final AuthorSeriesPair pair = new AuthorSeriesPair(a, series);
final SeriesTree seriesTree = authorTree.getSeriesSubTree(series);
seriesTree.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) { if (myDoGroupTitlesByFirstLetter) {
final String letter = TitleTree.firstTitleLetter(book); final String letter = TitleTree.firstTitleLetter(book);
if (letter != null) { if (letter != null) {
@ -288,14 +273,20 @@ public final class Library {
// Step 1: add "existing" books recent and favorites lists // Step 1: add "existing" books recent and favorites lists
for (long id : db.loadRecentBookIds()) { 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) { if (book != null) {
new BookTree(getFirstLevelTree(ROOT_RECENT), book, true); new BookTree(getFirstLevelTree(ROOT_RECENT), book, true);
} }
} }
for (long id : db.loadFavoritesIds()) { 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) { if (book != null) {
getFirstLevelTree(ROOT_FAVORITES).getBookSubTree(book, true); 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, // Step 3: collect books from physical files; add new, update already added,
// unmark orphaned as existing again, collect newly 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 Set<Book> newBooks = new HashSet<Book>();
final List<ZLPhysicalFile> physicalFilesList = collectPhysicalFiles(); final List<ZLPhysicalFile> physicalFilesList = collectPhysicalFiles();

View file

@ -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) { public boolean removeBook(Book book) {
final LinkedList<FBTree> toRemove = new LinkedList<FBTree>(); final LinkedList<FBTree> toRemove = new LinkedList<FBTree>();
for (FBTree tree : this) { for (FBTree tree : this) {

View file

@ -113,6 +113,10 @@ public abstract class FBTree extends ZLTree<FBTree> implements Comparable<FBTree
return null; return null;
} }
public int indexOf(FBTree tree) {
return subTrees().indexOf(tree);
}
public abstract String getName(); public abstract String getName();
public String getTreeTitle() { public String getTreeTitle() {