Fix double tap layout warning.
This commit is contained in:
parent
cfaf40e605
commit
e4d6f9240f
3 changed files with 32 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
|||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -58,6 +59,10 @@ public interface BindableConversationItem extends Unbindable, GiphyMp4Playable,
|
|||
|
||||
void setEventListener(@Nullable EventListener listener);
|
||||
|
||||
default void setGestureDetector(@Nullable GestureDetector gestureDetector) {
|
||||
// Intentionally Blank.
|
||||
}
|
||||
|
||||
default void setParentScrolling(boolean isParentScrolling) {
|
||||
// Intentionally Blank.
|
||||
}
|
||||
|
|
|
@ -237,6 +237,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
|||
private Stub<GiftMessageView> giftViewStub;
|
||||
private Stub<PaymentMessageView> paymentViewStub;
|
||||
private @Nullable EventListener eventListener;
|
||||
private @Nullable GestureDetector gestureDetector;
|
||||
|
||||
private int defaultBubbleColor;
|
||||
private int defaultBubbleColorForWallpaper;
|
||||
|
@ -499,6 +500,11 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
|||
this.eventListener = eventListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGestureDetector(GestureDetector gestureDetector) {
|
||||
this.gestureDetector = gestureDetector;
|
||||
}
|
||||
|
||||
public boolean disallowSwipe(float downX, float downY) {
|
||||
if (!hasAudio(messageRecord)) return false;
|
||||
|
||||
|
@ -2442,20 +2448,12 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
|||
}
|
||||
|
||||
private class DoubleTapEditTouchListener implements View.OnTouchListener {
|
||||
private final GestureDetector gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
|
||||
@Override
|
||||
public boolean onDoubleTap(MotionEvent e) {
|
||||
if (eventListener != null && batchSelected.isEmpty()) {
|
||||
eventListener.onItemDoubleClick(getMultiselectPartForLatestTouch());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
return gestureDetector.onTouchEvent(event);
|
||||
if (gestureDetector != null && batchSelected.isEmpty()) {
|
||||
return gestureDetector.onTouchEvent(event);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
package org.thoughtcrime.securesms.conversation.v2
|
||||
|
||||
import android.text.TextUtils
|
||||
import android.view.GestureDetector
|
||||
import android.view.GestureDetector.SimpleOnGestureListener
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.text.HtmlCompat
|
||||
|
@ -382,8 +385,22 @@ class ConversationAdapterV2(
|
|||
}
|
||||
|
||||
private inner class OutgoingMediaViewHolder(itemView: View) : ConversationViewHolder<OutgoingMedia>(itemView) {
|
||||
val gestureDetector = GestureDetector(
|
||||
context,
|
||||
object : SimpleOnGestureListener() {
|
||||
override fun onDoubleTap(e: MotionEvent): Boolean {
|
||||
if (clickListener != null) {
|
||||
clickListener.onItemDoubleClick(getMultiselectPartForLatestTouch())
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
override fun bind(model: OutgoingMedia) {
|
||||
bindable.setEventListener(clickListener)
|
||||
bindable.setGestureDetector(gestureDetector)
|
||||
|
||||
if (bindPayloadsIfAvailable()) {
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue