[android] - remove java 8 language features
This commit is contained in:
@@ -39,18 +39,32 @@ class LocalRequestTask extends AsyncTask<String, Void, byte[]> {
|
||||
|
||||
private static byte[] loadFile(AssetManager assets, String path) {
|
||||
byte[] buffer = null;
|
||||
try (InputStream input = assets.open(path)) {
|
||||
InputStream input = null;
|
||||
try {
|
||||
input = assets.open(path);
|
||||
int size = input.available();
|
||||
buffer = new byte[size];
|
||||
input.read(buffer);
|
||||
} catch (IOException exception) {
|
||||
String message = "Load file failed";
|
||||
Logger.e(TAG, message, exception);
|
||||
MapStrictMode.strictModeViolation(message, exception);
|
||||
logFileError(exception);
|
||||
} finally {
|
||||
if (input != null) {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException exception) {
|
||||
logFileError(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private static void logFileError(Exception exception) {
|
||||
String message = "Load file failed";
|
||||
Logger.e(TAG, message, exception);
|
||||
MapStrictMode.strictModeViolation(message, exception);
|
||||
}
|
||||
|
||||
public interface OnLocalRequestResponse {
|
||||
void onResponse(byte[] bytes);
|
||||
}
|
||||
|
||||
@@ -58,13 +58,16 @@ public class NativeHttpRequest implements HttpResponder {
|
||||
}
|
||||
|
||||
private void executeLocalRequest(String resourceUrl) {
|
||||
new LocalRequestTask(bytes -> {
|
||||
if (bytes != null) {
|
||||
lock.lock();
|
||||
if (nativePtr != 0) {
|
||||
nativeOnResponse(200, null, null, null, null, null, null, bytes);
|
||||
new LocalRequestTask(new LocalRequestTask.OnLocalRequestResponse() {
|
||||
@Override
|
||||
public void onResponse(byte[] bytes) {
|
||||
if (bytes != null) {
|
||||
lock.lock();
|
||||
if (nativePtr != 0) {
|
||||
NativeHttpRequest.this.nativeOnResponse(200, null, null, null, null, null, null, bytes);
|
||||
}
|
||||
lock.unlock();
|
||||
}
|
||||
lock.unlock();
|
||||
}
|
||||
}).execute(resourceUrl);
|
||||
}
|
||||
|
||||
@@ -201,6 +201,24 @@ public final class Logger {
|
||||
* @param message The message you would like logged.
|
||||
*/
|
||||
public static void log(int severity, String tag, String message) {
|
||||
LoggerDefinition.log(severity, tag, message);
|
||||
switch (severity) {
|
||||
case Log.VERBOSE:
|
||||
Logger.v(tag, message);
|
||||
break;
|
||||
case Log.DEBUG:
|
||||
Logger.d(tag, message);
|
||||
break;
|
||||
case Log.INFO:
|
||||
Logger.i(tag, message);
|
||||
break;
|
||||
case Log.WARN:
|
||||
Logger.w(tag, message);
|
||||
break;
|
||||
case Log.ERROR:
|
||||
Logger.e(tag, message);
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.mapbox.mapboxsdk.log;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Definition of a logger for the Mapbox Maps SDK for Android.
|
||||
*/
|
||||
@@ -101,34 +99,4 @@ public interface LoggerDefinition {
|
||||
* @param tr An exception to log
|
||||
*/
|
||||
void e(String tag, String msg, Throwable tr);
|
||||
|
||||
/**
|
||||
* Send a log message based on severity.
|
||||
*
|
||||
* @param severity the log severity
|
||||
* @param tag Used to identify the source of a log message. It usually identifies
|
||||
* the class or activity where the log call occurs.
|
||||
* @param message The message you would like logged.
|
||||
*/
|
||||
static void log(int severity, String tag, String message) {
|
||||
switch (severity) {
|
||||
case Log.VERBOSE:
|
||||
Logger.v(tag, message);
|
||||
break;
|
||||
case Log.DEBUG:
|
||||
Logger.d(tag, message);
|
||||
break;
|
||||
case Log.INFO:
|
||||
Logger.i(tag, message);
|
||||
break;
|
||||
case Log.WARN:
|
||||
Logger.w(tag, message);
|
||||
break;
|
||||
case Log.ERROR:
|
||||
Logger.e(tag, message);
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,7 +237,7 @@ public class OfflineManager {
|
||||
* @param callback completion/error callback
|
||||
*/
|
||||
public void mergeOfflineRegions(@NonNull String path, @NonNull final MergeOfflineRegionsCallback callback) {
|
||||
File src = new File(path);
|
||||
final File src = new File(path);
|
||||
new FileUtils.CheckFileReadPermissionTask(new FileUtils.OnCheckFileReadPermissionListener() {
|
||||
@Override
|
||||
public void onReadPermissionGranted() {
|
||||
@@ -329,12 +329,12 @@ public class OfflineManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void mergeOfflineDatabaseFiles(@NonNull File file, @NonNull final MergeOfflineRegionsCallback callback,
|
||||
boolean isTemporaryFile) {
|
||||
private void mergeOfflineDatabaseFiles(@NonNull final File file, @NonNull final MergeOfflineRegionsCallback callback,
|
||||
final boolean isTemporaryFile) {
|
||||
fileSource.activate();
|
||||
mergeOfflineRegions(fileSource, file.getAbsolutePath(), new MergeOfflineRegionsCallback() {
|
||||
@Override
|
||||
public void onMerge(OfflineRegion[] offlineRegions) {
|
||||
public void onMerge(final OfflineRegion[] offlineRegions) {
|
||||
getHandler().post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -348,7 +348,7 @@ public class OfflineManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
public void onError(final String error) {
|
||||
getHandler().post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -230,7 +230,7 @@ public class CustomGeometrySource extends Source {
|
||||
}
|
||||
|
||||
executor = new ThreadPoolExecutor(THREAD_POOL_LIMIT, THREAD_POOL_LIMIT,
|
||||
0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(),
|
||||
0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(),
|
||||
new ThreadFactory() {
|
||||
final AtomicInteger threadCount = new AtomicInteger();
|
||||
final int poolId = poolCount.getAndIncrement();
|
||||
|
||||
Reference in New Issue
Block a user