Search in sources :

Example 1 with ViewPropertyAnimatorListenerAdapter

use of android.support.v4.view.ViewPropertyAnimatorListenerAdapter in project floatingsearchview by arimorty.

the class FloatingSearchView method updateSuggestionsSectionHeight.

private void updateSuggestionsSectionHeight(List<? extends SearchSuggestion> newSearchSuggestions, boolean withAnim) {
    final int cardTopBottomShadowPadding = Util.dpToPx(CARD_VIEW_CORNERS_AND_TOP_BOTTOM_SHADOW_HEIGHT);
    final int cardRadiusSize = Util.dpToPx(CARD_VIEW_TOP_BOTTOM_SHADOW_HEIGHT);
    int visibleSuggestionHeight = calculateSuggestionItemsHeight(newSearchSuggestions, mSuggestionListContainer.getHeight());
    int diff = mSuggestionListContainer.getHeight() - visibleSuggestionHeight;
    int addedTranslationYForShadowOffsets = (diff <= cardTopBottomShadowPadding) ? -(cardTopBottomShadowPadding - diff) : diff < (mSuggestionListContainer.getHeight() - cardTopBottomShadowPadding) ? cardRadiusSize : 0;
    final float newTranslationY = -mSuggestionListContainer.getHeight() + visibleSuggestionHeight + addedTranslationYForShadowOffsets;
    final boolean animateAtEnd = newTranslationY >= mSuggestionListContainer.getTranslationY();
    //todo go over
    final float fullyInvisibleTranslationY = -mSuggestionListContainer.getHeight() + cardRadiusSize;
    ViewCompat.animate(mSuggestionListContainer).cancel();
    if (withAnim) {
        ViewCompat.animate(mSuggestionListContainer).setInterpolator(SUGGEST_ITEM_ADD_ANIM_INTERPOLATOR).setDuration(mSuggestionSectionAnimDuration).translationY(newTranslationY).setUpdateListener(new ViewPropertyAnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(View view) {
                if (mOnSuggestionsListHeightChanged != null) {
                    float newSuggestionsHeight = Math.abs(view.getTranslationY() - fullyInvisibleTranslationY);
                    mOnSuggestionsListHeightChanged.onSuggestionsListHeightChanged(newSuggestionsHeight);
                }
            }
        }).setListener(new ViewPropertyAnimatorListenerAdapter() {

            @Override
            public void onAnimationCancel(View view) {
                mSuggestionListContainer.setTranslationY(newTranslationY);
            }

            @Override
            public void onAnimationStart(View view) {
                if (!animateAtEnd) {
                    mSuggestionsList.smoothScrollToPosition(0);
                }
            }

            @Override
            public void onAnimationEnd(View view) {
                if (animateAtEnd) {
                    int lastPos = mSuggestionsList.getAdapter().getItemCount() - 1;
                    if (lastPos > -1) {
                        mSuggestionsList.smoothScrollToPosition(lastPos);
                    }
                }
            }
        }).start();
    } else {
        mSuggestionListContainer.setTranslationY(newTranslationY);
        if (mOnSuggestionsListHeightChanged != null) {
            float newSuggestionsHeight = Math.abs(mSuggestionListContainer.getTranslationY() - fullyInvisibleTranslationY);
            mOnSuggestionsListHeightChanged.onSuggestionsListHeightChanged(newSuggestionsHeight);
        }
    }
}
Also used : ViewPropertyAnimatorUpdateListener(android.support.v4.view.ViewPropertyAnimatorUpdateListener) ViewPropertyAnimatorListenerAdapter(android.support.v4.view.ViewPropertyAnimatorListenerAdapter) ImageView(android.widget.ImageView) MenuView(com.arlib.floatingsearchview.util.view.MenuView) View(android.view.View) CardView(android.support.v7.widget.CardView) SearchInputView(com.arlib.floatingsearchview.util.view.SearchInputView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView)

Example 2 with ViewPropertyAnimatorListenerAdapter

use of android.support.v4.view.ViewPropertyAnimatorListenerAdapter in project Space-Navigation-View by armcha.

the class BadgeHelper method showBadge.

/**
     * Show badge
     *
     * @param view      target badge
     * @param badgeItem BadgeItem object
     */
static void showBadge(RelativeLayout view, BadgeItem badgeItem, boolean shouldShowBadgeWithNinePlus) {
    Utils.changeViewVisibilityVisible(view);
    TextView badgeTextView = (TextView) view.findViewById(R.id.badge_text_view);
    if (shouldShowBadgeWithNinePlus)
        badgeTextView.setText(badgeItem.getBadgeText());
    else
        badgeTextView.setText(badgeItem.getFullBadgeText());
    view.setScaleX(0);
    view.setScaleY(0);
    ViewCompat.animate(view).setDuration(200).scaleX(1).scaleY(1).setListener(new ViewPropertyAnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(View view) {
            Utils.changeViewVisibilityVisible(view);
        }
    }).start();
}
Also used : TextView(android.widget.TextView) ViewPropertyAnimatorListenerAdapter(android.support.v4.view.ViewPropertyAnimatorListenerAdapter) TextView(android.widget.TextView) View(android.view.View)

Example 3 with ViewPropertyAnimatorListenerAdapter

use of android.support.v4.view.ViewPropertyAnimatorListenerAdapter in project android-topeka by googlesamples.

the class QuizActivity method revealFragmentContainerLollipop.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void revealFragmentContainerLollipop(final View clickedView, final FrameLayout fragmentContainer) {
    prepareCircularReveal(clickedView, fragmentContainer);
    ViewCompat.animate(clickedView).scaleX(0).scaleY(0).alpha(0).setInterpolator(mInterpolator).setListener(new ViewPropertyAnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(View view) {
            fragmentContainer.setVisibility(View.VISIBLE);
            clickedView.setVisibility(View.GONE);
        }
    }).start();
    fragmentContainer.setVisibility(View.VISIBLE);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(mCircularReveal).with(mColorChange);
    animatorSet.start();
}
Also used : AnimatorSet(android.animation.AnimatorSet) ViewPropertyAnimatorListenerAdapter(android.support.v4.view.ViewPropertyAnimatorListenerAdapter) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) TargetApi(android.annotation.TargetApi)

Example 4 with ViewPropertyAnimatorListenerAdapter

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

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 5 with ViewPropertyAnimatorListenerAdapter

use of android.support.v4.view.ViewPropertyAnimatorListenerAdapter in project AndroidChromium by JackyAndroid.

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)

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