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() {
|
private static boolean searchIsInProgress() {
|
||||||
return NetworkView.Instance().containsItemsLoadingRunnable(NetworkTree.SearchKey);
|
return NetworkView.Instance().containsItemsLoadingRunnable(
|
||||||
|
NetworkLibrary.Instance().getSearchItemTree().getUniqueKey()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class NetworkSearchActivity extends Activity {
|
||||||
myTree.setSearchResult(null);
|
myTree.setSearchResult(null);
|
||||||
} else {
|
} else {
|
||||||
myTree.updateSubTrees();
|
myTree.updateSubTrees();
|
||||||
afterUpdateCatalog(errorMessage, myTree.getSearchResult().empty());
|
afterUpdateCatalog(errorMessage, myTree.getSearchResult().isEmpty());
|
||||||
}
|
}
|
||||||
if (NetworkView.Instance().isInitialized()) {
|
if (NetworkView.Instance().isInitialized()) {
|
||||||
NetworkView.Instance().fireModelChangedAsync();
|
NetworkView.Instance().fireModelChangedAsync();
|
||||||
|
@ -103,20 +103,29 @@ public class NetworkSearchActivity extends Activity {
|
||||||
} else if (childrenEmpty) {
|
} else if (childrenEmpty) {
|
||||||
boxResource = dialogResource.getResource("emptySearchResults");
|
boxResource = dialogResource.getResource("emptySearchResults");
|
||||||
msg = boxResource.getResource("message").getValue();
|
msg = boxResource.getResource("message").getValue();
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (msg != null) {
|
|
||||||
if (NetworkView.Instance().isInitialized()) {
|
if (!NetworkView.Instance().isInitialized()) {
|
||||||
final NetworkCatalogActivity activity = NetworkView.Instance().getOpenedActivity(NetworkTree.SearchKey);
|
return;
|
||||||
if (activity != null) {
|
}
|
||||||
final ZLResource buttonResource = dialogResource.getResource("button");
|
|
||||||
new AlertDialog.Builder(activity)
|
final SearchItemTree tree = NetworkLibrary.Instance().getSearchItemTree();
|
||||||
.setTitle(boxResource.getResource("title").getValue())
|
if (tree == null) {
|
||||||
.setMessage(msg)
|
return;
|
||||||
.setIcon(0)
|
}
|
||||||
.setPositiveButton(buttonResource.getResource("ok").getValue(), null)
|
|
||||||
.create().show();
|
final NetworkCatalogActivity activity =
|
||||||
}
|
NetworkView.Instance().getOpenedActivity(tree.getUniqueKey());
|
||||||
}
|
if (activity != null) {
|
||||||
|
final ZLResource buttonResource = dialogResource.getResource("button");
|
||||||
|
new AlertDialog.Builder(activity)
|
||||||
|
.setTitle(boxResource.getResource("title").getValue())
|
||||||
|
.setMessage(msg)
|
||||||
|
.setIcon(0)
|
||||||
|
.setPositiveButton(buttonResource.getResource("ok").getValue(), null)
|
||||||
|
.create().show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,26 +154,24 @@ public class NetworkSearchActivity extends Activity {
|
||||||
final NetworkLibrary library = NetworkLibrary.Instance();
|
final NetworkLibrary library = NetworkLibrary.Instance();
|
||||||
library.NetworkSearchPatternOption.setValue(pattern);
|
library.NetworkSearchPatternOption.setValue(pattern);
|
||||||
|
|
||||||
if (NetworkView.Instance().containsItemsLoadingRunnable(NetworkTree.SearchKey)) {
|
final SearchItemTree tree = library.getSearchItemTree();
|
||||||
|
if (tree == null ||
|
||||||
|
NetworkView.Instance().containsItemsLoadingRunnable(tree.getUniqueKey())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String summary = ZLResource.resource("networkView").getResource("searchResults").getValue().replace("%s", pattern);
|
final String summary = ZLResource.resource("networkView").getResource("searchResults").getValue().replace("%s", pattern);
|
||||||
final SearchResult result = new SearchResult(summary);
|
final SearchResult result = new SearchResult(summary);
|
||||||
|
|
||||||
/*
|
|
||||||
final SearchItemTree tree = NetworkView.Instance().getSearchItemTree();
|
|
||||||
|
|
||||||
tree.setSearchResult(result);
|
tree.setSearchResult(result);
|
||||||
NetworkView.Instance().fireModelChangedAsync();
|
NetworkView.Instance().fireModelChangedAsync();
|
||||||
|
|
||||||
final SearchHandler handler = new SearchHandler(tree);
|
final SearchHandler handler = new SearchHandler(tree);
|
||||||
NetworkView.Instance().startItemsLoading(
|
NetworkView.Instance().startItemsLoading(
|
||||||
this,
|
this,
|
||||||
NetworkTree.SearchKey,
|
tree.getUniqueKey(),
|
||||||
new SearchRunnable(handler, pattern)
|
new SearchRunnable(handler, pattern)
|
||||||
);
|
);
|
||||||
NetworkView.Instance().openTree(this, tree);
|
NetworkView.Instance().openTree(this, tree);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class SearchItemActions extends NetworkTreeActions {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTreeTitle(NetworkTree tree) {
|
public String getTreeTitle(NetworkTree tree) {
|
||||||
final SearchResult result = ((SearchItemTree) tree).getSearchResult();
|
final SearchResult result = ((SearchItemTree)tree).getSearchResult();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return result.Summary;
|
return result.Summary;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ class SearchItemActions extends NetworkTreeActions {
|
||||||
public void buildContextMenu(Activity activity, ContextMenu menu, NetworkTree tree) {
|
public void buildContextMenu(Activity activity, ContextMenu menu, NetworkTree tree) {
|
||||||
menu.setHeaderTitle(tree.getName());
|
menu.setHeaderTitle(tree.getName());
|
||||||
|
|
||||||
final boolean isLoading = NetworkView.Instance().containsItemsLoadingRunnable(NetworkTree.SearchKey);
|
final boolean isLoading = NetworkView.Instance().containsItemsLoadingRunnable(tree.getUniqueKey());
|
||||||
|
|
||||||
if (!isLoading) {
|
if (!isLoading) {
|
||||||
addMenuItem(menu, RUN_SEARCH_ITEM_ID, "search");
|
addMenuItem(menu, RUN_SEARCH_ITEM_ID, "search");
|
||||||
|
@ -61,7 +61,7 @@ class SearchItemActions extends NetworkTreeActions {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDefaultActionCode(NetworkBaseActivity activity, NetworkTree tree) {
|
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) {
|
if (!isLoading) {
|
||||||
return RUN_SEARCH_ITEM_ID;
|
return RUN_SEARCH_ITEM_ID;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,6 +149,7 @@ public class NetworkLibrary {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final RootTree myRootTree = new RootTree();
|
private final RootTree myRootTree = new RootTree();
|
||||||
|
private SearchItemTree mySearchItemTree;
|
||||||
|
|
||||||
private boolean myChildrenAreInvalid = true;
|
private boolean myChildrenAreInvalid = true;
|
||||||
private boolean myUpdateVisibility;
|
private boolean myUpdateVisibility;
|
||||||
|
@ -364,7 +365,7 @@ public class NetworkLibrary {
|
||||||
tree.removeSelf();
|
tree.removeSelf();
|
||||||
}
|
}
|
||||||
new AddCustomCatalogItemTree(myRootTree);
|
new AddCustomCatalogItemTree(myRootTree);
|
||||||
new SearchItemTree(myRootTree, 0);
|
mySearchItemTree = new SearchItemTree(myRootTree, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateVisibility() {
|
private void updateVisibility() {
|
||||||
|
@ -390,6 +391,10 @@ public class NetworkLibrary {
|
||||||
return myRootTree;
|
return myRootTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SearchItemTree getSearchItemTree() {
|
||||||
|
return mySearchItemTree;
|
||||||
|
}
|
||||||
|
|
||||||
public NetworkTree getTreeByKey(NetworkTree.Key key) {
|
public NetworkTree getTreeByKey(NetworkTree.Key key) {
|
||||||
if (key.Parent == null) {
|
if (key.Parent == null) {
|
||||||
return key.equals(myRootTree.getUniqueKey()) ? myRootTree : 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;
|
import org.geometerplus.fbreader.tree.FBTree;
|
||||||
|
|
||||||
public abstract class NetworkTree extends FBTree {
|
public abstract class NetworkTree extends FBTree {
|
||||||
public static final Key SearchKey = new Key(null, "@Search");
|
|
||||||
|
|
||||||
public static class Key implements Serializable {
|
public static class Key implements Serializable {
|
||||||
final Key Parent;
|
final Key Parent;
|
||||||
final String Id;
|
final String Id;
|
||||||
|
|
|
@ -23,13 +23,12 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
public class SearchResult {
|
public class SearchResult {
|
||||||
|
|
||||||
public final String Summary;
|
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) {
|
public SearchResult(String summary) {
|
||||||
Summary = summary;
|
Summary = summary;
|
||||||
BooksMap = new LinkedHashMap<NetworkBookItem.AuthorData, LinkedList<NetworkBookItem>>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBook(NetworkBookItem book) {
|
public void addBook(NetworkBookItem book) {
|
||||||
|
@ -43,7 +42,7 @@ public class SearchResult {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean empty() {
|
public boolean isEmpty() {
|
||||||
return BooksMap.size() == 0;
|
return BooksMap.size() == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue