Commit c160213e authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update RoomListFragment.kt

parent 2f0fbf84
...@@ -22,6 +22,7 @@ class RoomListFragment : Fragment(), RoomListContract.View { ...@@ -22,6 +22,7 @@ class RoomListFragment : Fragment(), RoomListContract.View {
lateinit var token: String lateinit var token: String
lateinit var userId: String lateinit var userId: String
lateinit var presenter: RoomListPresenter lateinit var presenter: RoomListPresenter
var isDataRequested: Boolean = false
companion object { companion object {
fun newInstance(actionId: Int, fun newInstance(actionId: Int,
...@@ -60,7 +61,14 @@ class RoomListFragment : Fragment(), RoomListContract.View { ...@@ -60,7 +61,14 @@ class RoomListFragment : Fragment(), RoomListContract.View {
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) { override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
presenter = RoomListPresenter(context, this) presenter = RoomListPresenter(context, this)
requestData() }
override fun onResume() {
super.onResume()
if (!isDataRequested) {
requestData()
isDataRequested = true
}
} }
private fun requestData() { private fun requestData() {
...@@ -111,36 +119,37 @@ class RoomListFragment : Fragment(), RoomListContract.View { ...@@ -111,36 +119,37 @@ class RoomListFragment : Fragment(), RoomListContract.View {
} }
override fun showFavoriteMessages(dataSet: ArrayList<Message>) { override fun showFavoriteMessages(dataSet: ArrayList<Message>) {
waitingView.visibility = View.GONE
if (dataSet.isEmpty()) { if (dataSet.isEmpty()) {
showMessage(getString(R.string.fragment_room_list_no_pinned_message_to_show)) showMessage(getString(R.string.fragment_room_list_no_favorite_message_to_show))
} else { } else {
waitingView.visibility = View.GONE
recyclerView.adapter = RoomMessagesAdapter(dataSet, hostname, context) recyclerView.adapter = RoomMessagesAdapter(dataSet, hostname, context)
recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
} }
} }
override fun showFileList(dataSet: ArrayList<String>) { override fun showFileList(dataSet: ArrayList<String>) {
waitingView.visibility = View.GONE
if (dataSet.isEmpty()) { if (dataSet.isEmpty()) {
showMessage(getString(R.string.fragment_room_list_no_favorite_message_to_show)) showMessage(getString(R.string.fragment_room_list_no_file_list_to_show))
} else { } else {
waitingView.visibility = View.GONE
recyclerView.adapter = RoomFileListAdapter(dataSet) recyclerView.adapter = RoomFileListAdapter(dataSet)
recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
} }
} }
override fun showMemberList(dataSet: ArrayList<User>) { override fun showMemberList(dataSet: ArrayList<User>) {
waitingView.visibility = View.GONE
if (dataSet.isEmpty()) { if (dataSet.isEmpty()) {
showMessage(getString(R.string.fragment_room_list_no_member_list_to_show)) showMessage(getString(R.string.fragment_room_list_no_member_list_to_show))
} else { } else {
waitingView.visibility = View.GONE
recyclerView.adapter = RoomMemberListAdapter(dataSet, hostname, context) recyclerView.adapter = RoomMemberListAdapter(dataSet, hostname, context)
recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
} }
} }
override fun showMessage(message: String) { override fun showMessage(message: String) {
waitingView.visibility = View.GONE
messageText.text = message messageText.text = message
messageText.visibility = View.VISIBLE messageText.visibility = View.VISIBLE
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment