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

Commit

Permalink
[docs] EnterIdle -> BecomeIdle
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLoer committed Dec 10, 2018
1 parent 64c8cf9 commit 9fc6f30
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 50 deletions.
2 changes: 1 addition & 1 deletion include/mbgl/map/map_observer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MapObserver {
virtual void onDidFinishRenderingMap(RenderMode) {}
virtual void onDidFinishLoadingStyle() {}
virtual void onSourceChanged(style::Source&) {}
virtual void onDidEnterIdle() {}
virtual void onDidBecomeIdle() {}
};

} // namespace mbgl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MapChangeReceiver implements NativeMapView.StateCallback {
= new CopyOnWriteArrayList<>();
private final List<MapView.OnDidFinishRenderingMapListener> onDidFinishRenderingMapListenerList
= new CopyOnWriteArrayList<>();
private final List<MapView.OnDidEnterIdleListener> onDidEnterIdleListenerList
private final List<MapView.OnDidBecomeIdleListener> onDidBecomeIdleListenerList
= new CopyOnWriteArrayList<>();
private final List<MapView.OnDidFinishLoadingStyleListener> onDidFinishLoadingStyleListenerList
= new CopyOnWriteArrayList<>();
Expand Down Expand Up @@ -173,15 +173,15 @@ public void onDidFinishRenderingMap(boolean fully) {
}

@Override
public void onDidEnterIdle() {
public void onDidBecomeIdle() {
try {
if (!onDidEnterIdleListenerList.isEmpty()) {
for (MapView.OnDidEnterIdleListener listener : onDidEnterIdleListenerList) {
listener.onDidEnterIdle();
if (!onDidBecomeIdleListenerList.isEmpty()) {
for (MapView.OnDidBecomeIdleListener listener : onDidBecomeIdleListenerList) {
listener.onDidBecomeIdle();
}
}
} catch (Throwable err) {
Logger.e(TAG, "Exception in onDidEnterIdle", err);
Logger.e(TAG, "Exception in onDidBecomeIdle", err);
throw err;
}
}
Expand Down Expand Up @@ -294,12 +294,12 @@ void removeOnDidFinishRenderingMapListener(MapView.OnDidFinishRenderingMapListen
onDidFinishRenderingMapListenerList.remove(listener);
}

void addOnDidEnterIdleListener(MapView.OnDidEnterIdleListener listener) {
onDidEnterIdleListenerList.add(listener);
void addOnDidBecomeIdleListener(MapView.OnDidBecomeIdleListener listener) {
onDidBecomeIdleListenerList.add(listener);
}

void removeOnDidEnterIdleListener(MapView.OnDidEnterIdleListener listener) {
onDidEnterIdleListenerList.remove(listener);
void removeOnDidBecomeIdleListener(MapView.OnDidBecomeIdleListener listener) {
onDidBecomeIdleListenerList.remove(listener);
}

void addOnDidFinishLoadingStyleListener(MapView.OnDidFinishLoadingStyleListener listener) {
Expand Down Expand Up @@ -329,7 +329,7 @@ void clear() {
onDidFinishRenderingFrameList.clear();
onWillStartRenderingMapListenerList.clear();
onDidFinishRenderingMapListenerList.clear();
onDidEnterIdleListenerList.clear();
onDidBecomeIdleListenerList.clear();
onDidFinishLoadingStyleListenerList.clear();
onSourceChangedListenerList.clear();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,17 +702,17 @@ public void removeOnDidFinishRenderingMapListener(OnDidFinishRenderingMapListene
*
* @param listener The callback that's invoked when the map has entered the idle state.
*/
public void addOnDidEnterIdleListener(OnDidEnterIdleListener listener) {
mapChangeReceiver.addOnDidEnterIdleListener(listener);
public void addOnDidBecomeIdleListener(OnDidBecomeIdleListener listener) {
mapChangeReceiver.addOnDidBecomeIdleListener(listener);
}

/**
* Remove a callback that's invoked when the map has entered the idle state.
*
* @param listener The callback that's invoked when the map has entered the idle state.
*/
public void removeOnDidEnterIdleListener(OnDidEnterIdleListener listener) {
mapChangeReceiver.removeOnDidEnterIdleListener(listener);
public void removeOnDidBecomeIdleListener(OnDidBecomeIdleListener listener) {
mapChangeReceiver.removeOnDidBecomeIdleListener(listener);
}

/**
Expand Down Expand Up @@ -893,14 +893,14 @@ public interface OnDidFinishRenderingMapListener {
/**
* Interface definition for a callback to be invoked when the map has entered the idle state.
* <p>
* {@link MapView#addOnDidEnterIdleListener(OnDidEnterIdleListener)}
* {@link MapView#addOnDidBecomeIdleListener(OnDidBecomeIdleListener)}
* </p>
*/
public interface OnDidEnterIdleListener {
public interface OnDidBecomeIdleListener {
/**
* Called when the map has entered the idle state.
*/
void onDidEnterIdle();
void onDidBecomeIdle();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,8 @@ private void onDidFinishRenderingMap(boolean fully) {
}

@Keep
private void onDidEnterIdle() {
stateCallback.onDidEnterIdle();
private void onDidBecomeIdle() {
stateCallback.onDidBecomeIdle();
}

@Keep
Expand Down Expand Up @@ -1431,7 +1431,7 @@ interface StateCallback extends StyleCallback {

void onDidFinishRenderingMap(boolean fully);

void onDidEnterIdle();
void onDidBecomeIdle();

void onSourceChanged(String sourceId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class MapChangeReceiverTest {
private MapView.OnDidFinishRenderingMapListener onDidFinishRenderingMapListener;

@Mock
private MapView.OnDidEnterIdleListener onDidEnterIdleListener;
private MapView.OnDidBecomeIdleListener onDidBecomeIdleListener;

@Mock
private MapView.OnDidFinishLoadingStyleListener onDidFinishLoadingStyleListener;
Expand Down Expand Up @@ -495,29 +495,29 @@ public void testOnDidFinishRenderingMapFullyRenderedListener() {
}

@Test
public void testOnDidEnterIdleListener() {
mapChangeEventManager.addOnDidEnterIdleListener(onDidEnterIdleListener);
mapChangeEventManager.onDidEnterIdle();
verify(onDidEnterIdleListener).onDidEnterIdle();
mapChangeEventManager.removeOnDidEnterIdleListener(onDidEnterIdleListener);
mapChangeEventManager.onDidEnterIdle();
verify(onDidEnterIdleListener).onDidEnterIdle();

mapChangeEventManager.addOnDidEnterIdleListener(onDidEnterIdleListener);
public void testOnDidBecomeIdleListener() {
mapChangeEventManager.addOnDidBecomeIdleListener(onDidBecomeIdleListener);
mapChangeEventManager.onDidBecomeIdle();
verify(onDidBecomeIdleListener).onDidBecomeIdle();
mapChangeEventManager.removeOnDidBecomeIdleListener(onDidBecomeIdleListener);
mapChangeEventManager.onDidBecomeIdle();
verify(onDidBecomeIdleListener).onDidBecomeIdle();

mapChangeEventManager.addOnDidBecomeIdleListener(onDidBecomeIdleListener);
Logger.setLoggerDefinition(loggerDefinition);
Exception exc = new RuntimeException();
doThrow(exc).when(onDidEnterIdleListener).onDidEnterIdle();
doThrow(exc).when(onDidBecomeIdleListener).onDidBecomeIdle();
try {
mapChangeEventManager.onDidEnterIdle();
mapChangeEventManager.onDidBecomeIdle();
Assert.fail("The exception should've been re-thrown.");
} catch (RuntimeException throwable) {
verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
}

Error err = new ExecutionError("", new Error());
doThrow(err).when(onDidEnterIdleListener).onDidEnterIdle();
doThrow(err).when(onDidBecomeIdleListener).onDidBecomeIdle();
try {
mapChangeEventManager.onDidEnterIdle();
mapChangeEventManager.onDidBecomeIdle();
Assert.fail("The exception should've been re-thrown.");
} catch (ExecutionError throwable) {
verify(loggerDefinition).e(anyString(), anyString(), eq(err));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected void onCreate(Bundle savedInstanceState) {
mapView.addOnDidFinishLoadingStyleListener(() -> Timber.v("OnDidFinishLoadingStyle"));
mapView.addOnDidFinishRenderingFrameListener(fully -> Timber.v("OnDidFinishRenderingFrame: fully: %s", fully));
mapView.addOnDidFinishRenderingMapListener(fully -> Timber.v("OnDidFinishRenderingMap: fully: %s", fully));
mapView.addOnDidEnterIdleListener(() -> Timber.v("OnDidEnterIdle"));
mapView.addOnDidBecomeIdleListener(() -> Timber.v("OnDidBecomeIdle"));
mapView.addOnSourceChangedListener(sourceId -> Timber.v("OnSourceChangedListener: source with id: %s", sourceId));
mapView.addOnWillStartLoadingMapListener(() -> Timber.v("OnWillStartLoadingMap"));
mapView.addOnWillStartRenderingFrameListener(() -> Timber.v("OnWillStartRenderingFrame"));
Expand Down
6 changes: 3 additions & 3 deletions platform/android/src/native_map_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ void NativeMapView::onDidFinishRenderingMap(MapObserver::RenderMode mode) {
javaPeer.get(*_env).Call(*_env, onDidFinishRenderingMap, (jboolean) (mode != MapObserver::RenderMode::Partial));
}

void NativeMapView::onDidEnterIdle() {
void NativeMapView::onDidBecomeIdle() {
assert(vm != nullptr);

android::UniqueEnv _env = android::AttachEnv();
static auto& javaClass = jni::Class<NativeMapView>::Singleton(*_env);
static auto onDidEnterIdle = javaClass.GetMethod<void ()>(*_env, "onDidEnterIdle");
javaPeer.get(*_env).Call(*_env, onDidEnterIdle);
static auto onDidBecomeIdle = javaClass.GetMethod<void ()>(*_env, "onDidBecomeIdle");
javaPeer.get(*_env).Call(*_env, onDidBecomeIdle);
}

void NativeMapView::onDidFinishLoadingStyle() {
Expand Down
2 changes: 1 addition & 1 deletion platform/android/src/native_map_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class NativeMapView : public MapObserver {
void onDidFinishRenderingFrame(MapObserver::RenderMode) override;
void onWillStartRenderingMap() override;
void onDidFinishRenderingMap(MapObserver::RenderMode) override;
void onDidEnterIdle() override;
void onDidBecomeIdle() override;
void onDidFinishLoadingStyle() override;
void onSourceChanged(mbgl::style::Source&) override;

Expand Down
2 changes: 1 addition & 1 deletion platform/ios/src/MGLMapViewDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ NS_ASSUME_NONNULL_BEGIN
@param mapView The map view that has just entered the idle state.
*/
- (void)mapViewDidEnterIdle:(MGLMapView *)mapView;
- (void)mapViewDidBecomeIdle:(MGLMapView *)mapView;

/**
Tells the delegate that the map has just finished loading a style.
Expand Down
2 changes: 2 additions & 0 deletions platform/ios/test/MGLMapViewDelegateIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ extension MGLMapViewDelegateIntegrationTests: MGLMapViewDelegate {
func mapView(_ mapView: MGLMapView, didUpdate userLocation: MGLUserLocation?) {}

func mapViewDidFinishRenderingMap(_ mapView: MGLMapView, fullyRendered: Bool) {}

func mapViewDidBecomeIdle(_ mapView: MGLMapView) {}

func mapView(_ mapView: MGLMapView, didFailToLocateUserWithError error: Error) {}

Expand Down
10 changes: 5 additions & 5 deletions platform/macos/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -934,13 +934,13 @@ - (void)mapViewDidFinishRenderingMapFullyRendered:(BOOL)fullyRendered {
}
}

- (void)mapViewDidEnterIdle {
- (void)mapViewDidBecomeIdle {
if (!_mbglMap) {
return;
}

if ([self.delegate respondsToSelector:@selector(mapViewDidEnterIdle)]) {
[self.delegate mapViewDidEnterIdle:self];
if ([self.delegate respondsToSelector:@selector(mapViewDidBecomeIdle)]) {
[self.delegate mapViewDidBecomeIdle:self];
}
}

Expand Down Expand Up @@ -3061,8 +3061,8 @@ void onDidFinishRenderingMap(mbgl::MapObserver::RenderMode mode) override {
[nativeView mapViewDidFinishRenderingMapFullyRendered:fullyRendered];
}

void onDidEnterIdle() override {
[nativeView mapViewDidEnterIdle];
void onDidBecomeIdle() override {
[nativeView mapViewDidBecomeIdle];
}

void onDidFinishLoadingStyle() override {
Expand Down
2 changes: 1 addition & 1 deletion platform/macos/src/MGLMapViewDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ NS_ASSUME_NONNULL_BEGIN
@param mapView The map view that has just entered the idle state.
*/
- (void)mapViewDidEnterIdle:(MGLMapView *)mapView;
- (void)mapViewDidBecomeIdle:(MGLMapView *)mapView;

/**
Tells the delegate that the map has just finished loading a style.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension MGLMapViewDelegateIntegrationTests: MGLMapViewDelegate {

func mapViewDidFinishRenderingMap(_ mapView: MGLMapView, fullyRendered: Bool) {}

func mapViewDidEnterIdle(_ mapView: MGLMapView) {}
func mapViewDidBecomeIdle(_ mapView: MGLMapView) {}

func mapViewDidFailLoadingMap(_ mapView: MGLMapView, withError error: Error) {}

Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void Map::Impl::onDidFinishRenderingFrame(RenderMode renderMode, bool needsRepai
if (needsRepaint || transform.inTransition()) {
onUpdate();
} else if (rendererFullyLoaded) {
observer.onDidEnterIdle();
observer.onDidBecomeIdle();
}
} else if (stillImageRequest && rendererFullyLoaded) {
auto request = std::move(stillImageRequest);
Expand Down

0 comments on commit 9fc6f30

Please sign in to comment.