下面列出了android.view.View#getViewRootImpl ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Detaches the draw GL functor.
*
* @param nativeDrawGLFunctor the pointer to the native functor that implements
* system/core/include/utils/Functor.h
*/
public void detachDrawGlFunctor(View containerView, long nativeDrawGLFunctor) {
ViewRootImpl viewRootImpl = containerView.getViewRootImpl();
if (nativeDrawGLFunctor != 0 && viewRootImpl != null) {
viewRootImpl.detachFunctor(nativeDrawGLFunctor);
}
}
/**
* Provides the default implementation of {@link InputConnection#sendKeyEvent(KeyEvent)}, which
* is expected to dispatch an keyboard event sent from the IME to an appropriate event target
* depending on the given {@link View} and the current focus state.
*
* <p>CAUTION: This method is provided only for the situation where
* {@link InputConnection#sendKeyEvent(KeyEvent)} needs to be implemented without relying on
* {@link BaseInputConnection}. Do not use this API for anything else.</p>
*
* @param targetView the default target view. If {@code null} is specified, then this method
* tries to find a good event target based on the current focus state.
* @param event the key event to be dispatched.
*/
public void dispatchKeyEventFromInputMethod(@Nullable View targetView,
@NonNull KeyEvent event) {
synchronized (mH) {
ViewRootImpl viewRootImpl = targetView != null ? targetView.getViewRootImpl() : null;
if (viewRootImpl == null) {
if (mServedView != null) {
viewRootImpl = mServedView.getViewRootImpl();
}
}
if (viewRootImpl != null) {
viewRootImpl.dispatchKeyFromIme(event);
}
}
}
private void startInputWhenTransitionsComplete() {
if (mViewsTransitionComplete && mSharedElementTransitionComplete) {
final View decor = getDecor();
if (decor != null) {
final ViewRootImpl viewRoot = decor.getViewRootImpl();
if (viewRoot != null) {
viewRoot.setPausedForTransition(false);
}
}
onTransitionsComplete();
}
}
protected void pauseInput() {
final View decor = getDecor();
final ViewRootImpl viewRoot = decor == null ? null : decor.getViewRootImpl();
if (viewRoot != null) {
viewRoot.setPausedForTransition(true);
}
}
static void scheduleCheckFocusLocked(View view) {
ViewRootImpl viewRootImpl = view.getViewRootImpl();
if (viewRootImpl != null) {
viewRootImpl.dispatchCheckFocus();
}
}