From 2e8ab000dd2544c413b22e7a61d0c3aa82b694a0 Mon Sep 17 00:00:00 2001 From: Hari Lamichhane Date: Wed, 11 May 2022 12:22:38 +0545 Subject: [PATCH 1/4] Update dependencies --- build.gradle | 7 +++-- gradle/wrapper/gradle-wrapper.properties | 6 ++-- library/build.gradle | 30 +++++++++---------- .../videocache/ProxyCacheException.java | 2 +- sample/build.gradle | 20 ++++--------- test/build.gradle | 16 +++++----- 6 files changed, 36 insertions(+), 45 deletions(-) diff --git a/build.gradle b/build.gradle index 8ccd9c97..9f27f01e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,15 @@ buildscript { repositories { - jcenter() + google() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.1' + classpath 'com.android.tools.build:gradle:7.0.4' } } allprojects { repositories { - jcenter() + google() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3c115268..d43a1018 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Apr 18 11:58:38 MSK 2017 +#Wed May 11 11:59:53 NPT 2022 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +zipStoreBase=GRADLE_USER_HOME diff --git a/library/build.gradle b/library/build.gradle index 15dbe3df..a5ab94e7 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,23 +1,20 @@ buildscript { repositories { - jcenter() } dependencies { - classpath 'com.novoda:bintray-release:0.4.0' } } apply plugin: 'com.android.library' apply plugin: 'idea' -apply plugin: 'bintray-release' +apply plugin: 'maven-publish' android { - compileSdkVersion 23 - buildToolsVersion '25.0.2' + compileSdkVersion 31 defaultConfig { - minSdkVersion 9 - targetSdkVersion 23 + minSdkVersion 21 + targetSdkVersion 31 versionCode 22 versionName '2.7.1' } @@ -36,14 +33,15 @@ idea { } dependencies { - compile 'org.slf4j:slf4j-android:1.7.21' + implementation 'org.slf4j:slf4j-android:1.7.21' } -publish { - userOrg = 'alexeydanilov' - groupId = 'com.danikula' - artifactId = 'videocache' - publishVersion = android.defaultConfig.versionName - description = 'Cache support for android VideoView' - website = 'https://github.com/danikula/AndroidVideoCache' -} +publishing { + publications { + maven(MavenPublication) { + groupId = 'com.danikula' + artifactId = 'videocache' + version = '2.8.0' + } + } +} \ No newline at end of file diff --git a/library/src/main/java/com/danikula/videocache/ProxyCacheException.java b/library/src/main/java/com/danikula/videocache/ProxyCacheException.java index af13246d..0af8a0f3 100644 --- a/library/src/main/java/com/danikula/videocache/ProxyCacheException.java +++ b/library/src/main/java/com/danikula/videocache/ProxyCacheException.java @@ -7,7 +7,7 @@ */ public class ProxyCacheException extends Exception { - private static final String LIBRARY_VERSION = ". Version: " + BuildConfig.VERSION_NAME; + private static final String LIBRARY_VERSION = ". Version: " + BuildConfig.LIBRARY_PACKAGE_NAME; public ProxyCacheException(String message) { super(message + LIBRARY_VERSION); diff --git a/sample/build.gradle b/sample/build.gradle index 2e337905..b3eca93d 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,9 +1,8 @@ buildscript { repositories { - jcenter() + mavenCentral() } dependencies { - classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' } } @@ -12,7 +11,6 @@ repositories { } apply plugin: 'com.android.application' -apply plugin: 'com.neenbedankt.android-apt' android { compileSdkVersion 23 @@ -27,18 +25,12 @@ android { } } -apt { - arguments { - androidManifestFile variant.outputs[0].processResources.manifestFile - resourcePackageName android.defaultConfig.applicationId - } -} + dependencies { // compile project(':library') - compile 'com.android.support:support-v4:23.1.0' - compile 'org.androidannotations:androidannotations-api:3.3.2' - compile 'com.danikula:videocache:2.7.1' - compile 'com.viewpagerindicator:library:2.4.2-SNAPSHOT@aar' - apt 'org.androidannotations:androidannotations:3.3.2' + implementation 'com.android.support:support-v4:23.1.0' + implementation 'org.androidannotations:androidannotations-api:3.3.2' + implementation 'com.danikula:videocache:2.7.1' + implementation 'com.viewpagerindicator:library:2.4.2-SNAPSHOT@aar' } diff --git a/test/build.gradle b/test/build.gradle index 5dd2ee7d..c23fd6a2 100644 --- a/test/build.gradle +++ b/test/build.gradle @@ -58,14 +58,14 @@ tasks.withType(Test) { } dependencies { - compile project(':library') - testCompile 'org.slf4j:slf4j-simple:1.7.21' - testCompile 'junit:junit:4.12' - testCompile 'org.robolectric:robolectric:3.3.2' - testCompile 'com.squareup:fest-android:1.0.0' - testCompile 'com.google.guava:guava-jdk5:17.0' - testCompile('com.danikula:android-garden:2.1.4') { + implementation project(':library') + testImplementation 'org.slf4j:slf4j-simple:1.7.21' + testImplementation 'junit:junit:4.12' + testImplementation 'org.robolectric:robolectric:3.3.2' + testImplementation 'com.squareup:fest-android:1.0.0' + testImplementation 'com.google.guava:guava-jdk5:17.0' + testImplementation('com.danikula:android-garden:2.1.4') { exclude group: 'com.google.android' } - testCompile 'org.mockito:mockito-all:1.9.5' + testImplementation 'org.mockito:mockito-all:1.9.5' } From a563c7161f051922f88ab0deeaa208102e5024b1 Mon Sep 17 00:00:00 2001 From: Hari Lamichhane Date: Wed, 11 May 2022 12:28:54 +0545 Subject: [PATCH 2/4] Define repos --- library/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/build.gradle b/library/build.gradle index a5ab94e7..29fb4e4c 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,5 +1,7 @@ buildscript { repositories { + google() + mavenCentral() } dependencies { } From 9e5291cf370072023bbb7a0496556b9f7b0b3e0f Mon Sep 17 00:00:00 2001 From: Hari Lamichhane Date: Wed, 11 May 2022 12:37:45 +0545 Subject: [PATCH 3/4] Update logger --- library/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/build.gradle b/library/build.gradle index 29fb4e4c..b54761d2 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -35,7 +35,7 @@ idea { } dependencies { - implementation 'org.slf4j:slf4j-android:1.7.21' + implementation 'org.slf4j:slf4j-android:1.7.36' } publishing { From 3d8b35995d4d441204b3cb321a353fb9a1e417a3 Mon Sep 17 00:00:00 2001 From: Hari Lamichhane Date: Wed, 11 May 2022 13:06:11 +0545 Subject: [PATCH 4/4] Fix build issues locally --- build.gradle | 3 +- library/build.gradle | 1 - .../videocache/HttpProxyCacheServer.java | 29 +- .../danikula/videocache/HttpUrlSource.java | 19 +- .../java/com/danikula/videocache/Pinger.java | 15 +- .../com/danikula/videocache/ProxyCache.java | 11 +- .../danikula/videocache/ProxyCacheUtils.java | 7 +- .../com/danikula/videocache/StorageUtils.java | 9 +- .../com/danikula/videocache/file/Files.java | 7 +- .../videocache/file/LruDiskUsage.java | 9 +- sample/build.gradle | 36 -- sample/src/main/AndroidManifest.xml | 29 -- .../com/danikula/videocache/sample/App.java | 25 -- .../sample/GalleryVideoFragment.java | 130 ------ .../videocache/sample/MenuActivity.java | 76 ---- .../sample/MultipleVideosActivity.java | 29 -- .../sample/SharedCacheActivity.java | 29 -- .../sample/SingleVideoActivity.java | 22 - .../com/danikula/videocache/sample/Utils.java | 53 --- .../com/danikula/videocache/sample/Video.java | 20 - .../videocache/sample/VideoFragment.java | 124 ------ .../sample/VideoGalleryActivity.java | 49 --- .../main/res/drawable-hdpi/ic_cloud_done.png | Bin 379 -> 0 bytes .../res/drawable-hdpi/ic_cloud_download.png | Bin 353 -> 0 bytes .../main/res/drawable-mdpi/ic_cloud_done.png | Bin 265 -> 0 bytes .../res/drawable-mdpi/ic_cloud_download.png | Bin 242 -> 0 bytes .../main/res/drawable-xhdpi/ic_cloud_done.png | Bin 449 -> 0 bytes .../res/drawable-xhdpi/ic_cloud_download.png | Bin 417 -> 0 bytes .../res/drawable-xxhdpi/ic_cloud_done.png | Bin 672 -> 0 bytes .../res/drawable-xxhdpi/ic_cloud_download.png | Bin 610 -> 0 bytes .../res/drawable-xxxhdpi/ic_cloud_done.png | Bin 855 -> 0 bytes .../drawable-xxxhdpi/ic_cloud_download.png | Bin 789 -> 0 bytes sample/src/main/res/layout/activity_menu.xml | 23 - .../res/layout/activity_multiple_videos.xml | 58 --- .../main/res/layout/activity_single_video.xml | 7 - .../res/layout/activity_video_gallery.xml | 23 - sample/src/main/res/layout/fragment_video.xml | 30 -- .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 7718 -> 0 bytes sample/src/main/res/values/strings.xml | 3 - test/build.gradle | 71 --- test/src/main/AndroidManifest.xml | 10 - test/src/main/assets/android.jpg | Bin 4768 -> 0 bytes test/src/main/assets/phones.jpg | Bin 94363 -> 0 bytes test/src/main/assets/space.jpg | Bin 1079020 -> 0 bytes .../com/danikula/videocache/BaseTest.java | 17 - .../videocache/FileNameGeneratorTest.java | 73 ---- .../danikula/videocache/GetRequestTest.java | 69 --- .../videocache/HttpProxyCacheServerTest.java | 410 ------------------ .../videocache/HttpProxyCacheTest.java | 259 ----------- .../videocache/HttpUrlSourceTest.java | 180 -------- .../com/danikula/videocache/PingerTest.java | 82 ---- .../danikula/videocache/ProxyCacheTest.java | 180 -------- .../videocache/ProxySelectorTest.java | 54 --- .../videocache/file/DiskUsageTest.java | 117 ----- .../videocache/file/FileCacheTest.java | 189 -------- .../danikula/videocache/file/FilesTest.java | 57 --- .../sourcestorage/SourceInfoStorageTest.java | 84 ---- .../support/ProxyCacheTestUtils.java | 176 -------- .../danikula/videocache/support/Response.java | 67 --- 59 files changed, 51 insertions(+), 2920 deletions(-) delete mode 100644 sample/build.gradle delete mode 100644 sample/src/main/AndroidManifest.xml delete mode 100644 sample/src/main/java/com/danikula/videocache/sample/App.java delete mode 100644 sample/src/main/java/com/danikula/videocache/sample/GalleryVideoFragment.java delete mode 100644 sample/src/main/java/com/danikula/videocache/sample/MenuActivity.java delete mode 100644 sample/src/main/java/com/danikula/videocache/sample/MultipleVideosActivity.java delete mode 100644 sample/src/main/java/com/danikula/videocache/sample/SharedCacheActivity.java delete mode 100644 sample/src/main/java/com/danikula/videocache/sample/SingleVideoActivity.java delete mode 100644 sample/src/main/java/com/danikula/videocache/sample/Utils.java delete mode 100644 sample/src/main/java/com/danikula/videocache/sample/Video.java delete mode 100644 sample/src/main/java/com/danikula/videocache/sample/VideoFragment.java delete mode 100644 sample/src/main/java/com/danikula/videocache/sample/VideoGalleryActivity.java delete mode 100644 sample/src/main/res/drawable-hdpi/ic_cloud_done.png delete mode 100644 sample/src/main/res/drawable-hdpi/ic_cloud_download.png delete mode 100644 sample/src/main/res/drawable-mdpi/ic_cloud_done.png delete mode 100644 sample/src/main/res/drawable-mdpi/ic_cloud_download.png delete mode 100644 sample/src/main/res/drawable-xhdpi/ic_cloud_done.png delete mode 100644 sample/src/main/res/drawable-xhdpi/ic_cloud_download.png delete mode 100644 sample/src/main/res/drawable-xxhdpi/ic_cloud_done.png delete mode 100644 sample/src/main/res/drawable-xxhdpi/ic_cloud_download.png delete mode 100644 sample/src/main/res/drawable-xxxhdpi/ic_cloud_done.png delete mode 100644 sample/src/main/res/drawable-xxxhdpi/ic_cloud_download.png delete mode 100644 sample/src/main/res/layout/activity_menu.xml delete mode 100644 sample/src/main/res/layout/activity_multiple_videos.xml delete mode 100644 sample/src/main/res/layout/activity_single_video.xml delete mode 100644 sample/src/main/res/layout/activity_video_gallery.xml delete mode 100644 sample/src/main/res/layout/fragment_video.xml delete mode 100644 sample/src/main/res/mipmap-xxhdpi/ic_launcher.png delete mode 100644 sample/src/main/res/values/strings.xml delete mode 100644 test/build.gradle delete mode 100644 test/src/main/AndroidManifest.xml delete mode 100644 test/src/main/assets/android.jpg delete mode 100644 test/src/main/assets/phones.jpg delete mode 100644 test/src/main/assets/space.jpg delete mode 100644 test/src/test/java/com/danikula/videocache/BaseTest.java delete mode 100644 test/src/test/java/com/danikula/videocache/FileNameGeneratorTest.java delete mode 100644 test/src/test/java/com/danikula/videocache/GetRequestTest.java delete mode 100644 test/src/test/java/com/danikula/videocache/HttpProxyCacheServerTest.java delete mode 100644 test/src/test/java/com/danikula/videocache/HttpProxyCacheTest.java delete mode 100644 test/src/test/java/com/danikula/videocache/HttpUrlSourceTest.java delete mode 100644 test/src/test/java/com/danikula/videocache/PingerTest.java delete mode 100644 test/src/test/java/com/danikula/videocache/ProxyCacheTest.java delete mode 100644 test/src/test/java/com/danikula/videocache/ProxySelectorTest.java delete mode 100644 test/src/test/java/com/danikula/videocache/file/DiskUsageTest.java delete mode 100644 test/src/test/java/com/danikula/videocache/file/FileCacheTest.java delete mode 100644 test/src/test/java/com/danikula/videocache/file/FilesTest.java delete mode 100644 test/src/test/java/com/danikula/videocache/sourcestorage/SourceInfoStorageTest.java delete mode 100644 test/src/test/java/com/danikula/videocache/support/ProxyCacheTestUtils.java delete mode 100644 test/src/test/java/com/danikula/videocache/support/Response.java diff --git a/build.gradle b/build.gradle index 9f27f01e..e67216e1 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,8 @@ buildscript { } allprojects { - repositories { + repositories { google() + mavenCentral() } } diff --git a/library/build.gradle b/library/build.gradle index b54761d2..8b85edf1 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -35,7 +35,6 @@ idea { } dependencies { - implementation 'org.slf4j:slf4j-android:1.7.36' } publishing { diff --git a/library/src/main/java/com/danikula/videocache/HttpProxyCacheServer.java b/library/src/main/java/com/danikula/videocache/HttpProxyCacheServer.java index 1f34ae8f..832a8cd2 100644 --- a/library/src/main/java/com/danikula/videocache/HttpProxyCacheServer.java +++ b/library/src/main/java/com/danikula/videocache/HttpProxyCacheServer.java @@ -13,8 +13,7 @@ import com.danikula.videocache.sourcestorage.SourceInfoStorage; import com.danikula.videocache.sourcestorage.SourceInfoStorageFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + import java.io.File; import java.io.IOException; @@ -53,7 +52,7 @@ */ public class HttpProxyCacheServer { - private static final Logger LOG = LoggerFactory.getLogger("HttpProxyCacheServer"); + // private static final Logger LOG = LoggerFactory.getLogger("HttpProxyCacheServer"); private static final String PROXY_HOST = "127.0.0.1"; private final Object clientsLock = new Object(); @@ -81,7 +80,7 @@ private HttpProxyCacheServer(Config config) { this.waitConnectionThread.start(); startSignal.await(); // freeze thread, wait for server starts this.pinger = new Pinger(PROXY_HOST, port); - LOG.info("Proxy cache server started. Is it alive? " + isAlive()); + // Log.info("Proxy cache server started. Is it alive? " + isAlive()); } catch (IOException | InterruptedException e) { socketProcessor.shutdown(); throw new IllegalStateException("Error starting local proxy server", e); @@ -128,7 +127,7 @@ public void registerCacheListener(CacheListener cacheListener, String url) { try { getClients(url).registerCacheListener(cacheListener); } catch (ProxyCacheException e) { - LOG.warn("Error registering cache listener", e); + // Log.warn("Error registering cache listener", e); } } } @@ -139,7 +138,7 @@ public void unregisterCacheListener(CacheListener cacheListener, String url) { try { getClients(url).unregisterCacheListener(cacheListener); } catch (ProxyCacheException e) { - LOG.warn("Error registering cache listener", e); + // Log.warn("Error registering cache listener", e); } } } @@ -165,7 +164,7 @@ public boolean isCached(String url) { } public void shutdown() { - LOG.info("Shutdown proxy server"); + // Log.info("Shutdown proxy server"); shutdownClients(); @@ -199,7 +198,7 @@ private void touchFileSafely(File cacheFile) { try { config.diskUsage.touch(cacheFile); } catch (IOException e) { - LOG.error("Error touching file " + cacheFile, e); + // Log.error("Error touching file " + cacheFile, e); } } @@ -216,7 +215,7 @@ private void waitForRequest() { try { while (!Thread.currentThread().isInterrupted()) { Socket socket = serverSocket.accept(); - LOG.debug("Accept new socket " + socket); + // Log.debug("Accept new socket " + socket); socketProcessor.submit(new SocketProcessorRunnable(socket)); } } catch (IOException e) { @@ -227,7 +226,7 @@ private void waitForRequest() { private void processSocket(Socket socket) { try { GetRequest request = GetRequest.read(socket.getInputStream()); - LOG.debug("Request to cache proxy:" + request); + // Log.debug("Request to cache proxy:" + request); String url = ProxyCacheUtils.decode(request.uri); if (pinger.isPingRequest(url)) { pinger.responseToPing(socket); @@ -238,12 +237,12 @@ private void processSocket(Socket socket) { } catch (SocketException e) { // There is no way to determine that client closed connection http://stackoverflow.com/a/10241044/999458 // So just to prevent log flooding don't log stacktrace - LOG.debug("Closing socket… Socket is closed by client."); + // Log.debug("Closing socket… Socket is closed by client."); } catch (ProxyCacheException | IOException e) { onError(new ProxyCacheException("Error processing request", e)); } finally { releaseSocket(socket); - LOG.debug("Opened connections: " + getClientsCount()); + // Log.debug("Opened connections: " + getClientsCount()); } } @@ -282,7 +281,7 @@ private void closeSocketInput(Socket socket) { } catch (SocketException e) { // There is no way to determine that client closed connection http://stackoverflow.com/a/10241044/999458 // So just to prevent log flooding don't log stacktrace - LOG.debug("Releasing input stream… Socket is closed by client."); + // Log.debug("Releasing input stream… Socket is closed by client."); } catch (IOException e) { onError(new ProxyCacheException("Error closing socket input stream", e)); } @@ -294,7 +293,7 @@ private void closeSocketOutput(Socket socket) { socket.shutdownOutput(); } } catch (IOException e) { - LOG.warn("Failed to close socket on proxy side: {}. It seems client have already closed connection.", e.getMessage()); + // Log.warn("Failed to close socket on proxy side: {}. It seems client have already closed connection.", e.getMessage()); } } @@ -309,7 +308,7 @@ private void closeSocket(Socket socket) { } private void onError(Throwable e) { - LOG.error("HttpProxyCacheServer error", e); + // Log.error("HttpProxyCacheServer error", e); } private final class WaitRequestsRunnable implements Runnable { diff --git a/library/src/main/java/com/danikula/videocache/HttpUrlSource.java b/library/src/main/java/com/danikula/videocache/HttpUrlSource.java index c7fb8ada..9d581f4b 100644 --- a/library/src/main/java/com/danikula/videocache/HttpUrlSource.java +++ b/library/src/main/java/com/danikula/videocache/HttpUrlSource.java @@ -7,8 +7,7 @@ import com.danikula.videocache.sourcestorage.SourceInfoStorage; import com.danikula.videocache.sourcestorage.SourceInfoStorageFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + import java.io.BufferedInputStream; import java.io.IOException; @@ -33,7 +32,7 @@ */ public class HttpUrlSource implements Source { - private static final Logger LOG = LoggerFactory.getLogger("HttpUrlSource"); + // // private static final Logger LOG = LoggerFactory.getLogger("HttpUrlSource"); private static final int MAX_REDIRECTS = 5; private final SourceInfoStorage sourceInfoStorage; @@ -109,9 +108,9 @@ public void close() throws ProxyCacheException { "https://github.com/danikula/AndroidVideoCache/issues."; throw new RuntimeException(message, e); } catch (ArrayIndexOutOfBoundsException e) { - LOG.error("Error closing connection correctly. Should happen only on Android L. " + - "If anybody know how to fix it, please visit https://github.com/danikula/AndroidVideoCache/issues/88. " + - "Until good solution is not know, just ignore this issue :(", e); + // Log.error("Error closing connection correctly. Should happen only on Android L. " + + // "If anybody know how to fix it, please visit https://github.com/danikula/AndroidVideoCache/issues/88. " + + // "Until good solution is not know, just ignore this issue :(", e); } } } @@ -131,7 +130,7 @@ public int read(byte[] buffer) throws ProxyCacheException { } private void fetchContentInfo() throws ProxyCacheException { - LOG.debug("Read content info from " + sourceInfo.url); + // Log.debug("Read content info from " + sourceInfo.url); HttpURLConnection urlConnection = null; InputStream inputStream = null; try { @@ -141,9 +140,9 @@ private void fetchContentInfo() throws ProxyCacheException { inputStream = urlConnection.getInputStream(); this.sourceInfo = new SourceInfo(sourceInfo.url, length, mime); this.sourceInfoStorage.put(sourceInfo.url, sourceInfo); - LOG.debug("Source info fetched: " + sourceInfo); + // Log.debug("Source info fetched: " + sourceInfo); } catch (IOException e) { - LOG.error("Error fetching info from " + sourceInfo.url, e); + // Log.error("Error fetching info from " + sourceInfo.url, e); } finally { ProxyCacheUtils.close(inputStream); if (urlConnection != null) { @@ -158,7 +157,7 @@ private HttpURLConnection openConnection(long offset, int timeout) throws IOExce int redirectCount = 0; String url = this.sourceInfo.url; do { - LOG.debug("Open connection " + (offset > 0 ? " with offset " + offset : "") + " to " + url); + // Log.debug("Open connection " + (offset > 0 ? " with offset " + offset : "") + " to " + url); connection = (HttpURLConnection) new URL(url).openConnection(); injectCustomHeaders(connection, url); if (offset > 0) { diff --git a/library/src/main/java/com/danikula/videocache/Pinger.java b/library/src/main/java/com/danikula/videocache/Pinger.java index bea87f23..0628eae7 100644 --- a/library/src/main/java/com/danikula/videocache/Pinger.java +++ b/library/src/main/java/com/danikula/videocache/Pinger.java @@ -1,7 +1,6 @@ package com.danikula.videocache; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + import java.io.IOException; import java.io.OutputStream; @@ -32,7 +31,7 @@ class Pinger { - private static final Logger LOG = LoggerFactory.getLogger("Pinger"); + // private static final Logger LOG = LoggerFactory.getLogger("Pinger"); private static final String PING_REQUEST = "ping"; private static final String PING_RESPONSE = "ping ok"; @@ -59,9 +58,9 @@ boolean ping(int maxAttempts, int startTimeout) { return true; } } catch (TimeoutException e) { - LOG.warn("Error pinging server (attempt: " + attempts + ", timeout: " + timeout + "). "); + // Log.warn("Error pinging server (attempt: " + attempts + ", timeout: " + timeout + "). "); } catch (InterruptedException | ExecutionException e) { - LOG.error("Error pinging server due to unexpected error", e); + // Log.error("Error pinging server due to unexpected error", e); } attempts++; timeout *= 2; @@ -70,7 +69,7 @@ boolean ping(int maxAttempts, int startTimeout) { "If you see this message, please, report at https://github.com/danikula/AndroidVideoCache/issues/134. " + "Default proxies are: %s" , attempts, timeout / 2, getDefaultProxies()); - LOG.error(error, new ProxyCacheException(error)); + // Log.error(error, new ProxyCacheException(error)); return false; } @@ -102,10 +101,10 @@ private boolean pingServer() throws ProxyCacheException { byte[] response = new byte[expectedResponse.length]; source.read(response); boolean pingOk = Arrays.equals(expectedResponse, response); - LOG.info("Ping response: `" + new String(response) + "`, pinged? " + pingOk); + // Log.info("Ping response: `" + new String(response) + "`, pinged? " + pingOk); return pingOk; } catch (ProxyCacheException e) { - LOG.error("Error reading ping response", e); + // Log.error("Error reading ping response", e); return false; } finally { source.close(); diff --git a/library/src/main/java/com/danikula/videocache/ProxyCache.java b/library/src/main/java/com/danikula/videocache/ProxyCache.java index eeea9713..c4cde10c 100644 --- a/library/src/main/java/com/danikula/videocache/ProxyCache.java +++ b/library/src/main/java/com/danikula/videocache/ProxyCache.java @@ -1,7 +1,6 @@ package com.danikula.videocache; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + import java.util.concurrent.atomic.AtomicInteger; @@ -18,7 +17,7 @@ */ class ProxyCache { - private static final Logger LOG = LoggerFactory.getLogger("ProxyCache"); + // private static final Logger LOG = LoggerFactory.getLogger("ProxyCache"); private static final int MAX_READ_SOURCE_ATTEMPTS = 1; private final Source source; @@ -62,7 +61,7 @@ private void checkReadSourceErrorsCount() throws ProxyCacheException { public void shutdown() { synchronized (stopLock) { - LOG.debug("Shutdown proxy for " + source); + // Log.debug("Shutdown proxy for " + source); try { stopped = true; if (sourceReaderThread != null) { @@ -174,9 +173,9 @@ private void closeSource() { protected final void onError(final Throwable e) { boolean interruption = e instanceof InterruptedProxyCacheException; if (interruption) { - LOG.debug("ProxyCache is interrupted"); + // Log.debug("ProxyCache is interrupted"); } else { - LOG.error("ProxyCache error", e); + // Log.error("ProxyCache error", e); } } diff --git a/library/src/main/java/com/danikula/videocache/ProxyCacheUtils.java b/library/src/main/java/com/danikula/videocache/ProxyCacheUtils.java index 7e26a2b2..43ccf5b7 100644 --- a/library/src/main/java/com/danikula/videocache/ProxyCacheUtils.java +++ b/library/src/main/java/com/danikula/videocache/ProxyCacheUtils.java @@ -3,8 +3,7 @@ import android.text.TextUtils; import android.webkit.MimeTypeMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + import java.io.Closeable; import java.io.IOException; @@ -25,7 +24,7 @@ */ public class ProxyCacheUtils { - private static final Logger LOG = LoggerFactory.getLogger("ProxyCacheUtils"); + // private static final Logger LOG = LoggerFactory.getLogger("ProxyCacheUtils"); static final int DEFAULT_BUFFER_SIZE = 8 * 1024; static final int MAX_ARRAY_PREVIEW = 16; @@ -72,7 +71,7 @@ static void close(Closeable closeable) { try { closeable.close(); } catch (IOException e) { - LOG.error("Error closing resource", e); + // Log.error("Error closing resource", e); } } } diff --git a/library/src/main/java/com/danikula/videocache/StorageUtils.java b/library/src/main/java/com/danikula/videocache/StorageUtils.java index a4f2dcef..3adb68b6 100644 --- a/library/src/main/java/com/danikula/videocache/StorageUtils.java +++ b/library/src/main/java/com/danikula/videocache/StorageUtils.java @@ -3,8 +3,7 @@ import android.content.Context; import android.os.Environment; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + import java.io.File; @@ -20,7 +19,7 @@ */ final class StorageUtils { - private static final Logger LOG = LoggerFactory.getLogger("StorageUtils"); + // private static final Logger LOG = LoggerFactory.getLogger("StorageUtils"); private static final String INDIVIDUAL_DIR_NAME = "video-cache"; /** @@ -63,7 +62,7 @@ private static File getCacheDirectory(Context context, boolean preferExternal) { } if (appCacheDir == null) { String cacheDirPath = "/data/data/" + context.getPackageName() + "/cache/"; - LOG.warn("Can't define system cache directory! '" + cacheDirPath + "%s' will be used."); + // Log.warn("Can't define system cache directory! '" + cacheDirPath + "%s' will be used."); appCacheDir = new File(cacheDirPath); } return appCacheDir; @@ -74,7 +73,7 @@ private static File getExternalCacheDir(Context context) { File appCacheDir = new File(new File(dataDir, context.getPackageName()), "cache"); if (!appCacheDir.exists()) { if (!appCacheDir.mkdirs()) { - LOG.warn("Unable to create external cache directory"); + // Log.warn("Unable to create external cache directory"); return null; } } diff --git a/library/src/main/java/com/danikula/videocache/file/Files.java b/library/src/main/java/com/danikula/videocache/file/Files.java index 5f5234a5..0967f979 100644 --- a/library/src/main/java/com/danikula/videocache/file/Files.java +++ b/library/src/main/java/com/danikula/videocache/file/Files.java @@ -1,7 +1,6 @@ package com.danikula.videocache.file; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + import java.io.File; import java.io.IOException; @@ -20,7 +19,7 @@ */ class Files { - private static final Logger LOG = LoggerFactory.getLogger("Files"); + // private static final Logger LOG = LoggerFactory.getLogger("Files"); static void makeDir(File directory) throws IOException { if (directory.exists()) { @@ -53,7 +52,7 @@ static void setLastModifiedNow(File file) throws IOException { modify(file); if (file.lastModified() < now) { // NOTE: apparently this is a known issue (see: http://stackoverflow.com/questions/6633748/file-lastmodified-is-never-what-was-set-with-file-setlastmodified) - LOG.warn("Last modified date {} is not set for file {}", new Date(file.lastModified()), file.getAbsolutePath()); + // Log.warn("Last modified date {} is not set for file {}", new Date(file.lastModified()), file.getAbsolutePath()); } } } diff --git a/library/src/main/java/com/danikula/videocache/file/LruDiskUsage.java b/library/src/main/java/com/danikula/videocache/file/LruDiskUsage.java index 0b0b03ad..16d277c2 100644 --- a/library/src/main/java/com/danikula/videocache/file/LruDiskUsage.java +++ b/library/src/main/java/com/danikula/videocache/file/LruDiskUsage.java @@ -1,7 +1,6 @@ package com.danikula.videocache.file; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + import java.io.File; import java.io.IOException; @@ -17,7 +16,7 @@ */ public abstract class LruDiskUsage implements DiskUsage { - private static final Logger LOG = LoggerFactory.getLogger("LruDiskUsage"); + // private static final Logger LOG = LoggerFactory.getLogger("LruDiskUsage"); private final ExecutorService workerThread = Executors.newSingleThreadExecutor(); @Override @@ -44,9 +43,9 @@ private void trim(List files) { if (deleted) { totalCount--; totalSize -= fileSize; - LOG.info("Cache file " + file + " is deleted because it exceeds cache limit"); + // Log.info("Cache file " + file + " is deleted because it exceeds cache limit"); } else { - LOG.error("Error deleting file " + file + " for trimming cache"); + // Log.error("Error deleting file " + file + " for trimming cache"); } } } diff --git a/sample/build.gradle b/sample/build.gradle deleted file mode 100644 index b3eca93d..00000000 --- a/sample/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -buildscript { - repositories { - mavenCentral() - } - dependencies { - } -} - -repositories { - maven { url 'https://github.com/dahlgren/vpi-aar/raw/master' } -} - -apply plugin: 'com.android.application' - -android { - compileSdkVersion 23 - buildToolsVersion '25.0.2' - - defaultConfig { - applicationId 'com.danikula.videocache.sample' - minSdkVersion 15 - targetSdkVersion 23 - versionCode 1 - versionName '1.0' - } -} - - - -dependencies { -// compile project(':library') - implementation 'com.android.support:support-v4:23.1.0' - implementation 'org.androidannotations:androidannotations-api:3.3.2' - implementation 'com.danikula:videocache:2.7.1' - implementation 'com.viewpagerindicator:library:2.4.2-SNAPSHOT@aar' -} diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml deleted file mode 100644 index 3ba1f44d..00000000 --- a/sample/src/main/AndroidManifest.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/sample/src/main/java/com/danikula/videocache/sample/App.java b/sample/src/main/java/com/danikula/videocache/sample/App.java deleted file mode 100644 index 095469d9..00000000 --- a/sample/src/main/java/com/danikula/videocache/sample/App.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.danikula.videocache.sample; - -import android.app.Application; -import android.content.Context; - -import com.danikula.videocache.HttpProxyCacheServer; - -/** - * @author Alexey Danilov (danikula@gmail.com). - */ -public class App extends Application { - - private HttpProxyCacheServer proxy; - - public static HttpProxyCacheServer getProxy(Context context) { - App app = (App) context.getApplicationContext(); - return app.proxy == null ? (app.proxy = app.newProxy()) : app.proxy; - } - - private HttpProxyCacheServer newProxy() { - return new HttpProxyCacheServer.Builder(this) - .cacheDirectory(Utils.getVideoCacheDir(this)) - .build(); - } -} diff --git a/sample/src/main/java/com/danikula/videocache/sample/GalleryVideoFragment.java b/sample/src/main/java/com/danikula/videocache/sample/GalleryVideoFragment.java deleted file mode 100644 index 94a79ca0..00000000 --- a/sample/src/main/java/com/danikula/videocache/sample/GalleryVideoFragment.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.danikula.videocache.sample; - -import android.os.Handler; -import android.os.Message; -import android.support.v4.app.Fragment; -import android.widget.ProgressBar; -import android.widget.VideoView; - -import com.danikula.videocache.CacheListener; -import com.danikula.videocache.HttpProxyCacheServer; - -import org.androidannotations.annotations.AfterViews; -import org.androidannotations.annotations.EFragment; -import org.androidannotations.annotations.FragmentArg; -import org.androidannotations.annotations.InstanceState; -import org.androidannotations.annotations.SeekBarTouchStop; -import org.androidannotations.annotations.ViewById; - -import java.io.File; - -@EFragment(R.layout.fragment_video) -public class GalleryVideoFragment extends Fragment implements CacheListener { - - @FragmentArg String url; - - @InstanceState int position; - @InstanceState boolean playerStarted; - - @ViewById VideoView videoView; - @ViewById ProgressBar progressBar; - - private boolean visibleForUser; - - private final VideoProgressUpdater updater = new VideoProgressUpdater(); - - public static Fragment build(String url) { - return GalleryVideoFragment_.builder() - .url(url) - .build(); - } - - @AfterViews - void afterViewInjected() { - startProxy(); - - if (visibleForUser) { - startPlayer(); - } - } - - private void startPlayer() { - videoView.seekTo(position); - videoView.start(); - playerStarted = true; - } - - private void startProxy() { - HttpProxyCacheServer proxy = App.getProxy(getActivity()); - proxy.registerCacheListener(this, url); - videoView.setVideoPath(proxy.getProxyUrl(url)); - } - - @Override - public void setUserVisibleHint(boolean isVisibleToUser) { - super.setUserVisibleHint(isVisibleToUser); - - visibleForUser = isVisibleToUser; - if (videoView != null) { - if (visibleForUser) { - startPlayer(); - } else if (playerStarted) { - position = videoView.getCurrentPosition(); - videoView.pause(); - } - } - } - - @Override - public void onResume() { - super.onResume(); - updater.start(); - } - - @Override - public void onPause() { - super.onPause(); - updater.stop(); - } - - @Override - public void onDestroy() { - super.onDestroy(); - - videoView.stopPlayback(); - App.getProxy(getActivity()).unregisterCacheListener(this); - } - - @Override - public void onCacheAvailable(File file, String url, int percentsAvailable) { - progressBar.setSecondaryProgress(percentsAvailable); - } - - private void updateVideoProgress() { - int videoProgress = videoView.getCurrentPosition() * 100 / videoView.getDuration(); - progressBar.setProgress(videoProgress); - } - - @SeekBarTouchStop(R.id.progressBar) - void seekVideo() { - int videoPosition = videoView.getDuration() * progressBar.getProgress() / 100; - videoView.seekTo(videoPosition); - } - - private final class VideoProgressUpdater extends Handler { - - public void start() { - sendEmptyMessage(0); - } - - public void stop() { - removeMessages(0); - } - - @Override - public void handleMessage(Message msg) { - updateVideoProgress(); - sendEmptyMessageDelayed(0, 500); - } - } -} diff --git a/sample/src/main/java/com/danikula/videocache/sample/MenuActivity.java b/sample/src/main/java/com/danikula/videocache/sample/MenuActivity.java deleted file mode 100644 index 353ab4e8..00000000 --- a/sample/src/main/java/com/danikula/videocache/sample/MenuActivity.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.danikula.videocache.sample; - -import android.content.Intent; -import android.support.annotation.NonNull; -import android.support.v4.app.FragmentActivity; -import android.util.Log; -import android.widget.ArrayAdapter; -import android.widget.ListAdapter; -import android.widget.ListView; -import android.widget.Toast; - -import org.androidannotations.annotations.AfterViews; -import org.androidannotations.annotations.Click; -import org.androidannotations.annotations.EActivity; -import org.androidannotations.annotations.ItemClick; -import org.androidannotations.annotations.ViewById; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -@EActivity(R.layout.activity_menu) -public class MenuActivity extends FragmentActivity { - - @ViewById ListView listView; - - @AfterViews - void onViewInjected() { - ListAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, android.R.id.text1, buildListData()); - listView.setAdapter(adapter); - } - - @NonNull - private List buildListData() { - return Arrays.asList( - new ListEntry("Single Video", SingleVideoActivity_.class), - new ListEntry("Multiple Videos", MultipleVideosActivity_.class), - new ListEntry("Video Gallery with pre-caching", VideoGalleryActivity_.class), - new ListEntry("Shared Cache", SharedCacheActivity_.class) - ); - } - - @ItemClick(R.id.listView) - void onListItemClicked(int position) { - ListEntry item = (ListEntry) listView.getAdapter().getItem(position); - startActivity(new Intent(this, item.activityClass)); - } - - @Click(R.id.cleanCacheButton) - void onClearCacheButtonClick() { - try { - - Utils.cleanVideoCacheDir(this); - } catch (IOException e) { - Log.e(null, "Error cleaning cache", e); - Toast.makeText(this, "Error cleaning cache", Toast.LENGTH_LONG).show(); - } - } - - private static final class ListEntry { - - private final String title; - private final Class activityClass; - - public ListEntry(String title, Class activityClass) { - this.title = title; - this.activityClass = activityClass; - } - - @Override - public String toString() { - return title; - } - } - -} diff --git a/sample/src/main/java/com/danikula/videocache/sample/MultipleVideosActivity.java b/sample/src/main/java/com/danikula/videocache/sample/MultipleVideosActivity.java deleted file mode 100644 index d27dd12a..00000000 --- a/sample/src/main/java/com/danikula/videocache/sample/MultipleVideosActivity.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.danikula.videocache.sample; - -import android.os.Bundle; -import android.support.v4.app.FragmentActivity; - -import org.androidannotations.annotations.EActivity; - -@EActivity(R.layout.activity_multiple_videos) -public class MultipleVideosActivity extends FragmentActivity { - - @Override - protected void onCreate(Bundle state) { - super.onCreate(state); - - if (state == null) { - addVideoFragment(Video.ORANGE_1, R.id.videoContainer0); - addVideoFragment(Video.ORANGE_2, R.id.videoContainer1); - addVideoFragment(Video.ORANGE_3, R.id.videoContainer2); - addVideoFragment(Video.ORANGE_4, R.id.videoContainer3); - } - } - - private void addVideoFragment(Video video, int containerViewId) { - getSupportFragmentManager() - .beginTransaction() - .add(containerViewId, VideoFragment.build(video.url)) - .commit(); - } -} diff --git a/sample/src/main/java/com/danikula/videocache/sample/SharedCacheActivity.java b/sample/src/main/java/com/danikula/videocache/sample/SharedCacheActivity.java deleted file mode 100644 index 80ca82c9..00000000 --- a/sample/src/main/java/com/danikula/videocache/sample/SharedCacheActivity.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.danikula.videocache.sample; - -import android.os.Bundle; -import android.support.v4.app.FragmentActivity; - -import org.androidannotations.annotations.EActivity; - -@EActivity(R.layout.activity_multiple_videos) -public class SharedCacheActivity extends FragmentActivity { - - @Override - protected void onCreate(Bundle state) { - super.onCreate(state); - - if (state == null) { - addVideoFragment(Video.ORANGE_1, R.id.videoContainer0); - addVideoFragment(Video.ORANGE_1, R.id.videoContainer1); - addVideoFragment(Video.ORANGE_1, R.id.videoContainer2); - addVideoFragment(Video.ORANGE_1, R.id.videoContainer3); - } - } - - private void addVideoFragment(Video video, int containerViewId) { - getSupportFragmentManager() - .beginTransaction() - .add(containerViewId, VideoFragment.build(video.url)) - .commit(); - } -} diff --git a/sample/src/main/java/com/danikula/videocache/sample/SingleVideoActivity.java b/sample/src/main/java/com/danikula/videocache/sample/SingleVideoActivity.java deleted file mode 100644 index 2ecbe562..00000000 --- a/sample/src/main/java/com/danikula/videocache/sample/SingleVideoActivity.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.danikula.videocache.sample; - -import android.os.Bundle; -import android.support.v4.app.FragmentActivity; - -import org.androidannotations.annotations.EActivity; - -@EActivity(R.layout.activity_single_video) -public class SingleVideoActivity extends FragmentActivity { - - @Override - protected void onCreate(Bundle state) { - super.onCreate(state); - - if (state == null) { - getSupportFragmentManager() - .beginTransaction() - .add(R.id.containerView, VideoFragment.build(Video.ORANGE_1.url)) - .commit(); - } - } -} diff --git a/sample/src/main/java/com/danikula/videocache/sample/Utils.java b/sample/src/main/java/com/danikula/videocache/sample/Utils.java deleted file mode 100644 index 43779832..00000000 --- a/sample/src/main/java/com/danikula/videocache/sample/Utils.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.danikula.videocache.sample; - -import android.content.Context; - -import java.io.File; -import java.io.IOException; - -/** - * Some utils methods. - * - * @author Alexey Danilov (danikula@gmail.com). - */ -public class Utils { - - public static File getVideoCacheDir(Context context) { - return new File(context.getExternalCacheDir(), "video-cache"); - } - - public static void cleanVideoCacheDir(Context context) throws IOException { - File videoCacheDir = getVideoCacheDir(context); - cleanDirectory(videoCacheDir); - } - - private static void cleanDirectory(File file) throws IOException { - if (!file.exists()) { - return; - } - File[] contentFiles = file.listFiles(); - if (contentFiles != null) { - for (File contentFile : contentFiles) { - delete(contentFile); - } - } - } - - private static void delete(File file) throws IOException { - if (file.isFile() && file.exists()) { - deleteOrThrow(file); - } else { - cleanDirectory(file); - deleteOrThrow(file); - } - } - - private static void deleteOrThrow(File file) throws IOException { - if (file.exists()) { - boolean isDeleted = file.delete(); - if (!isDeleted) { - throw new IOException(String.format("File %s can't be deleted", file.getAbsolutePath())); - } - } - } -} diff --git a/sample/src/main/java/com/danikula/videocache/sample/Video.java b/sample/src/main/java/com/danikula/videocache/sample/Video.java deleted file mode 100644 index f364f854..00000000 --- a/sample/src/main/java/com/danikula/videocache/sample/Video.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.danikula.videocache.sample; - -public enum Video { - - ORANGE_1(Config.ROOT + "orange1.mp4"), - ORANGE_2(Config.ROOT + "orange2.mp4"), - ORANGE_3(Config.ROOT + "orange3.mp4"), - ORANGE_4(Config.ROOT + "orange4.mp4"), - ORANGE_5(Config.ROOT + "orange5.mp4"); - - public final String url; - - Video(String url) { - this.url = url; - } - - private class Config { - private static final String ROOT = "https://raw.githubusercontent.com/danikula/AndroidVideoCache/master/files/"; - } -} diff --git a/sample/src/main/java/com/danikula/videocache/sample/VideoFragment.java b/sample/src/main/java/com/danikula/videocache/sample/VideoFragment.java deleted file mode 100644 index 85c8086d..00000000 --- a/sample/src/main/java/com/danikula/videocache/sample/VideoFragment.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.danikula.videocache.sample; - -import android.os.Handler; -import android.os.Message; -import android.support.v4.app.Fragment; -import android.util.Log; -import android.widget.ImageView; -import android.widget.ProgressBar; -import android.widget.VideoView; - -import com.danikula.videocache.CacheListener; -import com.danikula.videocache.HttpProxyCacheServer; - -import org.androidannotations.annotations.AfterViews; -import org.androidannotations.annotations.EFragment; -import org.androidannotations.annotations.FragmentArg; -import org.androidannotations.annotations.SeekBarTouchStop; -import org.androidannotations.annotations.ViewById; - -import java.io.File; - -@EFragment(R.layout.fragment_video) -public class VideoFragment extends Fragment implements CacheListener { - - private static final String LOG_TAG = "VideoFragment"; - - @FragmentArg String url; - - @ViewById ImageView cacheStatusImageView; - @ViewById VideoView videoView; - @ViewById ProgressBar progressBar; - - private final VideoProgressUpdater updater = new VideoProgressUpdater(); - - public static Fragment build(String url) { - return VideoFragment_.builder() - .url(url) - .build(); - } - - @AfterViews - void afterViewInjected() { - checkCachedState(); - startVideo(); - } - - private void checkCachedState() { - HttpProxyCacheServer proxy = App.getProxy(getActivity()); - boolean fullyCached = proxy.isCached(url); - setCachedState(fullyCached); - if (fullyCached) { - progressBar.setSecondaryProgress(100); - } - } - - private void startVideo() { - HttpProxyCacheServer proxy = App.getProxy(getActivity()); - proxy.registerCacheListener(this, url); - String proxyUrl = proxy.getProxyUrl(url); - Log.d(LOG_TAG, "Use proxy url " + proxyUrl + " instead of original url " + url); - videoView.setVideoPath(proxyUrl); - videoView.start(); - } - - @Override - public void onResume() { - super.onResume(); - updater.start(); - } - - @Override - public void onPause() { - super.onPause(); - updater.stop(); - } - - @Override - public void onDestroy() { - super.onDestroy(); - - videoView.stopPlayback(); - App.getProxy(getActivity()).unregisterCacheListener(this); - } - - @Override - public void onCacheAvailable(File file, String url, int percentsAvailable) { - progressBar.setSecondaryProgress(percentsAvailable); - setCachedState(percentsAvailable == 100); - Log.d(LOG_TAG, String.format("onCacheAvailable. percents: %d, file: %s, url: %s", percentsAvailable, file, url)); - } - - private void updateVideoProgress() { - int videoProgress = videoView.getCurrentPosition() * 100 / videoView.getDuration(); - progressBar.setProgress(videoProgress); - } - - @SeekBarTouchStop(R.id.progressBar) - void seekVideo() { - int videoPosition = videoView.getDuration() * progressBar.getProgress() / 100; - videoView.seekTo(videoPosition); - } - - private void setCachedState(boolean cached) { - int statusIconId = cached ? R.drawable.ic_cloud_done : R.drawable.ic_cloud_download; - cacheStatusImageView.setImageResource(statusIconId); - } - - private final class VideoProgressUpdater extends Handler { - - public void start() { - sendEmptyMessage(0); - } - - public void stop() { - removeMessages(0); - } - - @Override - public void handleMessage(Message msg) { - updateVideoProgress(); - sendEmptyMessageDelayed(0, 500); - } - } -} diff --git a/sample/src/main/java/com/danikula/videocache/sample/VideoGalleryActivity.java b/sample/src/main/java/com/danikula/videocache/sample/VideoGalleryActivity.java deleted file mode 100644 index 2a88bc0b..00000000 --- a/sample/src/main/java/com/danikula/videocache/sample/VideoGalleryActivity.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.danikula.videocache.sample; - -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentActivity; -import android.support.v4.app.FragmentStatePagerAdapter; -import android.support.v4.view.ViewPager; - -import com.viewpagerindicator.CirclePageIndicator; - -import org.androidannotations.annotations.AfterViews; -import org.androidannotations.annotations.EActivity; -import org.androidannotations.annotations.ViewById; - -@EActivity(R.layout.activity_video_gallery) -public class VideoGalleryActivity extends FragmentActivity { - - @ViewById ViewPager viewPager; - @ViewById CirclePageIndicator viewPagerIndicator; - - @AfterViews - void afterViewInjected() { - ViewsPagerAdapter viewsPagerAdapter = new ViewsPagerAdapter(this); - viewPager.setAdapter(viewsPagerAdapter); - viewPagerIndicator.setViewPager(viewPager); - } - - private static final class ViewsPagerAdapter extends FragmentStatePagerAdapter { - - public ViewsPagerAdapter(FragmentActivity activity) { - super(activity.getSupportFragmentManager()); - } - - @Override - public Fragment getItem(int position) { - Video video = Video.values()[position]; - return GalleryVideoFragment.build(video.url); - } - - @Override - public int getCount() { - return Video.values().length; - } - - @Override - public CharSequence getPageTitle(int position) { - return Video.values()[position].name(); - } - } -} diff --git a/sample/src/main/res/drawable-hdpi/ic_cloud_done.png b/sample/src/main/res/drawable-hdpi/ic_cloud_done.png deleted file mode 100644 index 6a15640fc85cf261dd5cbe0f3feaf28350c237e8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 379 zcmV->0fhdEP)gD&F1Aruf<*+u-fHyUF*%=I2NPhov;OXX#!~U;y-SEr@yMEg8!cAR~TI%7LJ9f=Bb=Ps_ zkn`S3_1;n`bkUA^eQ}`#I%zD|mJ@mCiIN_tp(FYp8YyefQag0cK)zSLtGm|*UGi1F zb(MZi*=#~*P2^is3E{fBv8S#&s)h{88K-Ufv)9h-Lw)&HlMH;+6XCwLZd-3Kr&<{p z>V%PIw}i@CAp_UKH?!?n5JF|Okl}gwq1i@F)r<}E`yAeprV1H;g-6V#777@)!xhq0 zA;U@tFVj>Z!*U3VCJxq6C;w^lebN(Qe~SkGuA$!Sg}m&6H>S$kvu(w)j;Nu7?-2U8 Z&~KhQc*MMgoDu*4002ovPDHLkV1ki(ugL%a diff --git a/sample/src/main/res/drawable-hdpi/ic_cloud_download.png b/sample/src/main/res/drawable-hdpi/ic_cloud_download.png deleted file mode 100644 index 4c5d2d049e392a237958679a6599519c7f59cfd5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 353 zcmV-n0iOPeP)Ds!(`sk%0Imd!2!g#;^aK|14&oK&0Agip;Ro0XVm!fOA$tM8h?s!JLJdM9 zN*;?T%p^0rZ(OjDJpcaJ4D-sk{}n|xIpu*4pENjUiy{)5;NKM6bQrA54%4GRi`)?E zjw{K!!=Loc?S2@V zrwt=R(By=5CV!w9RFJ<*<}6f!To61GA;Mm62oeh7eegQQ&Vh^_b%xsz-tpxUF6Zk^ z_y9c>VBlG}1vO;|^(7pFk}`yA32UID3~AK_;X*+f(yIzWiFP`b$s`oQpH|-!5hB=? zi1}R!(cpz#WuI%h=<3m;MwJ3$q5K;|e+_*DoPSf;fViWX00000NkvXXu0mjf?unJ- diff --git a/sample/src/main/res/drawable-mdpi/ic_cloud_done.png b/sample/src/main/res/drawable-mdpi/ic_cloud_done.png deleted file mode 100644 index 99e1edf25e075575bdc278ad3f31edd0bba483cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 265 zcmV+k0rvihP)95bb@RQXsOtEftYljKyZ6SQBZRaS&518brH!V z&PwXM2TRCJ&mB7U!&lGT;6JXIJ25u)fO=k-a!Q)J*4bf}tG0b`Vx1u|n?9R1aL-RG zTl{j(7t{I%@XE@Y*KSj>ZQ7*)>>4`;yf=2}z)H^mcAb~u$f+AJ*tcf@kNm5^k+B>M z2C!pFiFeM*`DVwo68D{#n_H*AhEFao16=pf#hmcNhAnS>w_a&s#*+8~_QN&iVtKbv P00000NkvXXu0mjfd}VXy diff --git a/sample/src/main/res/drawable-mdpi/ic_cloud_download.png b/sample/src/main/res/drawable-mdpi/ic_cloud_download.png deleted file mode 100644 index 0c6978c1fd094c1d045389e83aed90b724495b1c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 242 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_+iot`d^Ar^vn58C=M1xmDCoX!== z+&Q&VIzc>z%c^|g(Grt*Rn=o{X9IltFJ>${V|Qjop@y7F+@ZfSv)5R%j6|idht{$r%KdvdG=I3 qtrz=sbV9UQ&BW^gfiHaCFdn(ZwdkJK-s?b5FnGH9xvX5lp<(nN7ng#;F{DrYQotA#6}*lQgS~25I+G7eDK_o%0Zy6 zUwS^Q`@4@8Wq|es=dZkhj`4NPhp+Ow zEks5n&qE{Z$*UZgb^DV{u6uwY|C^gR@Y?45AuQ;dPF>Xy!WGkLIeT!fntTsL287Fgm}DD{9t6TEFAPnhuI0RM%Yy6P r_-vp|16$e}sv-lXa{m=D17^T)A`FJ@MQ7BM00000NkvXXu0mjf-jd8( diff --git a/sample/src/main/res/drawable-xhdpi/ic_cloud_download.png b/sample/src/main/res/drawable-xhdpi/ic_cloud_download.png deleted file mode 100644 index d1a0573af65814d77858c4f04ad4467de81647df..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 417 zcmV;S0bc%zP))D*jn?auJVYUT*KKR0m$E(zB|-j;dX+0$g&eYKP9}0PF7g=t!OJ z&jLCMBlSD9It|z{Fs+!J)4Ey?+=01)y)s~%Mu4F&Ufa}~1Ud$_fbzcD_!lT>7=TC4 zjDe2PLI56*fn62^uqnd+0)d{@@Kbq7WGpGK8&1e4DxRm91(4=A&$sY{+C(y|Vc4f8 zk;nmdsYN6?9fT`J)d@*nMF?-HNF=#+Ls&DYL?pTOv_lBD$R?8fwnP~3w&r^>`DEVo zTa)cMI|+o#-WX}3o~^QP%bL4B_-?39Lk9|7ZBYg^wEqfN0!!d8m2gFXs7S&200000 LNkvXXu0mjfq%yl{ diff --git a/sample/src/main/res/drawable-xxhdpi/ic_cloud_done.png b/sample/src/main/res/drawable-xxhdpi/ic_cloud_done.png deleted file mode 100644 index 6c6b42855d580ba019c7925b09f44c5019087d61..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 672 zcmV;R0$=@!P)mKKvB zYA_*7FdEVf>Z)mZ!zh}r8sDIZL-z-s_q@;b4LaXvK0F_Im&19*=kxh|zW+D2(ZOXN zGQ&64Smi5k7~v8J*^0Q1+p#2v8DWKTWu+a(@hqe-gAQLN`vVa;c(N!%_7g`hsmDTbKj2b!(Y8XlCOi*YK|wXmQzrm1A#*=!H0BZF4+?Bgw^I%*5r&IDS` z(SoqEBx%SF)X0=FM}CoJC~Uz7RLcuRPRcA`M+wpt!}PP4s`8+WI>$_!a=qgWHKjmp zXf<2Jxv=huwn9*X=~y_Xiv$=D$JIE^P8@)n1P1ghb`HRmKcEz0O0z(zvd$b+$8XSS z?CU|;#Rm({dBXRRdPKN`ZRZdKp_TapPE%Bl*&w{cuHL_{CUg26AV*SI#-=9)OH<6M za{$_f73}IOSlmojodanD3QuY(;`9@>F<}{;N!lFvBus(|NrMA<;Wj9c`auhH65L73 z99R-k5Rue}USopr)SaZvfwUkT180&h2igT8V9JrC&B>7v1mOVxMm^?|f1UVSq~3sP zcuw4PA_gQh@R~RqFn4N08Yiyq5)^}k8U~4@0fO?+G5a_8(=F1u-h)-Z5k}dFa`aGd z`=r-IH@BGJGkJ8&v&0x_+DT~rp3)x=@*ofLAP@2&*ZB$l2m0nf_@Lte0000MSTYjf}^-3lMOyWom`6O;OJ20xG5q;ks?S25v$}QfCy47Za3Yla;8Af=GPOmsZ#y4mu&xlil9sWQOr|A&4 z4kzjJ0UF>Arrl3^R?dF2@Cxn8RmZSg#Knphlde%l_U$UC?G`AOX<09%zsz zBm#P?1M24qBm{yc6P#feeceGda0t@vB`3)L2~>hqKmczj{SL}9mm&z@EYZ)P!;mrv zt`V(*9`yhSF8ly(g`NPx&^Lp5!uRdLCgq3&qlmDwEA}L7&OC)xP@cz@B!z92UmuD^ zW=XS)YoF3Zrb(+?L~B7pp0Sj^PSpJzvzu9xY@W)$4ptEdm?DW1|&)A?BLf-P{8w)4a|QO zq0^VJ8w@bZwW0Zf(8<@-s=^(O17^U~{5l9vHVPOw`0aZMUvYbXvdbDT@?d>{A&Thk z%roCh_#OZ9yvE)BfHr;(X}&N|Jr!}dvo;_T@%e6tjNJ}MQi{QRfNSPS{2#Cyllg8R z(|Qwd59Jum2iPFt1-zKZjBwuY{C8-+W4c|y z6hWIq5SL(lKER?2SZ;E@mtb-}R2V>nFA36H2;xIHV?^_OfO$kXpz+>D5Fdh>`S1q` z;e^I>5Fdi6`2ddym!OnTYkn3TrCoqZg30-?CHxIa2`1-5UN`{Fge>~{OZWn`60+#* zLRbQgge>R=Oo28+7Tpzu`#=-HL4SEc_(2Q7!9<&a@G>YTIG8Cd2)&dQ6C6x6EC|B; zsL3%r|B!?W7^I|(;9#x=L~u`<_*Eh4eYE%saclYJ!`+7|5}!PO>b>t~u82<)x4qza zDNa8hFThKAwoD7+4-ndTlM>PEn2GwY8YEeyOmwQS zM0cZ?J$jiX$2DPh$O6gW*KPWl--fBOT!<-Ol0Y&M(CX0zFBHk(aV zRC9rT#)z{>iX3Y!v&cIh)6aSKBh-${$BuG~x8&Ha9J5>_;y*we&snF`ay+BeKY(+@ zanc*kmdI5X_fU~;=w3GK0;5#!s;0nh|12mHYF8~foaDxNe11k6gz6AiJknGzU&<{Qb z04&h9IUr0r5CF(CKfP-WL1%Pov#enM&FaX>w2E+phfQ$bCO%O=H z5;X-tS3m(UQ~<;R3&_%l5WK=!5}|M;P8vW6=D|2Y;;e6k1j}HUAaUMF!5SDPNZb@H z0L&32?wS<*1Y-n=+Y*9#Fhr2J?}y+e7$Hbhv?>?|0|W`G0A1iYL87Xp;4pYhkfuBGtseei%FQQZQe!qZKpwG$-j8$<{S69ugV ziTbjHi+?SC)<}@(D7NwE?g>(w2$G`If7BQ6X4W+jBzo%DY{Ah(P>OA}V(MWX|2IY1 zRscaezwvid?A?CNdYn1@Ta2=u7u^-yCXN4EqNDUvgD^v6@K0HWsoCwZM;(2{$z!?& z1_?Vqw`ri0d%WN)NmlWyRgxr_AW91%^@p#9#{w+C0xZA+EWiRRzyd750u;<&TKF}4 Tehrn800000NkvXXu0mjfJxo+? diff --git a/sample/src/main/res/layout/activity_menu.xml b/sample/src/main/res/layout/activity_menu.xml deleted file mode 100644 index 2cc27322..00000000 --- a/sample/src/main/res/layout/activity_menu.xml +++ /dev/null @@ -1,23 +0,0 @@ - - -