Created
November 4, 2018 09:59
-
-
Save imrankst1221/1218d5257f762619de49557b02181fa0 to your computer and use it in GitHub Desktop.
Subscribe to the Observable
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
@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