1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 17:59:33 +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;
protected LibraryTree myCurrentTree;
private final Map<FBTree,Integer> myIconMap = new HashMap<FBTree,Integer>();
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
@ -109,17 +107,24 @@ abstract class BaseActivity extends ListActivity implements View.OnCreateContext
return (ListAdapter)super.getListAdapter();
}
protected void addFBTreeWithIcon(FBTree tree, int coverResourceId) {
getListAdapter().add(tree);
myIconMap.put(tree, coverResourceId);
}
int getCoverResourceId(FBTree tree) {
final Integer icon = myIconMap.get(tree);
if (icon != null) {
return icon.intValue();
} else if (((LibraryTree)tree).getBook() != null) {
if (((LibraryTree)tree).getBook() != null) {
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) {
final ZLFile file = ((FileTree)tree).getFile();
if (file.isArchive()) {
@ -133,9 +138,9 @@ abstract class BaseActivity extends ListActivity implements View.OnCreateContext
return R.drawable.ic_list_library_author;
} else if (tree instanceof TagTree) {
return R.drawable.ic_list_library_tag;
} else {
return R.drawable.ic_list_library_books;
}
return R.drawable.ic_list_library_books;
}
@Override

View file

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

View file

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

View file

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

View file

@ -21,12 +21,12 @@ package org.geometerplus.fbreader.library;
import org.geometerplus.zlibrary.core.resources.ZLResource;
public class RootTree extends LibraryTree {
public class FirstLevelTree extends LibraryTree {
private final Library myLibrary;
private final String myId;
private final ZLResource myResource;
RootTree(Library library, String id) {
FirstLevelTree(Library library, String id) {
myLibrary = library;
myId = id;
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 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 boolean myInterrupted = false;
public Library() {
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) {
RootTree root = myRootTrees.get(id);
public FirstLevelTree getRootTree(String id) {
FirstLevelTree root = myRootTrees.get(id);
if (root == null) {
root = new RootTree(this, id);
root = new FirstLevelTree(this, id);
myRootTrees.put(id, root);
}
return root;
@ -408,7 +408,7 @@ public final class Library {
public LibraryTree searchBooks(String pattern) {
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) {
pattern = pattern.toLowerCase();
for (Book book : myBooks) {

View file

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