1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 10:19:33 +02:00

Refresh catalogs button

git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@1683 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
Vasiliy Bout 2010-09-01 10:01:19 +00:00
parent af4852e1b0
commit 943f7cb314
15 changed files with 99 additions and 32 deletions

View file

@ -232,7 +232,7 @@ public class NetworkLibrary {
public String initialize() {
final LinksComparator comparator = new LinksComparator();
final String error = OPDSLinkReader.loadOPDSLinks(false, new OnNewLinkListener() {
final String error = OPDSLinkReader.loadOPDSLinks(OPDSLinkReader.CACHE_LOAD, new OnNewLinkListener() {
public void onNewLink(INetworkLink link) {
addLinkInternal(myLoadedLinks, link, comparator);
}
@ -295,11 +295,12 @@ public class NetworkLibrary {
private Object myBackgroundLock = new Object();
// This method must be called from background thread
public boolean runBackgroundUpdate() {
public String runBackgroundUpdate(boolean clearCache) {
synchronized (myBackgroundLock) {
myBackgroundLinks = new ArrayList<INetworkLink>();
final String error = OPDSLinkReader.loadOPDSLinks(true, new OnNewLinkListener() {
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);
}
@ -309,23 +310,21 @@ public class NetworkLibrary {
myBackgroundLinks = null;
}
if (myBackgroundLinks == null) {
return false;
} else {
if (myBackgroundLinks != null) {
Collections.sort(myBackgroundLinks, new LinksComparator());
return true;
}
return error;
}
}
// This method MUST be called from main thread
// This method can be called only after runBackgroundUpdate method has returned true
// This method has effect only when runBackgroundUpdate method has returned null.
//
// synchronize() method MUST be called after this method
public void finishBackgroundUpdate() {
synchronized (myBackgroundLock) {
if (myBackgroundLinks == null) {
throw new RuntimeException("Invalid state: that's impossible!!!");
return;
}
synchronized (myLinks) {
myLoadedLinks.clear();