Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] - remove java 8 language features
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Oct 25, 2018
1 parent 7f12646 commit beb7566
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 59 deletions.
5 changes: 0 additions & 5 deletions platform/android/MapboxGLAndroidSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ android {
main.res.srcDirs += 'src/main/res-public'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {
disable 'MissingTranslation', 'TypographyQuotes', 'ObsoleteLintCustomCheck', 'MissingPermission', 'WrongThreadInterprocedural'
checkAllWarnings true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,32 @@ protected void onPostExecute(byte[] bytes) {

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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,16 @@ public void onResponse(int responseCode, String etag, String lastModified, Strin
}

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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@ public static void e(String tag, String msg, Throwable tr) {
* @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();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.mapbox.mapboxsdk.log;

import android.util.Log;

/**
* Definition of a logger for the Mapbox Maps SDK for Android.
*/
Expand Down Expand Up @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,14 @@ public void onSurfaceCreated(GL10 gl, EGLConfig config) {
);

// deprecated API
nativeMapView.addOnMapChangedListener(change -> {
// dispatch events to external listeners
if (!onMapChangedListeners.isEmpty()) {
for (OnMapChangedListener onMapChangedListener : onMapChangedListeners) {
onMapChangedListener.onMapChanged(change);
nativeMapView.addOnMapChangedListener(new OnMapChangedListener() {
@Override
public void onMapChanged(int change) {
// dispatch events to external listeners
if (!onMapChangedListeners.isEmpty()) {
for (OnMapChangedListener onMapChangedListener : onMapChangedListeners) {
onMapChangedListener.onMapChanged(change);
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public void run() {
* @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() {
Expand Down Expand Up @@ -329,12 +329,12 @@ private static void copyTempDatabaseFile(File sourceFile, File destFile) throws
}
}

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() {
Expand All @@ -348,7 +348,7 @@ public void run() {
}

@Override
public void onError(String error) {
public void onError(final String error) {
getHandler().post(new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private void startThreads() {
}

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();
Expand Down

0 comments on commit beb7566

Please sign in to comment.