@@ -11,7 +11,7 @@ Sample project available in **app** directory
1111
1212Custom button with progress anim and transition to another activity/fragment
1313
14- Better to use with ** AsyncTask** or ** Handler()** or * RxJava* ** doFinally ()**
14+ Better to use with ** AsyncTask** or ** Handler()** or * RxJava* ** doOnSuccess ()**
1515
1616![ ] ( https://github.com/muramrr/ProgressButton/blob/master/test.gif )
1717## Installation
@@ -40,10 +40,11 @@ dependencies {
4040 android : layout_width =" match_parent"
4141 android : id =" @+id/btn_done"
4242 android : layout_margin =" 20dp"
43- app : backgroundColor =" @android:color/holo_orange_light "
43+ app : backgroundColor =" #2962FF "
4444 app : progressColor =" @android:color/holo_orange_light"
4545 app : text =" DONE!"
4646 app : textColor =" @android:color/black" />
47+
4748```
4849Available attributes:
4950* app: backgroundColor - ** Button background color** * (default = Color.BLUE)*
@@ -52,6 +53,7 @@ Available attributes:
5253* app: textColor - ** Button text color** * (default = Color.WHITE)*
5354## Code
5455
56+ #### Java
5557``` java
5658private ProgressButton pb_button;
5759...
@@ -72,7 +74,32 @@ pb_button.setOnClickListener(new View.OnClickListener() {
7274 }
7375});
7476```
75- Available methods:
77+ #### Kotlin
78+ ``` kotlin
79+ val progressButton = findViewById<ProgressButton >(R .id.btn_done)
80+ progressButton.setOnClickListener {
81+ progressButton.startAnim()
82+ Handler ().postDelayed({ progressButton.stopAnim { startMainActivity() }}, 2000 )
83+ }
84+ ```
85+
86+ #### RxJava 2 + kotlin
87+ ``` rx
88+ disposables.add(signUp()
89+ .observeOn(AndroidSchedulers.mainThread())
90+ .doOnSubscribe { progressButton.startAnim() }
91+ .doOnSuccess { progressButton.stopAnim { startMainActivity() } }
92+ .subscribe({
93+ //your code
94+ },
95+ {
96+ Toast.makeText(this,"error",
97+ Toast.LENGTH_SHORT).show()
98+ }))
99+ ```
100+
101+
102+ #### Public methods:
76103* setBgColor(int color) - ** Set button background color**
77104* setProColor(int color) - ** Set progress color**
78105* setButtonText(String str) - ** Set button text**
0 commit comments