When you press the fab button we will see an alert box where you can input your status using submitPost(). In return, we get the post list named newPostList and pass the list to the setItems(newPostList) of the PostRecycleViewAdapter to replace with the older post list with the new one. Lastly, notify with notifyDataSetChanged(), and the RecycleView list will be updated.
Here is the code for the submitPost() function:
private fun submitPost(id: Long, text: String){
APIClient.postAPICall(PrefUtils.getUsername(this)!!, PrefUtils.getPassword(this)!!)
.submitNewPost(id, text)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
newPostList ->
postRecycleViewAdapter.setItems(newPostList)
postRecycleViewAdapter.notifyDataSetChanged()
},{
error ->
Toast.makeText(applicationContext, error.message.toString(), Toast.LENGTH_SHORT).show()
})
}