ability to check was content fully cached to file or not · atagotech/AndroidVideoCache@cd0b411 · GitHub
Skip to content

Commit cd0b411

Browse files
committed
ability to check was content fully cached to file or not
1 parent eb67640 commit cd0b411

17 files changed

Lines changed: 99 additions & 8 deletions

File tree

README.md

Lines changed: 14 additions & 5 deletions

library/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ publish {
2929
userOrg = 'alexeydanilov'
3030
groupId = 'com.danikula'
3131
artifactId = 'videocache'
32-
publishVersion = '2.3.4'
32+
publishVersion = '2.4.0'
3333
description = 'Cache support for android VideoView'
3434
website = 'https://github.com/danikula/AndroidVideoCache'
3535
}

library/src/main/java/com/danikula/videocache/HttpProxyCacheServer.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,20 @@ public void unregisterCacheListener(CacheListener cacheListener) {
173173
}
174174
}
175175

176+
/**
177+
* Checks is cache contains fully cached file for particular url.
178+
*
179+
* @param url an url cache file will be checked for.
180+
* @return {@code true} if cache contains fully cached file for passed in parameters url.
181+
*/
182+
public boolean isCached(String url) {
183+
checkNotNull(url, "Url can't be null!");
184+
File cacheDir = config.cacheRoot;
185+
String fileName = config.fileNameGenerator.generate(url);
186+
File cacheFile = new File(cacheDir, fileName);
187+
return cacheFile.exists();
188+
}
189+
176190
public void shutdown() {
177191
Log.i(LOG_TAG, "Shutdown proxy server");
178192

sample/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ android {
1919
buildToolsVersion '24'
2020

2121
defaultConfig {
22-
applicationId "com.danikula.videocache.sample"
22+
applicationId 'com.danikula.videocache.sample'
2323
minSdkVersion 15
2424
targetSdkVersion 23
2525
versionCode 1
@@ -38,7 +38,7 @@ dependencies {
3838
// compile project(':library')
3939
compile 'com.android.support:support-v4:23.1.0'
4040
compile 'org.androidannotations:androidannotations-api:3.3.2'
41-
compile 'com.danikula:videocache:2.3.3'
41+
compile 'com.danikula:videocache:2.4.0'
4242
compile 'com.viewpagerindicator:library:2.4.2-SNAPSHOT@aar'
4343
apt 'org.androidannotations:androidannotations:3.3.2'
4444
}

sample/src/main/java/com/danikula/videocache/sample/VideoFragment.java

Lines changed: 15 additions & 0 deletions
379 Bytes
Loading
353 Bytes
Loading
265 Bytes
Loading
242 Bytes
Loading
449 Bytes
Loading

0 commit comments

Comments
 (0)