From f87cb81f3541a0f35314626dcfd7b2da37b16959 Mon Sep 17 00:00:00 2001 From: tonihei Date: Thu, 28 Feb 2019 16:02:24 +0000 Subject: [PATCH] Enable caching in internal demo app. So far it's only enabled in the external demo app. PiperOrigin-RevId: 236122825 --- .../exoplayer2/demo/DemoApplication.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/demos/main/src/main/java/com/google/android/exoplayer2/demo/DemoApplication.java b/demos/main/src/main/java/com/google/android/exoplayer2/demo/DemoApplication.java index 27033bb03e..f2d10807fb 100644 --- a/demos/main/src/main/java/com/google/android/exoplayer2/demo/DemoApplication.java +++ b/demos/main/src/main/java/com/google/android/exoplayer2/demo/DemoApplication.java @@ -102,6 +102,14 @@ public class DemoApplication extends Application { 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() { if (downloadManager == null) { DefaultDownloadIndex downloadIndex = new DefaultDownloadIndex(new ExoDatabaseProvider(this)); @@ -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() { if (downloadDirectory == null) { downloadDirectory = getExternalFilesDir(null); @@ -148,8 +148,8 @@ public class DemoApplication extends Application { return downloadDirectory; } - private static CacheDataSourceFactory buildReadOnlyCacheDataSource( - DefaultDataSourceFactory upstreamFactory, Cache cache) { + protected static CacheDataSourceFactory buildReadOnlyCacheDataSource( + DataSource.Factory upstreamFactory, Cache cache) { return new CacheDataSourceFactory( cache, upstreamFactory,