Search in sources :

Example 6 with ViewPropertyAnimatorListenerAdapter

use of android.support.v4.view.ViewPropertyAnimatorListenerAdapter in project philm by chrisbanes.

the class FloatLabelLayout method hideLabel.

/**
     * Hide the label
     */
private void hideLabel(boolean animate) {
    if (animate) {
        float scale = mEditText.getTextSize() / mLabel.getTextSize();
        ViewCompat.setScaleX(mLabel, 1f);
        ViewCompat.setScaleY(mLabel, 1f);
        ViewCompat.setTranslationY(mLabel, 0f);
        ViewCompat.animate(mLabel).translationY(mLabel.getHeight()).setDuration(ANIMATION_DURATION).scaleX(scale).scaleY(scale).setListener(new ViewPropertyAnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(View view) {
                mLabel.setVisibility(INVISIBLE);
                mEditText.setHint(mHint);
            }
        }).setInterpolator(mInterpolator).start();
    } else {
        mLabel.setVisibility(INVISIBLE);
        mEditText.setHint(mHint);
    }
}
Also used : ViewPropertyAnimatorListenerAdapter(android.support.v4.view.ViewPropertyAnimatorListenerAdapter) TextView(android.widget.TextView) View(android.view.View)

Example 7 with ViewPropertyAnimatorListenerAdapter

use of android.support.v4.view.ViewPropertyAnimatorListenerAdapter in project MaterialViewPager by florent37.

the class MaterialViewPagerImageHelper method setImageDrawable.

/**
     * change the image with a fade
     *
     * @param drawable
     * @param fadeDuration
     */
public static void setImageDrawable(final ImageView imageView, final Drawable drawable, final int fadeDuration) {
    final float alpha = ViewCompat.getAlpha(imageView);
    final ImageView viewToAnimate = imageView;
    fadeOut(viewToAnimate, fadeDuration, new ViewPropertyAnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(View view) {
            super.onAnimationEnd(view);
            //change the image when alpha=0
            imageView.setImageDrawable(drawable);
            //then fade to alpha=1
            fadeIn(viewToAnimate, alpha, fadeDuration, new ViewPropertyAnimatorListenerAdapter());
        }
    });
}
Also used : ImageView(android.widget.ImageView) ViewPropertyAnimatorListenerAdapter(android.support.v4.view.ViewPropertyAnimatorListenerAdapter) ImageView(android.widget.ImageView) View(android.view.View)

Example 8 with ViewPropertyAnimatorListenerAdapter

use of android.support.v4.view.ViewPropertyAnimatorListenerAdapter in project MaterialViewPager by florent37.

the class MaterialViewPagerImageHelper method setImageUrl.

/**
     * change the image with a fade
     *
     * @param urlImage
     * @param fadeDuration TODO : remove Picasso
     */
public static void setImageUrl(final ImageView imageView, final String urlImage, final int fadeDuration) {
    final float alpha = ViewCompat.getAlpha(imageView);
    final ImageView viewToAnimate = imageView;
    //fade to alpha=0
    fadeOut(viewToAnimate, fadeDuration, new ViewPropertyAnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(View view) {
            super.onAnimationEnd(view);
            //change the image when alpha=0
            Glide.with(imageView.getContext()).load(urlImage).centerCrop().listener(new RequestListener<String, GlideDrawable>() {

                @Override
                public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
                    return false;
                }

                @Override
                public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                    //then fade to alpha=1
                    fadeIn(viewToAnimate, alpha, fadeDuration, new ViewPropertyAnimatorListenerAdapter());
                    if (imageLoadListener != null) {
                        imageLoadListener.OnImageLoad(imageView, ((BitmapDrawable) imageView.getDrawable()).getBitmap());
                    }
                    return false;
                }
            }).into(viewToAnimate);
        }
    });
}
Also used : ImageView(android.widget.ImageView) ViewPropertyAnimatorListenerAdapter(android.support.v4.view.ViewPropertyAnimatorListenerAdapter) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView) View(android.view.View) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 9 with ViewPropertyAnimatorListenerAdapter

use of android.support.v4.view.ViewPropertyAnimatorListenerAdapter in project easy by MehdiBenmesa.

the class MaterialViewPagerImageHelper method setImageDrawable.

/**
     * change the image with a fade
     *
     * @param drawable
     * @param fadeDuration
     */
public static void setImageDrawable(final ImageView imageView, final Drawable drawable, final int fadeDuration) {
    final float alpha = ViewCompat.getAlpha(imageView);
    final ImageView viewToAnimate = imageView;
    fadeOut(viewToAnimate, fadeDuration, new ViewPropertyAnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(View view) {
            super.onAnimationEnd(view);
            //change the image when alpha=0
            imageView.setImageDrawable(drawable);
            //then fade to alpha=1
            fadeIn(viewToAnimate, alpha, fadeDuration, new ViewPropertyAnimatorListenerAdapter());
        }
    });
}
Also used : ImageView(android.widget.ImageView) ViewPropertyAnimatorListenerAdapter(android.support.v4.view.ViewPropertyAnimatorListenerAdapter) ImageView(android.widget.ImageView) View(android.view.View)

Aggregations

ViewPropertyAnimatorListenerAdapter (android.support.v4.view.ViewPropertyAnimatorListenerAdapter)9 View (android.view.View)9 ImageView (android.widget.ImageView)6 TextView (android.widget.TextView)5 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 GlideDrawable (com.bumptech.glide.load.resource.drawable.GlideDrawable)2 AnimatorSet (android.animation.AnimatorSet)1 TargetApi (android.annotation.TargetApi)1 ViewPropertyAnimatorUpdateListener (android.support.v4.view.ViewPropertyAnimatorUpdateListener)1 CardView (android.support.v7.widget.CardView)1 RecyclerView (android.support.v7.widget.RecyclerView)1 MenuView (com.arlib.floatingsearchview.util.view.MenuView)1 SearchInputView (com.arlib.floatingsearchview.util.view.SearchInputView)1