當前位置: 首頁>>代碼示例>>Java>>正文


Java Choreographer.FrameCallback方法代碼示例

本文整理匯總了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);
    }
  };
}
 
開發者ID:gitxuyulin,項目名稱:EditorImageAndText,代碼行數:16,代碼來源:AndroidSpringLooperFactory.java

示例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;
}
 
開發者ID:wensefu,項目名稱:StackCardsView,代碼行數:13,代碼來源:ChoreographerCompat.java

示例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;

        }
 
開發者ID:zongwu233,項目名稱:Winter,代碼行數:35,代碼來源:Monitor.java

示例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);
  }
}
 
開發者ID:john1jan,項目名稱:ReactNativeSignatureExample,代碼行數:9,代碼來源:TextInputTest.java

示例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);
  }
}
 
開發者ID:john1jan,項目名稱:ReactNativeSignatureExample,代碼行數:8,代碼來源:TimingModuleTest.java

示例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");
  }
}
 
開發者ID:Right-Men,項目名稱:Ironman,代碼行數:10,代碼來源:ReactChoreographer.java

示例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;
  }
}
 
開發者ID:Right-Men,項目名稱:Ironman,代碼行數:11,代碼來源:ReactChoreographer.java

示例8: postFrameCallback

import android.view.Choreographer; //導入方法依賴的package包/類
@Override
public void postFrameCallback(Choreographer.FrameCallback callback) {
    mChoreographer.postFrameCallback(callback);
}
 
開發者ID:unixzii,項目名稱:android-SpringAnimator,代碼行數:5,代碼來源:AnimationHandler.java

示例9: choreographerPostFrameCallback

import android.view.Choreographer; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerPostFrameCallback(Choreographer.FrameCallback frameCallback) {
  mChoreographer.postFrameCallback(frameCallback);
}
 
開發者ID:wensefu,項目名稱:StackCardsView,代碼行數:5,代碼來源:ChoreographerCompat.java

示例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);
}
 
開發者ID:wensefu,項目名稱:StackCardsView,代碼行數:7,代碼來源:ChoreographerCompat.java

示例11: choreographerRemoveFrameCallback

import android.view.Choreographer; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerRemoveFrameCallback(Choreographer.FrameCallback frameCallback) {
  mChoreographer.removeFrameCallback(frameCallback);
}
 
開發者ID:wensefu,項目名稱:StackCardsView,代碼行數:5,代碼來源:ChoreographerCompat.java

示例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;
}
 
開發者ID:zongwu233,項目名稱:Winter,代碼行數:55,代碼來源:Monitor.java

示例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);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:7,代碼來源:ChoreographerCompat.java

示例14: getAndResetFrameCallback

import android.view.Choreographer; //導入方法依賴的package包/類
public Choreographer.FrameCallback getAndResetFrameCallback() {
  Choreographer.FrameCallback callback = mFrameCallback;
  mFrameCallback = null;
  return callback;
}
 
開發者ID:john1jan,項目名稱:ReactNativeSignatureExample,代碼行數:6,代碼來源:TimingModuleTest.java

示例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;
}
 
開發者ID:ManrajGrover,項目名稱:react-native-box-loaders,代碼行數:7,代碼來源:TimingModuleTest.java


注:本文中的android.view.Choreographer.FrameCallback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。