Commit 2093a1a7 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update RoomListFragment.kt

parent 63eeb947
...@@ -9,8 +9,10 @@ import android.view.View ...@@ -9,8 +9,10 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.helper.EndlessRecyclerViewScrollListener import chat.rocket.android.helper.EndlessRecyclerViewScrollListener
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.RoomMessagesAdapter import chat.rocket.android.layouthelper.chatroom.list.RoomMessagesAdapter
import chat.rocket.core.models.Attachment
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.*
...@@ -84,6 +86,14 @@ class RoomListFragment : Fragment(), RoomListContract.View { ...@@ -84,6 +86,14 @@ class RoomListFragment : Fragment(), RoomListContract.View {
userId, userId,
offset) offset)
} }
R.id.action_file_list -> {
presenter.requestFileList(roomId,
roomType,
hostname,
token,
userId,
offset)
}
R.id.action_favorite_messages -> { R.id.action_favorite_messages -> {
presenter.requestFavoriteMessages(roomId, presenter.requestFavoriteMessages(roomId,
roomType, roomType,
...@@ -139,8 +149,23 @@ class RoomListFragment : Fragment(), RoomListContract.View { ...@@ -139,8 +149,23 @@ class RoomListFragment : Fragment(), RoomListContract.View {
} }
} }
// TODO (after REST api fixes) override fun showFileList(dataSet: ArrayList<Attachment>, total: String) {
override fun showFileList(dataSet: ArrayList<String>, total: String) {} activity.title = getString(R.string.fragment_room_list_file_list_title, total)
if (recyclerView.adapter == null) {
recyclerView.adapter = RoomFileListAdapter(dataSet)
val linearLayoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
recyclerView.layoutManager = linearLayoutManager
if (dataSet.size >= 50) {
recyclerView.addOnScrollListener(object : EndlessRecyclerViewScrollListener(linearLayoutManager) {
override fun onLoadMore(page: Int, totalItemsCount: Int, recyclerView: RecyclerView?) {
loadNextDataFromApi(page)
}
})
}
} else {
(recyclerView.adapter as RoomFileListAdapter).addDataSet(dataSet)
}
}
override fun showMemberList(dataSet: ArrayList<User>, total: String) { override fun showMemberList(dataSet: ArrayList<User>, total: String) {
activity.title = getString(R.string.fragment_room_list_member_list_title, total) activity.title = getString(R.string.fragment_room_list_member_list_title, total)
......
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