mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 19:42:17 +02:00
summary code simplified; basket summary code is always up-to-date
This commit is contained in:
parent
5e0a0201a8
commit
53a9de5926
10 changed files with 14 additions and 33 deletions
|
@ -89,7 +89,7 @@ class LibraryTreeAdapter extends TreeAdapter {
|
|||
LayoutInflater.from(parent.getContext()).inflate(R.layout.library_tree_item, parent, false);
|
||||
|
||||
((TextView)view.findViewById(R.id.library_tree_item_name)).setText(tree.getName());
|
||||
((TextView)view.findViewById(R.id.library_tree_item_childrenlist)).setText(tree.getSecondString());
|
||||
((TextView)view.findViewById(R.id.library_tree_item_childrenlist)).setText(tree.getSummary());
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
|
@ -337,12 +337,6 @@ public class NetworkLibraryActivity extends TreeActivity implements NetworkLibra
|
|||
|
||||
getListAdapter().replaceAll(getCurrentTree().subTrees());
|
||||
getListView().invalidateViews();
|
||||
|
||||
for (FBTree child : getCurrentTree().subTrees()) {
|
||||
if (child instanceof TopUpTree) {
|
||||
child.invalidateSummary();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class NetworkLibraryAdapter extends TreeAdapter {
|
|||
LayoutInflater.from(parent.getContext()).inflate(R.layout.network_tree_item, parent, false);
|
||||
|
||||
((TextView)view.findViewById(R.id.network_tree_item_name)).setText(tree.getName());
|
||||
((TextView)view.findViewById(R.id.network_tree_item_childrenlist)).setText(tree.getSecondString());
|
||||
((TextView)view.findViewById(R.id.network_tree_item_childrenlist)).setText(tree.getSummary());
|
||||
|
||||
if (myCoverWidth == -1) {
|
||||
view.measure(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
|
|
@ -44,11 +44,11 @@ public class FirstLevelTree extends LibraryTree {
|
|||
|
||||
@Override
|
||||
public String getTreeTitle() {
|
||||
return getSecondString();
|
||||
return getSummary();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSummary() {
|
||||
public String getSummary() {
|
||||
return myResource.getResource("summary").getValue();
|
||||
}
|
||||
|
||||
|
|
|
@ -113,9 +113,6 @@ public abstract class LibraryTree extends FBTree {
|
|||
parent.removeSelf();
|
||||
}
|
||||
}
|
||||
for (; parent != null; parent = parent.Parent) {
|
||||
((LibraryTree)parent).invalidateSummary();
|
||||
}
|
||||
}
|
||||
return !toRemove.isEmpty();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class SearchResultsTree extends FirstLevelTree {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String getSummary() {
|
||||
public String getSummary() {
|
||||
return super.getSummary().replace("%s", myPattern);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,6 +120,7 @@ public abstract class AbstractNetworkLink implements INetworkLink, Basket {
|
|||
ids = new ArrayList<String>(ids);
|
||||
ids.add(book.Id);
|
||||
myBooksInBasketOption.setValue(ids);
|
||||
NetworkLibrary.Instance().fireModelChangedEvent(NetworkLibrary.ChangeListener.Code.SomeCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,6 +133,7 @@ public abstract class AbstractNetworkLink implements INetworkLink, Basket {
|
|||
ids = new ArrayList<String>(ids);
|
||||
ids.remove(book.Id);
|
||||
myBooksInBasketOption.setValue(ids);
|
||||
NetworkLibrary.Instance().fireModelChangedEvent(NetworkLibrary.ChangeListener.Code.SomeCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,6 +141,7 @@ public abstract class AbstractNetworkLink implements INetworkLink, Basket {
|
|||
// method from Basket interface
|
||||
public final void clear() {
|
||||
myBooksInBasketOption.setValue(null);
|
||||
NetworkLibrary.Instance().fireModelChangedEvent(NetworkLibrary.ChangeListener.Code.SomeCode);
|
||||
}
|
||||
|
||||
// method from Basket interface
|
||||
|
|
|
@ -69,7 +69,6 @@ public class NetworkAuthorTree extends NetworkTree {
|
|||
if (myBooksNumber >= books.size()) {
|
||||
return;
|
||||
}
|
||||
invalidateSummary();
|
||||
|
||||
ListIterator<NetworkBookItem> booksIterator = books.listIterator(myBooksNumber);
|
||||
while (booksIterator.hasNext()) {
|
||||
|
@ -108,7 +107,6 @@ public class NetworkAuthorTree extends NetworkTree {
|
|||
}
|
||||
++insertAt;
|
||||
}
|
||||
seriesTree.invalidateSummary();
|
||||
new NetworkBookTree(seriesTree, book, insertAt, false);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -36,4 +36,9 @@ public class SearchCatalogTree extends NetworkCatalogTree {
|
|||
public SearchCatalogTree getSearchTree() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTreeTitle() {
|
||||
return getSummary();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,23 +146,7 @@ public abstract class FBTree extends ZLTree<FBTree> implements Comparable<FBTree
|
|||
return key0.toLowerCase().compareTo(key1.toLowerCase());
|
||||
}
|
||||
|
||||
private String mySecondString;
|
||||
|
||||
public final void invalidateSummary() {
|
||||
mySecondString = null;
|
||||
}
|
||||
|
||||
public final String getSecondString() {
|
||||
if (mySecondString == null) {
|
||||
mySecondString = getSummary();
|
||||
if (mySecondString == null) {
|
||||
mySecondString = "";
|
||||
}
|
||||
}
|
||||
return mySecondString;
|
||||
}
|
||||
|
||||
protected String getSummary() {
|
||||
public String getSummary() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
int count = 0;
|
||||
for (FBTree subtree : subTrees()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue