From 73777a23e30cc1a12af6795dba9d948aa19e09e5 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Sun, 24 Dec 2017 23:35:54 +0800 Subject: [PATCH] improved compose media long click --- .../holder/compose/MediaPreviewViewHolder.kt | 12 +++---- .../res/layout/grid_item_media_editor.xml | 31 ++++++++++++++----- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/compose/MediaPreviewViewHolder.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/compose/MediaPreviewViewHolder.kt index 99a273086..80c45eb20 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/compose/MediaPreviewViewHolder.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/compose/MediaPreviewViewHolder.kt @@ -31,7 +31,7 @@ import org.mariotaku.twidere.model.ParcelableMedia import org.mariotaku.twidere.model.ParcelableMediaUpdate import java.lang.Exception -class MediaPreviewViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), View.OnLongClickListener, View.OnClickListener { +class MediaPreviewViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), View.OnClickListener { private val imageView = itemView.image private val videoIndicatorView = itemView.videoIndicator @@ -58,7 +58,10 @@ class MediaPreviewViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) var adapter: MediaPreviewAdapter? = null init { - itemView.setOnLongClickListener(this) + itemView.setOnLongClickListener listener@ { + adapter?.listener?.onStartDrag(this) + return@listener true + } itemView.setOnClickListener(this) removeView.setOnClickListener(this) editView.setOnClickListener(this) @@ -74,11 +77,6 @@ class MediaPreviewViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) } } - override fun onLongClick(v: View): Boolean { - adapter?.listener?.onStartDrag(this) - return false - } - override fun onClick(v: View) { when (v.id) { R.id.remove -> { diff --git a/twidere/src/main/res/layout/grid_item_media_editor.xml b/twidere/src/main/res/layout/grid_item_media_editor.xml index 51597971e..c39b69b21 100644 --- a/twidere/src/main/res/layout/grid_item_media_editor.xml +++ b/twidere/src/main/res/layout/grid_item_media_editor.xml @@ -59,18 +59,25 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"/> + + @@ -83,6 +90,16 @@ android:src="@drawable/ic_btn_grid_item_remove"/> + +