本文整理匯總了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;
}