Solve lint issues, reduce baseline (#9627)
* [android] - fix lint issues SDK
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.mapbox.mapboxsdk;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
@@ -26,6 +27,7 @@ import com.mapbox.services.android.telemetry.location.LocationEnginePriority;
|
||||
@UiThread
|
||||
public final class Mapbox {
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static Mapbox INSTANCE;
|
||||
private Context context;
|
||||
private String accessToken;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.annotations;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
@@ -35,6 +36,7 @@ public final class IconFactory {
|
||||
public static final String ICON_MARKERVIEW_ID = ICON_ID_PREFIX + "marker_view";
|
||||
|
||||
private Context context;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static IconFactory instance;
|
||||
private Icon defaultMarker;
|
||||
private Icon defaultMarkerView;
|
||||
|
||||
@@ -109,13 +109,11 @@ class HTTPRequest implements Callback {
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
if (response.isSuccessful()) {
|
||||
Timber.v(String.format("[HTTP] Request was successful (code = %d).", response.code()));
|
||||
Timber.v("[HTTP] Request was successful (code = %s).", response.code());
|
||||
} else {
|
||||
// We don't want to call this unsuccessful because a 304 isn't really an error
|
||||
String message = !TextUtils.isEmpty(response.message()) ? response.message() : "No additional information";
|
||||
Timber.d(String.format(
|
||||
"[HTTP] Request with response code = %d: %s",
|
||||
response.code(), message));
|
||||
Timber.d("[HTTP] Request with response code = %s: %s", response.code(), message);
|
||||
}
|
||||
|
||||
byte[] body;
|
||||
@@ -160,15 +158,12 @@ class HTTPRequest implements Callback {
|
||||
String errorMessage = e.getMessage() != null ? e.getMessage() : "Error processing the request";
|
||||
|
||||
if (type == TEMPORARY_ERROR) {
|
||||
Timber.d(String.format(MapboxConstants.MAPBOX_LOCALE,
|
||||
"Request failed due to a temporary error: %s", errorMessage));
|
||||
Timber.d("Request failed due to a temporary error: %s", errorMessage);
|
||||
} else if (type == CONNECTION_ERROR) {
|
||||
Timber.i(String.format(MapboxConstants.MAPBOX_LOCALE,
|
||||
"Request failed due to a connection error: %s", errorMessage));
|
||||
Timber.i("Request failed due to a connection error: %s", errorMessage);
|
||||
} else {
|
||||
// PERMANENT_ERROR
|
||||
Timber.w(String.format(MapboxConstants.MAPBOX_LOCALE,
|
||||
"Request failed due to a permanent error: %s", errorMessage));
|
||||
Timber.w("Request failed due to a permanent error: %s", errorMessage);
|
||||
}
|
||||
|
||||
mLock.lock();
|
||||
|
||||
@@ -272,7 +272,6 @@ public final class MapboxMap {
|
||||
* Check whether tile pre-fetching is enabled or not.
|
||||
*
|
||||
* @return true if enabled
|
||||
*
|
||||
* @see MapboxMap#setPrefetchesTiles(boolean)
|
||||
*/
|
||||
@UiThread
|
||||
@@ -316,7 +315,7 @@ public final class MapboxMap {
|
||||
// noinspection unchecked
|
||||
return (T) nativeMapView.getLayer(layerId);
|
||||
} catch (ClassCastException exception) {
|
||||
Timber.e(String.format("Layer: %s is a different type: %s", layerId, exception));
|
||||
Timber.e(exception, "Layer: %s is a different type: ", layerId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -437,7 +436,7 @@ public final class MapboxMap {
|
||||
// noinspection unchecked
|
||||
return (T) nativeMapView.getSource(sourceId);
|
||||
} catch (ClassCastException exception) {
|
||||
Timber.e(String.format("Source: %s is a different type: %s", sourceId, exception));
|
||||
Timber.e(exception, "Source: %s is a different type: ", sourceId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.Polygon;
|
||||
import com.mapbox.mapboxsdk.annotations.Polyline;
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.constants.MapboxConstants;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.geometry.ProjectedMeters;
|
||||
@@ -84,9 +83,10 @@ final class NativeMapView {
|
||||
|
||||
private boolean isDestroyedOn(String callingMethod) {
|
||||
if (destroyed && !TextUtils.isEmpty(callingMethod)) {
|
||||
Timber.e(String.format(MapboxConstants.MAPBOX_LOCALE,
|
||||
Timber.e(
|
||||
"You're calling `%s` after the `MapView` was destroyed, were you invoking it after `onDestroy()`?",
|
||||
callingMethod));
|
||||
callingMethod
|
||||
);
|
||||
}
|
||||
return destroyed;
|
||||
}
|
||||
@@ -143,14 +143,14 @@ final class NativeMapView {
|
||||
if (width > 65535) {
|
||||
// we have seen edge cases where devices return incorrect values #6111
|
||||
Timber.e("Device returned an out of range width size, "
|
||||
+ "capping value at 65535 instead of " + width);
|
||||
+ "capping value at 65535 instead of %s", width);
|
||||
width = 65535;
|
||||
}
|
||||
|
||||
if (height > 65535) {
|
||||
// we have seen edge cases where devices return incorrect values #6111
|
||||
Timber.e("Device returned an out of range height size, "
|
||||
+ "capping value at 65535 instead of " + height);
|
||||
+ "capping value at 65535 instead of %s", height);
|
||||
height = 65535;
|
||||
}
|
||||
nativeResizeView(width, height);
|
||||
|
||||
@@ -346,7 +346,7 @@ final class Transform implements MapView.OnMapChangedListener {
|
||||
|
||||
void setMinZoom(double minZoom) {
|
||||
if ((minZoom < MapboxConstants.MINIMUM_ZOOM) || (minZoom > MapboxConstants.MAXIMUM_ZOOM)) {
|
||||
Timber.e("Not setting minZoomPreference, value is in unsupported range: " + minZoom);
|
||||
Timber.e("Not setting minZoomPreference, value is in unsupported range: %s", minZoom);
|
||||
return;
|
||||
}
|
||||
mapView.setMinZoom(minZoom);
|
||||
@@ -358,7 +358,7 @@ final class Transform implements MapView.OnMapChangedListener {
|
||||
|
||||
void setMaxZoom(double maxZoom) {
|
||||
if ((maxZoom < MapboxConstants.MINIMUM_ZOOM) || (maxZoom > MapboxConstants.MAXIMUM_ZOOM)) {
|
||||
Timber.e("Not setting maxZoomPreference, value is in unsupported range: " + maxZoom);
|
||||
Timber.e("Not setting maxZoomPreference, value is in unsupported range: %s", maxZoom);
|
||||
return;
|
||||
}
|
||||
mapView.setMaxZoom(maxZoom);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mapbox.mapboxsdk.maps.widgets;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Camera;
|
||||
import android.graphics.Canvas;
|
||||
@@ -775,6 +776,7 @@ public class MyLocationView extends View {
|
||||
locationSource = new WeakReference<>(locationEngine);
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
public void onConnected() {
|
||||
MyLocationView locationView = userLocationView.get();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.net;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -21,6 +22,7 @@ import timber.log.Timber;
|
||||
* Not public api.
|
||||
*/
|
||||
public class ConnectivityReceiver extends BroadcastReceiver {
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static ConnectivityReceiver INSTANCE;
|
||||
|
||||
/**
|
||||
@@ -82,7 +84,7 @@ public class ConnectivityReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
boolean connected = isConnected(context);
|
||||
Timber.v("Connected: " + connected);
|
||||
Timber.v("Connected: %s", connected);
|
||||
|
||||
// Loop over listeners
|
||||
for (ConnectivityListener listener : listeners) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.offline;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@@ -40,6 +41,7 @@ public class OfflineManager {
|
||||
private Handler handler;
|
||||
|
||||
// This object is implemented as a singleton
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static OfflineManager instance;
|
||||
|
||||
// The application context
|
||||
@@ -90,11 +92,11 @@ public class OfflineManager {
|
||||
*/
|
||||
private OfflineManager(Context context) {
|
||||
this.context = context.getApplicationContext();
|
||||
this.fileSource = FileSource.getInstance(context);
|
||||
this.fileSource = FileSource.getInstance(this.context);
|
||||
initialize(fileSource);
|
||||
|
||||
// Delete any existing previous ambient cache database
|
||||
deleteAmbientDatabase(context);
|
||||
deleteAmbientDatabase(this.context);
|
||||
}
|
||||
|
||||
private void deleteAmbientDatabase(final Context context) {
|
||||
@@ -107,10 +109,10 @@ public class OfflineManager {
|
||||
File file = new File(path);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
Timber.d("Old ambient cache database deleted to save space: " + path);
|
||||
Timber.d("Old ambient cache database deleted to save space: %s", path);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
Timber.e("Failed to delete old ambient cache database: ", exception);
|
||||
Timber.e(exception, "Failed to delete old ambient cache database: ");
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
@@ -72,9 +72,9 @@ public class FileSource {
|
||||
MapboxConstants.KEY_META_DATA_SET_STORAGE_EXTERNAL,
|
||||
MapboxConstants.DEFAULT_SET_STORAGE_EXTERNAL);
|
||||
} catch (PackageManager.NameNotFoundException exception) {
|
||||
Timber.e("Failed to read the package metadata: ", exception);
|
||||
Timber.e(exception,"Failed to read the package metadata: ");
|
||||
} catch (Exception exception) {
|
||||
Timber.e("Failed to read the storage key: ", exception);
|
||||
Timber.e(exception, "Failed to read the storage key: ");
|
||||
}
|
||||
|
||||
String cachePath = null;
|
||||
@@ -83,7 +83,7 @@ public class FileSource {
|
||||
// Try getting the external storage path
|
||||
cachePath = context.getExternalFilesDir(null).getAbsolutePath();
|
||||
} catch (NullPointerException exception) {
|
||||
Timber.e("Failed to obtain the external storage path: ", exception);
|
||||
Timber.e(exception, "Failed to obtain the external storage path: ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ public class Function<I, O> {
|
||||
// noinspection unchecked
|
||||
return (S) stops;
|
||||
} catch (ClassCastException exception) {
|
||||
Timber.e(String.format("Stops: %s is a different type: %s", stops.getClass(), exception));
|
||||
Timber.e(exception, "Stops: %s is a different type: ", stops.getClass());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user