Skip to content

Commit 6e88893

Browse files
committed
Lint fixes for newer SDK
1 parent 7fad56f commit 6e88893

15 files changed

+47
-34
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ allprojects {
2323
mavenLocal()
2424
mavenCentral()
2525
google()
26-
26+
jcenter()
2727
}
2828

2929
tasks.withType(JavaCompile) {

library/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 23
4+
compileSdkVersion 28
55

66
defaultConfig {
77
minSdkVersion 9
8-
targetSdkVersion 23
8+
targetSdkVersion 28
99
consumerProguardFiles 'proguard.txt'
1010
}
1111

library/src/main/java/com/loopj/android/http/AsyncHttpResponseHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.io.InputStream;
2727
import java.lang.ref.WeakReference;
2828
import java.net.URI;
29+
import java.util.Locale;
2930

3031
import cz.msebera.android.httpclient.Header;
3132
import cz.msebera.android.httpclient.HttpEntity;
@@ -241,7 +242,7 @@ public void setCharset(final String charset) {
241242
* @param totalSize total size of file
242243
*/
243244
public void onProgress(long bytesWritten, long totalSize) {
244-
AsyncHttpClient.log.v(LOG_TAG, String.format("Progress %d from %d (%2.0f%%)", bytesWritten, totalSize, (totalSize > 0) ? (bytesWritten * 1.0 / totalSize) * 100 : -1));
245+
AsyncHttpClient.log.v(LOG_TAG, String.format(Locale.US, "Progress %d from %d (%2.0f%%)", bytesWritten, totalSize, (totalSize > 0) ? (bytesWritten * 1.0 / totalSize) * 100 : -1));
245246
}
246247

247248
/**
@@ -294,7 +295,7 @@ public void onPostProcessResponse(ResponseHandlerInterface instance, HttpRespons
294295
* @param retryNo number of retry
295296
*/
296297
public void onRetry(int retryNo) {
297-
AsyncHttpClient.log.d(LOG_TAG, String.format("Request retry no. %d", retryNo));
298+
AsyncHttpClient.log.d(LOG_TAG, String.format(Locale.US, "Request retry no. %d", retryNo));
298299
}
299300

300301
public void onCancel() {

sample/build.gradle

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,34 @@ repositories {
88
}
99

1010
android {
11-
compileSdkVersion 23
11+
compileSdkVersion 28
1212

1313
defaultConfig {
1414
minSdkVersion 9
15-
targetSdkVersion 23
15+
targetSdkVersion 28
1616
}
1717

1818
flavorDimensions "version"
1919
productFlavors {
2020
standard {
2121
dimension "version"
2222
minSdkVersion 9
23-
targetSdkVersion 23
23+
targetSdkVersion 28
2424

2525
}
2626
withLeakCanary {
2727
dimension "version"
2828
minSdkVersion 9
29-
targetSdkVersion 23
29+
targetSdkVersion 28
3030
}
3131
}
3232

33-
// compileOptions {
34-
// sourceCompatibility 'JavaVersion.VERSION_1_7'
35-
// targetCompatibility 'JavaVersion.VERSION_1_7'
36-
// }
37-
3833
lintOptions {
3934
xmlReport false
4035
warningsAsErrors true
4136
quiet false
4237
showAll true
43-
disable 'OldTargetApi', 'UnusedAttribute', 'LongLogTag'
38+
disable 'OldTargetApi', 'UnusedAttribute', 'LongLogTag', 'TrustAllX509TrustManager', 'GoogleAppIndexingWarning', 'Autofill', 'LabelFor', 'SetTextI18n'
4439
}
4540

4641
packagingOptions {

sample/src/main/java/com/loopj/android/http/sample/AsyncBackgroundThreadSample.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.concurrent.Executors;
3434
import java.util.concurrent.FutureTask;
3535
import java.util.concurrent.TimeUnit;
36+
import java.util.Locale;
3637

3738
import cz.msebera.android.httpclient.Header;
3839
import cz.msebera.android.httpclient.HttpEntity;
@@ -109,15 +110,15 @@ public void onStart() {
109110

110111
@Override
111112
public void onSuccess(int statusCode, Header[] headers, byte[] response) {
112-
Log.d(LOG_TAG, String.format("onSuccess executing on main thread : %B", Looper.myLooper() == Looper.getMainLooper()));
113+
Log.d(LOG_TAG, String.format(Locale.US, "onSuccess executing on main thread : %B", Looper.myLooper() == Looper.getMainLooper()));
113114
debugHeaders(LOG_TAG, headers);
114115
debugStatusCode(LOG_TAG, statusCode);
115116
debugResponse(LOG_TAG, new String(response));
116117
}
117118

118119
@Override
119120
public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {
120-
Log.d(LOG_TAG, String.format("onFailure executing on main thread : %B", Looper.myLooper() == Looper.getMainLooper()));
121+
Log.d(LOG_TAG, String.format(Locale.US, "onFailure executing on main thread : %B", Looper.myLooper() == Looper.getMainLooper()));
121122
debugHeaders(LOG_TAG, headers);
122123
debugStatusCode(LOG_TAG, statusCode);
123124
debugThrowable(LOG_TAG, e);
@@ -129,7 +130,7 @@ public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Th
129130
@Override
130131
public void onRetry(int retryNo) {
131132
Toast.makeText(AsyncBackgroundThreadSample.this,
132-
String.format("Request is retried, retry no. %d", retryNo),
133+
String.format(Locale.US, "Request is retried, retry no. %d", retryNo),
133134
Toast.LENGTH_SHORT)
134135
.show();
135136
}

sample/src/main/java/com/loopj/android/http/sample/CancelRequestHandleSample.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import android.util.Log;
2222

23+
import java.util.Locale;
24+
2325
import com.loopj.android.http.RequestHandle;
2426

2527
public class CancelRequestHandleSample extends ThreadingTimeoutSample {
@@ -33,14 +35,14 @@ public int getSampleTitle() {
3335

3436
@Override
3537
public void onCancelButtonPressed() {
36-
Log.d(LOG_TAG, String.format("Number of handles found: %d", getRequestHandles().size()));
38+
Log.d(LOG_TAG, String.format(Locale.US, "Number of handles found: %d", getRequestHandles().size()));
3739
int counter = 0;
3840
for (RequestHandle handle : getRequestHandles()) {
3941
if (!handle.isCancelled() && !handle.isFinished()) {
40-
Log.d(LOG_TAG, String.format("Cancelling handle %d", counter));
41-
Log.d(LOG_TAG, String.format("Handle %d cancel", counter) + (handle.cancel(true) ? " succeeded" : " failed"));
42+
Log.d(LOG_TAG, String.format(Locale.US, "Cancelling handle %d", counter));
43+
Log.d(LOG_TAG, String.format(Locale.US, "Handle %d cancel", counter) + (handle.cancel(true) ? " succeeded" : " failed"));
4244
} else {
43-
Log.d(LOG_TAG, String.format("Handle %d already non-cancellable", counter));
45+
Log.d(LOG_TAG, String.format(Locale.US, "Handle %d already non-cancellable", counter));
4446
}
4547
counter++;
4648
}

sample/src/main/java/com/loopj/android/http/sample/DirectorySample.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
import java.io.File;
3434

35+
import java.util.Locale;
36+
3537
import cz.msebera.android.httpclient.Header;
3638
import cz.msebera.android.httpclient.HttpEntity;
3739

@@ -71,8 +73,8 @@ public void onClick(View v) {
7173
clearOutputs();
7274
if (lastResponseHandler != null) {
7375
File toBeDeleted = lastResponseHandler.getTargetFile();
74-
debugResponse(LOG_TAG, String.format("File was deleted? %b", toBeDeleted.delete()));
75-
debugResponse(LOG_TAG, String.format("Delete file path: %s", toBeDeleted.getAbsolutePath()));
76+
debugResponse(LOG_TAG, String.format(Locale.US, "File was deleted? %b", toBeDeleted.delete()));
77+
debugResponse(LOG_TAG, String.format(Locale.US, "Delete file path: %s", toBeDeleted.getAbsolutePath()));
7678
} else {
7779
debugThrowable(LOG_TAG, new Error("You have to Run example first"));
7880
}

sample/src/main/java/com/loopj/android/http/sample/GetSample.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import com.loopj.android.http.RequestHandle;
2626
import com.loopj.android.http.ResponseHandlerInterface;
2727

28+
import java.util.Locale;
29+
2830
import cz.msebera.android.httpclient.Header;
2931
import cz.msebera.android.httpclient.HttpEntity;
3032

@@ -85,7 +87,7 @@ public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Th
8587
@Override
8688
public void onRetry(int retryNo) {
8789
Toast.makeText(GetSample.this,
88-
String.format("Request is retried, retry no. %d", retryNo),
90+
String.format(Locale.US, "Request is retried, retry no. %d", retryNo),
8991
Toast.LENGTH_SHORT)
9092
.show();
9193
}

sample/src/main/java/com/loopj/android/http/sample/HeadSample.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import cz.msebera.android.httpclient.Header;
2424
import cz.msebera.android.httpclient.HttpEntity;
2525

26+
import java.util.Locale;
27+
2628
public class HeadSample extends FileSample {
2729

2830
private static final String LOG_TAG = "HeadSample";
@@ -34,20 +36,20 @@ public ResponseHandlerInterface getResponseHandler() {
3436
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
3537
debugStatusCode(LOG_TAG, statusCode);
3638
debugHeaders(LOG_TAG, headers);
37-
debugResponse(LOG_TAG, String.format("Response of size: %d", responseBody == null ? 0 : responseBody.length));
39+
debugResponse(LOG_TAG, String.format(Locale.US, "Response of size: %d", responseBody == null ? 0 : responseBody.length));
3840
}
3941

4042
@Override
4143
public void onProgress(long bytesWritten, long totalSize) {
42-
addView(getColoredView(LIGHTRED, String.format("Progress %d from %d", bytesWritten, totalSize)));
44+
addView(getColoredView(LIGHTRED, String.format(Locale.US, "Progress %d from %d", bytesWritten, totalSize)));
4345
}
4446

4547
@Override
4648
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable throwable) {
4749
debugStatusCode(LOG_TAG, statusCode);
4850
debugHeaders(LOG_TAG, headers);
4951
debugThrowable(LOG_TAG, throwable);
50-
debugResponse(LOG_TAG, String.format("Response of size: %d", responseBody == null ? 0 : responseBody.length));
52+
debugResponse(LOG_TAG, String.format(Locale.US, "Response of size: %d", responseBody == null ? 0 : responseBody.length));
5153
}
5254
};
5355
}

sample/src/main/java/com/loopj/android/http/sample/Http401AuthSample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public DialogRunnable(String realm) {
188188
String prefaceText = preface.getText().toString();
189189

190190
// Substitute placeholders, and re-set the value.
191-
preface.setText(String.format(prefaceText, SECRET_USERNAME, SECRET_PASSWORD));
191+
preface.setText(String.format(Locale.US, prefaceText, SECRET_USERNAME, SECRET_PASSWORD));
192192
}
193193

194194
@Override

sample/src/main/java/com/loopj/android/http/sample/RangeResponseSample.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import java.io.File;
3131
import java.io.IOException;
3232

33+
import java.util.Locale;
34+
3335
import cz.msebera.android.httpclient.Header;
3436
import cz.msebera.android.httpclient.HttpEntity;
3537
import cz.msebera.android.httpclient.client.methods.HttpUriRequest;
@@ -75,7 +77,7 @@ protected void onDestroy() {
7577
// Remove temporary file.
7678
if (file != null) {
7779
if (!file.delete()) {
78-
Log.e(LOG_TAG, String.format("Couldn't remove temporary file in path: %s", file.getAbsolutePath()));
80+
Log.e(LOG_TAG, String.format(Locale.US, "Couldn't remove temporary file in path: %s", file.getAbsolutePath()));
7981
}
8082
file = null;
8183
}

sample/src/main/java/com/loopj/android/http/sample/Redirect302Sample.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import cz.msebera.android.httpclient.client.HttpClient;
2828
import cz.msebera.android.httpclient.impl.client.DefaultHttpClient;
2929

30+
import java.util.Locale;
31+
3032
public class Redirect302Sample extends GetSample {
3133

3234
private static final int MENU_ENABLE_REDIRECTS = 10;
@@ -89,7 +91,7 @@ public AsyncHttpClient getAsyncHttpClient() {
8991
HttpClient client = ahc.getHttpClient();
9092
if (client instanceof DefaultHttpClient) {
9193
Toast.makeText(this,
92-
String.format("redirects: %b\nrelative redirects: %b\ncircular redirects: %b",
94+
String.format(Locale.US, "redirects: %b\nrelative redirects: %b\ncircular redirects: %b",
9395
enableRedirects, enableRelativeRedirects, enableCircularRedirects),
9496
Toast.LENGTH_SHORT
9597
).show();

sample/src/main/java/com/loopj/android/http/sample/SampleParentActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public List<Header> getRequestHeadersList() {
263263

264264
String headerName = line.substring(0, equalSignPos).trim();
265265
String headerValue = line.substring(1 + equalSignPos).trim();
266-
Log.d(LOG_TAG, String.format("Added header: [%s:%s]", headerName, headerValue));
266+
Log.d(LOG_TAG, String.format(Locale.US, "Added header: [%s:%s]", headerName, headerValue));
267267

268268
headers.add(new BasicHeader(headerName, headerValue));
269269
} catch (Throwable t) {

sample/src/main/java/com/loopj/android/http/sample/ThreadingTimeoutSample.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import com.loopj.android.http.RequestHandle;
2626
import com.loopj.android.http.ResponseHandlerInterface;
2727

28+
import java.util.Locale;
29+
2830
import cz.msebera.android.httpclient.Header;
2931
import cz.msebera.android.httpclient.HttpEntity;
3032

@@ -64,7 +66,7 @@ protected synchronized void setStatus(int id, String status) {
6466
states.put(id, current == null ? status : current + "," + status);
6567
clearOutputs();
6668
for (int i = 0; i < states.size(); i++) {
67-
debugResponse(LOG_TAG, String.format("%d (from %d): %s", states.keyAt(i), getCounter(), states.get(states.keyAt(i))));
69+
debugResponse(LOG_TAG, String.format(Locale.US, "%d (from %d): %s", states.keyAt(i), getCounter(), states.get(states.keyAt(i))));
6870
}
6971
}
7072

sample/src/main/java/com/loopj/android/http/sample/services/ExampleIntentService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import com.loopj.android.http.sample.IntentServiceSample;
1111
import com.loopj.android.http.sample.util.IntentUtil;
1212

13+
import java.util.Locale;
14+
1315
import cz.msebera.android.httpclient.Header;
1416

1517
public class ExampleIntentService extends IntentService {
@@ -73,7 +75,7 @@ public void onCancel() {
7375
@Override
7476
public void onRetry(int retryNo) {
7577
sendBroadcast(new Intent(IntentServiceSample.ACTION_RETRY));
76-
Log.d(LOG_TAG, String.format("onRetry: %d", retryNo));
78+
Log.d(LOG_TAG, String.format(Locale.US, "onRetry: %d", retryNo));
7779
}
7880

7981
@Override

0 commit comments

Comments
 (0)