当前位置: 首页>>代码示例>>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;未经允许,请勿转载。