Cherry pick v5.0.2 changes (#8586)

* [android] execute resource transform callback on the right thread

* [android] allow resetting of resource transform callback

* update CHANGELOG for v5.0.2

* [android] - correct anchoring when Icon is updated (#8519)
This commit is contained in:
Tobrun
2017-03-31 13:48:47 +02:00
committed by GitHub
parent a46d91f7c5
commit 8e538b4d06
5 changed files with 23 additions and 5 deletions

View File

@@ -2,6 +2,14 @@
Mapbox welcomes participation and contributions from everyone. If you'd like to do so please see the [`Contributing Guide`](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) first to get started.
## 5.0.2 - April 3, 2017
5.0.2 is a patch release that contains the following changes:
* Fix resource transform callback [#8582](https://github.com/mapbox/mapbox-gl-native/pull/8582)
* Restore onTouch behaviour to 4.x version [#8585](https://github.com/mapbox/mapbox-gl-native/pull/8585)
* Restore anchoring after updating MarkerView Icon [#8519](https://github.com/mapbox/mapbox-gl-native/pull/8519)
## 5.0.1 - March 22nd, 2017
5.0.1 is a patch release that addresses a shader precision issue that created a rendering problem on some devices.

View File

@@ -389,6 +389,15 @@ public class MarkerView extends Marker {
}
}
/**
* Invalidates the MarkerView resulting in remeasuring the View.
*/
void invalidate() {
width = height = 0;
offsetX = offsetY = MapboxConstants.UNMEASURED;
markerViewManager.invalidateViewMarkersInVisibleRegion();
}
/**
* Get the String representation of a MarkerView.
*

View File

@@ -232,6 +232,7 @@ public class MarkerViewManager implements MapView.OnMapChangedListener {
View convertView = markerViewMap.get(markerView);
if (convertView != null && convertView instanceof ImageView) {
((ImageView) convertView).setImageBitmap(markerView.getIcon().getBitmap());
markerView.invalidate();
}
}

View File

@@ -123,9 +123,9 @@ public class FileSource {
* The callback will be executed on the main thread once for every requested URL.
* </p>
*
* @param callback the callback to be invoked
* @param callback the callback to be invoked or null to reset
*/
public native void setResourceTransform(@NonNull final ResourceTransformCallback callback);
public native void setResourceTransform(final ResourceTransformCallback callback);
private native void initialize(String accessToken, String cachePath, String apkPath);

View File

@@ -46,10 +46,10 @@ void FileSource::setResourceTransform(jni::JNIEnv& env, jni::Object<FileSource::
// a subsequent call.
// Note: we're converting it to shared_ptr because this lambda is converted to a std::function,
// which requires copyability of its captured variables.
callback = std::shared_ptr<jni::jobject>(transformCallback.NewGlobalRef(env).release()->Get(), GenericGlobalRefDeleter()),
env
callback = std::shared_ptr<jni::jobject>(transformCallback.NewGlobalRef(env).release()->Get(), GenericGlobalRefDeleter())
](mbgl::Resource::Kind kind, std::string&& url_) {
return FileSource::ResourceTransformCallback::onURL(const_cast<jni::JNIEnv&>(env), jni::Object<FileSource::ResourceTransformCallback>(*callback), int(kind), url_);
android::UniqueEnv _env = android::AttachEnv();
return FileSource::ResourceTransformCallback::onURL(*_env, jni::Object<FileSource::ResourceTransformCallback>(*callback), int(kind), url_);
});
} else {
// Reset the callback