Commit f87cb81f by tonihei Committed by Oliver Woodman

Enable caching in internal demo app.

So far it's only enabled in the external demo app.

PiperOrigin-RevId: 236122825
parent cde6189c
...@@ -102,6 +102,14 @@ public class DemoApplication extends Application { ...@@ -102,6 +102,14 @@ public class DemoApplication extends Application {
return downloadTracker; return downloadTracker;
} }
protected synchronized Cache getDownloadCache() {
if (downloadCache == null) {
File downloadContentDirectory = new File(getDownloadDirectory(), DOWNLOAD_CONTENT_DIRECTORY);
downloadCache = new SimpleCache(downloadContentDirectory, new NoOpCacheEvictor());
}
return downloadCache;
}
private synchronized void initDownloadManager() { private synchronized void initDownloadManager() {
if (downloadManager == null) { if (downloadManager == null) {
DefaultDownloadIndex downloadIndex = new DefaultDownloadIndex(new ExoDatabaseProvider(this)); DefaultDownloadIndex downloadIndex = new DefaultDownloadIndex(new ExoDatabaseProvider(this));
...@@ -130,14 +138,6 @@ public class DemoApplication extends Application { ...@@ -130,14 +138,6 @@ public class DemoApplication extends Application {
} }
} }
private synchronized Cache getDownloadCache() {
if (downloadCache == null) {
File downloadContentDirectory = new File(getDownloadDirectory(), DOWNLOAD_CONTENT_DIRECTORY);
downloadCache = new SimpleCache(downloadContentDirectory, new NoOpCacheEvictor());
}
return downloadCache;
}
private File getDownloadDirectory() { private File getDownloadDirectory() {
if (downloadDirectory == null) { if (downloadDirectory == null) {
downloadDirectory = getExternalFilesDir(null); downloadDirectory = getExternalFilesDir(null);
...@@ -148,8 +148,8 @@ public class DemoApplication extends Application { ...@@ -148,8 +148,8 @@ public class DemoApplication extends Application {
return downloadDirectory; return downloadDirectory;
} }
private static CacheDataSourceFactory buildReadOnlyCacheDataSource( protected static CacheDataSourceFactory buildReadOnlyCacheDataSource(
DefaultDataSourceFactory upstreamFactory, Cache cache) { DataSource.Factory upstreamFactory, Cache cache) {
return new CacheDataSourceFactory( return new CacheDataSourceFactory(
cache, cache,
upstreamFactory, upstreamFactory,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment