mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +02:00
synchronization with library-service branch + constants are moved from Library to LibraryTree
This commit is contained in:
parent
5f6a41fb3a
commit
a46e23e78e
17 changed files with 100 additions and 94 deletions
|
@ -99,7 +99,11 @@
|
|||
</activity>
|
||||
<activity android:name="org.geometerplus.android.fbreader.CancelActivity" android:theme="@style/FBReader.Dialog"/>
|
||||
<activity android:name="org.geometerplus.android.fbreader.image.ImageViewActivity" android:process=":imageView" android:theme="@style/FBReader.Activity"/>
|
||||
<service android:name="org.geometerplus.android.fbreader.libraryService.LibraryService" android:launchMode="singleTask" android:process=":libraryService"/>
|
||||
<service android:name="org.geometerplus.android.fbreader.libraryService.LibraryService" android:launchMode="singleTask" android:process=":libraryService">
|
||||
<intent-filter>
|
||||
<action android:name="android.fbreader.action.LIBRARY_SERVICE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<activity android:name="org.geometerplus.android.fbreader.library.BookInfoActivity" android:theme="@style/FBReader.Activity" android:process=":library"/>
|
||||
<receiver android:name="org.geometerplus.android.fbreader.library.KillerCallback" android:process=":library"/>
|
||||
<activity android:name="org.geometerplus.android.fbreader.library.LibrarySearchActivity" android:process=":library" android:theme="@android:style/Theme.NoDisplay">
|
||||
|
|
|
@ -99,7 +99,11 @@
|
|||
</activity>
|
||||
<activity android:name="org.geometerplus.android.fbreader.CancelActivity" android:theme="@style/FBReader.Dialog"/>
|
||||
<activity android:name="org.geometerplus.android.fbreader.image.ImageViewActivity" android:process=":imageView" android:theme="@style/FBReader.Activity"/>
|
||||
<service android:name="org.geometerplus.android.fbreader.libraryService.LibraryService" android:launchMode="singleTask" android:process=":libraryService"/>
|
||||
<service android:name="org.geometerplus.android.fbreader.libraryService.LibraryService" android:launchMode="singleTask" android:process=":libraryService">
|
||||
<intent-filter>
|
||||
<action android:name="android.fbreader.action.LIBRARY_SERVICE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<activity android:name="org.geometerplus.android.fbreader.library.BookInfoActivity" android:theme="@style/FBReader.Activity" android:process=":library"/>
|
||||
<receiver android:name="org.geometerplus.android.fbreader.library.KillerCallback" android:process=":library"/>
|
||||
<activity android:name="org.geometerplus.android.fbreader.library.LibrarySearchActivity" android:process=":library" android:theme="@android:style/Theme.NoDisplay">
|
||||
|
|
|
@ -149,7 +149,7 @@ public class LibraryActivity extends TreeActivity<LibraryTree> implements MenuIt
|
|||
new ZLStringOption("BookSearch", "Pattern", "");
|
||||
|
||||
private void openSearchResults() {
|
||||
final FBTree tree = myLibrary.getRootTree().getSubTree(Library.ROOT_FOUND);
|
||||
final FBTree tree = myLibrary.getRootTree().getSubTree(LibraryTree.ROOT_FOUND);
|
||||
if (tree != null) {
|
||||
openTree(tree);
|
||||
}
|
||||
|
|
|
@ -77,19 +77,19 @@ class LibraryTreeAdapter extends TreeAdapter {
|
|||
return R.drawable.ic_list_library_book;
|
||||
} else if (tree instanceof FirstLevelTree) {
|
||||
final String id = tree.getUniqueKey().Id;
|
||||
if (Library.ROOT_FAVORITES.equals(id)) {
|
||||
if (LibraryTree.ROOT_FAVORITES.equals(id)) {
|
||||
return R.drawable.ic_list_library_favorites;
|
||||
} else if (Library.ROOT_RECENT.equals(id)) {
|
||||
} else if (LibraryTree.ROOT_RECENT.equals(id)) {
|
||||
return R.drawable.ic_list_library_recent;
|
||||
} else if (Library.ROOT_BY_AUTHOR.equals(id)) {
|
||||
} else if (LibraryTree.ROOT_BY_AUTHOR.equals(id)) {
|
||||
return R.drawable.ic_list_library_authors;
|
||||
} else if (Library.ROOT_BY_TITLE.equals(id)) {
|
||||
} else if (LibraryTree.ROOT_BY_TITLE.equals(id)) {
|
||||
return R.drawable.ic_list_library_books;
|
||||
} else if (Library.ROOT_BY_TAG.equals(id)) {
|
||||
} else if (LibraryTree.ROOT_BY_TAG.equals(id)) {
|
||||
return R.drawable.ic_list_library_tags;
|
||||
} else if (Library.ROOT_FILE_TREE.equals(id)) {
|
||||
} else if (LibraryTree.ROOT_FILE_TREE.equals(id)) {
|
||||
return R.drawable.ic_list_library_folder;
|
||||
} else if (Library.ROOT_FOUND.equals(id)) {
|
||||
} else if (LibraryTree.ROOT_FOUND.equals(id)) {
|
||||
return R.drawable.ic_list_library_search;
|
||||
}
|
||||
} else if (tree instanceof FileTree) {
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
|
||||
package org.geometerplus.fbreader.library;
|
||||
|
||||
import org.geometerplus.fbreader.book.Author;
|
||||
import org.geometerplus.fbreader.book.Book;
|
||||
import org.geometerplus.fbreader.book.*;
|
||||
|
||||
public class AuthorTree extends LibraryTree {
|
||||
public final Author Author;
|
||||
|
||||
AuthorTree(Author author) {
|
||||
AuthorTree(IBookCollection collection, Author author) {
|
||||
super(collection);
|
||||
Author = author;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,12 @@ package org.geometerplus.fbreader.library;
|
|||
import java.math.BigDecimal;
|
||||
|
||||
import org.geometerplus.fbreader.book.Book;
|
||||
import org.geometerplus.fbreader.book.IBookCollection;
|
||||
import org.geometerplus.fbreader.tree.FBTree;
|
||||
|
||||
public final class BookInSeriesTree extends BookTree {
|
||||
BookInSeriesTree(Book book) {
|
||||
super(book, false);
|
||||
BookInSeriesTree(IBookCollection collection, Book book) {
|
||||
super(collection, book, false);
|
||||
}
|
||||
|
||||
BookInSeriesTree(LibraryTree parent, Book book, int position) {
|
||||
|
|
|
@ -28,7 +28,8 @@ public class BookTree extends LibraryTree {
|
|||
public final Book Book;
|
||||
private final boolean myShowAuthors;
|
||||
|
||||
BookTree(Book book, boolean showAuthors) {
|
||||
BookTree(IBookCollection collection, Book book, boolean showAuthors) {
|
||||
super(collection);
|
||||
Book = book;
|
||||
myShowAuthors = showAuthors;
|
||||
}
|
||||
|
|
|
@ -23,11 +23,8 @@ import org.geometerplus.fbreader.book.Book;
|
|||
import org.geometerplus.fbreader.book.IBookCollection;
|
||||
|
||||
public class FavoritesTree extends FirstLevelTree {
|
||||
private final IBookCollection myCollection;
|
||||
|
||||
FavoritesTree(IBookCollection collection, RootTree root, String id) {
|
||||
super(root, id);
|
||||
myCollection = collection;
|
||||
FavoritesTree(RootTree root) {
|
||||
super(root, ROOT_FAVORITES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,14 +23,10 @@ import org.geometerplus.zlibrary.core.resources.ZLResource;
|
|||
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||
|
||||
import org.geometerplus.fbreader.Paths;
|
||||
import org.geometerplus.fbreader.book.IBookCollection;
|
||||
|
||||
public class FileFirstLevelTree extends FirstLevelTree {
|
||||
private final IBookCollection myCollection;
|
||||
|
||||
FileFirstLevelTree(IBookCollection collection, RootTree root, String id) {
|
||||
super(root, id);
|
||||
myCollection = collection;
|
||||
FileFirstLevelTree(RootTree root) {
|
||||
super(root, ROOT_FILE_TREE);
|
||||
addChild(Paths.BooksDirectoryOption().getValue(), "fileTreeLibrary");
|
||||
addChild("/", "fileTreeRoot");
|
||||
addChild(Paths.cardDirectory(), "fileTreeCard");
|
||||
|
@ -42,7 +38,6 @@ public class FileFirstLevelTree extends FirstLevelTree {
|
|||
final ZLResource resource = Library.resource().getResource(resourceKey);
|
||||
new FileTree(
|
||||
this,
|
||||
myCollection,
|
||||
file,
|
||||
resource.getValue(),
|
||||
resource.getResource("summary").getValue()
|
||||
|
|
|
@ -29,15 +29,13 @@ import org.geometerplus.fbreader.formats.PluginCollection;
|
|||
import org.geometerplus.fbreader.tree.FBTree;
|
||||
|
||||
public class FileTree extends LibraryTree {
|
||||
private final IBookCollection myCollection;
|
||||
private final ZLFile myFile;
|
||||
private final String myName;
|
||||
private final String mySummary;
|
||||
private final boolean myIsSelectable;
|
||||
|
||||
FileTree(LibraryTree parent, IBookCollection collection, ZLFile file, String name, String summary) {
|
||||
FileTree(LibraryTree parent, ZLFile file, String name, String summary) {
|
||||
super(parent);
|
||||
myCollection = collection;
|
||||
myFile = file;
|
||||
myName = name;
|
||||
mySummary = summary;
|
||||
|
@ -46,7 +44,6 @@ public class FileTree extends LibraryTree {
|
|||
|
||||
public FileTree(FileTree parent, ZLFile file) {
|
||||
super(parent);
|
||||
myCollection = parent.myCollection;
|
||||
myFile = file;
|
||||
myName = null;
|
||||
mySummary = null;
|
||||
|
|
|
@ -35,15 +35,6 @@ public final class Library {
|
|||
return ZLResource.resource("library");
|
||||
}
|
||||
|
||||
public static final String ROOT_FOUND = "found";
|
||||
public static final String ROOT_FAVORITES = "favorites";
|
||||
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";
|
||||
|
||||
public static final int REMOVE_DONT_REMOVE = 0x00;
|
||||
public static final int REMOVE_FROM_LIBRARY = 0x01;
|
||||
public static final int REMOVE_FROM_DISK = 0x02;
|
||||
|
@ -92,7 +83,7 @@ public final class Library {
|
|||
|
||||
private final Map<ZLFile,Book> myBooks =
|
||||
Collections.synchronizedMap(new HashMap<ZLFile,Book>());
|
||||
private final RootTree myRootTree = new RootTree();
|
||||
private final RootTree myRootTree;
|
||||
private boolean myDoGroupTitlesByFirstLetter;
|
||||
|
||||
private final static int STATUS_LOADING = 1;
|
||||
|
@ -113,12 +104,14 @@ public final class Library {
|
|||
myDatabase = db;
|
||||
Collection = new BookCollection(db);
|
||||
|
||||
new FavoritesTree(Collection, myRootTree, ROOT_FAVORITES);
|
||||
new RecentBooksTree(Collection, myRootTree, ROOT_RECENT);
|
||||
new FirstLevelTree(myRootTree, ROOT_BY_AUTHOR);
|
||||
new FirstLevelTree(myRootTree, ROOT_BY_TITLE);
|
||||
new FirstLevelTree(myRootTree, ROOT_BY_TAG);
|
||||
new FileFirstLevelTree(Collection, myRootTree, ROOT_FILE_TREE);
|
||||
myRootTree = new RootTree(Collection);
|
||||
|
||||
new FavoritesTree(myRootTree);
|
||||
new RecentBooksTree(myRootTree);
|
||||
new FirstLevelTree(myRootTree, LibraryTree.ROOT_BY_AUTHOR);
|
||||
new FirstLevelTree(myRootTree, LibraryTree.ROOT_BY_TITLE);
|
||||
new FirstLevelTree(myRootTree, LibraryTree.ROOT_BY_TAG);
|
||||
new FileFirstLevelTree(myRootTree);
|
||||
}
|
||||
|
||||
public LibraryTree getRootTree() {
|
||||
|
@ -235,7 +228,7 @@ public final class Library {
|
|||
|
||||
private LibraryTree getTagTree(Tag tag) {
|
||||
if (tag == null || tag.Parent == null) {
|
||||
return getFirstLevelTree(ROOT_BY_TAG).getTagSubTree(tag);
|
||||
return getFirstLevelTree(LibraryTree.ROOT_BY_TAG).getTagSubTree(tag);
|
||||
} else {
|
||||
return getTagTree(tag.Parent).getTagSubTree(tag);
|
||||
}
|
||||
|
@ -253,7 +246,7 @@ public final class Library {
|
|||
}
|
||||
final SeriesInfo seriesInfo = book.getSeriesInfo();
|
||||
for (Author a : authors) {
|
||||
final AuthorTree authorTree = getFirstLevelTree(ROOT_BY_AUTHOR).getAuthorSubTree(a);
|
||||
final AuthorTree authorTree = getFirstLevelTree(LibraryTree.ROOT_BY_AUTHOR).getAuthorSubTree(a);
|
||||
if (seriesInfo == null) {
|
||||
authorTree.getBookSubTree(book, false);
|
||||
} else {
|
||||
|
@ -262,12 +255,12 @@ public final class Library {
|
|||
}
|
||||
|
||||
if (seriesInfo != null) {
|
||||
FirstLevelTree seriesRoot = getFirstLevelTree(ROOT_BY_SERIES);
|
||||
FirstLevelTree seriesRoot = getFirstLevelTree(LibraryTree.ROOT_BY_SERIES);
|
||||
if (seriesRoot == null) {
|
||||
seriesRoot = new FirstLevelTree(
|
||||
myRootTree,
|
||||
myRootTree.indexOf(getFirstLevelTree(ROOT_BY_TITLE)) + 1,
|
||||
ROOT_BY_SERIES
|
||||
myRootTree.indexOf(getFirstLevelTree(LibraryTree.ROOT_BY_TITLE)) + 1,
|
||||
LibraryTree.ROOT_BY_SERIES
|
||||
);
|
||||
}
|
||||
seriesRoot.getSeriesSubTree(seriesInfo.Title).getBookInSeriesSubTree(book);
|
||||
|
@ -277,11 +270,11 @@ public final class Library {
|
|||
final String letter = TitleTree.firstTitleLetter(book);
|
||||
if (letter != null) {
|
||||
final TitleTree tree =
|
||||
getFirstLevelTree(ROOT_BY_TITLE).getTitleSubTree(letter);
|
||||
getFirstLevelTree(LibraryTree.ROOT_BY_TITLE).getTitleSubTree(letter);
|
||||
tree.getBookSubTree(book, true);
|
||||
}
|
||||
} else {
|
||||
getFirstLevelTree(ROOT_BY_TITLE).getBookSubTree(book, true);
|
||||
getFirstLevelTree(LibraryTree.ROOT_BY_TITLE).getBookSubTree(book, true);
|
||||
}
|
||||
|
||||
List<Tag> tags = book.tags();
|
||||
|
@ -293,7 +286,7 @@ public final class Library {
|
|||
}
|
||||
|
||||
final SearchResultsTree found =
|
||||
(SearchResultsTree)getFirstLevelTree(ROOT_FOUND);
|
||||
(SearchResultsTree)getFirstLevelTree(LibraryTree.ROOT_FOUND);
|
||||
if (found != null && book.matches(found.getPattern())) {
|
||||
found.getBookSubTree(book, true);
|
||||
}
|
||||
|
@ -309,7 +302,7 @@ public final class Library {
|
|||
private void refreshInTree(String rootId, Book book) {
|
||||
final FirstLevelTree tree = getFirstLevelTree(rootId);
|
||||
if (tree != null) {
|
||||
int index = tree.indexOf(new BookTree(book, true));
|
||||
int index = tree.indexOf(new BookTree(Collection, book, true));
|
||||
if (index >= 0) {
|
||||
tree.removeBook(book, false);
|
||||
new BookTree(tree, book, true, index);
|
||||
|
@ -323,13 +316,12 @@ public final class Library {
|
|||
}
|
||||
|
||||
myBooks.remove(book.File);
|
||||
refreshInTree(ROOT_FAVORITES, book);
|
||||
refreshInTree(ROOT_RECENT, book);
|
||||
removeFromTree(ROOT_FOUND, book);
|
||||
removeFromTree(ROOT_BY_TITLE, book);
|
||||
removeFromTree(ROOT_BY_SERIES, book);
|
||||
removeFromTree(ROOT_BY_AUTHOR, book);
|
||||
removeFromTree(ROOT_BY_TAG, book);
|
||||
refreshInTree(LibraryTree.ROOT_FAVORITES, book);
|
||||
removeFromTree(LibraryTree.ROOT_FOUND, book);
|
||||
removeFromTree(LibraryTree.ROOT_BY_TITLE, book);
|
||||
removeFromTree(LibraryTree.ROOT_BY_SERIES, book);
|
||||
removeFromTree(LibraryTree.ROOT_BY_AUTHOR, book);
|
||||
removeFromTree(LibraryTree.ROOT_BY_TAG, book);
|
||||
addBookToLibrary(book);
|
||||
fireModelChangedEvent(ChangeListener.Code.BookAdded);
|
||||
}
|
||||
|
@ -357,7 +349,7 @@ public final class Library {
|
|||
}
|
||||
|
||||
for (Book book : Collection.favorites()) {
|
||||
getFirstLevelTree(ROOT_FAVORITES).getBookSubTree(book, true);
|
||||
getFirstLevelTree(LibraryTree.ROOT_FAVORITES).getBookSubTree(book, true);
|
||||
}
|
||||
|
||||
fireModelChangedEvent(ChangeListener.Code.BookAdded);
|
||||
|
@ -512,7 +504,7 @@ public final class Library {
|
|||
|
||||
pattern = pattern.toLowerCase();
|
||||
|
||||
final SearchResultsTree oldSearchResults = (SearchResultsTree)getFirstLevelTree(ROOT_FOUND);
|
||||
final SearchResultsTree oldSearchResults = (SearchResultsTree)getFirstLevelTree(LibraryTree.ROOT_FOUND);
|
||||
if (oldSearchResults != null && pattern.equals(oldSearchResults.getPattern())) {
|
||||
fireModelChangedEvent(ChangeListener.Code.Found);
|
||||
return;
|
||||
|
@ -530,7 +522,7 @@ public final class Library {
|
|||
if (oldSearchResults != null) {
|
||||
oldSearchResults.removeSelf();
|
||||
}
|
||||
newSearchResults = new SearchResultsTree(myRootTree, ROOT_FOUND, pattern);
|
||||
newSearchResults = new SearchResultsTree(myRootTree, LibraryTree.ROOT_FOUND, pattern);
|
||||
fireModelChangedEvent(ChangeListener.Code.Found);
|
||||
}
|
||||
newSearchResults.getBookSubTree(book, true);
|
||||
|
@ -551,7 +543,7 @@ public final class Library {
|
|||
if (book == null) {
|
||||
return false;
|
||||
}
|
||||
final LibraryTree rootFavorites = getFirstLevelTree(ROOT_FAVORITES);
|
||||
final LibraryTree rootFavorites = getFirstLevelTree(LibraryTree.ROOT_FAVORITES);
|
||||
for (FBTree tree : rootFavorites.subTrees()) {
|
||||
if (tree instanceof BookTree && book.equals(((BookTree)tree).Book)) {
|
||||
return true;
|
||||
|
@ -564,13 +556,13 @@ public final class Library {
|
|||
if (isBookInFavorites(book)) {
|
||||
return;
|
||||
}
|
||||
final LibraryTree rootFavorites = getFirstLevelTree(ROOT_FAVORITES);
|
||||
final LibraryTree rootFavorites = getFirstLevelTree(LibraryTree.ROOT_FAVORITES);
|
||||
rootFavorites.getBookSubTree(book, true);
|
||||
Collection.setBookFavorite(book, true);
|
||||
}
|
||||
|
||||
public void removeBookFromFavorites(Book book) {
|
||||
if (getFirstLevelTree(ROOT_FAVORITES).removeBook(book, false)) {
|
||||
if (getFirstLevelTree(LibraryTree.ROOT_FAVORITES).removeBook(book, false)) {
|
||||
Collection.setBookFavorite(book, false);
|
||||
fireModelChangedEvent(ChangeListener.Code.BookRemoved);
|
||||
}
|
||||
|
@ -595,12 +587,12 @@ public final class Library {
|
|||
return;
|
||||
}
|
||||
myBooks.remove(book.File);
|
||||
if (getFirstLevelTree(ROOT_RECENT).removeBook(book, false)) {
|
||||
if (getFirstLevelTree(LibraryTree.ROOT_RECENT).removeBook(book, false)) {
|
||||
final List<Long> ids = myDatabase.loadRecentBookIds();
|
||||
ids.remove(book.getId());
|
||||
myDatabase.saveRecentBookIds(ids);
|
||||
}
|
||||
getFirstLevelTree(ROOT_FAVORITES).removeBook(book, false);
|
||||
getFirstLevelTree(LibraryTree.ROOT_FAVORITES).removeBook(book, false);
|
||||
myRootTree.removeBook(book, true);
|
||||
|
||||
if ((removeMode & REMOVE_FROM_DISK) != 0) {
|
||||
|
|
|
@ -25,16 +25,30 @@ import org.geometerplus.fbreader.book.*;
|
|||
import org.geometerplus.fbreader.tree.FBTree;
|
||||
|
||||
public abstract class LibraryTree extends FBTree {
|
||||
protected LibraryTree() {
|
||||
public static final String ROOT_FOUND = "found";
|
||||
public static final String ROOT_FAVORITES = "favorites";
|
||||
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";
|
||||
|
||||
public final IBookCollection Collection;
|
||||
|
||||
protected LibraryTree(IBookCollection collection) {
|
||||
super();
|
||||
Collection = collection;
|
||||
}
|
||||
|
||||
protected LibraryTree(LibraryTree parent) {
|
||||
super(parent);
|
||||
Collection = parent.Collection;
|
||||
}
|
||||
|
||||
protected LibraryTree(LibraryTree parent, int position) {
|
||||
super(parent, position);
|
||||
Collection = parent.Collection;
|
||||
}
|
||||
|
||||
public Book getBook() {
|
||||
|
@ -50,7 +64,7 @@ public abstract class LibraryTree extends FBTree {
|
|||
}
|
||||
|
||||
TagTree getTagSubTree(Tag tag) {
|
||||
final TagTree temp = new TagTree(tag);
|
||||
final TagTree temp = new TagTree(Collection, tag);
|
||||
int position = Collections.binarySearch(subTrees(), temp);
|
||||
if (position >= 0) {
|
||||
return (TagTree)subTrees().get(position);
|
||||
|
@ -60,7 +74,7 @@ public abstract class LibraryTree extends FBTree {
|
|||
}
|
||||
|
||||
TitleTree getTitleSubTree(String title) {
|
||||
final TitleTree temp = new TitleTree(title);
|
||||
final TitleTree temp = new TitleTree(Collection, title);
|
||||
int position = Collections.binarySearch(subTrees(), temp);
|
||||
if (position >= 0) {
|
||||
return (TitleTree)subTrees().get(position);
|
||||
|
@ -70,7 +84,7 @@ public abstract class LibraryTree extends FBTree {
|
|||
}
|
||||
|
||||
AuthorTree getAuthorSubTree(Author author) {
|
||||
final AuthorTree temp = new AuthorTree(author);
|
||||
final AuthorTree temp = new AuthorTree(Collection, author);
|
||||
int position = Collections.binarySearch(subTrees(), temp);
|
||||
if (position >= 0) {
|
||||
return (AuthorTree)subTrees().get(position);
|
||||
|
@ -80,7 +94,7 @@ public abstract class LibraryTree extends FBTree {
|
|||
}
|
||||
|
||||
BookTree getBookSubTree(Book book, boolean showAuthors) {
|
||||
final BookTree temp = new BookTree(book, showAuthors);
|
||||
final BookTree temp = new BookTree(Collection, book, showAuthors);
|
||||
int position = Collections.binarySearch(subTrees(), temp);
|
||||
if (position >= 0) {
|
||||
return (BookTree)subTrees().get(position);
|
||||
|
@ -90,7 +104,7 @@ public abstract class LibraryTree extends FBTree {
|
|||
}
|
||||
|
||||
SeriesTree getSeriesSubTree(String series) {
|
||||
final SeriesTree temp = new SeriesTree(series);
|
||||
final SeriesTree temp = new SeriesTree(Collection, series);
|
||||
int position = Collections.binarySearch(subTrees(), temp);
|
||||
if (position >= 0) {
|
||||
return (SeriesTree)subTrees().get(position);
|
||||
|
|
|
@ -20,14 +20,10 @@
|
|||
package org.geometerplus.fbreader.library;
|
||||
|
||||
import org.geometerplus.fbreader.book.Book;
|
||||
import org.geometerplus.fbreader.book.IBookCollection;
|
||||
|
||||
public class RecentBooksTree extends FirstLevelTree {
|
||||
private final IBookCollection myCollection;
|
||||
|
||||
RecentBooksTree(IBookCollection collection, RootTree root, String id) {
|
||||
super(root, id);
|
||||
myCollection = collection;
|
||||
RecentBooksTree(RootTree root) {
|
||||
super(root, ROOT_RECENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,7 +34,7 @@ public class RecentBooksTree extends FirstLevelTree {
|
|||
@Override
|
||||
public void waitForOpening() {
|
||||
clear();
|
||||
for (Book book : myCollection.recentBooks()) {
|
||||
for (Book book : Collection.recentBooks()) {
|
||||
new BookTree(this, book, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,11 @@
|
|||
|
||||
package org.geometerplus.fbreader.library;
|
||||
|
||||
import org.geometerplus.fbreader.book.IBookCollection;
|
||||
|
||||
class RootTree extends LibraryTree {
|
||||
RootTree() {
|
||||
RootTree(IBookCollection collection) {
|
||||
super(collection);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,13 +21,13 @@ package org.geometerplus.fbreader.library;
|
|||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.geometerplus.fbreader.book.Book;
|
||||
import org.geometerplus.fbreader.book.SeriesInfo;
|
||||
import org.geometerplus.fbreader.book.*;
|
||||
|
||||
public final class SeriesTree extends LibraryTree {
|
||||
public final String Series;
|
||||
|
||||
SeriesTree(String series) {
|
||||
SeriesTree(IBookCollection collection, String series) {
|
||||
super(collection);
|
||||
Series = series;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public final class SeriesTree extends LibraryTree {
|
|||
}
|
||||
|
||||
BookTree getBookInSeriesSubTree(Book book) {
|
||||
final BookInSeriesTree temp = new BookInSeriesTree(book);
|
||||
final BookInSeriesTree temp = new BookInSeriesTree(Collection, book);
|
||||
int position = Collections.binarySearch(subTrees(), temp);
|
||||
if (position >= 0) {
|
||||
return (BookInSeriesTree)subTrees().get(position);
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
|
||||
package org.geometerplus.fbreader.library;
|
||||
|
||||
import org.geometerplus.fbreader.book.Book;
|
||||
import org.geometerplus.fbreader.book.Tag;
|
||||
import org.geometerplus.fbreader.book.*;
|
||||
|
||||
public final class TagTree extends LibraryTree {
|
||||
public final Tag Tag;
|
||||
|
||||
TagTree(Tag tag) {
|
||||
TagTree(IBookCollection collection, Tag tag) {
|
||||
super(collection);
|
||||
Tag = tag;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.geometerplus.fbreader.library;
|
||||
|
||||
import org.geometerplus.fbreader.book.Book;
|
||||
import org.geometerplus.fbreader.book.IBookCollection;
|
||||
|
||||
public final class TitleTree extends LibraryTree {
|
||||
static String firstTitleLetter(Book book) {
|
||||
|
@ -45,7 +46,8 @@ public final class TitleTree extends LibraryTree {
|
|||
|
||||
public final String Title;
|
||||
|
||||
TitleTree(String title) {
|
||||
TitleTree(IBookCollection collection, String title) {
|
||||
super(collection);
|
||||
Title = title;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue