improved compose media long click
This commit is contained in:
parent
6bbc6b721f
commit
73777a23e3
|
@ -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 -> {
|
||||
|
|
|
@ -59,18 +59,25 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<Space
|
||||
android:id="@+id/removeSpace"
|
||||
android:layout_width="@dimen/element_spacing_mlarge"
|
||||
android:layout_height="@dimen/element_spacing_mlarge"
|
||||
android:layout_marginEnd="@dimen/element_spacing_xlarge"
|
||||
android:layout_marginRight="@dimen/element_spacing_xlarge"
|
||||
android:layout_marginTop="@dimen/element_spacing_xlarge"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<com.lnikkila.extendedtouchview.ExtendedTouchView
|
||||
android:id="@+id/remove"
|
||||
style="?borderlessButtonStyle"
|
||||
android:layout_width="@dimen/element_size_normal"
|
||||
android:layout_height="@dimen/element_size_normal"
|
||||
android:layout_marginEnd="@dimen/element_spacing_minus_mlarge"
|
||||
android:layout_marginRight="@dimen/element_spacing_minus_mlarge"
|
||||
android:layout_marginTop="@dimen/element_spacing_minus_mlarge"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/remove"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/removeSpace"
|
||||
app:layout_constraintStart_toStartOf="@+id/removeSpace"
|
||||
app:touchHeight="@dimen/element_size_normal"
|
||||
app:touchWidth="@dimen/element_size_normal">
|
||||
|
||||
|
@ -83,6 +90,16 @@
|
|||
android:src="@drawable/ic_btn_grid_item_remove"/>
|
||||
</com.lnikkila.extendedtouchview.ExtendedTouchView>
|
||||
|
||||
<Space
|
||||
android:id="@+id/editSpace"
|
||||
android:layout_width="@dimen/element_spacing_mlarge"
|
||||
android:layout_height="@dimen/element_spacing_mlarge"
|
||||
android:layout_marginBottom="@dimen/element_spacing_xlarge"
|
||||
android:layout_marginEnd="@dimen/element_spacing_xlarge"
|
||||
android:layout_marginRight="@dimen/element_spacing_xlarge"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<com.lnikkila.extendedtouchview.ExtendedTouchView
|
||||
android:id="@+id/edit"
|
||||
style="?borderlessButtonStyle"
|
||||
|
@ -90,8 +107,8 @@
|
|||
android:layout_height="@dimen/element_size_normal"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/action_edit"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/editSpace"
|
||||
app:layout_constraintTop_toTopOf="@+id/editSpace"
|
||||
app:touchHeight="@dimen/element_size_normal"
|
||||
app:touchWidth="@dimen/element_size_normal">
|
||||
|
||||
|
|
Loading…
Reference in New Issue