android.view.View#removeOnLayoutChangeListener ( )源码实例Demo

下面列出了android.view.View#removeOnLayoutChangeListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: PopupWindow.java
/** @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;
}
 
@Override
public void onLayoutChange(final View v, final int left, final int top, final int right, final int bottom,
        final int oldLeft, final int oldTop, final int oldRight, final int oldBottom) {
    if (left == right) {
        return;
    }

    final WeakReference<T> found = viewModelMap.get(v.hashCode());
    if (found == null) {
        v.removeOnLayoutChangeListener(this);
        return;
    }

    final T urlProvider = found.get();
    // Remove from map.
    viewModelMap.delete(v.hashCode());

    if (urlProvider != null) {
        final String url = getUrl.apply(urlProvider);
        loadImage((ImageView) v, url);
        v.removeOnLayoutChangeListener(this);
    }
}
 
源代码3 项目: react-native-GPay   文件: ReactViewGroup.java
void removeViewWithSubviewClippingEnabled(View view) {
  Assertions.assertCondition(mRemoveClippedSubviews);
  Assertions.assertNotNull(mClippingRect);
  Assertions.assertNotNull(mAllChildren);
  view.removeOnLayoutChangeListener(mChildrenLayoutChangeListener);
  int index = indexOfChildInAllChildren(view);
  if (isChildInViewGroup(mAllChildren[index])) {
    int childIndexOffset = 0;
    for (int i = 0; i < index; i++) {
      if (!isChildInViewGroup(mAllChildren[i])) {
        childIndexOffset++;
      }
    }
    super.removeViewsInLayout(index - childIndexOffset, 1);
  }
  removeFromArray(index);
}
 
源代码4 项目: android_9.0.0_r45   文件: LayoutTransition.java
private void cleanup() {
    parent.getViewTreeObserver().removeOnPreDrawListener(this);
    parent.removeOnAttachStateChangeListener(this);
    int count = layoutChangeListenerMap.size();
    if (count > 0) {
        Collection<View> views = layoutChangeListenerMap.keySet();
        for (View view : views) {
            View.OnLayoutChangeListener listener = layoutChangeListenerMap.get(view);
            view.removeOnLayoutChangeListener(listener);
        }
        layoutChangeListenerMap.clear();
    }
}
 
源代码5 项目: ViewPrinter   文件: DocumentView.java
@Override
public void onLayoutChange(View view, int left, int top, int right, int bottom,
                           int oldLeft, int oldTop, int oldRight, int oldBottom) {
    if (view.isFocused() && view instanceof TextView) {
        // A focused view changed its bounds. Follow it?
        int height = bottom - top;
        int oldHeight = oldBottom - oldTop;
        if (oldHeight != height) {
            zoomToView(view, false);
        }
    } else {
        view.removeOnLayoutChangeListener(this);
    }
}
 
/**
 * Should be called when the view is detached from the screen.
 *
 * @see #setRelativeToView(View)
 */
public void detachView(@Nullable View view) {
  if (view == null) {
    return;
  }
  view.removeOnLayoutChangeListener(attachedViewLayoutChangeListener);
}
 
源代码7 项目: hipda   文件: ThreadDetailFragment.java
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
    if (oldTop - top > Utils.dpToPx(96)) {
        v.removeOnLayoutChangeListener(this);
        scrollPostForReply(top);
    }
}
 
源代码8 项目: ProjectX   文件: FloatingActionModeHelper.java
private void finish(boolean immediate) {
    mView.removeView(immediate);
    mCallback.onDestroyActionMode(mMode);
    mFinished = true;
    mTarget.removeOnAttachStateChangeListener(this);
    final View root = mTarget.getRootView();
    root.removeOnLayoutChangeListener(this);
    root.removeOnAttachStateChangeListener(this);
    mTarget = null;
}
 
源代码9 项目: react-native-screens   文件: LifecycleHelper.java
@Override
public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
  registerViewWithLifecycleOwner(view);
  view.removeOnLayoutChangeListener(this);
}
 
源代码10 项目: no-player   文件: BuggyVideoDriverPreventer.java
void clear(View containerView) {
    containerView.removeOnLayoutChangeListener(preventerListener);
    preventerListener = null;
}
 
源代码11 项目: material-components-android   文件: BottomAppBar.java
@Override
public void onLayoutChange(
    View v,
    int left,
    int top,
    int right,
    int bottom,
    int oldLeft,
    int oldTop,
    int oldRight,
    int oldBottom) {
  BottomAppBar child = viewRef.get();

  // If the child BAB no longer exists, remove the listener.
  if (child == null || !(v instanceof FloatingActionButton)) {
    v.removeOnLayoutChangeListener(this);
    return;
  }

  FloatingActionButton fab = ((FloatingActionButton) v);

  fab.getMeasuredContentRect(fabContentRect);
  int height = fabContentRect.height();

  // Set the cutout diameter based on the height of the fab.
  child.setFabDiameter(height);

  CoordinatorLayout.LayoutParams fabLayoutParams =
      (CoordinatorLayout.LayoutParams) v.getLayoutParams();

  // Manage the bottomMargin of the fab if it wasn't explicitly set to something. This
  // adds space below the fab if the BottomAppBar is hidden.
  if (originalBottomMargin == 0) {
    // Extra padding is added for the fake shadow on API < 21. Ensure we don't add too
    // much space by removing that extra padding.
    int bottomShadowPadding = (fab.getMeasuredHeight() - height) / 2;
    int bottomMargin =
        child
            .getResources()
            .getDimensionPixelOffset(R.dimen.mtrl_bottomappbar_fab_bottom_margin);
    // Should be moved above the bottom insets with space ignoring any shadow padding.
    int minBottomMargin = bottomMargin - bottomShadowPadding;
    fabLayoutParams.bottomMargin = child.getBottomInset() + minBottomMargin;
    fabLayoutParams.leftMargin = child.getLeftInset();
    fabLayoutParams.rightMargin = child.getRightInset();
    boolean isRtl = ViewUtils.isLayoutRtl(fab);
    if (isRtl) {
      fabLayoutParams.leftMargin += child.fabOffsetEndMode;
    } else {
      fabLayoutParams.rightMargin += child.fabOffsetEndMode;
    }
  }
}
 
源代码12 项目: ThreePhasesBottomSheet   文件: BottomSheetLayout.java
private void dismissSheet(Runnable runAfterDismissThis) {
    if (state == State.HIDDEN) {
        runAfterDismiss = null;
        return;
    }
    // This must be set every time, including if the parameter is null
    // Otherwise a new sheet might be shown when the caller called dismiss after a showWithSheet call, which would be
    runAfterDismiss = runAfterDismissThis;
    final View sheetView = getSheetView();
    sheetView.removeOnLayoutChangeListener(sheetViewOnLayoutChangeListener);
    cancelCurrentAnimation();
    ObjectAnimator anim = ObjectAnimator.ofFloat(this, SHEET_TRANSLATION, 0);
    anim.setDuration(ANIMATION_DURATION);
    anim.setInterpolator(animationInterpolator);
    anim.addListener(new CancelDetectionAnimationListener() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (!canceled) {
                currentAnimator = null;
                setState(State.HIDDEN);
                setSheetLayerTypeIfEnabled(LAYER_TYPE_NONE);
                final View view = getSheetView();
                if (view != null)
                    removeView(view);

                for (OnSheetDismissedListener onSheetDismissedListener : onSheetDismissedListeners)
                    onSheetDismissedListener.onDismissed(BottomSheetLayout.this);

                // Remove sheet specific properties
                viewTransformer = null;
                onSheetDismissedListeners.clear();
                onSheetStateChangeListeners.clear();
                if (runAfterDismiss != null) {
                    runAfterDismiss.run();
                    runAfterDismiss = null;
                }
            }
        }
    });
    anim.start();
    currentAnimator = anim;
    sheetStartX = 0;
    sheetEndX = screenWidth;
}
 
源代码13 项目: bottomsheet   文件: BottomSheetLayout.java
private void dismissSheet(Runnable runAfterDismissThis) {
    if (state == State.HIDDEN) {
        runAfterDismiss = null;
        return;
    }
    // This must be set every time, including if the parameter is null
    // Otherwise a new sheet might be shown when the caller called dismiss after a showWithSheet call, which would be 
    runAfterDismiss = runAfterDismissThis;
    final View sheetView = getSheetView();
    sheetView.removeOnLayoutChangeListener(sheetViewOnLayoutChangeListener);
    cancelCurrentAnimation();
    ObjectAnimator anim = ObjectAnimator.ofFloat(this, SHEET_TRANSLATION, 0);
    anim.setDuration(ANIMATION_DURATION);
    anim.setInterpolator(animationInterpolator);
    anim.addListener(new CancelDetectionAnimationListener() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (!canceled) {
                currentAnimator = null;
                setState(State.HIDDEN);
                setSheetLayerTypeIfEnabled(LAYER_TYPE_NONE);
                removeView(sheetView);

                for (OnSheetDismissedListener onSheetDismissedListener : onSheetDismissedListeners) {
                    onSheetDismissedListener.onDismissed(BottomSheetLayout.this);
                }

                // Remove sheet specific properties
                viewTransformer = null;
                if (runAfterDismiss != null) {
                    runAfterDismiss.run();
                    runAfterDismiss = null;
                }
            }
        }
    });
    anim.start();
    currentAnimator = anim;
    sheetStartX = 0;
    sheetEndX = screenWidth;
}
 
源代码14 项目: coursera-android   文件: DialtactsActivity.java
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
        int oldTop, int oldRight, int oldBottom) {
    v.removeOnLayoutChangeListener(this); // Unregister self.
    addSearchFragment();
}
 
 方法所在类
 同类方法