AndroidButtonProgress
AndroidButtonProgress copied to clipboard
Button sets visibility to VISIBLE when setting state
I'm running the following code:
<com.github.abdularis.buttonprogress.DownloadButtonProgress
android:id="@+id/button_synchronize"
android:layout_width="32dp"
android:layout_height="32dp"
android:visibility="@{entry.canSynchronize() ? View.VISIBLE : View.GONE}"
app:buttonState="@{entry.synchronizationState}"
/>
and using data-binding to synchronize the button state and visibility.
I'm using the following databinding adapter:
public class DownloadButtonStateBindingAdapter {
@BindingAdapter("buttonState")
public static void setMyAttr(DownloadButtonProgress myInnerView, int value) {
switch (value) {
case DownloadButtonProgress.STATE_IDLE:
myInnerView.setIdle();
break;
case DownloadButtonProgress.STATE_INDETERMINATE:
myInnerView.setIndeterminate();
break;
case DownloadButtonProgress.STATE_DETERMINATE:
myInnerView.setDeterminate();
break;
case DownloadButtonProgress.STATE_FINISHED:
myInnerView.setFinish();
break;
default:
break;
}
}
}
unfortunately, the setIdle, ... methods do more than just setting the state.
public void setIdle() {
mCurrState = STATE_IDLE;
setVisibility(VISIBLE);
invalidate();
}
This forces me to reset the visibility after each setIdle call. Why are you setting the visibility here? Could you please remove that call?
Hi @apacha, Thanks for reporting the issue
I actually put setVisibility() call to acomodate hideOnFinish flag (to automatically hide view after state changed to finish), But yes I thought it would be better to remove the setVisibility() call and hideOnFinish flag then exposes the on state changed listener to manually react for any state changes.
It's fixed on the latest version here