diff --git a/build.gradle b/build.gradle
index 8ccd9c9..5634595 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,14 +1,16 @@
buildscript {
repositories {
jcenter()
+ google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.3.1'
+ classpath 'com.android.tools.build:gradle:3.3.2'
}
}
allprojects {
repositories {
+ google()
jcenter()
}
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 3c11526..84e1ddd 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
+#Tue Apr 09 10:31:28 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
diff --git a/library/build.gradle b/library/build.gradle
index 15dbe3d..3bb10d0 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -1,23 +1,14 @@
-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: 'idea'
android {
- compileSdkVersion 23
+ compileSdkVersion 26
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 9
- targetSdkVersion 23
+ targetSdkVersion 26
versionCode 22
versionName '2.7.1'
}
@@ -28,22 +19,15 @@ android {
}
}
-idea {
- module {
- downloadJavadoc = true
- downloadSources = true
- }
-}
+//idea {
+// module {
+// downloadJavadoc = true
+// downloadSources = true
+// }
+//}
dependencies {
compile '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'
-}
+
diff --git a/library/src/main/java/com/danikula/videocache/Config.java b/library/src/main/java/com/danikula/videocache/Config.java
index 29ab95c..25add15 100644
--- a/library/src/main/java/com/danikula/videocache/Config.java
+++ b/library/src/main/java/com/danikula/videocache/Config.java
@@ -1,5 +1,6 @@
package com.danikula.videocache;
+import com.danikula.videocache.extend.IHttpUrlSourceMaker;
import com.danikula.videocache.file.DiskUsage;
import com.danikula.videocache.file.FileNameGenerator;
import com.danikula.videocache.headers.HeaderInjector;
@@ -19,13 +20,15 @@ class Config {
public final DiskUsage diskUsage;
public final SourceInfoStorage sourceInfoStorage;
public final HeaderInjector headerInjector;
+ public final IHttpUrlSourceMaker sourceMaker;
- Config(File cacheRoot, FileNameGenerator fileNameGenerator, DiskUsage diskUsage, SourceInfoStorage sourceInfoStorage, HeaderInjector headerInjector) {
+ Config(File cacheRoot, FileNameGenerator fileNameGenerator, DiskUsage diskUsage, SourceInfoStorage sourceInfoStorage, HeaderInjector headerInjector,IHttpUrlSourceMaker sourceMaker) {
this.cacheRoot = cacheRoot;
this.fileNameGenerator = fileNameGenerator;
this.diskUsage = diskUsage;
this.sourceInfoStorage = sourceInfoStorage;
this.headerInjector = headerInjector;
+ this.sourceMaker = sourceMaker;
}
File generateCacheFile(String url) {
diff --git a/library/src/main/java/com/danikula/videocache/HttpProxyCache.java b/library/src/main/java/com/danikula/videocache/HttpProxyCache.java
index 010354f..37e9816 100644
--- a/library/src/main/java/com/danikula/videocache/HttpProxyCache.java
+++ b/library/src/main/java/com/danikula/videocache/HttpProxyCache.java
@@ -84,7 +84,7 @@ private void responseWithCache(OutputStream out, long offset) throws ProxyCacheE
}
private void responseWithoutCache(OutputStream out, long offset) throws ProxyCacheException, IOException {
- HttpUrlSource newSourceNoCache = new HttpUrlSource(this.source);
+ HttpUrlSource newSourceNoCache = this.source.copy();
try {
newSourceNoCache.open((int) offset);
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
diff --git a/library/src/main/java/com/danikula/videocache/HttpProxyCacheServer.java b/library/src/main/java/com/danikula/videocache/HttpProxyCacheServer.java
index 1f34ae8..31920bb 100644
--- a/library/src/main/java/com/danikula/videocache/HttpProxyCacheServer.java
+++ b/library/src/main/java/com/danikula/videocache/HttpProxyCacheServer.java
@@ -3,6 +3,7 @@
import android.content.Context;
import android.net.Uri;
+import com.danikula.videocache.extend.IHttpUrlSourceMaker;
import com.danikula.videocache.file.DiskUsage;
import com.danikula.videocache.file.FileNameGenerator;
import com.danikula.videocache.file.Md5FileNameGenerator;
@@ -353,6 +354,7 @@ public static final class Builder {
private DiskUsage diskUsage;
private SourceInfoStorage sourceInfoStorage;
private HeaderInjector headerInjector;
+ private IHttpUrlSourceMaker sourceMaker;
public Builder(Context context) {
this.sourceInfoStorage = SourceInfoStorageFactory.newSourceInfoStorage(context);
@@ -419,6 +421,17 @@ public Builder maxCacheFilesCount(int count) {
return this;
}
+ /**
+ * Set a http source maker which can build your defined http source.This give you a change to
+ * change the http request,such as sign url at so on.
+ * @param sourceMaker
+ * @return
+ */
+ public Builder sourceMaker(IHttpUrlSourceMaker sourceMaker) {
+ this.sourceMaker = sourceMaker;
+ return this;
+ }
+
/**
* Set custom DiskUsage logic for handling when to keep or clean cache.
*
@@ -452,7 +465,7 @@ public HttpProxyCacheServer build() {
}
private Config buildConfig() {
- return new Config(cacheRoot, fileNameGenerator, diskUsage, sourceInfoStorage, headerInjector);
+ return new Config(cacheRoot, fileNameGenerator, diskUsage, sourceInfoStorage, headerInjector,sourceMaker);
}
}
diff --git a/library/src/main/java/com/danikula/videocache/HttpProxyCacheServerClients.java b/library/src/main/java/com/danikula/videocache/HttpProxyCacheServerClients.java
index df12622..0061c10 100644
--- a/library/src/main/java/com/danikula/videocache/HttpProxyCacheServerClients.java
+++ b/library/src/main/java/com/danikula/videocache/HttpProxyCacheServerClients.java
@@ -79,7 +79,15 @@ public int getClientsCount() {
}
private HttpProxyCache newHttpProxyCache() throws ProxyCacheException {
- HttpUrlSource source = new HttpUrlSource(url, config.sourceInfoStorage, config.headerInjector);
+ HttpUrlSource source = null;
+ if(null != config.sourceMaker)
+ {
+ source = config.sourceMaker.createHttpUrlSource(url, config.sourceInfoStorage, config.headerInjector);
+ }
+ else
+ {
+ source = new HttpUrlSource(url, config.sourceInfoStorage, config.headerInjector);
+ }
FileCache cache = new FileCache(config.generateCacheFile(url), config.diskUsage);
HttpProxyCache httpProxyCache = new HttpProxyCache(source, cache);
httpProxyCache.registerCacheListener(uiCacheListener);
diff --git a/library/src/main/java/com/danikula/videocache/HttpUrlSource.java b/library/src/main/java/com/danikula/videocache/HttpUrlSource.java
index c7fb8ad..e193d98 100644
--- a/library/src/main/java/com/danikula/videocache/HttpUrlSource.java
+++ b/library/src/main/java/com/danikula/videocache/HttpUrlSource.java
@@ -33,14 +33,14 @@
*/
public class HttpUrlSource implements Source {
- private static final Logger LOG = LoggerFactory.getLogger("HttpUrlSource");
+ protected static final Logger LOG = LoggerFactory.getLogger("HttpUrlSource");
- private static final int MAX_REDIRECTS = 5;
- private final SourceInfoStorage sourceInfoStorage;
- private final HeaderInjector headerInjector;
- private SourceInfo sourceInfo;
- private HttpURLConnection connection;
- private InputStream inputStream;
+ protected static final int MAX_REDIRECTS = 5;
+ protected final SourceInfoStorage sourceInfoStorage;
+ protected final HeaderInjector headerInjector;
+ protected SourceInfo sourceInfo;
+ protected HttpURLConnection connection;
+ protected InputStream inputStream;
public HttpUrlSource(String url) {
this(url, SourceInfoStorageFactory.newEmptySourceInfoStorage());
@@ -64,6 +64,11 @@ public HttpUrlSource(HttpUrlSource source) {
this.headerInjector = source.headerInjector;
}
+ public HttpUrlSource copy()
+ {
+ return new HttpUrlSource(this);
+ }
+
@Override
public synchronized long length() throws ProxyCacheException {
if (sourceInfo.length == Integer.MIN_VALUE) {
diff --git a/library/src/main/java/com/danikula/videocache/extend/IHttpUrlSourceMaker.java b/library/src/main/java/com/danikula/videocache/extend/IHttpUrlSourceMaker.java
new file mode 100644
index 0000000..e58ffed
--- /dev/null
+++ b/library/src/main/java/com/danikula/videocache/extend/IHttpUrlSourceMaker.java
@@ -0,0 +1,11 @@
+package com.danikula.videocache.extend;
+
+import com.danikula.videocache.HttpUrlSource;
+import com.danikula.videocache.Source;
+import com.danikula.videocache.headers.HeaderInjector;
+import com.danikula.videocache.sourcestorage.SourceInfoStorage;
+
+public interface IHttpUrlSourceMaker
+{
+ HttpUrlSource createHttpUrlSource(String url, SourceInfoStorage sourceInfoStorage, HeaderInjector headerInjector);
+}
diff --git a/sample/build.gradle b/sample/build.gradle
index 2e33790..25617b7 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -12,7 +12,7 @@ repositories {
}
apply plugin: 'com.android.application'
-apply plugin: 'com.neenbedankt.android-apt'
+//apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 23
@@ -27,12 +27,12 @@ android {
}
}
-apt {
- arguments {
- androidManifestFile variant.outputs[0].processResources.manifestFile
- resourcePackageName android.defaultConfig.applicationId
- }
-}
+//apt {
+// arguments {
+// androidManifestFile variant.outputs[0].processResources.manifestFile
+// resourcePackageName android.defaultConfig.applicationId
+// }
+//}
dependencies {
// compile project(':library')
@@ -40,5 +40,6 @@ dependencies {
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'
+// apt 'org.androidannotations:androidannotations:3.3.2'
+ annotationProcessor 'com.google.dagger:dagger-compiler:2.12'
}
diff --git a/settings.gradle b/settings.gradle
index c83799c..4c32e20 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1,3 @@
-include ':sample', ':library', ':test'
+include ':sample'
+include ':library'
+include ':test'
diff --git a/test/src/main/AndroidManifest.xml b/test/src/main/AndroidManifest.xml
index d667938..acc5c6f 100644
--- a/test/src/main/AndroidManifest.xml
+++ b/test/src/main/AndroidManifest.xml
@@ -3,8 +3,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.danikula.videocache.test">
-
-