Submitting comment

To submit a comment, click fabButton and enter a comment. The system of comment submission is similar to the post submission system. We create a function named submitComment(id: Long, text: String) and use it to submit the comment. Here is the submitComment() function: 

@SuppressLint("CheckResult")
private fun submitComment(id: Long, text: String){
UtilMethods.showLoading(this)
APIClient.commentAPICall(PrefUtils.getUsername(this)!!, PrefUtils.getPassword(this)!!)
.postCommentByPostId(id, PrefUtils.getUsernameID(this)!!,text)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
newPostList ->
commentList = newPostList.comment!!

Log.wtf("******", commentList.toString())
commentRecycleViewAdapter.setItems(commentList)
commentRecycleViewAdapter.notifyDataSetChanged()
UtilMethods.hideLoading()
},{
error ->
UtilMethods.hideLoading()
Log.wtf("******", error.message.toString())
Toast.makeText(applicationContext, error.message.toString(), Toast.LENGTH_SHORT).show()
})
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.235.23