mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 10:19:33 +02:00
network search has been restored
This commit is contained in:
parent
e562a54a29
commit
3f14059edb
6 changed files with 42 additions and 31 deletions
|
@ -266,7 +266,9 @@ public class NetworkLibraryActivity extends NetworkBaseActivity {
|
|||
}
|
||||
|
||||
private static boolean searchIsInProgress() {
|
||||
return NetworkView.Instance().containsItemsLoadingRunnable(NetworkTree.SearchKey);
|
||||
return NetworkView.Instance().containsItemsLoadingRunnable(
|
||||
NetworkLibrary.Instance().getSearchItemTree().getUniqueKey()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -86,7 +86,7 @@ public class NetworkSearchActivity extends Activity {
|
|||
myTree.setSearchResult(null);
|
||||
} else {
|
||||
myTree.updateSubTrees();
|
||||
afterUpdateCatalog(errorMessage, myTree.getSearchResult().empty());
|
||||
afterUpdateCatalog(errorMessage, myTree.getSearchResult().isEmpty());
|
||||
}
|
||||
if (NetworkView.Instance().isInitialized()) {
|
||||
NetworkView.Instance().fireModelChangedAsync();
|
||||
|
@ -103,10 +103,21 @@ public class NetworkSearchActivity extends Activity {
|
|||
} else if (childrenEmpty) {
|
||||
boxResource = dialogResource.getResource("emptySearchResults");
|
||||
msg = boxResource.getResource("message").getValue();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (msg != null) {
|
||||
if (NetworkView.Instance().isInitialized()) {
|
||||
final NetworkCatalogActivity activity = NetworkView.Instance().getOpenedActivity(NetworkTree.SearchKey);
|
||||
|
||||
if (!NetworkView.Instance().isInitialized()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final SearchItemTree tree = NetworkLibrary.Instance().getSearchItemTree();
|
||||
if (tree == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final NetworkCatalogActivity activity =
|
||||
NetworkView.Instance().getOpenedActivity(tree.getUniqueKey());
|
||||
if (activity != null) {
|
||||
final ZLResource buttonResource = dialogResource.getResource("button");
|
||||
new AlertDialog.Builder(activity)
|
||||
|
@ -118,8 +129,6 @@ public class NetworkSearchActivity extends Activity {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class SearchRunnable extends ItemsLoadingRunnable {
|
||||
private final String myPattern;
|
||||
|
@ -145,26 +154,24 @@ public class NetworkSearchActivity extends Activity {
|
|||
final NetworkLibrary library = NetworkLibrary.Instance();
|
||||
library.NetworkSearchPatternOption.setValue(pattern);
|
||||
|
||||
if (NetworkView.Instance().containsItemsLoadingRunnable(NetworkTree.SearchKey)) {
|
||||
final SearchItemTree tree = library.getSearchItemTree();
|
||||
if (tree == null ||
|
||||
NetworkView.Instance().containsItemsLoadingRunnable(tree.getUniqueKey())) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String summary = ZLResource.resource("networkView").getResource("searchResults").getValue().replace("%s", pattern);
|
||||
final SearchResult result = new SearchResult(summary);
|
||||
|
||||
/*
|
||||
final SearchItemTree tree = NetworkView.Instance().getSearchItemTree();
|
||||
|
||||
tree.setSearchResult(result);
|
||||
NetworkView.Instance().fireModelChangedAsync();
|
||||
|
||||
final SearchHandler handler = new SearchHandler(tree);
|
||||
NetworkView.Instance().startItemsLoading(
|
||||
this,
|
||||
NetworkTree.SearchKey,
|
||||
tree.getUniqueKey(),
|
||||
new SearchRunnable(handler, pattern)
|
||||
);
|
||||
NetworkView.Instance().openTree(this, tree);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ class SearchItemActions extends NetworkTreeActions {
|
|||
public void buildContextMenu(Activity activity, ContextMenu menu, NetworkTree tree) {
|
||||
menu.setHeaderTitle(tree.getName());
|
||||
|
||||
final boolean isLoading = NetworkView.Instance().containsItemsLoadingRunnable(NetworkTree.SearchKey);
|
||||
final boolean isLoading = NetworkView.Instance().containsItemsLoadingRunnable(tree.getUniqueKey());
|
||||
|
||||
if (!isLoading) {
|
||||
addMenuItem(menu, RUN_SEARCH_ITEM_ID, "search");
|
||||
|
@ -61,7 +61,7 @@ class SearchItemActions extends NetworkTreeActions {
|
|||
|
||||
@Override
|
||||
public int getDefaultActionCode(NetworkBaseActivity activity, NetworkTree tree) {
|
||||
final boolean isLoading = NetworkView.Instance().containsItemsLoadingRunnable(NetworkTree.SearchKey);
|
||||
final boolean isLoading = NetworkView.Instance().containsItemsLoadingRunnable(tree.getUniqueKey());
|
||||
if (!isLoading) {
|
||||
return RUN_SEARCH_ITEM_ID;
|
||||
}
|
||||
|
|
|
@ -149,6 +149,7 @@ public class NetworkLibrary {
|
|||
}
|
||||
|
||||
private final RootTree myRootTree = new RootTree();
|
||||
private SearchItemTree mySearchItemTree;
|
||||
|
||||
private boolean myChildrenAreInvalid = true;
|
||||
private boolean myUpdateVisibility;
|
||||
|
@ -364,7 +365,7 @@ public class NetworkLibrary {
|
|||
tree.removeSelf();
|
||||
}
|
||||
new AddCustomCatalogItemTree(myRootTree);
|
||||
new SearchItemTree(myRootTree, 0);
|
||||
mySearchItemTree = new SearchItemTree(myRootTree, 0);
|
||||
}
|
||||
|
||||
private void updateVisibility() {
|
||||
|
@ -390,6 +391,10 @@ public class NetworkLibrary {
|
|||
return myRootTree;
|
||||
}
|
||||
|
||||
public SearchItemTree getSearchItemTree() {
|
||||
return mySearchItemTree;
|
||||
}
|
||||
|
||||
public NetworkTree getTreeByKey(NetworkTree.Key key) {
|
||||
if (key.Parent == null) {
|
||||
return key.equals(myRootTree.getUniqueKey()) ? myRootTree : null;
|
||||
|
|
|
@ -29,8 +29,6 @@ import org.geometerplus.zlibrary.core.image.ZLImage;
|
|||
import org.geometerplus.fbreader.tree.FBTree;
|
||||
|
||||
public abstract class NetworkTree extends FBTree {
|
||||
public static final Key SearchKey = new Key(null, "@Search");
|
||||
|
||||
public static class Key implements Serializable {
|
||||
final Key Parent;
|
||||
final String Id;
|
||||
|
|
|
@ -23,13 +23,12 @@ import java.util.LinkedHashMap;
|
|||
import java.util.LinkedList;
|
||||
|
||||
public class SearchResult {
|
||||
|
||||
public final String Summary;
|
||||
public final LinkedHashMap<NetworkBookItem.AuthorData, LinkedList<NetworkBookItem>> BooksMap;
|
||||
public final LinkedHashMap<NetworkBookItem.AuthorData, LinkedList<NetworkBookItem>> BooksMap =
|
||||
new LinkedHashMap<NetworkBookItem.AuthorData, LinkedList<NetworkBookItem>>();
|
||||
|
||||
public SearchResult(String summary) {
|
||||
Summary = summary;
|
||||
BooksMap = new LinkedHashMap<NetworkBookItem.AuthorData, LinkedList<NetworkBookItem>>();
|
||||
}
|
||||
|
||||
public void addBook(NetworkBookItem book) {
|
||||
|
@ -43,7 +42,7 @@ public class SearchResult {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean empty() {
|
||||
public boolean isEmpty() {
|
||||
return BooksMap.size() == 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue