File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -179,15 +179,36 @@ class MainActivity : AppCompatActivity() {
179179 }
180180
181181}
182+ ```
182183
183- 🌟 You are all set!
184+ You can also directly integrate livedata to your button. This will automatically change the state of
185+ button according to the livedata.
186+
187+ ``` kotlin
188+
189+ // This is an enum that contains all button states, use this for livedata
190+ enum class ButtonStates {
191+ LOADING , ENABLED , DISABLED , FINISHED
192+ }
184193
185- ## 🍰 Contribute
194+ // liveData variable
195+ val buttonState = MutableLiveData <ButtonStates >()
196+
197+ // In Fragment or Activity
198+ binding.progressButton.attachToLiveData(buttonState)
199+
200+ ```
201+
202+ Just post the button state to the livedata like
203+ ` livedata.postValue(ButtonStates.LOADING) ` and button will change to loading state automatically
204+
205+ 🌟 You are all set!
186206
187- Feel free to fork this project, to optimise the code or to add new features.
207+ ## 🍰 Contribute
188208
209+ Feel free to fork this project, to optimise the code or to add new features.
189210
190- ## 📝 TODO
211+ ## 📝 TODO
191212
192213* Lottie support
193214
You can’t perform that action at this time.
0 commit comments