Java Code Examples for android.view.Choreographer.FrameCallback

The following are top voted examples for showing how to use android.view.Choreographer.FrameCallback. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: 365browser   File: VrShellDelegate.java   View source code 6 votes vote down vote up
private VrShellDelegate(ChromeActivity activity, VrClassesWrapper wrapper) {
    mActivity = activity;
    mVrClassesWrapper = wrapper;
    // If an activity isn't resumed at the point, it must have been paused.
    mPaused = ApplicationStatus.getStateForActivity(activity) != ActivityState.RESUMED;
    updateVrSupportLevel();
    mNativeVrShellDelegate = nativeInit();
    mFeedbackFrequency = VrFeedbackStatus.getFeedbackFrequency();
    mEnterVrHandler = new Handler();
    Choreographer.getInstance().postFrameCallback(new FrameCallback() {
        @Override
        public void doFrame(long frameTimeNanos) {
            if (mNativeVrShellDelegate == 0) return;
            Display display =
                    ((WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE))
                            .getDefaultDisplay();
            nativeUpdateVSyncInterval(
                    mNativeVrShellDelegate, frameTimeNanos, 1.0d / display.getRefreshRate());
        }
    });
    ApplicationStatus.registerStateListenerForAllActivities(this);
}