bump gl-native submodule and bring platform changes

This commit is contained in:
Łukasz Paczos
2019-11-13 14:14:21 +01:00
parent b381086338
commit dfdbaf5493
8 changed files with 182 additions and 6 deletions

View File

@@ -8,6 +8,7 @@ import android.support.annotation.Keep;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
import com.mapbox.mapboxsdk.LibraryLoader;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.R;
@@ -306,6 +307,47 @@ public class OfflineManager {
});
}
/**
* Packs the existing database file into a minimal amount of disk space.
* <p>
* When the operation is complete or encounters an error, the given callback will be
* executed on the database thread; it is the responsibility of the SDK bindings
* to re-execute a user-provided callback on the main thread.
* </p>
*
* @param callback the callback to be invoked when the database was reset or when the operation erred.
*/
public void packDatabase(@Nullable final FileSourceCallback callback) {
fileSource.activate();
nativePackDatabase(new FileSourceCallback() {
@Override
public void onSuccess() {
handler.post(new Runnable() {
@Override
public void run() {
fileSource.deactivate();
if (callback != null) {
callback.onSuccess();
}
}
});
}
@Override
public void onError(@NonNull final String message) {
handler.post(new Runnable() {
@Override
public void run() {
fileSource.deactivate();
if (callback != null) {
callback.onError(message);
}
}
});
}
});
}
/**
* Forces re-validation of the ambient cache.
* <p>
@@ -648,6 +690,9 @@ public class OfflineManager {
@Keep
private native void nativeResetDatabase(@Nullable FileSourceCallback callback);
@Keep
private native void nativePackDatabase(@Nullable FileSourceCallback callback);
@Keep
private native void nativeInvalidateAmbientCache(@Nullable FileSourceCallback callback);

View File

@@ -401,7 +401,55 @@ public class OfflineRegion {
if (!isDeleted) {
isDeleted = true;
fileSource.activate();
deleteOfflineRegion(new OfflineRegionDeleteCallback() {
deleteOfflineRegion(true /*pack*/, new OfflineRegionDeleteCallback() {
@Override
public void onDelete() {
handler.post(new Runnable() {
@Override
public void run() {
fileSource.deactivate();
callback.onDelete();
OfflineRegion.this.finalize();
}
});
}
@Override
public void onError(final String error) {
handler.post(new Runnable() {
@Override
public void run() {
isDeleted = false;
fileSource.deactivate();
callback.onError(error);
}
});
}
});
}
}
/**
* Same as {@link OfflineRegion#delete} but skipping database file packing for performance reasons.
* <p>
* Database file packing can be done later with {@link OfflineManager#packDatabase}.
* This method is a useful optimization e.g. when several regions should be deleted in a row.
* </p>
* <p>
* When the operation is complete or encounters an error, the given callback will be
* executed on the main thread.
* </p>
* <p>
* After you call this method, you may not call any additional methods on this object.
* </p>
*
* @param callback the callback to be invoked
*/
public void deleteAndSkipPackDatabase(@NonNull final OfflineRegionDeleteCallback callback) {
if (!isDeleted) {
isDeleted = true;
fileSource.activate();
deleteOfflineRegion(false /*pack*/, new OfflineRegionDeleteCallback() {
@Override
public void onDelete() {
handler.post(new Runnable() {
@@ -521,7 +569,7 @@ public class OfflineRegion {
private native void getOfflineRegionStatus(OfflineRegionStatusCallback callback);
@Keep
private native void deleteOfflineRegion(OfflineRegionDeleteCallback callback);
private native void deleteOfflineRegion(boolean pack, OfflineRegionDeleteCallback callback);
@Keep
private native void updateOfflineRegionMetadata(byte[] metadata, OfflineRegionUpdateMetadataCallback callback);

View File

@@ -5,6 +5,7 @@ import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.Size;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
@@ -3150,7 +3151,7 @@ public class Expression {
* If set, the min-fraction-digits and max-fraction-digits arguments specify the minimum and maximum number
* of fractional digits to include.
*
* @param number number expression
* @param number number expression
* @param options number formatting options
* @return expression
*/
@@ -3169,7 +3170,7 @@ public class Expression {
* If set, the min-fraction-digits and max-fraction-digits arguments specify the minimum and maximum number
* of fractional digits to include.
*
* @param number number expression
* @param number number expression
* @param options number formatting options
* @return expression
*/
@@ -3409,6 +3410,49 @@ public class Expression {
return new FormatEntry(literal(text), null);
}
/**
* Returns image expression for use in '*-pattern' and 'icon-image' layer properties. Compared to
* string literals that can be used to represent an image, image expression allows to determine an
* image's availability at runtime, thus, can be used in conditional <a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-coalesce">coalesce operator</a>.
*
* <p>
* Example usage:
* </p>
* <pre>
* {@code
* SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id");
* symbolLayer.setProperties(
* iconImage(image(get("key-to-feature")))
* );
* }
* </pre>
*
* <p>
* Example usage with coalesce operator:
* </p>
* <pre>
* {@code
* SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id");
* symbolLayer.setProperties(
* iconImage(
* coalesce(
* image(literal("maki-11")),
* image(literal("bicycle-15")),
* image(literal("default-icon"))
* )
* )
* );
* }
* </pre>
*
* @param input expression input
* @return expression
* @see <a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-types-image">Image expression</a>
*/
public static Expression image(@NonNull Expression input) {
return new Expression("image", input);
}
/**
* Asserts that the input value is an object. If it is not, the expression is an error
* The asserted input value is returned as result.
@@ -4430,7 +4474,7 @@ public class Expression {
/**
* Create an option option entry that is encapsulated as a json object member for an expression.
*
* @param type json object member name
* @param type json object member name
* @param value json object member value
*/
Option(@NonNull String type, @NonNull Expression value) {