use of org.telegram.ui.Cells.BotSwitchCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class MentionsAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
int type = holder.getItemViewType();
if (type == 4) {
StickerCell stickerCell = (StickerCell) holder.itemView;
StickerResult result = stickers.get(position);
stickerCell.setSticker(result.sticker, result.parent);
stickerCell.setClearsInputField(true);
} else if (type == 3) {
TextView textView = (TextView) holder.itemView;
TLRPC.Chat chat = parentFragment.getCurrentChat();
if (chat != null) {
if (!ChatObject.hasAdminRights(chat) && chat.default_banned_rights != null && chat.default_banned_rights.send_inline) {
textView.setText(LocaleController.getString("GlobalAttachInlineRestricted", R.string.GlobalAttachInlineRestricted));
} else if (AndroidUtilities.isBannedForever(chat.banned_rights)) {
textView.setText(LocaleController.getString("AttachInlineRestrictedForever", R.string.AttachInlineRestrictedForever));
} else {
textView.setText(LocaleController.formatString("AttachInlineRestricted", R.string.AttachInlineRestricted, LocaleController.formatDateForBan(chat.banned_rights.until_date)));
}
}
} else if (searchResultBotContext != null) {
boolean hasTop = searchResultBotContextSwitch != null;
if (holder.getItemViewType() == 2) {
if (hasTop) {
((BotSwitchCell) holder.itemView).setText(searchResultBotContextSwitch.text);
}
} else {
if (hasTop) {
position--;
}
((ContextLinkCell) holder.itemView).setLink(searchResultBotContext.get(position), foundContextBot, contextMedia, position != searchResultBotContext.size() - 1, hasTop && position == 0, "gif".equals(searchingContextUsername));
}
} else {
if (searchResultUsernames != null) {
TLObject object = searchResultUsernames.get(position);
if (object instanceof TLRPC.User) {
((MentionCell) holder.itemView).setUser((TLRPC.User) object);
} else if (object instanceof TLRPC.Chat) {
((MentionCell) holder.itemView).setChat((TLRPC.Chat) object);
}
} else if (searchResultHashtags != null) {
((MentionCell) holder.itemView).setText(searchResultHashtags.get(position));
} else if (searchResultSuggestions != null) {
((MentionCell) holder.itemView).setEmojiSuggestion(searchResultSuggestions.get(position));
} else if (searchResultCommands != null) {
((MentionCell) holder.itemView).setBotCommand(searchResultCommands.get(position), searchResultCommandsHelp.get(position), searchResultCommandsUsers != null ? searchResultCommandsUsers.get(position) : null);
}
}
}
use of org.telegram.ui.Cells.BotSwitchCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class MentionsAdapter method onCreateViewHolder.
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view;
switch(viewType) {
case 0:
view = new MentionCell(mContext);
((MentionCell) view).setIsDarkTheme(isDarkTheme);
break;
case 1:
view = new ContextLinkCell(mContext);
((ContextLinkCell) view).setDelegate(cell -> delegate.onContextClick(cell.getResult()));
break;
case 2:
view = new BotSwitchCell(mContext);
break;
case 3:
TextView textView = new TextView(mContext);
textView.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(8), AndroidUtilities.dp(8), AndroidUtilities.dp(8));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView.setTextColor(getThemedColor(Theme.key_windowBackgroundWhiteGrayText2));
view = textView;
break;
case 4:
default:
view = new StickerCell(mContext);
break;
}
return new RecyclerListView.Holder(view);
}
Aggregations