I have View and one CircleShape , which should show toast in this View. And I use it in main Activity. This is my interface
interface OnClickListenerInterfa
to use Kotlin callbacks , I use them in my api calls for success or failure use
create enum class for state
enum class APIState(val result: Boolean) {
SUCCESS(true),
FAILURE(false)}
use call back in fun
private fun fetchFeesList(studentID:String,call:(APIState)->Unit){
... do stuff here , and use call(APIState.SUCCESS) or call(APIState.FAILURE) }
when calling function fetchFeesList , call it like
fetchFeesList(studentID){
val res = it.result
if(res){
toast("success")
}else {
toast("failure")
}
}
for toast("message") , use Anko Lib from GitHub : - https://github.com/Kotlin/anko