use of com.waz.zclient.pages.main.pickuser.views.viewholders.TopUsersViewHolder in project wire-android by wireapp.
the class SearchResultAdapter method onCreateViewHolder.
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, @ItemType int viewType) {
View view;
switch(viewType) {
case ITEM_TYPE_TOP_USER:
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.startui_top_users, parent, false);
TopUserAdapter topUserAdapter = new TopUserAdapter(new TopUserAdapter.Callback() {
@Override
public Set<User> getSelectedUsers() {
return callback.getSelectedUsers();
}
});
return new TopUsersViewHolder(view, topUserAdapter, parent.getContext());
case ITEM_TYPE_OTHER_USER:
case ITEM_TYPE_CONNECTED_USER:
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.startui_user, parent, false);
return new UserViewHolder(view, darkTheme, true);
case ITEM_TYPE_CONVERSATION:
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.startui_conversation, parent, false);
return new ConversationViewHolder(view);
case ITEM_TYPE_SECTION_HEADER:
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.startui_section_header, parent, false);
return new SectionHeaderViewHolder(view);
case ITEM_TYPE_INITIAL:
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.startui_section_header, parent, false);
return new AddressBookSectionHeaderViewHolder(view, darkTheme);
case ITEM_TYPE_CONTACT:
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.contactlist_user, parent, false);
return new AddressBookContactViewHolder(view, darkTheme);
case ITEM_TYPE_EXPAND_BUTTON:
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.startui_section_expander, parent, false);
return new SectionExpanderViewHolder(view);
}
return null;
}
use of com.waz.zclient.pages.main.pickuser.views.viewholders.TopUsersViewHolder in project wire-android by wireapp.
the class SearchResultAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
@ItemType int itemType = getItemViewType(position);
switch(itemType) {
case ITEM_TYPE_TOP_USER:
((TopUsersViewHolder) holder).bind(topUsers);
((TopUsersViewHolder) holder).bindOnItemTouchListener(topUsersOnItemTouchListener);
break;
case ITEM_TYPE_CONVERSATION:
IConversation conversation = conversations[getConversationInternalPosition(position) - ROW_COUNT_SECTION_HEADER];
((ConversationViewHolder) holder).bind(conversation);
break;
case ITEM_TYPE_OTHER_USER:
User otherUser = otherUsers[getOtherUserInternalPosition(position) - ROW_COUNT_SECTION_HEADER];
boolean otherIsSelected = callback.getSelectedUsers().contains(otherUser);
((UserViewHolder) holder).bind(otherUser, otherIsSelected);
break;
case ITEM_TYPE_CONNECTED_USER:
int index = mergedContacts.get(position - ROW_COUNT_SECTION_HEADER).index;
User connectedUser = connectedUsers[index];
boolean contactIsSelected = callback.getSelectedUsers().contains(connectedUser);
((UserViewHolder) holder).bind(connectedUser, contactIsSelected);
break;
case ITEM_TYPE_SECTION_HEADER:
int type = getSectionItemType(position);
((SectionHeaderViewHolder) holder).bind(type);
break;
case ITEM_TYPE_INITIAL:
if (contacts == null || contacts.getInitials() == null || contacts.getInitials().isEmpty()) {
break;
}
position = showSearch ? position - ROW_COUNT_SECTION_HEADER : position;
String initial = getContactInitial(position);
((AddressBookSectionHeaderViewHolder) holder).bind(initial);
break;
case ITEM_TYPE_CONTACT:
if (contacts == null || contacts.getInitials() == null || contacts.getInitials().isEmpty()) {
break;
}
if (showSearch) {
position = mergedContacts.get(position - ROW_COUNT_SECTION_HEADER).index;
Contact contact = contacts.get(position);
((AddressBookContactViewHolder) holder).bind(contact, contactsCallback, accentColor);
} else {
int[] contactMapping = getContactMapping(position);
String contactInitial = getContactInitial(position);
int contactInternalPosition = contactMapping[2];
Contact contact = contacts.getContactForInitial(contactInitial, contactInternalPosition);
((AddressBookContactViewHolder) holder).bind(contact, contactsCallback, accentColor);
}
break;
case ITEM_TYPE_EXPAND_BUTTON:
if (getSectionForPosition(position) == ITEM_TYPE_CONNECTED_USER) {
((SectionExpanderViewHolder) holder).bind(mergedContacts.size(), new View.OnClickListener() {
@Override
public void onClick(View v) {
setContactsCollapsed(false);
}
});
} else {
((SectionExpanderViewHolder) holder).bind(conversations.length, new View.OnClickListener() {
@Override
public void onClick(View v) {
setGroupsCollapsed(false);
}
});
}
break;
}
}
Aggregations