Java Code Examples for android.support.v4.view.ViewCompat#isLaidOut()
The following examples show how to use
android.support.v4.view.ViewCompat#isLaidOut() .
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: MainActivity.java From connectivity-samples with Apache License 2.0 | 6 votes |
/** Transitions from the old state to the new state with an animation implying moving forward. */ @UiThread private void transitionForward(State oldState, final State newState) { mPreviousStateView.setVisibility(View.VISIBLE); mCurrentStateView.setVisibility(View.VISIBLE); updateTextView(mPreviousStateView, oldState); updateTextView(mCurrentStateView, newState); if (ViewCompat.isLaidOut(mCurrentStateView)) { mCurrentAnimator = createAnimator(false /* reverse */); mCurrentAnimator.addListener( new AnimatorListener() { @Override public void onAnimationEnd(Animator animator) { updateTextView(mCurrentStateView, newState); } }); mCurrentAnimator.start(); } }
Example 2
Source File: MainActivity.java From connectivity-samples with Apache License 2.0 | 6 votes |
/** Transitions from the old state to the new state with an animation implying moving backward. */ @UiThread private void transitionBackward(State oldState, final State newState) { mPreviousStateView.setVisibility(View.VISIBLE); mCurrentStateView.setVisibility(View.VISIBLE); updateTextView(mCurrentStateView, oldState); updateTextView(mPreviousStateView, newState); if (ViewCompat.isLaidOut(mCurrentStateView)) { mCurrentAnimator = createAnimator(true /* reverse */); mCurrentAnimator.addListener( new AnimatorListener() { @Override public void onAnimationEnd(Animator animator) { updateTextView(mCurrentStateView, newState); } }); mCurrentAnimator.start(); } }
Example 3
Source File: MainActivity.java From connectivity-samples with Apache License 2.0 | 6 votes |
/** Transitions from the old state to the new state with an animation implying moving forward. */ @UiThread private void transitionForward(State oldState, final State newState) { mPreviousStateView.setVisibility(View.VISIBLE); mCurrentStateView.setVisibility(View.VISIBLE); updateTextView(mPreviousStateView, oldState); updateTextView(mCurrentStateView, newState); if (ViewCompat.isLaidOut(mCurrentStateView)) { mCurrentAnimator = createAnimator(false /* reverse */); mCurrentAnimator.addListener( new AnimatorListener() { @Override public void onAnimationEnd(Animator animator) { updateTextView(mCurrentStateView, newState); } }); mCurrentAnimator.start(); } }
Example 4
Source File: MainActivity.java From connectivity-samples with Apache License 2.0 | 6 votes |
/** Transitions from the old state to the new state with an animation implying moving backward. */ @UiThread private void transitionBackward(State oldState, final State newState) { mPreviousStateView.setVisibility(View.VISIBLE); mCurrentStateView.setVisibility(View.VISIBLE); updateTextView(mCurrentStateView, oldState); updateTextView(mPreviousStateView, newState); if (ViewCompat.isLaidOut(mCurrentStateView)) { mCurrentAnimator = createAnimator(true /* reverse */); mCurrentAnimator.addListener( new AnimatorListener() { @Override public void onAnimationEnd(Animator animator) { updateTextView(mCurrentStateView, newState); } }); mCurrentAnimator.start(); } }
Example 5
Source File: Snackbar.java From Nimingban with Apache License 2.0 | 6 votes |
final void showView() { if (mView.getParent() == null) { mParent.addView(mView); } if (ViewCompat.isLaidOut(mView)) { animateViewIn(); } else { mView.setOnLayoutChangeListener(new Snackbar.SnackbarLayout.OnLayoutChangeListener() { @Override public void onLayoutChange(View view, int left, int top, int right, int bottom) { animateViewIn(); mView.setOnLayoutChangeListener(null); } }); } }
Example 6
Source File: BubbleActions.java From BubbleActions with Apache License 2.0 | 6 votes |
/** * Show the bubble actions. Internally this will do 3 things: * 1. Add the overlay to the root view * 2. Use reflection to get the last touched xy location * 3. Animate the overlay in */ public void show() { if (showing) { return; } if (overlay.getParent() == null) { root.addView(overlay); } if (ViewCompat.isLaidOut(overlay)) { showOverlay(); } else { overlay.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { overlay.removeOnLayoutChangeListener(this); showOverlay(); } }); } }
Example 7
Source File: LabelView.java From AppCompat-Extension-Library with Apache License 2.0 | 6 votes |
/** * Hides the label using a translation animation */ public void hide() { if (mIsHiding || getVisibility() != VISIBLE) { // Already hiding or hidden, skip the call return; } if (!ViewCompat.isLaidOut(this)) { // View isn't laid out yet setVisibility(GONE); } // Use platform dependent animations if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { hideIceCreamSandwich(); } else { hideEclairMr1(); } }
Example 8
Source File: LabelView.java From AppCompat-Extension-Library with Apache License 2.0 | 6 votes |
/** * Shows the label using a translation animation */ public void show() { if (!mIsHiding && getVisibility() == VISIBLE) { // Already showing or shown, skip the call return; } if (!ViewCompat.isLaidOut(this)) { // View isn't laid out yet return; } // Use platform dependent animations if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { showIceCreamSandwich(); } else { showEclairMr1(); } }
Example 9
Source File: TitleFAB.java From FABsMenu with Apache License 2.0 | 5 votes |
private boolean shouldAnimateVisibilityChange() { View label = getLabelView(); if (label != null) { return ViewCompat.isLaidOut(this) && ViewCompat.isLaidOut(label) && !isInEditMode(); } else { return ViewCompat.isLaidOut(this) && !isInEditMode(); } }
Example 10
Source File: AnimHelper.java From mvvm-template with GNU General Public License v3.0 | 5 votes |
@UiThread public static void mimicFabVisibility(boolean show, @NonNull View view, @Nullable FloatingActionButton.OnVisibilityChangedListener listener) { if (show) { view.animate().cancel(); if (ViewCompat.isLaidOut(view)) { if (view.getVisibility() != View.VISIBLE) { view.setAlpha(0f); view.setScaleY(0f); view.setScaleX(0f); } view.animate() .scaleX(1f) .scaleY(1f) .alpha(1f) .setDuration(200) .setInterpolator(LINEAR_OUT_SLOW_IN_INTERPOLATOR) .withStartAction(() -> { view.setVisibility(View.VISIBLE); if (listener != null) listener.onShown(null); }); } else { view.setVisibility(View.VISIBLE); view.setAlpha(1f); view.setScaleY(1f); view.setScaleX(1f); if (listener != null) listener.onShown(null); } } else { view.animate() .scaleX(0f) .scaleY(0f) .alpha(0f) .setDuration(40) .setInterpolator(FAST_OUT_LINEAR_IN_INTERPOLATOR); view.setVisibility(View.GONE); if (listener != null) listener.onHidden(null); } }
Example 11
Source File: ViewUtils.java From px-android with MIT License | 5 votes |
public static void runWhenViewIsFullyMeasured(@NonNull final View view, @NonNull final Runnable runnable) { if (ViewCompat.isLaidOut(view)) { runnable.run(); } else { view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @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) { view.removeOnLayoutChangeListener(this); runnable.run(); } }); } }
Example 12
Source File: FloatingActionButton.java From ticdesign with Apache License 2.0 | 5 votes |
/** * Return in {@code rect} the bounds of the actual floating action button content in view-local * coordinates. This is defined as anything within any visible shadow. * * @return true if this view actually has been laid out and has a content rect, else false. */ public boolean getContentRect(@NonNull Rect rect) { if (ViewCompat.isLaidOut(this)) { rect.set(0, 0, getWidth(), getHeight()); rect.left += mProgressPadding.left; rect.top += mProgressPadding.top; rect.right -= mProgressPadding.right; rect.bottom -= mProgressPadding.bottom; return true; } else { return false; } }
Example 13
Source File: ViewUtil.java From styT with Apache License 2.0 | 4 votes |
/** * Returns whether or not the view has been laid out **/ private static boolean isLaidOut(View view) { return ViewCompat.isLaidOut(view) && view.getWidth() > 0 && view.getHeight() > 0; }