mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
catalog's items hiding has been implemented
git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@1135 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
0a5bd768cf
commit
1744d5c718
4 changed files with 111 additions and 7 deletions
|
@ -3,7 +3,7 @@ DONE переместить в главном меню наверх (вмест
|
||||||
DONE пункт меню "delete sample"
|
DONE пункт меню "delete sample"
|
||||||
DONE BookDownloaderService - i18n
|
DONE BookDownloaderService - i18n
|
||||||
DONE указывать HTTP-agent = "FBReader/<version>(java)" -- номер версии смотреть, как в диалоге About
|
DONE указывать HTTP-agent = "FBReader/<version>(java)" -- номер версии смотреть, как в диалоге About
|
||||||
* прятать Profile (прятать запрещенные каталоги)
|
DONE прятать Profile (прятать запрещенные каталоги)
|
||||||
* при щелчке на книжку - сделать default action, и о нем спрашивать.
|
* при щелчке на книжку - сделать default action, и о нем спрашивать.
|
||||||
|
|
||||||
* асинхронная загрузка каталогов
|
* асинхронная загрузка каталогов
|
||||||
|
|
|
@ -263,8 +263,9 @@ public class NetworkLibraryActivity extends ListActivity implements MenuItem.OnM
|
||||||
private void updateCatalogChildren(NetworkCatalogTree tree) {
|
private void updateCatalogChildren(NetworkCatalogTree tree) {
|
||||||
tree.clear();
|
tree.clear();
|
||||||
|
|
||||||
ArrayList<NetworkLibraryItem> children = new ArrayList<NetworkLibraryItem>();
|
ArrayList<NetworkLibraryItem> children = tree.ChildrenItems;
|
||||||
|
|
||||||
|
children.clear();
|
||||||
LoadSubCatalogRunnable loader = new LoadSubCatalogRunnable(tree.Item, children);
|
LoadSubCatalogRunnable loader = new LoadSubCatalogRunnable(tree.Item, children);
|
||||||
loader.executeWithUI();
|
loader.executeWithUI();
|
||||||
if (loader.hasErrors()) {
|
if (loader.hasErrors()) {
|
||||||
|
@ -296,8 +297,8 @@ public class NetworkLibraryActivity extends ListActivity implements MenuItem.OnM
|
||||||
} else {
|
} else {
|
||||||
NetworkTreeFactory.fillAuthorNode(tree, children);
|
NetworkTreeFactory.fillAuthorNode(tree, children);
|
||||||
}
|
}
|
||||||
//NetworkLibrary.invalidateAccountDependents();
|
NetworkLibrary.Instance().invalidateAccountDependents();
|
||||||
//NetworkLibrary.synchronize();
|
NetworkLibrary.Instance().synchronize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ public class NetworkLibrary {
|
||||||
private final RootTree myRootTree = new RootTree();
|
private final RootTree myRootTree = new RootTree();
|
||||||
|
|
||||||
private boolean myUpdateChildren = true;
|
private boolean myUpdateChildren = true;
|
||||||
|
private boolean myUpdateAccountDependents;
|
||||||
|
|
||||||
private static class LinksComparator implements Comparator<NetworkLink> {
|
private static class LinksComparator implements Comparator<NetworkLink> {
|
||||||
public int compare(NetworkLink link1, NetworkLink link2) {
|
public int compare(NetworkLink link1, NetworkLink link2) {
|
||||||
|
@ -90,10 +91,14 @@ public class NetworkLibrary {
|
||||||
myUpdateChildren = true;
|
myUpdateChildren = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void invalidateAccountDependents() {
|
||||||
|
myUpdateAccountDependents = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void makeUpToDate() {
|
private void makeUpToDate() {
|
||||||
final LinkedList<FBTree> toRemove = new LinkedList<FBTree>();
|
final LinkedList<FBTree> toRemove = new LinkedList<FBTree>();
|
||||||
|
|
||||||
Iterator<FBTree> nodeIterator = myRootTree.iterator();
|
Iterator<FBTree> nodeIterator = myRootTree.subTrees().iterator();
|
||||||
FBTree currentNode = null;
|
FBTree currentNode = null;
|
||||||
int nodeCount = 0;
|
int nodeCount = 0;
|
||||||
|
|
||||||
|
@ -109,6 +114,7 @@ public class NetworkLibrary {
|
||||||
}
|
}
|
||||||
if (!(currentNode instanceof NetworkCatalogTree)) {
|
if (!(currentNode instanceof NetworkCatalogTree)) {
|
||||||
currentNode = null;
|
currentNode = null;
|
||||||
|
++nodeCount;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final NetworkLink nodeLink = ((NetworkCatalogTree)currentNode).Item.Link;
|
final NetworkLink nodeLink = ((NetworkCatalogTree)currentNode).Item.Link;
|
||||||
|
@ -165,7 +171,7 @@ public class NetworkLibrary {
|
||||||
NetworkNodesFactory::createSubnodes(srNode, result);
|
NetworkNodesFactory::createSubnodes(srNode, result);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
for (FBTree tree : toRemove) {
|
for (FBTree tree: toRemove) {
|
||||||
tree.removeSelf();
|
tree.removeSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,11 +181,24 @@ public class NetworkLibrary {
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateAccountDependents() {
|
||||||
|
for (FBTree tree: myRootTree.subTrees()) {
|
||||||
|
if (!(tree instanceof NetworkCatalogTree)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
((NetworkCatalogTree) tree).updateAccountDependents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void synchronize() {
|
public void synchronize() {
|
||||||
if (myUpdateChildren) {
|
if (myUpdateChildren) {
|
||||||
myUpdateChildren = false;
|
myUpdateChildren = false;
|
||||||
makeUpToDate();
|
makeUpToDate();
|
||||||
}
|
}
|
||||||
|
if (myUpdateAccountDependents) {
|
||||||
|
myUpdateAccountDependents = false;
|
||||||
|
updateAccountDependents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkTree getTree() {
|
public NetworkTree getTree() {
|
||||||
|
|
|
@ -21,12 +21,15 @@ package org.geometerplus.fbreader.network.tree;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import org.geometerplus.zlibrary.core.util.ZLBoolean3;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.tree.FBTree;
|
||||||
import org.geometerplus.fbreader.network.*;
|
import org.geometerplus.fbreader.network.*;
|
||||||
|
|
||||||
public class NetworkCatalogTree extends NetworkTree {
|
public class NetworkCatalogTree extends NetworkTree {
|
||||||
|
|
||||||
public final NetworkCatalogItem Item;
|
public final NetworkCatalogItem Item;
|
||||||
|
public final ArrayList<NetworkLibraryItem> ChildrenItems = new ArrayList<NetworkLibraryItem>();
|
||||||
|
|
||||||
NetworkCatalogTree(RootTree parent, NetworkCatalogItem item, int position) {
|
NetworkCatalogTree(RootTree parent, NetworkCatalogItem item, int position) {
|
||||||
super(parent, position);
|
super(parent, position);
|
||||||
|
@ -50,4 +53,85 @@ public class NetworkCatalogTree extends NetworkTree {
|
||||||
}
|
}
|
||||||
return Item.Summary;
|
return Item.Summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean processAccountDependent(NetworkCatalogItem item) {
|
||||||
|
if (item.Visibility == NetworkCatalogItem.VISIBLE_ALWAYS) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final NetworkLink link = item.Link;
|
||||||
|
if (link.authenticationManager() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return link.authenticationManager().isAuthorised(true).Status != ZLBoolean3.B3_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateAccountDependents() {
|
||||||
|
final LinkedList<FBTree> toRemove = new LinkedList<FBTree>();
|
||||||
|
|
||||||
|
Iterator<FBTree> nodeIterator = subTrees().iterator();
|
||||||
|
FBTree currentNode = null;
|
||||||
|
int nodeCount = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < ChildrenItems.size(); ++i) {
|
||||||
|
NetworkLibraryItem currentItem = ChildrenItems.get(i);
|
||||||
|
if (!(currentItem instanceof NetworkCatalogItem)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
boolean processed = false;
|
||||||
|
while (currentNode != null || nodeIterator.hasNext()) {
|
||||||
|
if (currentNode == null) {
|
||||||
|
currentNode = nodeIterator.next();
|
||||||
|
}
|
||||||
|
if (!(currentNode instanceof NetworkCatalogTree)) {
|
||||||
|
currentNode = null;
|
||||||
|
++nodeCount;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
NetworkCatalogTree child = (NetworkCatalogTree) currentNode;
|
||||||
|
if (child.Item == currentItem) {
|
||||||
|
if (processAccountDependent(child.Item)) {
|
||||||
|
child.updateAccountDependents();
|
||||||
|
} else {
|
||||||
|
toRemove.add(child);
|
||||||
|
}
|
||||||
|
currentNode = null;
|
||||||
|
++nodeCount;
|
||||||
|
processed = true;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
boolean found = false;
|
||||||
|
for (int j = i + 1; j < ChildrenItems.size(); ++j) {
|
||||||
|
if (child.Item == ChildrenItems.get(j)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
toRemove.add(currentNode);
|
||||||
|
currentNode = null;
|
||||||
|
++nodeCount;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!processed && processAccountDependent((NetworkCatalogItem) currentItem)) {
|
||||||
|
NetworkTreeFactory.createNetworkTree(this, currentItem, nodeCount++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (currentNode != null || nodeIterator.hasNext()) {
|
||||||
|
if (currentNode == null) {
|
||||||
|
currentNode = nodeIterator.next();
|
||||||
|
}
|
||||||
|
if (currentNode instanceof NetworkCatalogTree) {
|
||||||
|
toRemove.add(currentNode);
|
||||||
|
}
|
||||||
|
currentNode = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (FBTree tree: toRemove) {
|
||||||
|
tree.removeSelf();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue