Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix issue #998 #1317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 13, 2019
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
buildscript {
repositories {
jcenter()
mavenCentral()
google()

}

dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'com.android.tools.build:gradle:3.4.1'
}
}

Expand All @@ -19,6 +22,8 @@ allprojects {
repositories {
mavenLocal()
mavenCentral()
google()

}

tasks.withType(JavaCompile) {
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jul 31 10:35:35 CEST 2015
#Fri Jul 12 02:01:07 PDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
8 changes: 1 addition & 7 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion '23.0.3'

defaultConfig {
minSdkVersion 9
Expand All @@ -17,15 +16,10 @@ android {
showAll true
disable 'OldTargetApi'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
}

dependencies {
compile 'cz.msebera.android:httpclient:4.3.6'
compile 'cz.msebera.android:httpclient:4.5.8'
}

android.libraryVariants.all { variant ->
Expand Down
39 changes: 20 additions & 19 deletions library/src/main/java/com/loopj/android/http/RequestParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentSkipList;
import java.util.concurrent.ConcurrentSkipListMap;
//import java.util.concurrent.ConcurrentSkipList;

import cz.msebera.android.httpclient.HttpEntity;
import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity;
Expand Down Expand Up @@ -99,11 +100,11 @@ public class RequestParams implements Serializable {
"application/json";

protected final static String LOG_TAG = "RequestParams";
protected final ConcurrentSkipList<String, String> urlParams = new ConcurrentSkipList<String, String>();
protected final ConcurrentSkipList<String, StreamWrapper> streamParams = new ConcurrentSkipList<String, StreamWrapper>();
protected final ConcurrentSkipList<String, FileWrapper> fileParams = new ConcurrentSkipList<String, FileWrapper>();
protected final ConcurrentSkipList<String, List<FileWrapper>> fileArrayParams = new ConcurrentSkipList<String, List<FileWrapper>>();
protected final ConcurrentSkipList<String, Object> urlParamsWithObjects = new ConcurrentSkipList<String, Object>();
protected final ConcurrentSkipListMap<String, String> urlParams = new ConcurrentSkipListMap<String, String>();
protected final ConcurrentSkipListMap<String, StreamWrapper> streamParams = new ConcurrentSkipListMap<String, StreamWrapper>();
protected final ConcurrentSkipListMap<String, FileWrapper> fileParams = new ConcurrentSkipListMap<String, FileWrapper>();
protected final ConcurrentSkipListMap<String, List<FileWrapper>> fileArrayParams = new ConcurrentSkipListMap<String, List<FileWrapper>>();
protected final ConcurrentSkipListMap<String, Object> urlParamsWithObjects = new ConcurrentSkipListMap<String, Object>();
protected boolean isRepeatable;
protected boolean forceMultipartEntity = false;
protected boolean useJsonStreamer;
Expand Down Expand Up @@ -425,7 +426,7 @@ public boolean has(String key) {
@Override
public String toString() {
StringBuilder result = new StringBuilder();
for (ConcurrentSkipList.Entry<String, String> entry : urlParams.entrySet()) {
for (ConcurrentSkipListMap.Entry<String, String> entry : urlParams.entrySet()) {
if (result.length() > 0)
result.append("&");

Expand All @@ -434,7 +435,7 @@ public String toString() {
result.append(entry.getValue());
}

for (ConcurrentSkipList.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
for (ConcurrentSkipListMap.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
if (result.length() > 0)
result.append("&");

Expand All @@ -443,7 +444,7 @@ public String toString() {
result.append("STREAM");
}

for (ConcurrentSkipList.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
for (ConcurrentSkipListMap.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
if (result.length() > 0)
result.append("&");

Expand All @@ -452,7 +453,7 @@ public String toString() {
result.append("FILE");
}

for (ConcurrentSkipList.Entry<String, List<FileWrapper>> entry : fileArrayParams.entrySet()) {
for (ConcurrentSkipListMap.Entry<String, List<FileWrapper>> entry : fileArrayParams.entrySet()) {
if (result.length() > 0)
result.append("&");

Expand Down Expand Up @@ -530,22 +531,22 @@ private HttpEntity createJsonStreamerEntity(ResponseHandlerInterface progressHan
elapsedFieldInJsonStreamer);

// Add string params
for (ConcurrentSkipList.Entry<String, String> entry : urlParams.entrySet()) {
for (ConcurrentSkipListMap.Entry<String, String> entry : urlParams.entrySet()) {
entity.addPart(entry.getKey(), entry.getValue());
}

// Add non-string params
for (ConcurrentSkipList.Entry<String, Object> entry : urlParamsWithObjects.entrySet()) {
for (ConcurrentSkipListMap.Entry<String, Object> entry : urlParamsWithObjects.entrySet()) {
entity.addPart(entry.getKey(), entry.getValue());
}

// Add file params
for (ConcurrentSkipList.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
for (ConcurrentSkipListMap.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
entity.addPart(entry.getKey(), entry.getValue());
}

// Add stream params
for (ConcurrentSkipList.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
for (ConcurrentSkipListMap.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
StreamWrapper stream = entry.getValue();
if (stream.inputStream != null) {
entity.addPart(entry.getKey(),
Expand Down Expand Up @@ -575,7 +576,7 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
entity.setIsRepeatable(isRepeatable);

// Add string params
for (ConcurrentSkipList.Entry<String, String> entry : urlParams.entrySet()) {
for (ConcurrentSkipListMap.Entry<String, String> entry : urlParams.entrySet()) {
entity.addPartWithCharset(entry.getKey(), entry.getValue(), contentEncoding);
}

Expand All @@ -586,7 +587,7 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
}

// Add stream params
for (ConcurrentSkipList.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
for (ConcurrentSkipListMap.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
StreamWrapper stream = entry.getValue();
if (stream.inputStream != null) {
entity.addPart(entry.getKey(), stream.name, stream.inputStream,
Expand All @@ -595,13 +596,13 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
}

// Add file params
for (ConcurrentSkipList.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
for (ConcurrentSkipListMap.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
FileWrapper fileWrapper = entry.getValue();
entity.addPart(entry.getKey(), fileWrapper.file, fileWrapper.contentType, fileWrapper.customFileName);
}

// Add file collection
for (ConcurrentSkipList.Entry<String, List<FileWrapper>> entry : fileArrayParams.entrySet()) {
for (ConcurrentSkipListMap.Entry<String, List<FileWrapper>> entry : fileArrayParams.entrySet()) {
List<FileWrapper> fileWrapper = entry.getValue();
for (FileWrapper fw : fileWrapper) {
entity.addPart(entry.getKey(), fw.file, fw.contentType, fw.customFileName);
Expand All @@ -614,7 +615,7 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
protected List<BasicNameValuePair> getParamsList() {
List<BasicNameValuePair> lparams = new LinkedList<BasicNameValuePair>();

for (ConcurrentSkipList.Entry<String, String> entry : urlParams.entrySet()) {
for (ConcurrentSkipListMap.Entry<String, String> entry : urlParams.entrySet()) {
lparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}

Expand Down
17 changes: 11 additions & 6 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,31 @@ repositories {

android {
compileSdkVersion 23
buildToolsVersion '23.0.3'

defaultConfig {
minSdkVersion 9
targetSdkVersion 23
}

flavorDimensions "version"
productFlavors {
standard {
dimension "version"
minSdkVersion 9
targetSdkVersion 23

}
withLeakCanary {
dimension "version"
minSdkVersion 9
targetSdkVersion 23
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
// compileOptions {
// sourceCompatibility 'JavaVersion.VERSION_1_7'
// targetCompatibility 'JavaVersion.VERSION_1_7'
// }

lintOptions {
xmlReport false
Expand All @@ -49,5 +54,5 @@ dependencies {
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.3'
compile project(':library')
// LeakCanary
withLeakCanaryCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
withLeakCanaryImplementation 'com.squareup.leakcanary:leakcanary-android:1.3.1'
}