X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2FDataLoader.java;h=3e0e7704e8e93068d93b7454a25e7f5fffb311f1;hp=d342580614c4a8441efcd967ad4ce37ed9c9879c;hb=f1ce03f76073d9ba0777d0f47058d614577fbe2e;hpb=8d59ce0748baeeea0458bab49716ab4543aae439 diff --git a/src/be/nikiroo/fanfix/DataLoader.java b/src/be/nikiroo/fanfix/DataLoader.java index d342580..3e0e770 100644 --- a/src/be/nikiroo/fanfix/DataLoader.java +++ b/src/be/nikiroo/fanfix/DataLoader.java @@ -28,6 +28,7 @@ public class DataLoader { private Downloader downloader; private Downloader downloaderNoCache; private Cache cache; + private boolean offline; /** * Create a new {@link DataLoader} object. @@ -69,6 +70,41 @@ public class DataLoader { downloaderNoCache = downloader; cache = new CacheMemory(); } + + /** + * This {@link Downloader} is forbidden to try and connect to the network. + *

+ * If TRUE, it will only check the cache (even in no-cache mode!). + *

+ * Default is FALSE. + * + * @return TRUE if offline + */ + public boolean isOffline() { + return offline; + } + + /** + * This {@link Downloader} is forbidden to try and connect to the network. + *

+ * If TRUE, it will only check the cache (even in no-cache mode!). + *

+ * Default is FALSE. + * + * @param offline TRUE for offline, FALSE for online + */ + public void setOffline(boolean offline) { + this.offline = offline; + downloader.setOffline(offline); + downloaderNoCache.setOffline(offline); + + // If we don't, we cannot support no-cache using code in OFFLINE mode + if (offline) { + downloaderNoCache.setCache(cache); + } else { + downloaderNoCache.setCache(null); + } + } /** * The traces handler for this {@link Cache}.