use of org.thoughtcrime.securesms.BindableConversationItem in project Signal-Android by WhisperSystems.
the class ConversationAdapter method onCreateViewHolder.
@SuppressLint("ClickableViewAccessibility")
@Override
@NonNull
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
switch(viewType) {
case MESSAGE_TYPE_INCOMING_TEXT:
case MESSAGE_TYPE_INCOMING_MULTIMEDIA:
case MESSAGE_TYPE_OUTGOING_TEXT:
case MESSAGE_TYPE_OUTGOING_MULTIMEDIA:
case MESSAGE_TYPE_UPDATE:
View itemView = CachedInflater.from(parent.getContext()).inflate(getLayoutForViewType(viewType), parent, false);
BindableConversationItem bindable = (BindableConversationItem) itemView;
itemView.setOnClickListener((v) -> {
if (clickListener != null) {
clickListener.onItemClick(bindable.getMultiselectPartForLatestTouch());
}
});
itemView.setOnLongClickListener((v) -> {
if (clickListener != null) {
clickListener.onItemLongClick(itemView, bindable.getMultiselectPartForLatestTouch());
}
return true;
});
bindable.setEventListener(clickListener);
return new ConversationViewHolder(itemView);
case MESSAGE_TYPE_PLACEHOLDER:
View v = new FrameLayout(parent.getContext());
v.setLayoutParams(new FrameLayout.LayoutParams(1, ViewUtil.dpToPx(100)));
return new PlaceholderViewHolder(v);
case MESSAGE_TYPE_HEADER:
return new HeaderViewHolder(CachedInflater.from(parent.getContext()).inflate(R.layout.cursor_adapter_header_footer_view, parent, false));
case MESSAGE_TYPE_FOOTER:
return new FooterViewHolder(CachedInflater.from(parent.getContext()).inflate(R.layout.cursor_adapter_header_footer_view, parent, false));
default:
throw new IllegalStateException("Cannot create viewholder for type: " + viewType);
}
}
use of org.thoughtcrime.securesms.BindableConversationItem in project Signal-Android by signalapp.
the class ConversationAdapter method onCreateViewHolder.
@SuppressLint("ClickableViewAccessibility")
@Override
@NonNull
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
switch(viewType) {
case MESSAGE_TYPE_INCOMING_TEXT:
case MESSAGE_TYPE_INCOMING_MULTIMEDIA:
case MESSAGE_TYPE_OUTGOING_TEXT:
case MESSAGE_TYPE_OUTGOING_MULTIMEDIA:
case MESSAGE_TYPE_UPDATE:
View itemView = CachedInflater.from(parent.getContext()).inflate(getLayoutForViewType(viewType), parent, false);
BindableConversationItem bindable = (BindableConversationItem) itemView;
itemView.setOnClickListener((v) -> {
if (clickListener != null) {
clickListener.onItemClick(bindable.getMultiselectPartForLatestTouch());
}
});
itemView.setOnLongClickListener((v) -> {
if (clickListener != null) {
clickListener.onItemLongClick(itemView, bindable.getMultiselectPartForLatestTouch());
}
return true;
});
bindable.setEventListener(clickListener);
return new ConversationViewHolder(itemView);
case MESSAGE_TYPE_PLACEHOLDER:
View v = new FrameLayout(parent.getContext());
v.setLayoutParams(new FrameLayout.LayoutParams(1, ViewUtil.dpToPx(100)));
return new PlaceholderViewHolder(v);
case MESSAGE_TYPE_HEADER:
return new HeaderViewHolder(CachedInflater.from(parent.getContext()).inflate(R.layout.cursor_adapter_header_footer_view, parent, false));
case MESSAGE_TYPE_FOOTER:
return new FooterViewHolder(CachedInflater.from(parent.getContext()).inflate(R.layout.cursor_adapter_header_footer_view, parent, false));
default:
throw new IllegalStateException("Cannot create viewholder for type: " + viewType);
}
}
Aggregations