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

Improve code.

parent c0b2083b
......@@ -809,8 +809,13 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
recycler_view.addOnScrollListener(fabScrollListener)
if (!isReadOnly) {
val touchCallback: ItemTouchHelper.SimpleCallback = object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {
override fun onMove(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean {
val touchCallback: ItemTouchHelper.SimpleCallback =
object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {
override fun onMove(
recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder,
target: RecyclerView.ViewHolder
): Boolean {
return true
}
......@@ -829,7 +834,10 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
adapter.notifyItemChanged(viewHolder.adapterPosition)
}
override fun getSwipeDirs(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
override fun getSwipeDirs(
recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder
): Int {
// Currently enable swipes for text and attachment messages only
if (viewHolder is MessageViewHolder || viewHolder is AttachmentViewHolder) {
......@@ -840,8 +848,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
val itemTouchHelper = ItemTouchHelper(touchCallback)
itemTouchHelper.attachToRecyclerView(recycler_view)
ItemTouchHelper(touchCallback).attachToRecyclerView(recycler_view)
}
}
......
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