Fetching post details

Now create a function called getPostById(id: Long), and we will pass the given postId from MainActivity. We will handle all the value in the specific TextView, such as MainActivity:

@SuppressLint("CheckResult")
private fun getPostById(id: Long){
UtilMethods.showLoading(this)
APIClient.postAPICall(PrefUtils.getUsername(this)!!, PrefUtils.getPassword(this)!!)
.getPostById(id)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
post ->
postText_pd.text = post.text
profileFullNamePost_pd.text = "${post.profile!!.firstName} ${post.profile!!.lastName}"
usernamePost_pd.text = post.profile!!.username
postedDate_pd.text = SimpleDateFormat(Constants.TIME_FORMAT).format(post.postCreatedTime!!)

commentList = post.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()
})
}