Commit 3c0c1303 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update RoomDialogFragment.kt

parent 5a668a4f
......@@ -2,12 +2,16 @@ package chat.rocket.android.fragment.chatroom.dialog
import android.os.Bundle
import android.support.v4.app.DialogFragment
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageButton
import android.widget.TextView
import chat.rocket.android.R
import chat.rocket.android.layouthelper.chatroom.dialog.RoomFileListAdapter
import chat.rocket.android.layouthelper.chatroom.dialog.RoomMemberListAdapter
/**
* Displays a dialog containing pinned messages, favorite messages, file list or member list of a room.
......@@ -20,13 +24,19 @@ class RoomDialogFragment : DialogFragment(), RoomDialogContract.View {
lateinit var token: String
lateinit var userId: String
private var actionId: Int = 0
lateinit var closeButton: ImageButton
lateinit var fileListRecyclerView: RecyclerView
private lateinit var closeButton: ImageButton
lateinit var messageText: TextView
lateinit var recyclerView: RecyclerView
lateinit var presenter: RoomDialogContract.Presenter
companion object {
fun newInstance(roomId: String, roomName: String, roomType: String, hostname: String, token: String, userId: String, actionId: Int): RoomDialogFragment {
fun newInstance(roomId: String,
roomName: String,
roomType: String,
hostname: String,
token: String,
userId: String,
actionId: Int): RoomDialogFragment {
val args = Bundle()
args.putString("roomId", roomId)
args.putString("roomName", roomName)
......@@ -55,11 +65,12 @@ class RoomDialogFragment : DialogFragment(), RoomDialogContract.View {
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.dialog_room_file_list, container, false)
val view = inflater.inflate(R.layout.dialog_room, container, false)
messageText = view.findViewById(R.id.text_message)
closeButton = view.findViewById(R.id.button_close)
closeButton.setOnClickListener { dismissDialogFragment() }
fileListRecyclerView = view.findViewById(R.id.recycler_view_file_list)
recyclerView = view.findViewById(R.id.recycler_view)
presenter = RoomDialogPresenter(context, this)
......@@ -72,19 +83,40 @@ class RoomDialogFragment : DialogFragment(), RoomDialogContract.View {
}
override fun showPinnedMessages() {
// fileListRecyclerView.adapter = RoomFileListAdapter(dataSet)
// fileListRecyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, true)
// TODO("not implemented")
}
override fun showFavoriteMessages() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
// TODO("not implemented")
}
override fun showFileList(dataSet: ArrayList<String>) {
activity.runOnUiThread({
if (dataSet.isEmpty()) {
// TODO("move to strings.xml")
showMessage("None file to show")
} else {
recyclerView.adapter = RoomFileListAdapter(dataSet)
recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, true)
}
})
}
override fun showFileList() {
override fun showMemberList(dataSet: ArrayList<String>) {
activity.runOnUiThread({
if (dataSet.isEmpty()) {
// TODO("move to strings.xml")
showMessage("None member to show")
} else {
recyclerView.adapter = RoomMemberListAdapter(dataSet)
recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, true)
}
})
}
override fun showMemberList() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
override fun showMessage(message: String) {
messageText.text = message
messageText.visibility = View.VISIBLE
}
private fun dismissDialogFragment() {
......
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