Skip to content

Instantly share code, notes, and snippets.

@imrankst1221
Created November 4, 2018 09:59
Show Gist options
  • Save imrankst1221/1218d5257f762619de49557b02181fa0 to your computer and use it in GitHub Desktop.
Save imrankst1221/1218d5257f762619de49557b02181fa0 to your computer and use it in GitHub Desktop.
Subscribe to the Observable
@SuppressLint("CheckResult")
private fun loginApiCall(userID: String, userPassword: String){
if(UtilMethods.isConnectedToInternet(mContext)){
UtilMethods.showLoading(mContext)
val observable = ApiService.loginApiCall().doLogin(LoginPostData(userID, userPassword))
observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ loginResponse ->
UtilMethods.hideLoading()
/** loginResponse is response data class*/
}, { error ->
UtilMethods.hideLoading()
UtilMethods.showLongToast(mContext, error.message.toString())
}
)
}else{
UtilMethods.showLongToast(mContext, "No Internet Connection!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment