mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-06 03:50:19 +02:00
Memory usage fix: 9MB --> 6MB
git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@1171 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
17c0ee0145
commit
32f8462eb2
6 changed files with 33 additions and 26 deletions
|
@ -54,6 +54,9 @@ class NetworkCatalogActions extends NetworkTreeActions {
|
||||||
|
|
||||||
private ZLTreeAdapter myAdapter;
|
private ZLTreeAdapter myAdapter;
|
||||||
|
|
||||||
|
private int dbgCatalogsCounter;
|
||||||
|
private int dbgBooksCounter;
|
||||||
|
|
||||||
public NetworkCatalogActions(NetworkLibraryActivity activity, ZLTreeAdapter adapter) {
|
public NetworkCatalogActions(NetworkLibraryActivity activity, ZLTreeAdapter adapter) {
|
||||||
super(activity);
|
super(activity);
|
||||||
myAdapter = adapter;
|
myAdapter = adapter;
|
||||||
|
@ -221,9 +224,13 @@ class NetworkCatalogActions extends NetworkTreeActions {
|
||||||
tree.ChildrenItems.add(item);
|
tree.ChildrenItems.add(item);
|
||||||
NetworkTreeFactory.createNetworkTree(tree, item);
|
NetworkTreeFactory.createNetworkTree(tree, item);
|
||||||
tree.updateAccountDependents();
|
tree.updateAccountDependents();
|
||||||
if (!hasMessages(0)) {
|
|
||||||
myAdapter.resetTree();
|
if (item instanceof NetworkCatalogItem) {
|
||||||
|
++dbgCatalogsCounter;
|
||||||
|
} if (item instanceof NetworkBookItem) {
|
||||||
|
++dbgBooksCounter;
|
||||||
}
|
}
|
||||||
|
myAdapter.resetTree();
|
||||||
if (expand) {
|
if (expand) {
|
||||||
// If catalog loading started => Tree must be expanded after the first item has been loaded
|
// If catalog loading started => Tree must be expanded after the first item has been loaded
|
||||||
myAdapter.expandOrCollapseTree(tree);
|
myAdapter.expandOrCollapseTree(tree);
|
||||||
|
@ -234,6 +241,8 @@ class NetworkCatalogActions extends NetworkTreeActions {
|
||||||
public void handleMessage(Message message) {
|
public void handleMessage(Message message) {
|
||||||
afterUpdateCatalog((String) message.obj, tree.ChildrenItems.size() == 0);
|
afterUpdateCatalog((String) message.obj, tree.ChildrenItems.size() == 0);
|
||||||
endProgressNotification(tree);
|
endProgressNotification(tree);
|
||||||
|
System.err.println("FBREADER -- dbgCatalogsCounter = " + dbgCatalogsCounter);
|
||||||
|
System.err.println("FBREADER -- dbgBooksCounter = " + dbgBooksCounter);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
|
@ -281,9 +290,7 @@ class NetworkCatalogActions extends NetworkTreeActions {
|
||||||
tree.ChildrenItems.add(item);
|
tree.ChildrenItems.add(item);
|
||||||
NetworkTreeFactory.createNetworkTree(tree, item);
|
NetworkTreeFactory.createNetworkTree(tree, item);
|
||||||
tree.updateAccountDependents();
|
tree.updateAccountDependents();
|
||||||
if (!hasMessages(0)) {
|
myAdapter.resetTree();
|
||||||
myAdapter.resetTree();
|
|
||||||
}
|
|
||||||
if (expand) {
|
if (expand) {
|
||||||
// If catalog loading started => Tree must be expanded after the first item has been loaded
|
// If catalog loading started => Tree must be expanded after the first item has been loaded
|
||||||
myAdapter.expandOrCollapseTree(tree);
|
myAdapter.expandOrCollapseTree(tree);
|
||||||
|
|
|
@ -38,8 +38,8 @@ public class NetworkBookItem extends NetworkLibraryItem {
|
||||||
* @param sortKey string that defines sorting order of book's authors. Must be not <code>null</code>.
|
* @param sortKey string that defines sorting order of book's authors. Must be not <code>null</code>.
|
||||||
*/
|
*/
|
||||||
public AuthorData(String displayName, String sortKey) {
|
public AuthorData(String displayName, String sortKey) {
|
||||||
DisplayName = displayName;
|
DisplayName = displayName.intern();
|
||||||
SortKey = sortKey;
|
SortKey = sortKey.intern();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(AuthorData data) {
|
public int compareTo(AuthorData data) {
|
||||||
|
@ -67,10 +67,10 @@ public class NetworkBookItem extends NetworkLibraryItem {
|
||||||
|
|
||||||
public final int Index;
|
public final int Index;
|
||||||
public final String Id;
|
public final String Id;
|
||||||
public final String Language;
|
//public final String Language;
|
||||||
public final String Date;
|
//public final String Date;
|
||||||
public final List<AuthorData> Authors;
|
public final LinkedList<AuthorData> Authors;
|
||||||
public final List<String> Tags;
|
//public final LinkedList<String> Tags;
|
||||||
public final String SeriesTitle;
|
public final String SeriesTitle;
|
||||||
public final int IndexInSeries;
|
public final int IndexInSeries;
|
||||||
|
|
||||||
|
@ -84,27 +84,27 @@ public class NetworkBookItem extends NetworkLibraryItem {
|
||||||
* @param index sequence number of this book in corresponding catalog
|
* @param index sequence number of this book in corresponding catalog
|
||||||
* @param title title of this book. Must be not <code>null</code>.
|
* @param title title of this book. Must be not <code>null</code>.
|
||||||
* @param summary description of this book. Can be <code>null</code>.
|
* @param summary description of this book. Can be <code>null</code>.
|
||||||
* @param langage string specifies language of this book. Can be <code>null</code>.
|
* //@param langage string specifies language of this book. Can be <code>null</code>.
|
||||||
* @param date string specifies release date of this book. Can be <code>null</code>.
|
* //@param date string specifies release date of this book. Can be <code>null</code>.
|
||||||
* @param authors list of book authors. Should contain at least one author.
|
* @param authors list of book authors. Should contain at least one author.
|
||||||
* @param tags list of book tags. Must be not <code>null</code> (can be empty).
|
* //@param tags list of book tags. Must be not <code>null</code> (can be empty).
|
||||||
* @param seriesTitle title of this book's series. Can be <code>null</code>.
|
* @param seriesTitle title of this book's series. Can be <code>null</code>.
|
||||||
* @param indexInSeries sequence number of this book within book's series. Ignored if seriesTitle is <code>null</code>.
|
* @param indexInSeries sequence number of this book within book's series. Ignored if seriesTitle is <code>null</code>.
|
||||||
* @param linkByType map contains URLs and their types. Must be not <code>null</code>.
|
* @param linkByType map contains URLs and their types. Must be not <code>null</code>.
|
||||||
* @param references list of references related to this book. Must be not <code>null</code>.
|
* @param references list of references related to this book. Must be not <code>null</code>.
|
||||||
*/
|
*/
|
||||||
public NetworkBookItem(NetworkLink link, String id, int index,
|
public NetworkBookItem(NetworkLink link, String id, int index,
|
||||||
String title, String summary, String language, String date,
|
String title, String summary, /*String language, String date,*/
|
||||||
List<AuthorData> authors, List<String> tags, String seriesTitle, int indexInSeries,
|
List<AuthorData> authors, /*List<String> tags,*/ String seriesTitle, int indexInSeries,
|
||||||
Map<Integer, Link> linkByType,
|
Map<Integer, Link> linkByType,
|
||||||
List<BookReference> references) {
|
List<BookReference> references) {
|
||||||
super(link, title, summary, linkByType);
|
super(link, title, summary, linkByType);
|
||||||
Index = index;
|
Index = index;
|
||||||
Id = id;
|
Id = id;
|
||||||
Language = language;
|
//Language = language;
|
||||||
Date = date;
|
//Date = date;
|
||||||
Authors = new LinkedList<AuthorData>(authors);
|
Authors = new LinkedList<AuthorData>(authors);
|
||||||
Tags = new LinkedList<String>(tags);
|
//Tags = new LinkedList<String>(tags);
|
||||||
SeriesTitle = seriesTitle;
|
SeriesTitle = seriesTitle;
|
||||||
IndexInSeries = indexInSeries;
|
IndexInSeries = indexInSeries;
|
||||||
myReferences = new LinkedList(references);
|
myReferences = new LinkedList(references);
|
||||||
|
|
|
@ -46,7 +46,7 @@ public abstract class NetworkTree extends FBTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ZLImage createCover(String url, String mimeType) {
|
public static ZLImage createCover(String url, String mimeType) {
|
||||||
if (url == null) {
|
/*if (url == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (mimeType == null) {
|
if (mimeType == null) {
|
||||||
|
@ -74,7 +74,7 @@ public abstract class NetworkTree extends FBTree {
|
||||||
img.setData(url.substring(commaIndex + 1));
|
img.setData(url.substring(commaIndex + 1));
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,10 +260,10 @@ class NetworkOPDSFeedReader implements OPDSFeedReader {
|
||||||
myIndex++,
|
myIndex++,
|
||||||
entry.Title,
|
entry.Title,
|
||||||
entry.Summary,
|
entry.Summary,
|
||||||
entry.DCLanguage,
|
//entry.DCLanguage,
|
||||||
date,
|
//date,
|
||||||
authors,
|
authors,
|
||||||
tags,
|
//tags,
|
||||||
entry.SeriesTitle,
|
entry.SeriesTitle,
|
||||||
entry.SeriesIndex,
|
entry.SeriesIndex,
|
||||||
urlMap,
|
urlMap,
|
||||||
|
|
|
@ -367,7 +367,7 @@ class OPDSXMLReader extends ZLXMLReaderAdapter {
|
||||||
tag = tag.intern();
|
tag = tag.intern();
|
||||||
}
|
}
|
||||||
|
|
||||||
String bufferContent = myBuffer.toString().trim();
|
String bufferContent = myBuffer.toString().trim().intern();
|
||||||
if (bufferContent.length() == 0) {
|
if (bufferContent.length() == 0) {
|
||||||
bufferContent = null;
|
bufferContent = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ public abstract class FBTree extends ZLTree<FBTree> implements Comparable<FBTree
|
||||||
public final ZLImage getCover() {
|
public final ZLImage getCover() {
|
||||||
if (!myCoverRequested) {
|
if (!myCoverRequested) {
|
||||||
myCover = createCover();
|
myCover = createCover();
|
||||||
if (myCover == null) {
|
if (myCover == null && Parent != null) {
|
||||||
myCover = Parent.getCover();
|
myCover = Parent.getCover();
|
||||||
}
|
}
|
||||||
myCoverRequested = true;
|
myCoverRequested = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue