Last active
May 1, 2020 19:16
-
-
Save NitinPraksash9911/b0acc81fd09b67da08aa71ae1b8ee4e7 to your computer and use it in GitHub Desktop.
FloatingExample kotlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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