Skip to content

Instantly share code, notes, and snippets.

@NitinPraksash9911
Last active May 1, 2020 19:16
Show Gist options
  • Save NitinPraksash9911/b0acc81fd09b67da08aa71ae1b8ee4e7 to your computer and use it in GitHub Desktop.
Save NitinPraksash9911/b0acc81fd09b67da08aa71ae1b8ee4e7 to your computer and use it in GitHub Desktop.
FloatingExample kotlin
val floatingLoaderButton: FloatingLoaderButton = findViewById<FloatingLoaderButton>(R.id.floatingLoaderBtn)
floatingLoaderButton.setOnClickListener {
// to start circular animation when api calling starts
floatingLoaderButton.setLoadingStatus(FloatingLoaderButton.LoaderStatus.LOADING)
val apiInterface = ApiInterface.create().getData()
apiInterface.enqueue(object : Callback<List<Data>> {
override fun onResponse(call: Call<List<Data>>?, response: Response<List<Data>>?) {
if (response?.body() != null)
recyclerAdapter.setData(response.body()!!)
// to stop circular animation when api calling success
floatingLoaderButton.setLoadingStatus(FloatingLoaderButton.LoaderStatus.FINISH)
}
override fun onFailure(call: Call<List<Data>>?, t: Throwable?) {
//to stop circular animation when api calling fails
floatingLoaderButton.setLoadingStatus(FloatingLoaderButton.LoaderStatus.FINISH)
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment