本文整理汇总了Java中com.facebook.react.common.SystemClock类的典型用法代码示例。如果您正苦于以下问题:Java SystemClock类的具体用法?Java SystemClock怎么用?Java SystemClock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SystemClock类属于com.facebook.react.common包,在下文中一共展示了SystemClock类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addEventEmitters
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
@Override
protected void addEventEmitters(
final ThemedReactContext reactContext,
final RCTSwipeRefreshLayout view) {
view.setOnEvTouchListener(
new RCTSwipeRefreshLayout.OnEvTouchListener() {
@Override
public void onSwipe(int movement) {
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
.dispatchEvent(new TouchEvent(view.getId(), SystemClock.nanoTime(), movement));
}
@Override
public void onSwipeRefresh() {
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
.dispatchEvent(new TouchUpEvent(view.getId(), SystemClock.nanoTime()));
}
});
}
开发者ID:React-Native-Library,项目名称:react-native-pull-up-down-refresh,代码行数:21,代码来源:RCTSwipeRefreshLayoutManager.java
示例2: getCurrentPosition
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
/**
* Get the current position. This can return almost immediately if the location is cached or
* request an update, which might take a while.
*
* @param options map containing optional arguments: timeout (millis), maximumAge (millis) and
* highAccuracy (boolean)
*/
@ReactMethod
public void getCurrentPosition(
ReadableMap options,
final Callback success,
Callback error) {
LocationOptions locationOptions = LocationOptions.fromReactMap(options);
try {
LocationManager locationManager =
(LocationManager) getReactApplicationContext().getSystemService(Context.LOCATION_SERVICE);
String provider = getValidProvider(locationManager, locationOptions.highAccuracy);
if (provider == null) {
error.invoke(PositionError.buildError(
PositionError.PERMISSION_DENIED,
"No location provider available."));
return;
}
Location location = locationManager.getLastKnownLocation(provider);
if (location != null &&
SystemClock.currentTimeMillis() - location.getTime() < locationOptions.maximumAge) {
success.invoke(locationToMap(location));
return;
}
new SingleUpdateRequest(locationManager, provider, locationOptions.timeout, success, error)
.invoke();
} catch (SecurityException e) {
throwLocationPermissionMissing(e);
}
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:37,代码来源:LocationModule.java
示例3: onSelectionChanged
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
@Override
public void onSelectionChanged(int start, int end) {
// Android will call us back for both the SELECTION_START span and SELECTION_END span in text
// To prevent double calling back into js we cache the result of the previous call and only
// forward it on if we have new values
if (mPreviousSelectionStart != start || mPreviousSelectionEnd != end) {
mEventDispatcher.dispatchEvent(
new ReactTextInputSelectionEvent(
mReactEditText.getId(),
SystemClock.nanoTime(),
start,
end
)
);
mPreviousSelectionStart = start;
mPreviousSelectionEnd = end;
}
}
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:20,代码来源:ReactTextInputManager.java
示例4: onScrollChanged
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
((ReactContext) getContext()).getNativeModule(UIManagerModule.class).getEventDispatcher()
.dispatchEvent(ScrollEvent.obtain(
getId(),
SystemClock.nanoTime(),
ScrollEventType.SCROLL,
0, /* offsetX = 0, horizontal scrolling only */
calculateAbsoluteOffset(),
getWidth(),
((ReactListAdapter) getAdapter()).getTotalChildrenHeight(),
getWidth(),
getHeight()));
}
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:17,代码来源:RecyclerViewBackedScrollView.java
示例5: onReceivedError
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
@Override
public void onReceivedError(
WebView webView,
int errorCode,
String description,
String failingUrl) {
super.onReceivedError(webView, errorCode, description, failingUrl);
mLastLoadFailed = true;
// In case of an error JS side expect to get a finish event first, and then get an error event
// Android WebView does it in the opposite way, so we need to simulate that behavior
emitFinishEvent(webView, failingUrl);
WritableMap eventData = createWebViewEvent(webView, failingUrl);
eventData.putDouble("code", errorCode);
eventData.putString("description", description);
dispatchEvent(
webView,
new TopLoadingErrorEvent(webView.getId(), SystemClock.nanoTime(), eventData));
}
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:22,代码来源:ReactWebViewManager.java
示例6: onPageScrollStateChanged
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
@Override
public void onPageScrollStateChanged(int state) {
String pageScrollState;
switch (state) {
case SCROLL_STATE_IDLE:
pageScrollState = "idle";
break;
case SCROLL_STATE_DRAGGING:
pageScrollState = "dragging";
break;
case SCROLL_STATE_SETTLING:
pageScrollState = "settling";
break;
default:
throw new IllegalStateException("Unsupported pageScrollState");
}
mEventDispatcher.dispatchEvent(
new PageScrollStateChangedEvent(getId(), SystemClock.nanoTime(), pageScrollState));
}
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:20,代码来源:ReactViewPager.java
示例7: addEventEmitters
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
@Override
protected void addEventEmitters(final ThemedReactContext reactContext, final ReactToolbar view) {
final EventDispatcher mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class)
.getEventDispatcher();
view.setNavigationOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
mEventDispatcher.dispatchEvent(
new ToolbarClickEvent(view.getId(), SystemClock.nanoTime(), -1));
}
});
view.setOnMenuItemClickListener(
new ReactToolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
mEventDispatcher.dispatchEvent(
new ToolbarClickEvent(
view.getId(),
SystemClock.nanoTime(),
menuItem.getOrder()));
return true;
}
});
}
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:27,代码来源:ReactToolbarManager.java
示例8: emitScrollEvent
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
private static void emitScrollEvent(ViewGroup scrollView, ScrollEventType scrollEventType) {
View contentView = scrollView.getChildAt(0);
if (contentView == null) {
return;
}
ReactContext reactContext = (ReactContext) scrollView.getContext();
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
ScrollEvent.obtain(
scrollView.getId(),
SystemClock.nanoTime(),
scrollEventType,
scrollView.getScrollX(),
scrollView.getScrollY(),
contentView.getWidth(),
contentView.getHeight(),
scrollView.getWidth(),
scrollView.getHeight()));
}
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:21,代码来源:ReactScrollViewHelper.java
示例9: dispatchCancelEvent
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
private void dispatchCancelEvent(MotionEvent androidEvent, EventDispatcher eventDispatcher) {
// This means the gesture has already ended, via some other CANCEL or UP event. This is not
// expected to happen very often as it would mean some child View has decided to intercept the
// touch stream and start a native gesture only upon receiving the UP/CANCEL event.
if (mTargetTag == -1) {
FLog.w(
ReactConstants.TAG,
"Can't cancel already finished gesture. Is a child View trying to start a gesture from " +
"an UP/CANCEL event?");
return;
}
Assertions.assertCondition(
!mChildIsHandlingNativeGesture,
"Expected to not have already sent a cancel for this gesture");
Assertions.assertNotNull(eventDispatcher).dispatchEvent(
TouchEvent.obtain(
mTargetTag,
SystemClock.nanoTime(),
TouchEventType.CANCEL,
androidEvent,
mTargetCoordinates[0],
mTargetCoordinates[1]));
}
开发者ID:ManrajGrover,项目名称:react-native-box-loaders,代码行数:25,代码来源:JSTouchDispatcher.java
示例10: onPageScrollStateChanged
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
@Override
public void onPageScrollStateChanged(int state) {
String pageScrollState;
switch (state) {
case SCROLL_STATE_IDLE:
pageScrollState = "idle";
break;
case SCROLL_STATE_DRAGGING:
pageScrollState = "dragging";
break;
case SCROLL_STATE_SETTLING:
pageScrollState = "settling";
break;
default:
throw new IllegalStateException("Unsupported pageScrollState");
}
mEventDispatcher.dispatchEvent(
new PageScrollStateChangedEvent(getId(), SystemClock.nanoTime(), pageScrollState));
}
开发者ID:Anthonyzou,项目名称:react-native-image-zoom,代码行数:20,代码来源:ReactViewPager.java
示例11: onScrollChanged
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
if (mOnScrollDispatchHelper.onScrollChanged(l, t)) {
getReactContext().getNativeModule(UIManagerModule.class).getEventDispatcher()
.dispatchEvent(ScrollEvent.obtain(
getId(),
ScrollEventType.SCROLL,
0, /* offsetX = 0, horizontal scrolling only */
computeVerticalScrollOffset(),
mOnScrollDispatchHelper.getXFlingVelocity(),
mOnScrollDispatchHelper.getYFlingVelocity(),
getWidth(),
computeVerticalScrollRange(),
getWidth(),
getHeight()));
}
final int firstIndex = ((LinearLayoutManager) getLayoutManager()).findFirstVisibleItemPosition();
final int lastIndex = ((LinearLayoutManager) getLayoutManager()).findLastVisibleItemPosition();
if (firstIndex != mFirstVisibleIndex || lastIndex != mLastVisibleIndex) {
getReactContext().getNativeModule(UIManagerModule.class).getEventDispatcher()
.dispatchEvent(new VisibleItemsChangeEvent(
getId(),
SystemClock.nanoTime(),
firstIndex,
lastIndex));
mFirstVisibleIndex = firstIndex;
mLastVisibleIndex = lastIndex;
}
}
开发者ID:godness84,项目名称:react-native-recyclerview-list,代码行数:35,代码来源:RecyclerViewBackedScrollView.java
示例12: addEventEmitters
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
@Override
protected void addEventEmitters(
final ThemedReactContext reactContext,
final RCTLazyLoadView view) {
view.setOnEvChangeListener(
new OnEvChangeListener() {
@Override
public void onWindowVisibilityChange( boolean hiddenState) {
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
.dispatchEvent(new WindowVisibilityChangeEvent(view.getId(), SystemClock.nanoTime(), hiddenState));
}
});
}
开发者ID:React-Native-Library,项目名称:react-native-pull-up-down-refresh,代码行数:15,代码来源:RCTLazyLoadViewManager.java
示例13: run
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
@Override
public void run() {
if (mCancelled) {
return;
}
long frameTimeMillis = mFrameStartTime / 1000000;
long timeSinceBoot = SystemClock.uptimeMillis();
long frameTimeElapsed = timeSinceBoot - frameTimeMillis;
long time = SystemClock.currentTimeMillis();
long absoluteFrameStartTime = time - frameTimeElapsed;
if (FRAME_DURATION_MS - (float) frameTimeElapsed < IDLE_CALLBACK_FRAME_DEADLINE_MS) {
return;
}
mIdleCallbackContextsToCall.clear();
synchronized (mIdleCallbackGuard) {
mIdleCallbackContextsToCall.addAll(mSendIdleEventsExecutorTokens);
}
for (ExecutorToken context : mIdleCallbackContextsToCall) {
getReactApplicationContext().getJSModule(context, JSTimersExecution.class)
.callIdleCallbacks(absoluteFrameStartTime);
}
mCurrentIdleCallbackRunnable = null;
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:29,代码来源:Timing.java
示例14: stepChoreographerFrame
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
private void stepChoreographerFrame() {
ChoreographerCompat.FrameCallback callback = mPostFrameCallbackHandler.getAndResetFrameCallback();
ChoreographerCompat.FrameCallback idleCallback = mIdlePostFrameCallbackHandler.getAndResetFrameCallback();
mCurrentTimeNs += FRAME_TIME_NS;
when(SystemClock.uptimeMillis()).thenReturn(mCurrentTimeNs / 1000000);
if (callback != null) {
callback.doFrame(mCurrentTimeNs);
}
if (idleCallback != null) {
idleCallback.doFrame(mCurrentTimeNs);
}
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:15,代码来源:TimingModuleTest.java
示例15: testIdleCallback
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
@Test
public void testIdleCallback() {
mTiming.onHostResume();
mTiming.setSendIdleEvents(mExecutorTokenMock, true);
stepChoreographerFrame();
verify(mJSTimersMock).callIdleCallbacks(SystemClock.currentTimeMillis());
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:9,代码来源:TimingModuleTest.java
示例16: getCurrentPosition
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
/**
* Get the current position. This can return almost immediately if the location is cached or
* request an update, which might take a while.
*
* @param options map containing optional arguments: timeout (millis), maximumAge (millis) and
* highAccuracy (boolean)
*/
@ReactMethod
public void getCurrentPosition(
ReadableMap options,
final Callback success,
Callback error) {
LocationOptions locationOptions = LocationOptions.fromReactMap(options);
try {
LocationManager locationManager =
(LocationManager) getReactApplicationContext().getSystemService(Context.LOCATION_SERVICE);
String provider = getValidProvider(locationManager, locationOptions.highAccuracy);
if (provider == null) {
emitError(PositionError.PERMISSION_DENIED, "No location provider available.");
return;
}
Location location = locationManager.getLastKnownLocation(provider);
if (location != null &&
SystemClock.currentTimeMillis() - location.getTime() < locationOptions.maximumAge) {
success.invoke(locationToMap(location));
return;
}
new SingleUpdateRequest(locationManager, provider, locationOptions.timeout, success, error)
.invoke();
} catch (SecurityException e) {
throwLocationPermissionMissing(e);
}
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:35,代码来源:LocationModule.java
示例17: onCheckedChanged
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
ReactContext reactContext = (ReactContext) buttonView.getContext();
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
new ReactSwitchEvent(
buttonView.getId(),
SystemClock.nanoTime(),
isChecked));
}
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:10,代码来源:ReactSwitchManager.java
示例18: onTotalChildrenHeightChange
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
private void onTotalChildrenHeightChange(int newTotalChildrenHeight) {
if (mSendContentSizeChangeEvents) {
((ReactContext) getContext()).getNativeModule(UIManagerModule.class).getEventDispatcher()
.dispatchEvent(new ContentSizeChangeEvent(
getId(),
SystemClock.nanoTime(),
getWidth(),
newTotalChildrenHeight));
}
}
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:11,代码来源:RecyclerViewBackedScrollView.java
示例19: addEventEmitters
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
@Override
protected void addEventEmitters(
final ThemedReactContext reactContext,
final ReactSwipeRefreshLayout view) {
view.setOnRefreshListener(
new OnRefreshListener() {
@Override
public void onRefresh() {
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
.dispatchEvent(new RefreshEvent(view.getId(), SystemClock.nanoTime()));
}
});
}
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:14,代码来源:SwipeRefreshLayoutManager.java
示例20: onPageStarted
import com.facebook.react.common.SystemClock; //导入依赖的package包/类
@Override
public void onPageStarted(WebView webView, String url, Bitmap favicon) {
super.onPageStarted(webView, url, favicon);
mLastLoadFailed = false;
dispatchEvent(
webView,
new TopLoadingStartEvent(
webView.getId(),
SystemClock.nanoTime(),
createWebViewEvent(webView, url)));
}
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:13,代码来源:ReactWebViewManager.java
注:本文中的com.facebook.react.common.SystemClock类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论