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

Commit

Permalink
Cherry pick v5.0.2 changes (#8586)
Browse files Browse the repository at this point in the history
* [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)
  • Loading branch information
tobrun authored Mar 31, 2017
1 parent a46d91f commit 8e538b4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
8 changes: 8 additions & 0 deletions platform/android/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,15 @@ public void setMapboxMap(MapboxMap mapboxMap) {
}
}

/**
* 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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public void updateIcon(@NonNull MarkerView markerView) {
View convertView = markerViewMap.get(markerView);
if (convertView != null && convertView instanceof ImageView) {
((ImageView) convertView).setImageBitmap(markerView.getIcon().getBitmap());
markerView.invalidate();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ private FileSource(String cachePath, String apkPath) {
* 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);

Expand Down
6 changes: 3 additions & 3 deletions platform/android/src/file_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8e538b4

Please sign in to comment.