LoadingButtonAndroid icon indicating copy to clipboard operation
LoadingButtonAndroid copied to clipboard

Usage in viewholder for recyclerview

Open Gounlaf opened this issue 7 years ago • 4 comments

Might be related #17...

Original view: capture d ecran 2017-08-25 a 14 15 34 View reused/recycled: got original + done loading image+filled color capture d ecran 2017-08-25 a 14 15 40

If I use dispose when the view is unbind, setupAnimations() is never called again. It will not work...

The only way I think to fix the problem, right now, is to instantiate a new view from code instead from layout...

Not tested yet, I will soon

Edit:

Setting up the Button programmatically, without attributes (new CircularProgressButton(context)) thrown exception:

java.lang.ClassCastException: android.graphics.drawable.StateListDrawable cannot be cast to android.graphics.drawable.GradientDrawable
    at br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.init(CircularProgressButton.java:115)
    at br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.<init>(CircularProgressButton.java:63)

Gounlaf avatar Aug 25 '17 12:08 Gounlaf

Thanks for pointing it out. I will take look.

leandroBorgesFerreira avatar Aug 25 '17 12:08 leandroBorgesFerreira

Hello @Gounlaf. I just added I fix for the creation of this button programatically. Although this issue is not fixed yet, the instantiation of the view from code will work, so at least with have a workaround. Use version 1.8.3

leandroBorgesFerreira avatar Oct 13 '17 19:10 leandroBorgesFerreira

Hello, @leandroBorgesFerreira! Still have a question about your Buttons in RV. I need to set button state (normal or finished) according to boolean field in my model. But what should I call in bindViewHolder to set current state? I tried this way:

if (event.isFollowed()) {
                mBtnFollow.doneLoadingAnimation(Utils.getResources().getColor(R.color.orange_juice), BitmapFactory.decodeResource(Utils.getResources(), R.drawable.ic_followed_button));
            } else {
                mBtnFollow.revertAnimation();
            }

But it always created in the normal state, event.getFollowed() == true or false, whatever.

foxwoosh avatar Feb 09 '18 09:02 foxwoosh

Okay, I added one thing and now it works:

if (event.isFollowed()) {
                mBtnFollow.startAnimation();
                mBtnFollow.doneLoadingAnimation(Utils.getResources().getColor(R.color.orange_juice), BitmapFactory.decodeResource(Utils.getResources(), R.drawable.ic_followed_button));
            } else {
                mBtnFollow.revertAnimation();
            }

But still I guess we should have functions to init this button with any state, because I can see quick animation everytime I scroll my RV ;p Thank you.

By the way, where should I call dispose() if Im using this button in RV items?

foxwoosh avatar Feb 09 '18 10:02 foxwoosh