diff --git a/ChangeLog b/ChangeLog
index bc477c084..d280830c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/assets/resources/application/en.xml b/assets/resources/application/en.xml
index d3659139e..c1cff2d59 100644
--- a/assets/resources/application/en.xml
+++ b/assets/resources/application/en.xml
@@ -11,6 +11,9 @@
+
+
+
diff --git a/src/org/geometerplus/fbreader/library/AuthorTree.java b/src/org/geometerplus/fbreader/library/AuthorTree.java
index 891900699..7ac7419f6 100644
--- a/src/org/geometerplus/fbreader/library/AuthorTree.java
+++ b/src/org/geometerplus/fbreader/library/AuthorTree.java
@@ -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
diff --git a/src/org/geometerplus/fbreader/library/Library.java b/src/org/geometerplus/fbreader/library/Library.java
index 2139d1905..5e3f7aff6 100644
--- a/src/org/geometerplus/fbreader/library/Library.java
+++ b/src/org/geometerplus/fbreader/library/Library.java
@@ -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 orphanedBooksByFileId = db.loadBooks(fileInfos, true);
+ final Map orphanedBooksByFileId = db.loadBooks(fileInfos, false);
final Set newBooks = new HashSet();
final List physicalFilesList = collectPhysicalFiles();
diff --git a/src/org/geometerplus/fbreader/library/LibraryTree.java b/src/org/geometerplus/fbreader/library/LibraryTree.java
index eef11a7db..cc3223cdc 100644
--- a/src/org/geometerplus/fbreader/library/LibraryTree.java
+++ b/src/org/geometerplus/fbreader/library/LibraryTree.java
@@ -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 toRemove = new LinkedList();
for (FBTree tree : this) {
diff --git a/src/org/geometerplus/fbreader/tree/FBTree.java b/src/org/geometerplus/fbreader/tree/FBTree.java
index dd12be99e..88eb3f7c6 100644
--- a/src/org/geometerplus/fbreader/tree/FBTree.java
+++ b/src/org/geometerplus/fbreader/tree/FBTree.java
@@ -113,6 +113,10 @@ public abstract class FBTree extends ZLTree implements Comparable