arimorty / floatingsearchview

A search view that implements a floating search bar also known as persistent search
https://github.com/arimorty/floatingsearchview/blob/master/README.md
Apache License 2.0
3.54k stars 668 forks source link

Action transitionOutLeftSection does have animation when leftActionMode is showSearch #240

Closed lenguyenthanh closed 7 years ago

lenguyenthanh commented 7 years ago

When SearchView looses focus, left icon is changed from backImage to searchImage. This action doesn't have animation now. It's caused by changeIcon method:

    private void changeIcon(ImageView imageView, Drawable newIcon, boolean withAnim) {
        imageView.setImageDrawable(newIcon);
        if (withAnim) {
            ObjectAnimator fadeInVoiceInputOrClear = ObjectAnimator.ofFloat(imageView, "alpha", 0.0f, 1.0f);
            fadeInVoiceInputOrClear.setDuration(250);
            fadeInVoiceInputOrClear.start();
        } else {
            imageView.setAlpha(1.0f);
        }
    }

We can fix it by updating it:

    private void changeIcon(ImageView imageView, Drawable newIcon, boolean withAnim) {
        imageView.setImageDrawable(newIcon);
        if (withAnim) {
            mLeftAction.setRotation(-45);
            mLeftAction.setAlpha(0.0f);
            ObjectAnimator rotateAnim = ViewPropertyObjectAnimator.animate(mLeftAction).rotation(0).get();
            ObjectAnimator fadeAnim = ViewPropertyObjectAnimator.animate(mLeftAction).alpha(1.0f).get();
            AnimatorSet animSet = new AnimatorSet();
            animSet.setDuration(500);
            animSet.playTogether(rotateAnim, fadeAnim);
            animSet.start();
        } else {
            imageView.setAlpha(1.0f);
        }
    }

@arimorty What do you think about this issue? Does it happen with any intention or just a bug? If it's a bug, I'm happy to do a PR. Thanks!

arimorty commented 7 years ago

That's a nice animation :) (I love animations!), but that method is used for other scenarios as well, so it will require some more thought. But feel free to fork and adapt the library to your needs, because I won't be able to actively maintain the project anymore anyway.

Have a look at this announcement

It has been a blast supporting the project, but I really think that with a little digging, the code can be adapted and I just don't have the time to update the library for everyone's custom needs.

Best, Ari

lenguyenthanh commented 7 years ago

Thanks @arimorty for great work you've done. This library is amazing! I understand your decision.

Best, Thanh.