Java Code Examples for android.view.View#removeOnLayoutChangeListener()
The following examples show how to use
android.view.View#removeOnLayoutChangeListener() .
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 |
/** @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: ImageLoader.java From Android-App-Architecture-MVVM-Databinding with Apache License 2.0 | 6 votes |
@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); } }
Example 3
Source File: ReactViewGroup.java From react-native-GPay with MIT License | 6 votes |
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); }
Example 4
Source File: LayoutTransition.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
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(); } }
Example 5
Source File: DocumentView.java From ViewPrinter with Apache License 2.0 | 5 votes |
@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); } }
Example 6
Source File: TooltipDrawable.java From material-components-android with Apache License 2.0 | 5 votes |
/** * 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); }
Example 7
Source File: ThreadDetailFragment.java From hipda with GNU General Public License v2.0 | 5 votes |
@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); } }
Example 8
Source File: FloatingActionModeHelper.java From ProjectX with Apache License 2.0 | 5 votes |
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; }
Example 9
Source File: LifecycleHelper.java From react-native-screens with MIT License | 4 votes |
@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); }
Example 10
Source File: BuggyVideoDriverPreventer.java From no-player with Apache License 2.0 | 4 votes |
void clear(View containerView) { containerView.removeOnLayoutChangeListener(preventerListener); preventerListener = null; }
Example 11
Source File: BottomAppBar.java From material-components-android with Apache License 2.0 | 4 votes |
@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; } } }
Example 12
Source File: BottomSheetLayout.java From ThreePhasesBottomSheet with BSD 3-Clause "New" or "Revised" License | 4 votes |
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; }
Example 13
Source File: BottomSheetLayout.java From bottomsheet with BSD 3-Clause "New" or "Revised" License | 4 votes |
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; }
Example 14
Source File: DialtactsActivity.java From coursera-android with MIT License | 4 votes |
@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(); }