Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix threading issue in RNGestureHandlerStateChangeEvent #1171

Merged
merged 1 commit into from
Aug 21, 2020
Merged
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
Expand Up @@ -3,6 +3,8 @@
import android.view.MotionEvent;
import android.view.View;

import com.facebook.react.bridge.UiThreadUtil;

import java.util.Arrays;

public class GestureHandler<T extends GestureHandler> {
Expand Down Expand Up @@ -104,7 +106,12 @@ public T setEnabled(boolean enabled) {
if (mView != null) {
// If view is set then handler is in "active" state. In that case we want to "cancel" handler
// when it changes enabled state so that it gets cleared from the orchestrator
cancel();
UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public void run() {
cancel();
}
});
}
mEnabled = enabled;
return (T) this;
Expand Down Expand Up @@ -326,6 +333,7 @@ public final void handle(MotionEvent origEvent) {
}

private void moveToState(int newState) {
UiThreadUtil.assertOnUiThread();
if (mState == newState) {
return;
}
Expand Down