January 2019
Intermediate to advanced
392 pages
10h 11m
English
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!!)
Read now
Unlock full access