Java Code Examples for android.view.View#removeOnLayoutChangeListener()
The following examples show how to use
android.view.View#removeOnLayoutChangeListener() .
These examples are extracted from open source projects.
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 Project: android_9.0.0_r45 File: PopupWindow.java License: 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 Project: Android-App-Architecture-MVVM-Databinding File: ImageLoader.java License: 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 Project: react-native-GPay File: ReactViewGroup.java License: 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 Project: android_9.0.0_r45 File: LayoutTransition.java License: 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 Project: ViewPrinter File: DocumentView.java License: 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 Project: material-components-android File: TooltipDrawable.java License: 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 Project: hipda File: ThreadDetailFragment.java License: 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 Project: ProjectX File: FloatingActionModeHelper.java License: 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 Project: react-native-screens File: LifecycleHelper.java License: 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 Project: no-player File: BuggyVideoDriverPreventer.java License: Apache License 2.0 | 4 votes |
void clear(View containerView) { containerView.removeOnLayoutChangeListener(preventerListener); preventerListener = null; }
Example 11
Source Project: material-components-android File: BottomAppBar.java License: 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 Project: ThreePhasesBottomSheet File: BottomSheetLayout.java License: 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 Project: bottomsheet File: BottomSheetLayout.java License: 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 Project: coursera-android File: DialtactsActivity.java License: 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(); }