Show button with progress bar
Add this to your project build.gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'org.bitbucket.droidhelios:ProgressButton:x.y'
}
dependencies {
implementation 'org.bitbucket.droidhelios:ProgressButtonX:x.y'
}
In your activity_main.xml class:
<include layout="@layout/button_progress"/>
In your activity class:
btnAction = ProgressButton.newInstance(this)
.setText("Send Request")
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
//use this method to initiate progress bar while starting task in background
btnAction.startProgress();
// call this method when getting success response from background task
btnAction.revertSuccessProgress(new ProgressButton.Listener() {
@Override
public void onAnimationCompleted() {
}
});
// use this method when getting wrong response and revert the initial stage of button
btnAction.revertProgress();