本文整理汇总了Java中android.view.Choreographer.FrameCallback方法的典型用法代码示例。如果您正苦于以下问题:Java Choreographer.FrameCallback方法的具体用法?Java Choreographer.FrameCallback怎么用?Java Choreographer.FrameCallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.Choreographer
的用法示例。
在下文中一共展示了Choreographer.FrameCallback方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ChoreographerAndroidSpringLooper
import android.view.Choreographer; //导入方法依赖的package包/类
public ChoreographerAndroidSpringLooper(Choreographer choreographer) {
mChoreographer = choreographer;
mFrameCallback = new Choreographer.FrameCallback() {
@Override
public void doFrame(long frameTimeNanos) {
if (!mStarted || mSpringSystem == null) {
return;
}
long currentTime = SystemClock.uptimeMillis();
mSpringSystem.loop(currentTime - mLastTime);
mLastTime = currentTime;
mChoreographer.postFrameCallback(mFrameCallback);
}
};
}
示例2: getFrameCallback
import android.view.Choreographer; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
Choreographer.FrameCallback getFrameCallback() {
if (mFrameCallback == null) {
mFrameCallback = new Choreographer.FrameCallback() {
@Override
public void doFrame(long frameTimeNanos) {
FrameCallback.this.doFrame(frameTimeNanos);
}
};
}
return mFrameCallback;
}
示例3: onLooperPrepared
import android.view.Choreographer; //导入方法依赖的package包/类
@Override
protected void onLooperPrepared() {
mSampleChoreographer = Choreographer.getInstance();
mSampleCallback = new Choreographer.FrameCallback() {
@Override
public void doFrame(final long frameTimeNanos) {
final long delta = (frameTimeNanos - lastSampleTime) / 1000000;
if (lastSampleTime != 0 && delta > delay) {
//采样周期不准了,目前丢弃吧
//LogUtils.w("monitor", "sample doFrame " + delta);
// mCheckerHandler.post(new Runnable() {
// @Override
// public void run() {
// processInfo(lastSampleTime / 1000000,frameTimeNanos / 1000000);
// }
// });
} else {
mCheckerHandler.post(new Runnable() {
@Override
public void run() {
statisticsStack(frameTimeNanos / 1000000, delta, StackInfo.TYPE_SAMPLE);
}
});
}
lastSampleTime = frameTimeNanos;
if (mLoopFlag) {
mSampleChoreographer.postFrameCallback(mSampleCallback);
}
}
};
lock[0] = true;
}
示例4: executePendingChoreographerCallbacks
import android.view.Choreographer; //导入方法依赖的package包/类
private void executePendingChoreographerCallbacks() {
ArrayList<Choreographer.FrameCallback> callbacks =
new ArrayList<>(mPendingChoreographerCallbacks);
mPendingChoreographerCallbacks.clear();
for (Choreographer.FrameCallback frameCallback : callbacks) {
frameCallback.doFrame(0);
}
}
示例5: stepChoreographerFrame
import android.view.Choreographer; //导入方法依赖的package包/类
private void stepChoreographerFrame() {
Choreographer.FrameCallback callback = mPostFrameCallbackHandler.getAndResetFrameCallback();
mCurrentTimeNs += FRAME_TIME_NS;
if (callback != null) {
callback.doFrame(mCurrentTimeNs);
}
}
示例6: removeFrameCallback
import android.view.Choreographer; //导入方法依赖的package包/类
public void removeFrameCallback(CallbackType type, Choreographer.FrameCallback frameCallback) {
UiThreadUtil.assertOnUiThread();
if (mCallbackQueues[type.getOrder()].removeFirstOccurrence(frameCallback)) {
mTotalCallbacks--;
maybeRemoveFrameCallback();
} else {
FLog.e(ReactConstants.TAG, "Tried to remove non-existent frame callback");
}
}
示例7: postFrameCallback
import android.view.Choreographer; //导入方法依赖的package包/类
public void postFrameCallback(CallbackType type, Choreographer.FrameCallback frameCallback) {
UiThreadUtil.assertOnUiThread();
mCallbackQueues[type.getOrder()].addLast(frameCallback);
mTotalCallbacks++;
Assertions.assertCondition(mTotalCallbacks > 0);
if (!mHasPostedCallback) {
mChoreographer.postFrameCallback(mReactChoreographerDispatcher);
mHasPostedCallback = true;
}
}
示例8: postFrameCallback
import android.view.Choreographer; //导入方法依赖的package包/类
@Override
public void postFrameCallback(Choreographer.FrameCallback callback) {
mChoreographer.postFrameCallback(callback);
}
示例9: choreographerPostFrameCallback
import android.view.Choreographer; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerPostFrameCallback(Choreographer.FrameCallback frameCallback) {
mChoreographer.postFrameCallback(frameCallback);
}
示例10: choreographerPostFrameCallbackDelayed
import android.view.Choreographer; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerPostFrameCallbackDelayed(
Choreographer.FrameCallback frameCallback,
long delayMillis) {
mChoreographer.postFrameCallbackDelayed(frameCallback, delayMillis);
}
示例11: choreographerRemoveFrameCallback
import android.view.Choreographer; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerRemoveFrameCallback(Choreographer.FrameCallback frameCallback) {
mChoreographer.removeFrameCallback(frameCallback);
}
示例12: init
import android.view.Choreographer; //导入方法依赖的package包/类
/**
*
* @param threshold 设置输出日志的阈值,
* 比如设置为10,日志会追踪所有丢帧超过10帧的场景
* @param noSystemCode 堆栈是否需要含有Android系统代码
* @return
*/
public Monitor init(int threshold,boolean noSystemCode) {
if (new Handler().getLooper() != Looper.getMainLooper()) {
throw new RuntimeException(" must init in Main thread !");
}
if (inited) {
return this;
}
if (threshold <= 0) {
threshold = 1;
}
this.threshold = threshold;
this.delay = delay * threshold;
HandlerThread mHandlerThread = new CheckerHandlerThread("monitor",
Process.THREAD_PRIORITY_FOREGROUND);
mHandlerThread.start();
mCheckerHandler = new Handler(mHandlerThread.getLooper(), this);
mMainHandler = new Handler(Looper.getMainLooper());
stackQueue = new QueueCache<>(threshold + 1);
mInfoConsumer = new InfoConsumer(noSystemCode);
mMainChoreographer = Choreographer.getInstance();
mMainCallback = new Choreographer.FrameCallback() {
@Override
public void doFrame(final long frameTimeNanos) {
final long delta = (frameTimeNanos - lastDoFrameTime) / 1000000;
if (lastDoFrameTime != 0 && delta > delay) {
//LogUtils.d("monitor", "main doFrame " + delta);
final long lastTime = lastDoFrameTime;
// 单线程操作 queue
mCheckerHandler.post(new Runnable() {
@Override
public void run() {
statisticsStack(frameTimeNanos / 1000000, delta, StackInfo.TYPE_CHECK);
processInfo(lastTime / 1000000, frameTimeNanos / 1000000);
}
});
}
lastDoFrameTime = frameTimeNanos;
if (mLoopFlag) {
mMainChoreographer.postFrameCallback(mMainCallback);
}
}
};
inited = true;
return this;
}
示例13: choreographerPostFrameCallbackDelayed
import android.view.Choreographer; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerPostFrameCallbackDelayed(
Choreographer.FrameCallback frameCallback,
long delayMillis) {
mChoreographer.postFrameCallbackDelayed(frameCallback, delayMillis);
}
示例14: getAndResetFrameCallback
import android.view.Choreographer; //导入方法依赖的package包/类
public Choreographer.FrameCallback getAndResetFrameCallback() {
Choreographer.FrameCallback callback = mFrameCallback;
mFrameCallback = null;
return callback;
}
示例15: answer
import android.view.Choreographer; //导入方法依赖的package包/类
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
mFrameCallback = (Choreographer.FrameCallback) args[1];
return null;
}