Java Code Examples for android.view.ViewTreeObserver#removeOnScrollChangedListener()

The following examples show how to use android.view.ViewTreeObserver#removeOnScrollChangedListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PopupWindow.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** @hide */
protected void detachFromAnchor() {
    final View anchor = getAnchor();
    if (anchor != null) {
        final ViewTreeObserver vto = anchor.getViewTreeObserver();
        vto.removeOnScrollChangedListener(mOnScrollChangedListener);
        anchor.removeOnAttachStateChangeListener(mOnAnchorDetachedListener);
    }

    final View anchorRoot = mAnchorRoot != null ? mAnchorRoot.get() : null;
    if (anchorRoot != null) {
        anchorRoot.removeOnAttachStateChangeListener(mOnAnchorRootDetachedListener);
        anchorRoot.removeOnLayoutChangeListener(mOnLayoutChangeListener);
    }

    mAnchor = null;
    mAnchorRoot = null;
    mIsAnchorRootAttached = false;
}
 
Example 2
Source File: BorderView.java    From AndroidTvDemo with Apache License 2.0 6 votes vote down vote up
public void detachFrom(ViewGroup viewGroup)
{
    try
    {
        if (viewGroup == mViewGroup)
        {
            ViewTreeObserver viewTreeObserver = mViewGroup.getViewTreeObserver();
            viewTreeObserver.removeOnGlobalFocusChangeListener(this);
            viewTreeObserver.removeOnScrollChangedListener(this);
            viewTreeObserver.removeOnGlobalLayoutListener(this);
            viewTreeObserver.removeOnTouchModeChangeListener(this);
            borderEffect.OnDetach(mView, viewGroup);
        }
    }
    catch (Exception ex)
    {
        ex.printStackTrace();
    }
}
 
Example 3
Source File: MetroViewBorderImpl.java    From LivePlayback with Apache License 2.0 5 votes vote down vote up
public void detachFrom(ViewGroup viewGroup) {
    try {
        if (viewGroup == mViewGroup) {
            ViewTreeObserver viewTreeObserver = mViewGroup.getViewTreeObserver();//获取view树的观察者
            viewTreeObserver.removeOnGlobalFocusChangeListener(this);//通知全局性移除相应的listener
            viewTreeObserver.removeOnScrollChangedListener(this);
            viewTreeObserver.removeOnGlobalLayoutListener(this);
            viewTreeObserver.removeOnTouchModeChangeListener(this);
            mMetroViewBorder.OnDetach(mView, viewGroup);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
Example 4
Source File: BorderView.java    From TvWidget with Apache License 2.0 5 votes vote down vote up
public void detachFrom(ViewGroup viewGroup) {
    try {
        if (viewGroup == mViewGroup) {
            ViewTreeObserver viewTreeObserver = mViewGroup.getViewTreeObserver();
            viewTreeObserver.removeOnGlobalFocusChangeListener(this);
            viewTreeObserver.removeOnScrollChangedListener(this);
            viewTreeObserver.removeOnGlobalLayoutListener(this);
            viewTreeObserver.removeOnTouchModeChangeListener(this);
            borderEffect.OnDetach(mView, viewGroup);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
Example 5
Source File: MetroViewBorderImpl.java    From TVSample with Apache License 2.0 5 votes vote down vote up
public void detachFrom(ViewGroup viewGroup) {
    try {
        if (viewGroup == mViewGroup) {
            ViewTreeObserver viewTreeObserver = mViewGroup.getViewTreeObserver();//获取view树的观察者
            viewTreeObserver.removeOnGlobalFocusChangeListener(this);//通知全局性移除相应的listener
            viewTreeObserver.removeOnScrollChangedListener(this);
            viewTreeObserver.removeOnGlobalLayoutListener(this);
            viewTreeObserver.removeOnTouchModeChangeListener(this);
            mMetroViewBorder.OnDetach(mView, viewGroup);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
Example 6
Source File: MetroViewBorderImpl.java    From TVSample with Apache License 2.0 5 votes vote down vote up
public void detachFrom(ViewGroup viewGroup) {
    try {
        if (viewGroup == mViewGroup) {
            ViewTreeObserver viewTreeObserver = mViewGroup.getViewTreeObserver();
            viewTreeObserver.removeOnGlobalFocusChangeListener(this);
            viewTreeObserver.removeOnScrollChangedListener(this);
            viewTreeObserver.removeOnGlobalLayoutListener(this);
            viewTreeObserver.removeOnTouchModeChangeListener(this);
            mMetroViewBorder.OnDetach(mView, viewGroup);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
Example 7
Source File: AppActivityLifecycleCallbacks.java    From sa-sdk-android with Apache License 2.0 5 votes vote down vote up
/**
 * 取消注册 ViewTreeObserver
 */
private void unRegisterViewTreeObserver(Activity activity) {
    ViewTreeObserver viewTreeObserver = activity.getWindow().getDecorView().getViewTreeObserver();
    viewTreeObserver.removeOnGlobalFocusChangeListener(AppViewTreeObserver.getInstance());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        viewTreeObserver.removeOnGlobalLayoutListener(AppViewTreeObserver.getInstance());
    }
    viewTreeObserver.removeOnScrollChangedListener(AppViewTreeObserver.getInstance());
}
 
Example 8
Source File: PEWTextView.java    From ParallaxEverywhere with MIT License 5 votes vote down vote up
@Override
protected void onDetachedFromWindow() {
    ViewTreeObserver viewTreeObserver = getViewTreeObserver();
    viewTreeObserver.removeOnScrollChangedListener(mOnScrollChangedListener);
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        viewTreeObserver.removeOnGlobalLayoutListener(mOnGlobalLayoutListener);
    } else {
        viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener);
    }
    if (updateOnDraw
            && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        viewTreeObserver.removeOnDrawListener(onDrawListener);
    }
    super.onDetachedFromWindow();
}
 
Example 9
Source File: PEWImageView.java    From ParallaxEverywhere with MIT License 5 votes vote down vote up
@Override
protected void onDetachedFromWindow() {
    ViewTreeObserver viewTreeObserver = getViewTreeObserver();
    viewTreeObserver.removeOnScrollChangedListener(mOnScrollChangedListener);
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        viewTreeObserver.removeOnGlobalLayoutListener(mOnGlobalLayoutListener);
    } else {
        viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener);
    }
    if (updateOnDraw
        && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            viewTreeObserver.removeOnDrawListener(onDrawListener);
    }
    super.onDetachedFromWindow();
}
 
Example 10
Source File: AdWebView.java    From mobile-sdk-android with Apache License 2.0 5 votes vote down vote up
private void removeViewTreeObserverListeners() {
    ViewTreeObserver treeObserver = getViewTreeObserver();
    if (treeObserver.isAlive()) {
        treeObserver.removeOnScrollChangedListener(this);
        treeObserver.removeGlobalOnLayoutListener(this);
    }
}
 
Example 11
Source File: AdWebView.java    From mobile-sdk-android with Apache License 2.0 5 votes vote down vote up
private void setupViewTreeObserver() {
    ViewTreeObserver treeObserver = getViewTreeObserver();
    if (treeObserver.isAlive()) {
        treeObserver.removeOnScrollChangedListener(this);
        treeObserver.removeGlobalOnLayoutListener(this);

        treeObserver.addOnScrollChangedListener(this);
        treeObserver.addOnGlobalLayoutListener(this);
    }
}
 
Example 12
Source File: InterpolateOnScrollPositionChangeHelper.java    From material-components-android with Apache License 2.0 2 votes vote down vote up
/**
 * Stop listening for scroll changes and interpolating based on position.
 *
 * @param viewTreeObserver {@link ViewTreeObserver belonging to the {@link View} being
 * interpolated.
 */
public void stopListeningForScrollChanges(@NonNull ViewTreeObserver viewTreeObserver) {
  viewTreeObserver.removeOnScrollChangedListener(scrollChangedListener);
}