mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 02:09:35 +02:00
see previous comment
This commit is contained in:
parent
87ef3e2063
commit
b2f140c612
20 changed files with 231 additions and 265 deletions
|
@ -23,8 +23,9 @@ import java.util.*;
|
|||
|
||||
import org.geometerplus.zlibrary.core.util.ZLNetworkUtil;
|
||||
import org.geometerplus.zlibrary.core.options.ZLStringOption;
|
||||
import org.geometerplus.zlibrary.core.network.ZLNetworkRequest;
|
||||
import org.geometerplus.zlibrary.core.network.ZLNetworkManager;
|
||||
import org.geometerplus.zlibrary.core.network.ZLNetworkException;
|
||||
import org.geometerplus.zlibrary.core.network.ZLNetworkRequest;
|
||||
|
||||
import org.geometerplus.fbreader.tree.FBTree;
|
||||
import org.geometerplus.fbreader.network.tree.*;
|
||||
|
@ -226,20 +227,20 @@ public class NetworkLibrary {
|
|||
myLinks = new CompositeList(linksList, new LinksComparator());
|
||||
}
|
||||
|
||||
public String initialize() {
|
||||
public void initialize() throws ZLNetworkException {
|
||||
final LinksComparator comparator = new LinksComparator();
|
||||
|
||||
final String error = OPDSLinkReader.loadOPDSLinks(OPDSLinkReader.CACHE_LOAD, new OnNewLinkListener() {
|
||||
public void onNewLink(INetworkLink link) {
|
||||
addLinkInternal(myLoadedLinks, link, comparator);
|
||||
}
|
||||
});
|
||||
|
||||
if (error != null) {
|
||||
try {
|
||||
OPDSLinkReader.loadOPDSLinks(OPDSLinkReader.CACHE_LOAD, new OnNewLinkListener() {
|
||||
public void onNewLink(INetworkLink link) {
|
||||
addLinkInternal(myLoadedLinks, link, comparator);
|
||||
}
|
||||
});
|
||||
} catch (ZLNetworkException e) {
|
||||
synchronized (myLinks) {
|
||||
myLoadedLinks.clear();
|
||||
}
|
||||
return error;
|
||||
throw e;
|
||||
}
|
||||
|
||||
NetworkDatabase.Instance().loadCustomLinks(
|
||||
|
@ -273,8 +274,6 @@ public class NetworkLibrary {
|
|||
new ATOMUpdated(2012, 2, 15, 23, 40, 1, 0, 3, 30));
|
||||
testDate(new ATOMUpdated(2012, 2, 15, 23, 40, 0, 0.001f, 3, 30),
|
||||
new ATOMUpdated(2012, 2, 15, 23, 40, 0, 0, 3, 30));*/
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/*private void testDate(ATOMDateConstruct date1, ATOMDateConstruct date2) {
|
||||
|
@ -292,25 +291,29 @@ public class NetworkLibrary {
|
|||
private Object myBackgroundLock = new Object();
|
||||
|
||||
// This method must be called from background thread
|
||||
public String runBackgroundUpdate(boolean clearCache) {
|
||||
public void runBackgroundUpdate(boolean clearCache) throws ZLNetworkException {
|
||||
synchronized (myBackgroundLock) {
|
||||
myBackgroundLinks = new ArrayList<INetworkLink>();
|
||||
|
||||
final int cacheMode = clearCache ? OPDSLinkReader.CACHE_CLEAR : OPDSLinkReader.CACHE_UPDATE;
|
||||
final String error = OPDSLinkReader.loadOPDSLinks(cacheMode, new OnNewLinkListener() {
|
||||
public void onNewLink(INetworkLink link) {
|
||||
myBackgroundLinks.add(link);
|
||||
}
|
||||
});
|
||||
|
||||
if (error != null || myBackgroundLinks.isEmpty()) {
|
||||
try {
|
||||
OPDSLinkReader.loadOPDSLinks(cacheMode, new OnNewLinkListener() {
|
||||
public void onNewLink(INetworkLink link) {
|
||||
myBackgroundLinks.add(link);
|
||||
}
|
||||
});
|
||||
} catch (ZLNetworkException e) {
|
||||
myBackgroundLinks = null;
|
||||
throw e;
|
||||
} finally {
|
||||
if (myBackgroundLinks != null) {
|
||||
if (myBackgroundLinks.isEmpty()) {
|
||||
myBackgroundLinks = null;
|
||||
} else {
|
||||
Collections.sort(myBackgroundLinks, new LinksComparator());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (myBackgroundLinks != null) {
|
||||
Collections.sort(myBackgroundLinks, new LinksComparator());
|
||||
}
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue