Skip to content

Commit

Permalink
Merge pull request rnmapbox#65 from mfazekas/android-fix-is-user-inte…
Browse files Browse the repository at this point in the history
…raction

Android: fix is user interaction
  • Loading branch information
mfazekas authored May 29, 2019
2 parents 954664a + 62a607c commit f00d3c0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,50 +429,20 @@ public void onCameraIdle() {
markerViewManager.invalidateViewMarkersInVisibleRegion();
} */

// if we have onCameraIdle during mCameraChangeTracker.isAnimating()
// it's a 'fling animation' after user gesture

// don't send didChange event if we gonna still animate fling
// we should use fling listener or send didCHange but with isUserInteraction false
// region didn't finish changing yet

// what to send as 'animated' at the end if we have fling? probably false as
// whole region change was triggered by user gesture

// actually we should have proper reason set in onCameraMoveStarted

if (!mCameraChangeTracker.isAnimating()) {
Log.d("MOVE_EVENT", "onCameraIdle SENDING DID_CHANGE EVENT isUserInteraction: " + mCameraChangeTracker.isUserInteraction() + " isAnimated: " + mCameraChangeTracker.isAnimated());
sendRegionDidChangeEvent();
} else {
Log.d("MOVE_EVENT", "onCameraIdle NOT SENDING DID_CHANGE EVENT on fling");
}
}
Log.d("MOVE_EVENT", "onCameraIdle SENDING DID_CHANGE EVENT isUserInteraction: " + mCameraChangeTracker.isUserInteraction() + " isAnimated: " + mCameraChangeTracker.isAnimated());
sendRegionDidChangeEvent(); }
});

mMap.addOnCameraMoveStartedListener(new MapboxMap.OnCameraMoveStartedListener() {
@Override
public void onCameraMoveStarted(int reason) {
// actually now we don't send DID CHANGE event when we are animating fling
// and we don't reset reason, then we will not send WILL CHANGE when starting fling
if (mCameraChangeTracker.isEmpty()) {
// was this condition here because it can be set by setCamera ?
// setCamera will not trigger events for camera listeners ?
// or other cause?
// actually we can say if we are starting fling here if reason is set, was it an original condition intention here?

// when is reason 2 send?
// can we have SDK reason but not animated?
mCameraChangeTracker.setReason(reason);

Log.d("MOVE_EVENT", "onCameraMoveStarted SENDING WILL_CHANGE EVENT reason: " + reason + " isUserInteraction: " + mCameraChangeTracker.isUserInteraction() + " isAnimated: " + mCameraChangeTracker.isAnimated());
handleMapChangedEvent(EventTypes.REGION_WILL_CHANGE);
} else {
Log.d("MOVE_EVENT", "onCameraMoveStarted NOT SENDING WILL_CHANGE EVENT on fling");
}
mCameraChangeTracker.setReason(reason);
Log.d("MOVE_EVENT", "onCameraMoveStarted SENDING WILL_CHANGE EVENT reason: " + reason + " isUserInteraction: " + mCameraChangeTracker.isUserInteraction() + " isAnimated: " + mCameraChangeTracker.isAnimated());
handleMapChangedEvent(EventTypes.REGION_WILL_CHANGE);
}
});


/*mLocalizationPlugin = new LocalizationPlugin(this, mMap);
if (mLocalizeLabels) {
try {
Expand Down
129 changes: 0 additions & 129 deletions example/src/components/ShowRegionChange.js

This file was deleted.

2 changes: 1 addition & 1 deletion example/src/examples/ShowRegionDidChange.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ShowRegionDidChange extends React.Component {
{label: 'Fly To', data: SF_OFFICE_COORDINATE},
{
label: 'Fit Bounds',
data: [[-74.12641, 40.797968], [-74.143727, 40.772177]],
data: {ne: [-74.12641, 40.797968], sw: [-74.143727, 40.772177]},
},
{label: 'Zoom To', data: 16},
];
Expand Down

0 comments on commit f00d3c0

Please sign in to comment.