LoadingButtonAndroid
LoadingButtonAndroid copied to clipboard
Usage in viewholder for recyclerview
Might be related #17...
Original view:
View reused/recycled: got original + done loading image+filled color
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)
Thanks for pointing it out. I will take look.
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
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.
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?