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

Backport #13291 and #13290 to horchata #13294

Merged
merged 2 commits into from
Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.mapbox.mapboxsdk.maps;

import com.mapbox.mapboxsdk.MapStrictMode;
import com.mapbox.mapboxsdk.log.Logger;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

class MapChangeReceiver implements NativeMapView.StateCallback {

private static final String TAG = "Mbgl-MapChangeReceiver";

private final List<MapView.OnCameraWillChangeListener> onCameraWillChangeListenerList = new CopyOnWriteArrayList<>();
private final List<MapView.OnCameraIsChangingListener> onCameraIsChangingListenerList = new CopyOnWriteArrayList<>();
private final List<MapView.OnCameraDidChangeListener> onCameraDidChangeListenerList = new CopyOnWriteArrayList<>();
Expand All @@ -28,109 +33,169 @@ class MapChangeReceiver implements NativeMapView.StateCallback {

@Override
public void onCameraWillChange(boolean animated) {
if (!onCameraWillChangeListenerList.isEmpty()) {
for (MapView.OnCameraWillChangeListener onCameraWillChangeListener : onCameraWillChangeListenerList) {
onCameraWillChangeListener.onCameraWillChange(animated);
try {
if (!onCameraWillChangeListenerList.isEmpty()) {
for (MapView.OnCameraWillChangeListener onCameraWillChangeListener : onCameraWillChangeListenerList) {
onCameraWillChangeListener.onCameraWillChange(animated);
}
}
} catch (RuntimeException err) {
Logger.e(TAG, "Exception in onCameraWillChange", err);
MapStrictMode.strictModeViolation(err);
}
}

@Override
public void onCameraIsChanging() {
if (!onCameraIsChangingListenerList.isEmpty()) {
for (MapView.OnCameraIsChangingListener onCameraIsChangingListener : onCameraIsChangingListenerList) {
onCameraIsChangingListener.onCameraIsChanging();
try {
if (!onCameraIsChangingListenerList.isEmpty()) {
for (MapView.OnCameraIsChangingListener onCameraIsChangingListener : onCameraIsChangingListenerList) {
onCameraIsChangingListener.onCameraIsChanging();
}
}
} catch (RuntimeException err) {
Logger.e(TAG, "Exception in onCameraIsChanging", err);
MapStrictMode.strictModeViolation(err);
}
}

@Override
public void onCameraDidChange(boolean animated) {
if (!onCameraDidChangeListenerList.isEmpty()) {
for (MapView.OnCameraDidChangeListener onCameraDidChangeListener : onCameraDidChangeListenerList) {
onCameraDidChangeListener.onCameraDidChange(animated);
try {
if (!onCameraDidChangeListenerList.isEmpty()) {
for (MapView.OnCameraDidChangeListener onCameraDidChangeListener : onCameraDidChangeListenerList) {
onCameraDidChangeListener.onCameraDidChange(animated);
}
}
} catch (RuntimeException err) {
Logger.e(TAG, "Exception in onCameraDidChange", err);
MapStrictMode.strictModeViolation(err);
}
}

@Override
public void onWillStartLoadingMap() {
if (!onWillStartLoadingMapListenerList.isEmpty()) {
for (MapView.OnWillStartLoadingMapListener onWillStartLoadingMapListener : onWillStartLoadingMapListenerList) {
onWillStartLoadingMapListener.onWillStartLoadingMap();
try {
if (!onWillStartLoadingMapListenerList.isEmpty()) {
for (MapView.OnWillStartLoadingMapListener onWillStartLoadingMapListener : onWillStartLoadingMapListenerList) {
onWillStartLoadingMapListener.onWillStartLoadingMap();
}
}
} catch (RuntimeException err) {
Logger.e(TAG, "Exception in onWillStartLoadingMap", err);
MapStrictMode.strictModeViolation(err);
}
}

@Override
public void onDidFinishLoadingMap() {
if (!onDidFinishLoadingMapListenerList.isEmpty()) {
for (MapView.OnDidFinishLoadingMapListener onDidFinishLoadingMapListener : onDidFinishLoadingMapListenerList) {
onDidFinishLoadingMapListener.onDidFinishLoadingMap();
try {
if (!onDidFinishLoadingMapListenerList.isEmpty()) {
for (MapView.OnDidFinishLoadingMapListener onDidFinishLoadingMapListener : onDidFinishLoadingMapListenerList) {
onDidFinishLoadingMapListener.onDidFinishLoadingMap();
}
}
} catch (RuntimeException err) {
Logger.e(TAG, "Exception in onDidFinishLoadingMap", err);
MapStrictMode.strictModeViolation(err);
}
}

@Override
public void onDidFailLoadingMap(String error) {
if (!onDidFailLoadingMapListenerList.isEmpty()) {
for (MapView.OnDidFailLoadingMapListener onDidFailLoadingMapListener : onDidFailLoadingMapListenerList) {
onDidFailLoadingMapListener.onDidFailLoadingMap(error);
try {
if (!onDidFailLoadingMapListenerList.isEmpty()) {
for (MapView.OnDidFailLoadingMapListener onDidFailLoadingMapListener : onDidFailLoadingMapListenerList) {
onDidFailLoadingMapListener.onDidFailLoadingMap(error);
}
}
} catch (RuntimeException err) {
Logger.e(TAG, "Exception in onDidFailLoadingMap", err);
MapStrictMode.strictModeViolation(err);
}
}

@Override
public void onWillStartRenderingFrame() {
if (!onWillStartRenderingFrameList.isEmpty()) {
for (MapView.OnWillStartRenderingFrameListener listener : onWillStartRenderingFrameList) {
listener.onWillStartRenderingFrame();
try {
if (!onWillStartRenderingFrameList.isEmpty()) {
for (MapView.OnWillStartRenderingFrameListener listener : onWillStartRenderingFrameList) {
listener.onWillStartRenderingFrame();
}
}
} catch (RuntimeException err) {
Logger.e(TAG, "Exception in onWillStartRenderingFrame", err);
MapStrictMode.strictModeViolation(err);
}
}

@Override
public void onDidFinishRenderingFrame(boolean fully) {
if (!onDidFinishRenderingFrameList.isEmpty()) {
for (MapView.OnDidFinishRenderingFrameListener listener : onDidFinishRenderingFrameList) {
listener.onDidFinishRenderingFrame(fully);
try {
if (!onDidFinishRenderingFrameList.isEmpty()) {
for (MapView.OnDidFinishRenderingFrameListener listener : onDidFinishRenderingFrameList) {
listener.onDidFinishRenderingFrame(fully);
}
}
} catch (RuntimeException err) {
Logger.e(TAG, "Exception in onDidFinishRenderingFrame", err);
MapStrictMode.strictModeViolation(err);
}
}

@Override
public void onWillStartRenderingMap() {
if (!onWillStartRenderingMapListenerList.isEmpty()) {
for (MapView.OnWillStartRenderingMapListener listener : onWillStartRenderingMapListenerList) {
listener.onWillStartRenderingMap();
try {
if (!onWillStartRenderingMapListenerList.isEmpty()) {
for (MapView.OnWillStartRenderingMapListener listener : onWillStartRenderingMapListenerList) {
listener.onWillStartRenderingMap();
}
}
} catch (RuntimeException err) {
Logger.e(TAG, "Exception in onWillStartRenderingMap", err);
MapStrictMode.strictModeViolation(err);
}
}

@Override
public void onDidFinishRenderingMap(boolean fully) {
if (!onDidFinishRenderingMapListenerList.isEmpty()) {
for (MapView.OnDidFinishRenderingMapListener listener : onDidFinishRenderingMapListenerList) {
listener.onDidFinishRenderingMap(fully);
try {
if (!onDidFinishRenderingMapListenerList.isEmpty()) {
for (MapView.OnDidFinishRenderingMapListener listener : onDidFinishRenderingMapListenerList) {
listener.onDidFinishRenderingMap(fully);
}
}
} catch (RuntimeException err) {
Logger.e(TAG, "Exception in onDidFinishRenderingMap", err);
MapStrictMode.strictModeViolation(err);
}
}

@Override
public void onDidFinishLoadingStyle() {
if (!onDidFinishLoadingStyleListenerList.isEmpty()) {
for (MapView.OnDidFinishLoadingStyleListener listener : onDidFinishLoadingStyleListenerList) {
listener.onDidFinishLoadingStyle();
try {
if (!onDidFinishLoadingStyleListenerList.isEmpty()) {
for (MapView.OnDidFinishLoadingStyleListener listener : onDidFinishLoadingStyleListenerList) {
listener.onDidFinishLoadingStyle();
}
}
} catch (RuntimeException err) {
Logger.e(TAG, "Exception in onDidFinishLoadingStyle", err);
MapStrictMode.strictModeViolation(err);
}
}

@Override
public void onSourceChanged(String sourceId) {
if (!onSourceChangedListenerList.isEmpty()) {
for (MapView.OnSourceChangedListener onSourceChangedListener : onSourceChangedListenerList) {
onSourceChangedListener.onSourceChangedListener(sourceId);
try {
if (!onSourceChangedListenerList.isEmpty()) {
for (MapView.OnSourceChangedListener onSourceChangedListener : onSourceChangedListenerList) {
onSourceChangedListener.onSourceChangedListener(sourceId);
}
}
} catch (RuntimeException err) {
Logger.e(TAG, "Exception in onSourceChanged", err);
MapStrictMode.strictModeViolation(err);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,12 @@ public void removeOnSourceChangedListener(OnSourceChangedListener listener) {
mapChangeReceiver.removeOnSourceChangedListener(listener);
}

/**
* Interface definition for a callback to be invoked when the camera will change.
* <p>
* {@link MapView#addOnCameraWillChangeListener(OnCameraWillChangeListener)}
* </p>
*/
public interface OnCameraWillChangeListener {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,18 @@ public PropertyValue<String> getTextField() {
if (propertyValue.isExpression()) {
return (PropertyValue<String>) propertyValue;
} else {
String text = null;

Formatted formatted = (Formatted) nativeGetTextField();
StringBuilder builder = new StringBuilder();
for (FormattedSection section : formatted.getFormattedSections()) {
builder.append(section.getText());
if (formatted != null) {
StringBuilder builder = new StringBuilder();
for (FormattedSection section : formatted.getFormattedSections()) {
builder.append(section.getText());
}
text = builder.toString();
}

return (PropertyValue<String>) new PropertyValue("text-field", builder.toString());
return (PropertyValue<String>) new PropertyValue("text-field", text);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,18 @@ public class <%- camelize(type) %>Layer extends Layer {
if (propertyValue.isExpression()) {
return (PropertyValue<String>) propertyValue;
} else {
String text = null;

Formatted formatted = (Formatted) nativeGetTextField();
StringBuilder builder = new StringBuilder();
for (FormattedSection section : formatted.getFormattedSections()) {
builder.append(section.getText());
if (formatted != null) {
StringBuilder builder = new StringBuilder();
for (FormattedSection section : formatted.getFormattedSections()) {
builder.append(section.getText());
}
text = builder.toString();
}

return (PropertyValue<String>) new PropertyValue("text-field", builder.toString());
return (PropertyValue<String>) new PropertyValue("text-field", text);
}
<% } else { -%>
return (PropertyValue<<%- propertyType(property) %>>) new PropertyValue("<%- property.name %>", nativeGet<%- camelize(property.name) %>());
Expand Down
Loading