Add touch delegate for user avatar in conversation list view.
This commit is contained in:
parent
049e5a1b99
commit
9a20447993
1 changed files with 27 additions and 0 deletions
|
@ -17,12 +17,14 @@
|
||||||
package org.thoughtcrime.securesms.conversationlist;
|
package org.thoughtcrime.securesms.conversationlist;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.style.StyleSpan;
|
import android.text.style.StyleSpan;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.view.TouchDelegate;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -94,6 +96,9 @@ public final class ConversationListItem extends ConstraintLayout
|
||||||
private final static Typeface BOLD_TYPEFACE = Typeface.create("sans-serif-medium", Typeface.NORMAL);
|
private final static Typeface BOLD_TYPEFACE = Typeface.create("sans-serif-medium", Typeface.NORMAL);
|
||||||
private final static Typeface LIGHT_TYPEFACE = Typeface.create("sans-serif", Typeface.NORMAL);
|
private final static Typeface LIGHT_TYPEFACE = Typeface.create("sans-serif", Typeface.NORMAL);
|
||||||
|
|
||||||
|
private final Rect conversationAvatarTouchDelegateBounds = new Rect();
|
||||||
|
private final Rect newConversationAvatarTouchDelegateBounds = new Rect();
|
||||||
|
|
||||||
private Set<Long> typingThreads;
|
private Set<Long> typingThreads;
|
||||||
private LiveRecipient recipient;
|
private LiveRecipient recipient;
|
||||||
private long threadId;
|
private long threadId;
|
||||||
|
@ -153,6 +158,28 @@ public final class ConversationListItem extends ConstraintLayout
|
||||||
getLayoutTransition().setDuration(150);
|
getLayoutTransition().setDuration(150);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("DrawAllocation")
|
||||||
|
@Override
|
||||||
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||||
|
super.onLayout(changed, left, top, right, bottom);
|
||||||
|
|
||||||
|
contactPhotoImage.getHitRect(newConversationAvatarTouchDelegateBounds);
|
||||||
|
newConversationAvatarTouchDelegateBounds.left = left;
|
||||||
|
newConversationAvatarTouchDelegateBounds.top = top;
|
||||||
|
newConversationAvatarTouchDelegateBounds.bottom = bottom;
|
||||||
|
|
||||||
|
TouchDelegate currentDelegate = getTouchDelegate();
|
||||||
|
|
||||||
|
if (currentDelegate == null || !newConversationAvatarTouchDelegateBounds.equals(conversationAvatarTouchDelegateBounds)) {
|
||||||
|
conversationAvatarTouchDelegateBounds.set(newConversationAvatarTouchDelegateBounds);
|
||||||
|
TouchDelegate conversationAvatarTouchDelegate = new TouchDelegate(conversationAvatarTouchDelegateBounds, contactPhotoImage);
|
||||||
|
setTouchDelegate(conversationAvatarTouchDelegate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bind(@NonNull ThreadRecord thread,
|
public void bind(@NonNull ThreadRecord thread,
|
||||||
@NonNull GlideRequests glideRequests,
|
@NonNull GlideRequests glideRequests,
|
||||||
|
|
Loading…
Add table
Reference in a new issue