Fix timestamps on android touch events to use milliseconds, to be consistent with iOS
Summary: So `PanReponder.onPanResponderRelease/onPanResponderTerminate` receive a `gestureState` object containing a `onPanResponderTerminate.vx/vy` property. On Android and iOS, they appear to be orders of magnitude different, which appear to be due to the different scale of timestamps that are used when generating touch events. This pull request fixes the timestamps to be milliseconds on both platforms (since I assume iOS is the more authoritative one, and is the one that `react-native-viewpager`'s vx thresholds written written to compare against.) As far as I can tell, the RN code doesn't use the `vx/vy` properties, so they should be okay. And looks like the RN code only cares about relative values of `startTimestamp/currentTimestamp/previousTimestamp` though, so should be fine too. it's quite possible there will be downstream android breakage with this change, particularly for those who are already compensating for the RN discrepancy. Closes https://github.com/facebook/react-native/pull/8199 Differential Revision: D3528215 Pulled By: dmmiller fbshipit-source-id: cbd25bb7e7bb87fa77b661a057643a6ea97bc3f1
This commit is contained in:
parent
f5345601d9
commit
4f5c2b48fe
|
@ -116,7 +116,7 @@ public class TextInputTestCase extends ReactAppInstrumentationTestCase {
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
new ReactTextChangedEvent(
|
new ReactTextChangedEvent(
|
||||||
reactEditText.getId(),
|
reactEditText.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
newText.toString(),
|
newText.toString(),
|
||||||
(int) PixelUtil.toDIPFromPixel(contentWidth),
|
(int) PixelUtil.toDIPFromPixel(contentWidth),
|
||||||
(int) PixelUtil.toDIPFromPixel(contentHeight),
|
(int) PixelUtil.toDIPFromPixel(contentHeight),
|
||||||
|
@ -125,7 +125,7 @@ public class TextInputTestCase extends ReactAppInstrumentationTestCase {
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
new ReactTextInputEvent(
|
new ReactTextInputEvent(
|
||||||
reactEditText.getId(),
|
reactEditText.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
newText.toString(),
|
newText.toString(),
|
||||||
"",
|
"",
|
||||||
start,
|
start,
|
||||||
|
@ -150,7 +150,7 @@ public class TextInputTestCase extends ReactAppInstrumentationTestCase {
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
new ReactTextChangedEvent(
|
new ReactTextChangedEvent(
|
||||||
reactEditText.getId(),
|
reactEditText.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
newText.toString(),
|
newText.toString(),
|
||||||
(int) PixelUtil.toDIPFromPixel(contentWidth),
|
(int) PixelUtil.toDIPFromPixel(contentWidth),
|
||||||
(int) PixelUtil.toDIPFromPixel(contentHeight),
|
(int) PixelUtil.toDIPFromPixel(contentHeight),
|
||||||
|
@ -159,7 +159,7 @@ public class TextInputTestCase extends ReactAppInstrumentationTestCase {
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
new ReactTextInputEvent(
|
new ReactTextInputEvent(
|
||||||
reactEditText.getId(),
|
reactEditText.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
moreText,
|
moreText,
|
||||||
"",
|
"",
|
||||||
start,
|
start,
|
||||||
|
@ -184,7 +184,7 @@ public class TextInputTestCase extends ReactAppInstrumentationTestCase {
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
new ReactTextChangedEvent(
|
new ReactTextChangedEvent(
|
||||||
reactEditText.getId(),
|
reactEditText.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
newText.toString(),
|
newText.toString(),
|
||||||
(int) PixelUtil.toDIPFromPixel(contentWidth),
|
(int) PixelUtil.toDIPFromPixel(contentWidth),
|
||||||
(int) PixelUtil.toDIPFromPixel(contentHeight),
|
(int) PixelUtil.toDIPFromPixel(contentHeight),
|
||||||
|
@ -193,7 +193,7 @@ public class TextInputTestCase extends ReactAppInstrumentationTestCase {
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
new ReactTextInputEvent(
|
new ReactTextInputEvent(
|
||||||
reactEditText.getId(),
|
reactEditText.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
moreText,
|
moreText,
|
||||||
"",
|
"",
|
||||||
start,
|
start,
|
||||||
|
|
|
@ -22,4 +22,8 @@ public class SystemClock {
|
||||||
public static long nanoTime() {
|
public static long nanoTime() {
|
||||||
return System.nanoTime();
|
return System.nanoTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long elapsedRealtime() {
|
||||||
|
return android.os.SystemClock.elapsedRealtime();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,7 +244,7 @@ public final class Timing extends ReactContextBaseJavaModule implements Lifecycl
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long initialTargetTime = SystemClock.nanoTime() / 1000000 + adjustedDuration;
|
long initialTargetTime = SystemClock.elapsedRealtime() + adjustedDuration;
|
||||||
Timer timer = new Timer(executorToken, callbackID, initialTargetTime, duration, repeat);
|
Timer timer = new Timer(executorToken, callbackID, initialTargetTime, duration, repeat);
|
||||||
synchronized (mTimerGuard) {
|
synchronized (mTimerGuard) {
|
||||||
mTimers.add(timer);
|
mTimers.add(timer);
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class JSTouchDispatcher {
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
TouchEvent.obtain(
|
TouchEvent.obtain(
|
||||||
mTargetTag,
|
mTargetTag,
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
TouchEventType.START,
|
TouchEventType.START,
|
||||||
ev,
|
ev,
|
||||||
mTargetCoordinates[0],
|
mTargetCoordinates[0],
|
||||||
|
@ -105,7 +105,7 @@ public class JSTouchDispatcher {
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
TouchEvent.obtain(
|
TouchEvent.obtain(
|
||||||
mTargetTag,
|
mTargetTag,
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
TouchEventType.END,
|
TouchEventType.END,
|
||||||
ev,
|
ev,
|
||||||
mTargetCoordinates[0],
|
mTargetCoordinates[0],
|
||||||
|
@ -117,7 +117,7 @@ public class JSTouchDispatcher {
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
TouchEvent.obtain(
|
TouchEvent.obtain(
|
||||||
mTargetTag,
|
mTargetTag,
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
TouchEventType.MOVE,
|
TouchEventType.MOVE,
|
||||||
ev,
|
ev,
|
||||||
mTargetCoordinates[0],
|
mTargetCoordinates[0],
|
||||||
|
@ -128,7 +128,7 @@ public class JSTouchDispatcher {
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
TouchEvent.obtain(
|
TouchEvent.obtain(
|
||||||
mTargetTag,
|
mTargetTag,
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
TouchEventType.START,
|
TouchEventType.START,
|
||||||
ev,
|
ev,
|
||||||
mTargetCoordinates[0],
|
mTargetCoordinates[0],
|
||||||
|
@ -139,7 +139,7 @@ public class JSTouchDispatcher {
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
TouchEvent.obtain(
|
TouchEvent.obtain(
|
||||||
mTargetTag,
|
mTargetTag,
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
TouchEventType.END,
|
TouchEventType.END,
|
||||||
ev,
|
ev,
|
||||||
mTargetCoordinates[0],
|
mTargetCoordinates[0],
|
||||||
|
@ -180,7 +180,7 @@ public class JSTouchDispatcher {
|
||||||
Assertions.assertNotNull(eventDispatcher).dispatchEvent(
|
Assertions.assertNotNull(eventDispatcher).dispatchEvent(
|
||||||
TouchEvent.obtain(
|
TouchEvent.obtain(
|
||||||
mTargetTag,
|
mTargetTag,
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
TouchEventType.CANCEL,
|
TouchEventType.CANCEL,
|
||||||
androidEvent,
|
androidEvent,
|
||||||
mTargetCoordinates[0],
|
mTargetCoordinates[0],
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class OnLayoutEvent extends Event<OnLayoutEvent> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void init(int viewTag, int x, int y, int width, int height) {
|
protected void init(int viewTag, int x, int y, int width, int height) {
|
||||||
super.init(viewTag, SystemClock.nanoTime());
|
super.init(viewTag, SystemClock.elapsedRealtime());
|
||||||
mX = x;
|
mX = x;
|
||||||
mY = y;
|
mY = y;
|
||||||
mWidth = width;
|
mWidth = width;
|
||||||
|
|
|
@ -188,25 +188,25 @@ public class ReactDrawerLayoutManager extends ViewGroupManager<ReactDrawerLayout
|
||||||
@Override
|
@Override
|
||||||
public void onDrawerSlide(View view, float v) {
|
public void onDrawerSlide(View view, float v) {
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new DrawerSlideEvent(mDrawerLayout.getId(), SystemClock.nanoTime(), v));
|
new DrawerSlideEvent(mDrawerLayout.getId(), SystemClock.elapsedRealtime(), v));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDrawerOpened(View view) {
|
public void onDrawerOpened(View view) {
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new DrawerOpenedEvent(mDrawerLayout.getId(), SystemClock.nanoTime()));
|
new DrawerOpenedEvent(mDrawerLayout.getId(), SystemClock.elapsedRealtime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDrawerClosed(View view) {
|
public void onDrawerClosed(View view) {
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new DrawerClosedEvent(mDrawerLayout.getId(), SystemClock.nanoTime()));
|
new DrawerClosedEvent(mDrawerLayout.getId(), SystemClock.elapsedRealtime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDrawerStateChanged(int i) {
|
public void onDrawerStateChanged(int i) {
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new DrawerStateChangedEvent(mDrawerLayout.getId(), SystemClock.nanoTime(), i));
|
new DrawerStateChangedEvent(mDrawerLayout.getId(), SystemClock.elapsedRealtime(), i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ public class ReactImageView extends GenericDraweeView {
|
||||||
@Override
|
@Override
|
||||||
public void onSubmit(String id, Object callerContext) {
|
public void onSubmit(String id, Object callerContext) {
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new ImageLoadEvent(getId(), SystemClock.nanoTime(), ImageLoadEvent.ON_LOAD_START));
|
new ImageLoadEvent(getId(), SystemClock.elapsedRealtime(), ImageLoadEvent.ON_LOAD_START));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -202,18 +202,18 @@ public class ReactImageView extends GenericDraweeView {
|
||||||
@Nullable Animatable animatable) {
|
@Nullable Animatable animatable) {
|
||||||
if (imageInfo != null) {
|
if (imageInfo != null) {
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new ImageLoadEvent(getId(), SystemClock.nanoTime(), ImageLoadEvent.ON_LOAD));
|
new ImageLoadEvent(getId(), SystemClock.elapsedRealtime(), ImageLoadEvent.ON_LOAD));
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new ImageLoadEvent(getId(), SystemClock.nanoTime(), ImageLoadEvent.ON_LOAD_END));
|
new ImageLoadEvent(getId(), SystemClock.elapsedRealtime(), ImageLoadEvent.ON_LOAD_END));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(String id, Throwable throwable) {
|
public void onFailure(String id, Throwable throwable) {
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new ImageLoadEvent(getId(), SystemClock.nanoTime(), ImageLoadEvent.ON_ERROR));
|
new ImageLoadEvent(getId(), SystemClock.elapsedRealtime(), ImageLoadEvent.ON_ERROR));
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new ImageLoadEvent(getId(), SystemClock.nanoTime(), ImageLoadEvent.ON_LOAD_END));
|
new ImageLoadEvent(getId(), SystemClock.elapsedRealtime(), ImageLoadEvent.ON_LOAD_END));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,14 +85,14 @@ public class ReactModalHostManager extends ViewGroupManager<ReactModalHostView>
|
||||||
new ReactModalHostView.OnRequestCloseListener() {
|
new ReactModalHostView.OnRequestCloseListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onRequestClose(DialogInterface dialog) {
|
public void onRequestClose(DialogInterface dialog) {
|
||||||
dispatcher.dispatchEvent(new RequestCloseEvent(view.getId(), SystemClock.nanoTime()));
|
dispatcher.dispatchEvent(new RequestCloseEvent(view.getId(), SystemClock.elapsedRealtime()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
view.setOnShowListener(
|
view.setOnShowListener(
|
||||||
new DialogInterface.OnShowListener() {
|
new DialogInterface.OnShowListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onShow(DialogInterface dialog) {
|
public void onShow(DialogInterface dialog) {
|
||||||
dispatcher.dispatchEvent(new ShowEvent(view.getId(), SystemClock.nanoTime()));
|
dispatcher.dispatchEvent(new ShowEvent(view.getId(), SystemClock.elapsedRealtime()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ public abstract class ReactPickerManager extends SimpleViewManager<ReactPicker>
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(int position) {
|
public void onItemSelected(int position) {
|
||||||
mEventDispatcher.dispatchEvent( new PickerItemSelectEvent(
|
mEventDispatcher.dispatchEvent( new PickerItemSelectEvent(
|
||||||
mReactPicker.getId(), SystemClock.nanoTime(), position));
|
mReactPicker.getId(), SystemClock.elapsedRealtime(), position));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,7 +344,7 @@ public class RecyclerViewBackedScrollView extends RecyclerView {
|
||||||
((ReactContext) getContext()).getNativeModule(UIManagerModule.class).getEventDispatcher()
|
((ReactContext) getContext()).getNativeModule(UIManagerModule.class).getEventDispatcher()
|
||||||
.dispatchEvent(ScrollEvent.obtain(
|
.dispatchEvent(ScrollEvent.obtain(
|
||||||
getId(),
|
getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
ScrollEventType.SCROLL,
|
ScrollEventType.SCROLL,
|
||||||
0, /* offsetX = 0, horizontal scrolling only */
|
0, /* offsetX = 0, horizontal scrolling only */
|
||||||
calculateAbsoluteOffset(),
|
calculateAbsoluteOffset(),
|
||||||
|
@ -359,7 +359,7 @@ public class RecyclerViewBackedScrollView extends RecyclerView {
|
||||||
((ReactContext) getContext()).getNativeModule(UIManagerModule.class).getEventDispatcher()
|
((ReactContext) getContext()).getNativeModule(UIManagerModule.class).getEventDispatcher()
|
||||||
.dispatchEvent(new ContentSizeChangeEvent(
|
.dispatchEvent(new ContentSizeChangeEvent(
|
||||||
getId(),
|
getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
getWidth(),
|
getWidth(),
|
||||||
newTotalChildrenHeight));
|
newTotalChildrenHeight));
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class ReactScrollViewHelper {
|
||||||
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
|
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
|
||||||
ScrollEvent.obtain(
|
ScrollEvent.obtain(
|
||||||
scrollView.getId(),
|
scrollView.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
scrollEventType,
|
scrollEventType,
|
||||||
scrollView.getScrollX(),
|
scrollView.getScrollX(),
|
||||||
scrollView.getScrollY(),
|
scrollView.getScrollY(),
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class ReactSliderManager extends SimpleViewManager<ReactSlider> {
|
||||||
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
|
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
|
||||||
new ReactSliderEvent(
|
new ReactSliderEvent(
|
||||||
seekbar.getId(),
|
seekbar.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
((ReactSlider)seekbar).toRealProgress(progress),
|
((ReactSlider)seekbar).toRealProgress(progress),
|
||||||
fromUser));
|
fromUser));
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class ReactSliderManager extends SimpleViewManager<ReactSlider> {
|
||||||
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
|
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
|
||||||
new ReactSlidingCompleteEvent(
|
new ReactSlidingCompleteEvent(
|
||||||
seekbar.getId(),
|
seekbar.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
((ReactSlider)seekbar).toRealProgress(seekbar.getProgress())));
|
((ReactSlider)seekbar).toRealProgress(seekbar.getProgress())));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class SwipeRefreshLayoutManager extends ViewGroupManager<ReactSwipeRefres
|
||||||
@Override
|
@Override
|
||||||
public void onRefresh() {
|
public void onRefresh() {
|
||||||
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
|
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
|
||||||
.dispatchEvent(new RefreshEvent(view.getId(), SystemClock.nanoTime()));
|
.dispatchEvent(new RefreshEvent(view.getId(), SystemClock.elapsedRealtime()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class ReactSwitchManager extends SimpleViewManager<ReactSwitch> {
|
||||||
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
|
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
|
||||||
new ReactSwitchEvent(
|
new ReactSwitchEvent(
|
||||||
buttonView.getId(),
|
buttonView.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
isChecked));
|
isChecked));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -567,7 +567,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new ReactTextChangedEvent(
|
new ReactTextChangedEvent(
|
||||||
mEditText.getId(),
|
mEditText.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
s.toString(),
|
s.toString(),
|
||||||
(int) PixelUtil.toDIPFromPixel(contentWidth),
|
(int) PixelUtil.toDIPFromPixel(contentWidth),
|
||||||
(int) PixelUtil.toDIPFromPixel(contentHeight),
|
(int) PixelUtil.toDIPFromPixel(contentHeight),
|
||||||
|
@ -576,7 +576,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new ReactTextInputEvent(
|
new ReactTextInputEvent(
|
||||||
mEditText.getId(),
|
mEditText.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
newText,
|
newText,
|
||||||
oldText,
|
oldText,
|
||||||
start,
|
start,
|
||||||
|
@ -602,17 +602,17 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
new ReactTextInputFocusEvent(
|
new ReactTextInputFocusEvent(
|
||||||
editText.getId(),
|
editText.getId(),
|
||||||
SystemClock.nanoTime()));
|
SystemClock.elapsedRealtime()));
|
||||||
} else {
|
} else {
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
new ReactTextInputBlurEvent(
|
new ReactTextInputBlurEvent(
|
||||||
editText.getId(),
|
editText.getId(),
|
||||||
SystemClock.nanoTime()));
|
SystemClock.elapsedRealtime()));
|
||||||
|
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
new ReactTextInputEndEditingEvent(
|
new ReactTextInputEndEditingEvent(
|
||||||
editText.getId(),
|
editText.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
editText.getText().toString()));
|
editText.getText().toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -630,7 +630,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
new ReactTextInputSubmitEditingEvent(
|
new ReactTextInputSubmitEditingEvent(
|
||||||
editText.getId(),
|
editText.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
editText.getText().toString()));
|
editText.getText().toString()));
|
||||||
}
|
}
|
||||||
if (actionId == EditorInfo.IME_ACTION_NEXT ||
|
if (actionId == EditorInfo.IME_ACTION_NEXT ||
|
||||||
|
@ -667,7 +667,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new ReactTextInputSelectionEvent(
|
new ReactTextInputSelectionEvent(
|
||||||
mReactEditText.getId(),
|
mReactEditText.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
start,
|
start,
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class ReactToolbarManager extends ViewGroupManager<ReactToolbar> {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new ToolbarClickEvent(view.getId(), SystemClock.nanoTime(), -1));
|
new ToolbarClickEvent(view.getId(), SystemClock.elapsedRealtime(), -1));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ public class ReactToolbarManager extends ViewGroupManager<ReactToolbar> {
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new ToolbarClickEvent(
|
new ToolbarClickEvent(
|
||||||
view.getId(),
|
view.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
menuItem.getOrder()));
|
menuItem.getOrder()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,14 +91,14 @@ import com.facebook.react.uimanager.events.NativeGestureUtil;
|
||||||
@Override
|
@Override
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new PageScrollEvent(getId(), SystemClock.nanoTime(), position, positionOffset));
|
new PageScrollEvent(getId(), SystemClock.elapsedRealtime(), position, positionOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageSelected(int position) {
|
public void onPageSelected(int position) {
|
||||||
if (!mIsCurrentItemFromJs) {
|
if (!mIsCurrentItemFromJs) {
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new PageSelectedEvent(getId(), SystemClock.nanoTime(), position));
|
new PageSelectedEvent(getId(), SystemClock.elapsedRealtime(), position));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ import com.facebook.react.uimanager.events.NativeGestureUtil;
|
||||||
throw new IllegalStateException("Unsupported pageScrollState");
|
throw new IllegalStateException("Unsupported pageScrollState");
|
||||||
}
|
}
|
||||||
mEventDispatcher.dispatchEvent(
|
mEventDispatcher.dispatchEvent(
|
||||||
new PageScrollStateChangedEvent(getId(), SystemClock.nanoTime(), pageScrollState));
|
new PageScrollStateChangedEvent(getId(), SystemClock.elapsedRealtime(), pageScrollState));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
|
||||||
webView,
|
webView,
|
||||||
new TopLoadingStartEvent(
|
new TopLoadingStartEvent(
|
||||||
webView.getId(),
|
webView.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
createWebViewEvent(webView, url)));
|
createWebViewEvent(webView, url)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
|
||||||
|
|
||||||
dispatchEvent(
|
dispatchEvent(
|
||||||
webView,
|
webView,
|
||||||
new TopLoadingErrorEvent(webView.getId(), SystemClock.nanoTime(), eventData));
|
new TopLoadingErrorEvent(webView.getId(), SystemClock.elapsedRealtime(), eventData));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -141,7 +141,7 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
|
||||||
webView,
|
webView,
|
||||||
new TopLoadingStartEvent(
|
new TopLoadingStartEvent(
|
||||||
webView.getId(),
|
webView.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
createWebViewEvent(webView, url)));
|
createWebViewEvent(webView, url)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
|
||||||
webView,
|
webView,
|
||||||
new TopLoadingFinishEvent(
|
new TopLoadingFinishEvent(
|
||||||
webView.getId(),
|
webView.getId(),
|
||||||
SystemClock.nanoTime(),
|
SystemClock.elapsedRealtime(),
|
||||||
createWebViewEvent(webView, url)));
|
createWebViewEvent(webView, url)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class RootViewTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
final long ts = SystemClock.nanoTime();
|
final long ts = SystemClock.elapsedRealtime();
|
||||||
PowerMockito.mockStatic(Arguments.class);
|
PowerMockito.mockStatic(Arguments.class);
|
||||||
PowerMockito.when(Arguments.createArray()).thenAnswer(new Answer<Object>() {
|
PowerMockito.when(Arguments.createArray()).thenAnswer(new Answer<Object>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,7 +80,7 @@ public class RootViewTest {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
PowerMockito.mockStatic(SystemClock.class);
|
PowerMockito.mockStatic(SystemClock.class);
|
||||||
PowerMockito.when(SystemClock.nanoTime()).thenAnswer(new Answer<Object>() {
|
PowerMockito.when(SystemClock.elapsedRealtime()).thenAnswer(new Answer<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||||
return ts;
|
return ts;
|
||||||
|
@ -116,7 +116,7 @@ public class RootViewTest {
|
||||||
rootView.startReactApplication(instanceManager, "");
|
rootView.startReactApplication(instanceManager, "");
|
||||||
rootView.simulateAttachForTesting();
|
rootView.simulateAttachForTesting();
|
||||||
|
|
||||||
long ts = SystemClock.nanoTime();
|
long ts = SystemClock.elapsedRealtime();
|
||||||
|
|
||||||
// Test ACTION_DOWN event
|
// Test ACTION_DOWN event
|
||||||
rootView.onTouchEvent(
|
rootView.onTouchEvent(
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class TimingModuleTest {
|
||||||
|
|
||||||
PowerMockito.mockStatic(SystemClock.class);
|
PowerMockito.mockStatic(SystemClock.class);
|
||||||
when(SystemClock.currentTimeMillis()).thenReturn(mCurrentTimeNs / 1000000);
|
when(SystemClock.currentTimeMillis()).thenReturn(mCurrentTimeNs / 1000000);
|
||||||
when(SystemClock.nanoTime()).thenReturn(mCurrentTimeNs);
|
when(SystemClock.elapsedRealtime()).thenReturn(mCurrentTimeNs / 1000000);
|
||||||
|
|
||||||
mChoreographerMock = mock(ReactChoreographer.class);
|
mChoreographerMock = mock(ReactChoreographer.class);
|
||||||
PowerMockito.mockStatic(ReactChoreographer.class);
|
PowerMockito.mockStatic(ReactChoreographer.class);
|
||||||
|
|
Loading…
Reference in New Issue