Commit 32f56c75 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update RoomListFragment.kt

parent 7444b8ee
...@@ -9,7 +9,7 @@ import android.view.ViewGroup ...@@ -9,7 +9,7 @@ import android.view.ViewGroup
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.layouthelper.chatroom.list.RoomFileListAdapter import chat.rocket.android.layouthelper.chatroom.list.RoomFileListAdapter
import chat.rocket.android.layouthelper.chatroom.list.RoomMemberListAdapter import chat.rocket.android.layouthelper.chatroom.list.RoomMemberListAdapter
import chat.rocket.android.layouthelper.chatroom.list.RoomPinnedMessagesAdapter import chat.rocket.android.layouthelper.chatroom.list.RoomMessagesAdapter
import chat.rocket.core.models.Message import chat.rocket.core.models.Message
import chat.rocket.core.models.User import chat.rocket.core.models.User
import kotlinx.android.synthetic.main.fragment_room_list.* import kotlinx.android.synthetic.main.fragment_room_list.*
...@@ -60,12 +60,13 @@ class RoomListFragment : Fragment(), RoomListContract.View { ...@@ -60,12 +60,13 @@ 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() { private fun requestData() {
super.onResume()
when (actionId) { when (actionId) {
R.id.action_pinned_messages -> { R.id.action_pinned_messages -> {
activity.title = getString(R.string.fragment_room_list_pinned_message_title)
presenter.requestPinnedMessages(roomId, presenter.requestPinnedMessages(roomId,
roomType, roomType,
hostname, hostname,
...@@ -73,6 +74,7 @@ class RoomListFragment : Fragment(), RoomListContract.View { ...@@ -73,6 +74,7 @@ class RoomListFragment : Fragment(), RoomListContract.View {
userId) userId)
} }
R.id.action_favorite_messages -> { R.id.action_favorite_messages -> {
activity.title = getString(R.string.fragment_room_list_favorite_message_title)
presenter.requestFavoriteMessages(roomId, presenter.requestFavoriteMessages(roomId,
roomType, roomType,
hostname, hostname,
...@@ -80,6 +82,7 @@ class RoomListFragment : Fragment(), RoomListContract.View { ...@@ -80,6 +82,7 @@ class RoomListFragment : Fragment(), RoomListContract.View {
userId) userId)
} }
R.id.action_file_list -> { R.id.action_file_list -> {
activity.title = getString(R.string.fragment_room_list_file_list_title)
presenter.requestFileList(roomId, presenter.requestFileList(roomId,
roomType, roomType,
hostname, hostname,
...@@ -87,6 +90,7 @@ class RoomListFragment : Fragment(), RoomListContract.View { ...@@ -87,6 +90,7 @@ class RoomListFragment : Fragment(), RoomListContract.View {
userId) userId)
} }
R.id.action_member_list -> { R.id.action_member_list -> {
activity.title = getString(R.string.fragment_room_list_member_list_title)
presenter.requestMemberList(roomId, presenter.requestMemberList(roomId,
roomType, roomType,
hostname, hostname,
...@@ -97,38 +101,42 @@ class RoomListFragment : Fragment(), RoomListContract.View { ...@@ -97,38 +101,42 @@ class RoomListFragment : Fragment(), RoomListContract.View {
} }
override fun showPinnedMessages(dataSet: ArrayList<Message>) { override fun showPinnedMessages(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_pinned_message_to_show))
} else { } else {
recyclerView.adapter = RoomPinnedMessagesAdapter(dataSet, hostname) recyclerView.adapter = RoomMessagesAdapter(dataSet, hostname, context)
recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, true) recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
} }
} }
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_pinned_message_to_show))
} else { } else {
recyclerView.adapter = RoomPinnedMessagesAdapter(dataSet, hostname) recyclerView.adapter = RoomMessagesAdapter(dataSet, hostname, context)
recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, true) 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_favorite_message_to_show))
} else { } else {
recyclerView.adapter = RoomFileListAdapter(dataSet) recyclerView.adapter = RoomFileListAdapter(dataSet)
recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, true) 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 {
recyclerView.adapter = RoomMemberListAdapter(dataSet) recyclerView.adapter = RoomMemberListAdapter(dataSet, hostname, context)
recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, true) recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
} }
} }
......
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