1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 02:09:35 +02:00

renaming RootTree -> FileFirstLevelTree

This commit is contained in:
Nikolay Pultsin 2011-07-14 17:34:02 +01:00
parent dd9116d41c
commit be09a18e71
7 changed files with 38 additions and 37 deletions

View file

@ -66,8 +66,6 @@ abstract class BaseActivity extends ListActivity implements View.OnCreateContext
private Book mySelectedBook; private Book mySelectedBook;
protected LibraryTree myCurrentTree; protected LibraryTree myCurrentTree;
private final Map<FBTree,Integer> myIconMap = new HashMap<FBTree,Integer>();
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
@ -109,17 +107,24 @@ abstract class BaseActivity extends ListActivity implements View.OnCreateContext
return (ListAdapter)super.getListAdapter(); return (ListAdapter)super.getListAdapter();
} }
protected void addFBTreeWithIcon(FBTree tree, int coverResourceId) {
getListAdapter().add(tree);
myIconMap.put(tree, coverResourceId);
}
int getCoverResourceId(FBTree tree) { int getCoverResourceId(FBTree tree) {
final Integer icon = myIconMap.get(tree); if (((LibraryTree)tree).getBook() != null) {
if (icon != null) {
return icon.intValue();
} else if (((LibraryTree)tree).getBook() != null) {
return R.drawable.ic_list_library_book; return R.drawable.ic_list_library_book;
} else if (tree instanceof FirstLevelTree) {
final String id = tree.getUniqueKey().Id;
if (Library.ROOT_FAVORITES.equals(id)) {
return R.drawable.ic_list_library_favorites;
} else if (Library.ROOT_RECENT.equals(id)) {
return R.drawable.ic_list_library_recent;
} else if (Library.ROOT_BY_AUTHOR.equals(id)) {
return R.drawable.ic_list_library_authors;
} else if (Library.ROOT_BY_TITLE.equals(id)) {
return R.drawable.ic_list_library_books;
} else if (Library.ROOT_BY_TAG.equals(id)) {
return R.drawable.ic_list_library_tags;
} else if (Library.ROOT_FILE_TREE.equals(id)) {
return R.drawable.ic_list_library_folder;
}
} else if (tree instanceof FileTree) { } else if (tree instanceof FileTree) {
final ZLFile file = ((FileTree)tree).getFile(); final ZLFile file = ((FileTree)tree).getFile();
if (file.isArchive()) { if (file.isArchive()) {
@ -133,9 +138,9 @@ abstract class BaseActivity extends ListActivity implements View.OnCreateContext
return R.drawable.ic_list_library_author; return R.drawable.ic_list_library_author;
} else if (tree instanceof TagTree) { } else if (tree instanceof TagTree) {
return R.drawable.ic_list_library_tag; return R.drawable.ic_list_library_tag;
} else {
return R.drawable.ic_list_library_books;
} }
return R.drawable.ic_list_library_books;
} }
@Override @Override

View file

@ -29,12 +29,12 @@ import org.geometerplus.zlibrary.ui.android.R;
import org.geometerplus.fbreader.tree.FBTree; import org.geometerplus.fbreader.tree.FBTree;
import org.geometerplus.fbreader.library.Library; import org.geometerplus.fbreader.library.Library;
import org.geometerplus.fbreader.library.RootTree; import org.geometerplus.fbreader.library.FirstLevelTree;
import org.geometerplus.android.util.UIUtil; import org.geometerplus.android.util.UIUtil;
public class LibraryTopLevelActivity extends LibraryBaseActivity { public class LibraryTopLevelActivity extends LibraryBaseActivity {
private RootTree mySearchResultsItem; private FirstLevelTree mySearchResultsItem;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
@ -42,20 +42,16 @@ public class LibraryTopLevelActivity extends LibraryBaseActivity {
final ListAdapter adapter = new ListAdapter(this, Collections.<FBTree>emptyList()); final ListAdapter adapter = new ListAdapter(this, Collections.<FBTree>emptyList());
addTopLevelTree(Library.ROOT_FAVORITES, R.drawable.ic_list_library_favorites); adapter.add(LibraryInstance.getRootTree(Library.ROOT_FAVORITES));
addTopLevelTree(Library.ROOT_RECENT, R.drawable.ic_list_library_recent); adapter.add(LibraryInstance.getRootTree(Library.ROOT_RECENT));
addTopLevelTree(Library.ROOT_BY_AUTHOR, R.drawable.ic_list_library_authors); adapter.add(LibraryInstance.getRootTree(Library.ROOT_BY_AUTHOR));
addTopLevelTree(Library.ROOT_BY_TITLE, R.drawable.ic_list_library_books); adapter.add(LibraryInstance.getRootTree(Library.ROOT_BY_TITLE));
addTopLevelTree(Library.ROOT_BY_TAG, R.drawable.ic_list_library_tags); adapter.add(LibraryInstance.getRootTree(Library.ROOT_BY_TAG));
addTopLevelTree(Library.ROOT_FILE_TREE, R.drawable.ic_list_library_folder); adapter.add(LibraryInstance.getRootTree(Library.ROOT_FILE_TREE));
onNewIntent(getIntent()); onNewIntent(getIntent());
} }
private void addTopLevelTree(String key, int imageId) {
addFBTreeWithIcon(LibraryInstance.getRootTree(key), imageId);
}
@Override @Override
public void onDestroy() { public void onDestroy() {
LibraryInstance = null; LibraryInstance = null;

View file

@ -21,7 +21,7 @@ package org.geometerplus.fbreader.library;
import org.geometerplus.zlibrary.core.resources.ZLResource; import org.geometerplus.zlibrary.core.resources.ZLResource;
public class FavoritesTree extends RootTree { public class FavoritesTree extends FirstLevelTree {
FavoritesTree(Library library, String id) { FavoritesTree(Library library, String id) {
super(library, id); super(library, id);
} }

View file

@ -24,8 +24,8 @@ import org.geometerplus.zlibrary.core.filesystem.ZLFile;
import org.geometerplus.fbreader.Paths; import org.geometerplus.fbreader.Paths;
public class FileRootTree extends RootTree { public class FileFirstLevelTree extends FirstLevelTree {
FileRootTree(Library library, String id) { FileFirstLevelTree(Library library, String id) {
super(library, id); super(library, id);
addChild(Paths.BooksDirectoryOption().getValue(), "fileTreeLibrary"); addChild(Paths.BooksDirectoryOption().getValue(), "fileTreeLibrary");
addChild("/", "fileTreeRoot"); addChild("/", "fileTreeRoot");

View file

@ -21,12 +21,12 @@ package org.geometerplus.fbreader.library;
import org.geometerplus.zlibrary.core.resources.ZLResource; import org.geometerplus.zlibrary.core.resources.ZLResource;
public class RootTree extends LibraryTree { public class FirstLevelTree extends LibraryTree {
private final Library myLibrary; private final Library myLibrary;
private final String myId; private final String myId;
private final ZLResource myResource; private final ZLResource myResource;
RootTree(Library library, String id) { FirstLevelTree(Library library, String id) {
myLibrary = library; myLibrary = library;
myId = id; myId = id;
myResource = Library.resource().getResource(myId); myResource = Library.resource().getResource(myId);

View file

@ -51,20 +51,20 @@ public final class Library {
private final List<Book> myBooks = new LinkedList<Book>(); private final List<Book> myBooks = new LinkedList<Book>();
private final Set<Book> myExternalBooks = new HashSet<Book>(); private final Set<Book> myExternalBooks = new HashSet<Book>();
private final Map<String,RootTree> myRootTrees = new HashMap<String,RootTree>(); private final Map<String,FirstLevelTree> myRootTrees = new HashMap<String,FirstLevelTree>();
private volatile int myState = STATE_NOT_INITIALIZED; private volatile int myState = STATE_NOT_INITIALIZED;
private volatile boolean myInterrupted = false; private volatile boolean myInterrupted = false;
public Library() { public Library() {
myRootTrees.put(ROOT_FAVORITES, new FavoritesTree(this, ROOT_FAVORITES)); myRootTrees.put(ROOT_FAVORITES, new FavoritesTree(this, ROOT_FAVORITES));
myRootTrees.put(ROOT_FILE_TREE, new FileRootTree(this, ROOT_FILE_TREE)); myRootTrees.put(ROOT_FILE_TREE, new FileFirstLevelTree(this, ROOT_FILE_TREE));
} }
public RootTree getRootTree(String id) { public FirstLevelTree getRootTree(String id) {
RootTree root = myRootTrees.get(id); FirstLevelTree root = myRootTrees.get(id);
if (root == null) { if (root == null) {
root = new RootTree(this, id); root = new FirstLevelTree(this, id);
myRootTrees.put(id, root); myRootTrees.put(id, root);
} }
return root; return root;
@ -408,7 +408,7 @@ public final class Library {
public LibraryTree searchBooks(String pattern) { public LibraryTree searchBooks(String pattern) {
waitForState(STATE_FULLY_INITIALIZED); waitForState(STATE_FULLY_INITIALIZED);
final RootTree newSearchResults = new SearchResultsTree(this, ROOT_SEARCH_RESULTS, pattern); final FirstLevelTree newSearchResults = new SearchResultsTree(this, ROOT_SEARCH_RESULTS, pattern);
if (pattern != null) { if (pattern != null) {
pattern = pattern.toLowerCase(); pattern = pattern.toLowerCase();
for (Book book : myBooks) { for (Book book : myBooks) {

View file

@ -19,7 +19,7 @@
package org.geometerplus.fbreader.library; package org.geometerplus.fbreader.library;
class SearchResultsTree extends RootTree { class SearchResultsTree extends FirstLevelTree {
private final String myPattern; private final String myPattern;
SearchResultsTree(Library library, String id, String pattern) { SearchResultsTree(Library library, String id, String pattern) {