Example usage for android.support.v4.view ViewPropertyAnimatorListenerAdapter ViewPropertyAnimatorListenerAdapter

List of usage examples for android.support.v4.view ViewPropertyAnimatorListenerAdapter ViewPropertyAnimatorListenerAdapter

Introduction

In this page you can find the example usage for android.support.v4.view ViewPropertyAnimatorListenerAdapter ViewPropertyAnimatorListenerAdapter.

Prototype

ViewPropertyAnimatorListenerAdapter

Source Link

Usage

From source file:com.github.rubensousa.floatingtoolbar.FloatingAnimatorImpl.java

@Override
public void hide() {
    super.hide();

    // A snackbar might have appeared, so we need to update the fab position again
    if (getAppBar() != null) {
        getFab().setY(getFloatingToolbar().getY());
    } else {/*from  w  w  w.j  a v  a 2 s . c o m*/
        getFab().setTranslationY(getFloatingToolbar().getTranslationY());
    }

    final int fabNewY = getFab().getTop();
    ViewCompat.animate(getFab()).x(getFab().getLeft()).y(fabNewY)
            .translationY(getFloatingToolbar().getTranslationY()).scaleX(1f).scaleY(1f)
            .setStartDelay(FAB_UNMORPH_DELAY).setDuration(FAB_UNMORPH_DURATION)
            .setInterpolator(new AccelerateInterpolator())
            .setListener(new ViewPropertyAnimatorListenerAdapter() {
                @Override
                public void onAnimationStart(View view) {
                    getFab().setVisibility(View.VISIBLE);
                }

                @Override
                public void onAnimationEnd(View view) {
                    // Make sure the fab goes to the right place after the animation ends
                    // when the Appbar is attached
                    if (getAppBar() != null && getFab().getVisibility() == View.INVISIBLE) {
                        getFab().show();
                    }
                    getAnimationListener().onAnimationFinished();
                }
            });

    ViewCompat.animate(getFloatingToolbar()).scaleX(0f).setDuration(CIRCULAR_UNREVEAL_DURATION)
            .setStartDelay(CIRCULAR_UNREVEAL_DELAY).setInterpolator(new AccelerateDecelerateInterpolator())
            .setListener(new ViewPropertyAnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(View view) {
                    getFloatingToolbar().setVisibility(View.INVISIBLE);
                    ViewCompat.animate(getFloatingToolbar()).setListener(null);
                }
            });
}

From source file:com.example.ray.firstapp.bottombar.MiscUtils.java

/**
 * Animate a background color change. Uses Circular Reveal if supported,
 * otherwise crossfades the background color in.
 *
 * @param clickedView    the view that was clicked for calculating the start position
 *                       for the Circular Reveal.
 * @param backgroundView the currently showing background color.
 * @param bgOverlay      the overlay view for the new background color that will be
 *                       animated in./* www  .j a v  a 2s .  c  om*/
 * @param newColor       the new color.
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected static void animateBGColorChange(View clickedView, final View backgroundView, final View bgOverlay,
        final int newColor) {
    int centerX = (int) (ViewCompat.getX(clickedView) + (clickedView.getMeasuredWidth() / 2));
    int centerY = clickedView.getMeasuredHeight() / 2;
    int finalRadius = backgroundView.getWidth();

    backgroundView.clearAnimation();
    bgOverlay.clearAnimation();

    Object animator;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (!bgOverlay.isAttachedToWindow()) {
            return;
        }

        animator = ViewAnimationUtils.createCircularReveal(bgOverlay, centerX, centerY, 0, finalRadius);
    } else {
        ViewCompat.setAlpha(bgOverlay, 0);
        animator = ViewCompat.animate(bgOverlay).alpha(1);
    }

    if (animator instanceof ViewPropertyAnimatorCompat) {
        ((ViewPropertyAnimatorCompat) animator).setListener(new ViewPropertyAnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(View view) {
                onCancel();
            }

            @Override
            public void onAnimationCancel(View view) {
                onCancel();
            }

            private void onCancel() {
                backgroundView.setBackgroundColor(newColor);
                bgOverlay.setVisibility(View.INVISIBLE);
                ViewCompat.setAlpha(bgOverlay, 1);
            }
        }).start();
    } else if (animator != null) {
        ((Animator) animator).addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                onCancel();
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                onCancel();
            }

            private void onCancel() {
                backgroundView.setBackgroundColor(newColor);
                bgOverlay.setVisibility(View.INVISIBLE);
                ViewCompat.setAlpha(bgOverlay, 1);
            }
        });

        ((Animator) animator).start();
    }

    bgOverlay.setBackgroundColor(newColor);
    bgOverlay.setVisibility(View.VISIBLE);
}

From source file:org.wso2.iot.nfcprovisioning.uielements.TextInputLayoutWithHelpText.java

public void setHelperText(CharSequence _helperText) {
    mHelperText = _helperText;//from ww  w  . j a v a 2  s.  co  m
    if (!this.mHelperTextEnabled) {
        if (TextUtils.isEmpty(mHelperText)) {
            return;
        }
        this.setHelperTextEnabled(true);
    }

    if (!TextUtils.isEmpty(mHelperText)) {
        this.mHelperView.setText(mHelperText);
        this.mHelperView.setVisibility(VISIBLE);
        ViewCompat.setAlpha(this.mHelperView, 0.0F);
        ViewCompat.animate(this.mHelperView).alpha(1.0F).setDuration(200L)
                .setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR).setListener(null).start();
    } else if (this.mHelperView.getVisibility() == VISIBLE) {
        ViewCompat.animate(this.mHelperView).alpha(0.0F).setDuration(200L)
                .setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR)
                .setListener(new ViewPropertyAnimatorListenerAdapter() {
                    public void onAnimationEnd(View view) {
                        mHelperView.setText(null);
                        mHelperView.setVisibility(INVISIBLE);
                    }
                }).start();
    }
    this.sendAccessibilityEvent(2048);
}

From source file:moe.yukinoneko.gcomic.module.gallery.external.ExternalGalleryActivity.java

public void toggleSystemUi() {
    boolean isShown = mToolbar.getAlpha() == 1.0f;
    ViewCompat.animate(mToolbar).alpha(isShown ? 0.0f : 1.0f).start();
    ViewCompat.animate(bottomBar).alpha(isShown ? 0.0f : 1.0f)
            .setListener(new ViewPropertyAnimatorListenerAdapter() {
                @Override/*from  ww w.  j  a va  2s  . co m*/
                public void onAnimationStart(View view) {
                    super.onAnimationStart(view);

                    if (view.isShown()) {
                        return;
                    }

                    view.setVisibility(View.VISIBLE);
                }

                @Override
                public void onAnimationEnd(View view) {
                    super.onAnimationEnd(view);

                    if (view.getAlpha() == 1.0f) {
                        return;
                    }

                    view.setVisibility(View.INVISIBLE);
                }
            }).start();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mDecorView.setSystemUiVisibility(isShown ? FULL_SCREEN_FLAG : NOT_FULL_SCREEN_FLAG);
    }
}

From source file:com.freshdigitable.udonroad.TimelineAnimator.java

private void animateMoveImpl(final Move move) {
    //    Log.d(TAG, "animateMoveImpl: " + debugString(move.holder));
    moveAnimations.add(move.holder);/*from  w  ww. ja  v a2s .  com*/
    final ViewPropertyAnimatorCompat animate = ViewCompat.animate(move.holder.itemView);
    if (move.deltaX() != 0) {
        animate.translationX(0);
    }
    if (move.deltaY() != 0) {
        animate.translationY(0);
    }
    animate.setDuration(getMoveDuration()).setListener(new ViewPropertyAnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(View view) {
            dispatchMoveStarting(move.holder);
        }

        @Override
        public void onAnimationEnd(View view) {
            animate.setListener(null);
            dispatchMoveFinished(move.holder);
            moveAnimations.remove(move.holder);
            dispatchFinishedWhenDone();
        }

        @Override
        public void onAnimationCancel(View view) {
            if (move.deltaX() != 0) {
                ViewCompat.setTranslationX(view, 0);
            }
            if (move.deltaY() != 0) {
                ViewCompat.setTranslationY(view, 0);
            }
        }
    }).start();
}

From source file:org.strongswan.android.ui.view.TextInputLayoutHelper.java

private void showHelper(boolean show) {
    if (show == (mHelperContainer.getVisibility() == View.VISIBLE)) {
        return;//w  ww.  j a  v  a2s  . c  o  m
    }
    if (show) {
        ViewCompat.animate(mHelperContainer).alpha(1f).setDuration(200)
                .setListener(new ViewPropertyAnimatorListenerAdapter() {
                    @Override
                    public void onAnimationStart(View view) {
                        view.setVisibility(View.VISIBLE);
                    }
                }).start();
    } else {
        ViewCompat.animate(mHelperContainer).alpha(0f).setDuration(200)
                .setListener(new ViewPropertyAnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(View view) {
                        view.setVisibility(View.INVISIBLE);
                    }
                }).start();
    }
}

From source file:com.freshdigitable.udonroad.TimelineAnimator.java

private void animateAddImpl(final ViewHolder holder) {
    //    Log.d(TAG, "animateAddImpl: " + debugString(holder));
    addAnimations.add(holder);//from   w w w .  j  a v  a  2 s .  c  o  m
    ViewCompat.animate(holder.itemView).setDuration(0).setListener(new ViewPropertyAnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(View view) {
            dispatchAddStarting(holder);
        }

        @Override
        public void onAnimationEnd(View view) {
            clearAllAnimationSettings(view);
            dispatchAddFinished(holder);
            addAnimations.remove(holder);
        }

        @Override
        public void onAnimationCancel(View view) {
            clearAllAnimationSettings(view);
        }
    }).start();
}

From source file:com.hufeiya.SignIn.activity.QuizActivity.java

@Override
public void onBackPressed() {
    if (mQuizFab == null) {
        // Skip the animation if icon or fab are not initialized.
        super.onBackPressed();
        return;/*from www .  j  a  v a2  s.co m*/
    } else if (mContent != null && mContent == cameraPreviewfFragment) {
        switchContent(cameraPreviewfFragment, courseInfoFragment);
        mContent = courseInfoFragment;
        return;
    }

    ViewCompat.animate(mToolbarBack).scaleX(0f).scaleY(0f).alpha(0f).setDuration(100).start();

    ViewCompat.animate(mQuizFab).scaleX(0f).scaleY(0f).setInterpolator(mInterpolator).setStartDelay(100)
            .setListener(new ViewPropertyAnimatorListenerAdapter() {
                @SuppressLint("NewApi")
                @Override
                public void onAnimationEnd(View view) {
                    if (isFinishing() || (ApiLevelHelper.isAtLeast(Build.VERSION_CODES.JELLY_BEAN_MR1)
                            && isDestroyed())) {
                        return;
                    }
                    QuizActivity.super.onBackPressed();
                }
            }).start();
}

From source file:com.google.samples.apps.topeka.activity.QuizActivity.java

@Override
public void onBackPressed() {
    if (mIcon == null || mQuizFab == null) {
        // Skip the animation if icon or fab are not initialized.
        super.onBackPressed();
        return;/*from  w w  w. ja va 2s.  c o  m*/
    }

    ViewCompat.animate(mToolbarBack).scaleX(0f).scaleY(0f).alpha(0f).setDuration(100).start();

    // Scale the icon and fab to 0 size before calling onBackPressed if it exists.
    ViewCompat.animate(mIcon).scaleX(.7f).scaleY(.7f).alpha(0f).setInterpolator(mInterpolator).start();

    ViewCompat.animate(mQuizFab).scaleX(0f).scaleY(0f).setInterpolator(mInterpolator).setStartDelay(100)
            .setListener(new ViewPropertyAnimatorListenerAdapter() {
                @SuppressLint("NewApi")
                @Override
                public void onAnimationEnd(View view) {
                    if (isFinishing() || (ApiLevelHelper.isAtLeast(Build.VERSION_CODES.JELLY_BEAN_MR1)
                            && isDestroyed())) {
                        return;
                    }
                    QuizActivity.super.onBackPressed();
                }
            }).start();
}

From source file:sg.fxl.topekaport.QuizActivity.java

@Override
public void onBackPressed() {
    if (icon == null || quizFab == null) {
        // Skip the animation if icon or fab are not initialized.
        super.onBackPressed();
        return;//from w w  w . ja  va  2  s . co m
    }

    ViewCompat.animate(toolbarBack).scaleX(0f).scaleY(0f).alpha(0f).setDuration(100).start();

    // Scale the icon and fab to 0 size before calling onBackPressed if it exists.
    ViewCompat.animate(icon).scaleX(.7f).scaleY(.7f).alpha(0f).setInterpolator(interpolator).start();

    ViewCompat.animate(quizFab).scaleX(0f).scaleY(0f).setInterpolator(interpolator).setStartDelay(100)
            .setListener(new ViewPropertyAnimatorListenerAdapter() {
                @SuppressLint("NewApi")
                @Override
                public void onAnimationEnd(View view) {
                    if (isFinishing() || (ApiLevelHelper.isAtLeast(Build.VERSION_CODES.JELLY_BEAN_MR1)
                            && isDestroyed())) {
                        return;
                    }
                    QuizActivity.super.onBackPressed();
                }
            }).start();
}