[go: nahoru, domu]

Skip to content

Commit

Permalink
Lint fixes for newer SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
smarek committed Jul 13, 2019
1 parent 7fad56f commit 6e88893
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 34 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ allprojects {
mavenLocal()
mavenCentral()
google()

jcenter()
}

tasks.withType(JavaCompile) {
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
compileSdkVersion 28

defaultConfig {
minSdkVersion 9
targetSdkVersion 23
targetSdkVersion 28
consumerProguardFiles 'proguard.txt'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.net.URI;
import java.util.Locale;

import cz.msebera.android.httpclient.Header;
import cz.msebera.android.httpclient.HttpEntity;
Expand Down Expand Up @@ -241,7 +242,7 @@ public void setCharset(final String charset) {
* @param totalSize total size of file
*/
public void onProgress(long bytesWritten, long totalSize) {
AsyncHttpClient.log.v(LOG_TAG, String.format("Progress %d from %d (%2.0f%%)", bytesWritten, totalSize, (totalSize > 0) ? (bytesWritten * 1.0 / totalSize) * 100 : -1));
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));
}

/**
Expand Down Expand Up @@ -294,7 +295,7 @@ public void onPostProcessResponse(ResponseHandlerInterface instance, HttpRespons
* @param retryNo number of retry
*/
public void onRetry(int retryNo) {
AsyncHttpClient.log.d(LOG_TAG, String.format("Request retry no. %d", retryNo));
AsyncHttpClient.log.d(LOG_TAG, String.format(Locale.US, "Request retry no. %d", retryNo));
}

public void onCancel() {
Expand Down
15 changes: 5 additions & 10 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,34 @@ repositories {
}

android {
compileSdkVersion 23
compileSdkVersion 28

defaultConfig {
minSdkVersion 9
targetSdkVersion 23
targetSdkVersion 28
}

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

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

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

lintOptions {
xmlReport false
warningsAsErrors true
quiet false
showAll true
disable 'OldTargetApi', 'UnusedAttribute', 'LongLogTag'
disable 'OldTargetApi', 'UnusedAttribute', 'LongLogTag', 'TrustAllX509TrustManager', 'GoogleAppIndexingWarning', 'Autofill', 'LabelFor', 'SetTextI18n'
}

packagingOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.Locale;

import cz.msebera.android.httpclient.Header;
import cz.msebera.android.httpclient.HttpEntity;
Expand Down Expand Up @@ -109,15 +110,15 @@ public void onStart() {

@Override
public void onSuccess(int statusCode, Header[] headers, byte[] response) {
Log.d(LOG_TAG, String.format("onSuccess executing on main thread : %B", Looper.myLooper() == Looper.getMainLooper()));
Log.d(LOG_TAG, String.format(Locale.US, "onSuccess executing on main thread : %B", Looper.myLooper() == Looper.getMainLooper()));
debugHeaders(LOG_TAG, headers);
debugStatusCode(LOG_TAG, statusCode);
debugResponse(LOG_TAG, new String(response));
}

@Override
public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {
Log.d(LOG_TAG, String.format("onFailure executing on main thread : %B", Looper.myLooper() == Looper.getMainLooper()));
Log.d(LOG_TAG, String.format(Locale.US, "onFailure executing on main thread : %B", Looper.myLooper() == Looper.getMainLooper()));
debugHeaders(LOG_TAG, headers);
debugStatusCode(LOG_TAG, statusCode);
debugThrowable(LOG_TAG, e);
Expand All @@ -129,7 +130,7 @@ public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Th
@Override
public void onRetry(int retryNo) {
Toast.makeText(AsyncBackgroundThreadSample.this,
String.format("Request is retried, retry no. %d", retryNo),
String.format(Locale.US, "Request is retried, retry no. %d", retryNo),
Toast.LENGTH_SHORT)
.show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import android.util.Log;

import java.util.Locale;

import com.loopj.android.http.RequestHandle;

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

@Override
public void onCancelButtonPressed() {
Log.d(LOG_TAG, String.format("Number of handles found: %d", getRequestHandles().size()));
Log.d(LOG_TAG, String.format(Locale.US, "Number of handles found: %d", getRequestHandles().size()));
int counter = 0;
for (RequestHandle handle : getRequestHandles()) {
if (!handle.isCancelled() && !handle.isFinished()) {
Log.d(LOG_TAG, String.format("Cancelling handle %d", counter));
Log.d(LOG_TAG, String.format("Handle %d cancel", counter) + (handle.cancel(true) ? " succeeded" : " failed"));
Log.d(LOG_TAG, String.format(Locale.US, "Cancelling handle %d", counter));
Log.d(LOG_TAG, String.format(Locale.US, "Handle %d cancel", counter) + (handle.cancel(true) ? " succeeded" : " failed"));
} else {
Log.d(LOG_TAG, String.format("Handle %d already non-cancellable", counter));
Log.d(LOG_TAG, String.format(Locale.US, "Handle %d already non-cancellable", counter));
}
counter++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

import java.io.File;

import java.util.Locale;

import cz.msebera.android.httpclient.Header;
import cz.msebera.android.httpclient.HttpEntity;

Expand Down Expand Up @@ -71,8 +73,8 @@ public void onClick(View v) {
clearOutputs();
if (lastResponseHandler != null) {
File toBeDeleted = lastResponseHandler.getTargetFile();
debugResponse(LOG_TAG, String.format("File was deleted? %b", toBeDeleted.delete()));
debugResponse(LOG_TAG, String.format("Delete file path: %s", toBeDeleted.getAbsolutePath()));
debugResponse(LOG_TAG, String.format(Locale.US, "File was deleted? %b", toBeDeleted.delete()));
debugResponse(LOG_TAG, String.format(Locale.US, "Delete file path: %s", toBeDeleted.getAbsolutePath()));
} else {
debugThrowable(LOG_TAG, new Error("You have to Run example first"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.loopj.android.http.RequestHandle;
import com.loopj.android.http.ResponseHandlerInterface;

import java.util.Locale;

import cz.msebera.android.httpclient.Header;
import cz.msebera.android.httpclient.HttpEntity;

Expand Down Expand Up @@ -85,7 +87,7 @@ public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Th
@Override
public void onRetry(int retryNo) {
Toast.makeText(GetSample.this,
String.format("Request is retried, retry no. %d", retryNo),
String.format(Locale.US, "Request is retried, retry no. %d", retryNo),
Toast.LENGTH_SHORT)
.show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import cz.msebera.android.httpclient.Header;
import cz.msebera.android.httpclient.HttpEntity;

import java.util.Locale;

public class HeadSample extends FileSample {

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

@Override
public void onProgress(long bytesWritten, long totalSize) {
addView(getColoredView(LIGHTRED, String.format("Progress %d from %d", bytesWritten, totalSize)));
addView(getColoredView(LIGHTRED, String.format(Locale.US, "Progress %d from %d", bytesWritten, totalSize)));
}

@Override
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable throwable) {
debugStatusCode(LOG_TAG, statusCode);
debugHeaders(LOG_TAG, headers);
debugThrowable(LOG_TAG, throwable);
debugResponse(LOG_TAG, String.format("Response of size: %d", responseBody == null ? 0 : responseBody.length));
debugResponse(LOG_TAG, String.format(Locale.US, "Response of size: %d", responseBody == null ? 0 : responseBody.length));
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public DialogRunnable(String realm) {
String prefaceText = preface.getText().toString();

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import java.io.File;
import java.io.IOException;

import java.util.Locale;

import cz.msebera.android.httpclient.Header;
import cz.msebera.android.httpclient.HttpEntity;
import cz.msebera.android.httpclient.client.methods.HttpUriRequest;
Expand Down Expand Up @@ -75,7 +77,7 @@ protected void onDestroy() {
// Remove temporary file.
if (file != null) {
if (!file.delete()) {
Log.e(LOG_TAG, String.format("Couldn't remove temporary file in path: %s", file.getAbsolutePath()));
Log.e(LOG_TAG, String.format(Locale.US, "Couldn't remove temporary file in path: %s", file.getAbsolutePath()));
}
file = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import cz.msebera.android.httpclient.client.HttpClient;
import cz.msebera.android.httpclient.impl.client.DefaultHttpClient;

import java.util.Locale;

public class Redirect302Sample extends GetSample {

private static final int MENU_ENABLE_REDIRECTS = 10;
Expand Down Expand Up @@ -89,7 +91,7 @@ public AsyncHttpClient getAsyncHttpClient() {
HttpClient client = ahc.getHttpClient();
if (client instanceof DefaultHttpClient) {
Toast.makeText(this,
String.format("redirects: %b\nrelative redirects: %b\ncircular redirects: %b",
String.format(Locale.US, "redirects: %b\nrelative redirects: %b\ncircular redirects: %b",
enableRedirects, enableRelativeRedirects, enableCircularRedirects),
Toast.LENGTH_SHORT
).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public List<Header> getRequestHeadersList() {

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

headers.add(new BasicHeader(headerName, headerValue));
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.loopj.android.http.RequestHandle;
import com.loopj.android.http.ResponseHandlerInterface;

import java.util.Locale;

import cz.msebera.android.httpclient.Header;
import cz.msebera.android.httpclient.HttpEntity;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.loopj.android.http.sample.IntentServiceSample;
import com.loopj.android.http.sample.util.IntentUtil;

import java.util.Locale;

import cz.msebera.android.httpclient.Header;

public class ExampleIntentService extends IntentService {
Expand Down Expand Up @@ -73,7 +75,7 @@ public void onCancel() {
@Override
public void onRetry(int retryNo) {
sendBroadcast(new Intent(IntentServiceSample.ACTION_RETRY));
Log.d(LOG_TAG, String.format("onRetry: %d", retryNo));
Log.d(LOG_TAG, String.format(Locale.US, "onRetry: %d", retryNo));
}

@Override
Expand Down

0 comments on commit 6e88893

Please sign in to comment.