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