@Override public void bindView(View view, Context context, Cursor cursor) { switch (getItemViewType(cursor.getPosition())) { case VIEW_TYPE_SEARCH_HISTORY: { final SearchViewHolder holder = (SearchViewHolder) view.getTag(); final String title = cursor.getString(mIndices.title); holder.edit_query.setTag(title); holder.text1.setText(title); holder.icon.setImageResource(R.drawable.ic_action_history); break; } case VIEW_TYPE_SAVED_SEARCH: { final SearchViewHolder holder = (SearchViewHolder) view.getTag(); final String title = cursor.getString(mIndices.title); holder.edit_query.setTag(title); holder.text1.setText(title); holder.icon.setImageResource(R.drawable.ic_action_save); break; } case VIEW_TYPE_USER_SUGGESTION_ITEM: { final UserViewHolder holder = (UserViewHolder) view.getTag(); holder.text1.setText( mUserColorNameManager.getUserNickname( cursor.getLong(mIndices.extra_id), cursor.getString(mIndices.title), false)); holder.text2.setVisibility(View.VISIBLE); holder.text2.setText(String.format("@%s", cursor.getString(mIndices.summary))); holder.icon.clearColorFilter(); mImageLoader.displayProfileImage(holder.icon, cursor.getString(mIndices.icon)); break; } case VIEW_TYPE_USER_SCREEN_NAME: { final UserViewHolder holder = (UserViewHolder) view.getTag(); holder.text1.setText(String.format("@%s", cursor.getString(mIndices.title))); holder.text2.setVisibility(View.GONE); holder.icon.setColorFilter(holder.text1.getCurrentTextColor(), Mode.SRC_ATOP); mImageLoader.cancelDisplayTask(holder.icon); holder.icon.setImageResource(R.drawable.ic_action_user); break; } } }
@Override public void displayStatus( @NonNull final ParcelableStatus status, final boolean displayInReplyTo, final boolean shouldDisplayExtraType) { final MediaLoaderWrapper loader = adapter.getMediaLoader(); final AsyncTwitterWrapper twitter = adapter.getTwitterWrapper(); final TwidereLinkify linkify = adapter.getTwidereLinkify(); final BidiFormatter formatter = adapter.getBidiFormatter(); final Context context = adapter.getContext(); final boolean nameFirst = adapter.isNameFirst(); final boolean showCardActions = isCardActionsShown(); actionButtons.setVisibility(showCardActions ? View.VISIBLE : View.GONE); itemMenu.setVisibility(showCardActions ? View.VISIBLE : View.GONE); if (statusContentLowerSpace != null) { statusContentLowerSpace.setVisibility(showCardActions ? View.GONE : View.VISIBLE); } final long replyCount = status.reply_count; final long retweetCount; final long favoriteCount; if (TwitterCardUtils.isPoll(status)) { statusInfoLabel.setText(R.string.label_poll); statusInfoIcon.setImageResource(R.drawable.ic_activity_action_poll); statusInfoLabel.setVisibility(View.VISIBLE); statusInfoIcon.setVisibility(View.VISIBLE); if (statusContentUpperSpace != null) { statusContentUpperSpace.setVisibility(View.GONE); } } else if (status.retweet_id != null) { final String retweetedBy = UserColorNameManager.decideDisplayName( status.retweet_user_nickname, status.retweeted_by_user_name, status.retweeted_by_user_screen_name, nameFirst); statusInfoLabel.setText( context.getString(R.string.name_retweeted, formatter.unicodeWrap(retweetedBy))); statusInfoIcon.setImageResource(R.drawable.ic_activity_action_retweet); statusInfoLabel.setVisibility(View.VISIBLE); statusInfoIcon.setVisibility(View.VISIBLE); if (statusContentUpperSpace != null) { statusContentUpperSpace.setVisibility(View.GONE); } } else if (status.in_reply_to_status_id != null && status.in_reply_to_user_id != null && displayInReplyTo) { final String inReplyTo = UserColorNameManager.decideDisplayName( status.in_reply_to_user_nickname, status.in_reply_to_name, status.in_reply_to_screen_name, nameFirst); statusInfoLabel.setText( context.getString(R.string.in_reply_to_name, formatter.unicodeWrap(inReplyTo))); statusInfoIcon.setImageResource(R.drawable.ic_activity_action_reply); statusInfoLabel.setVisibility(View.VISIBLE); statusInfoIcon.setVisibility(View.VISIBLE); if (statusContentUpperSpace != null) { statusContentUpperSpace.setVisibility(View.GONE); } } else { statusInfoLabel.setVisibility(View.GONE); statusInfoIcon.setVisibility(View.GONE); if (statusContentUpperSpace != null) { statusContentUpperSpace.setVisibility(View.VISIBLE); } } boolean skipLinksInText = status.extras != null && status.extras.support_entities; if (status.is_quote) { quotedNameView.setVisibility(View.VISIBLE); quotedTextView.setVisibility(View.VISIBLE); quoteIndicator.setVisibility(View.VISIBLE); quotedNameView.setName( UserColorNameManager.decideNickname( status.quoted_user_nickname, status.quoted_user_name)); quotedNameView.setScreenName("@" + status.quoted_user_screen_name); if (adapter.getLinkHighlightingStyle() != VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE) { final SpannableStringBuilder text = SpannableStringBuilder.valueOf(status.quoted_text_unescaped); ParcelableStatusUtils.applySpans(text, status.quoted_spans); linkify.applyAllLinks( text, status.account_key, getLayoutPosition(), status.is_possibly_sensitive, adapter.getLinkHighlightingStyle(), skipLinksInText); quotedTextView.setText(text); } else { final String text = status.quoted_text_unescaped; quotedTextView.setText(text); } quoteIndicator.setColor(status.quoted_user_color); itemContent.drawStart(status.user_color); } else { quotedNameView.setVisibility(View.GONE); quotedTextView.setVisibility(View.GONE); quoteIndicator.setVisibility(View.GONE); if (status.is_retweet) { final int retweetUserColor = status.retweet_user_color; final int userColor = status.user_color; if (retweetUserColor == 0) { itemContent.drawStart(userColor); } else if (userColor == 0) { itemContent.drawStart(retweetUserColor); } else { itemContent.drawStart(retweetUserColor, userColor); } } else { itemContent.drawStart(status.user_color); } } if (status.is_retweet) { timeView.setTime(status.retweet_timestamp); } else { timeView.setTime(status.timestamp); } nameView.setName(UserColorNameManager.decideNickname(status.user_nickname, status.user_name)); nameView.setScreenName("@" + status.user_screen_name); if (statusInfoSpace != null) { statusInfoSpace.setVisibility(View.VISIBLE); } if (adapter.isProfileImageEnabled()) { profileImageView.setVisibility(View.VISIBLE); if (profileImageSpace != null) { profileImageSpace.setVisibility(View.VISIBLE); } loader.displayProfileImage(profileImageView, status); profileTypeView.setImageResource( getUserTypeIconRes(status.user_is_verified, status.user_is_protected)); profileTypeView.setVisibility(View.VISIBLE); } else { profileTypeView.setVisibility(View.GONE); profileImageView.setVisibility(View.GONE); if (profileImageSpace != null) { profileImageSpace.setVisibility(View.GONE); } loader.cancelDisplayTask(profileImageView); profileTypeView.setImageDrawable(null); profileTypeView.setVisibility(View.GONE); } if (adapter.shouldShowAccountsColor()) { itemContent.drawEnd(status.account_color); } else { itemContent.drawEnd(); } if (adapter.isMediaPreviewEnabled() && (adapter.isSensitiveContentEnabled() || !status.is_possibly_sensitive)) { mediaPreview.setStyle(adapter.getMediaPreviewStyle()); quoteMediaPreview.setStyle(adapter.getMediaPreviewStyle()); final boolean showQuotedMedia = !ArrayUtils.isEmpty(status.quoted_media); final boolean showMedia = !showQuotedMedia && !ArrayUtils.isEmpty(status.media); mediaPreview.setVisibility(showMedia ? View.VISIBLE : View.GONE); if (textMediaSpace != null) { textMediaSpace.setVisibility( !status.is_quote && (showMedia || showCardActions) ? View.GONE : View.VISIBLE); } quoteMediaPreview.setVisibility(showQuotedMedia ? View.VISIBLE : View.GONE); if (quotedTextMediaSpace != null) { quotedTextMediaSpace.setVisibility( !status.is_quote || showQuotedMedia ? View.GONE : View.VISIBLE); } mediaPreview.displayMedia( status.media, loader, status.account_key, -1, this, adapter.getMediaLoadingHandler()); quoteMediaPreview.displayMedia( status.quoted_media, loader, status.account_key, -1, this, adapter.getMediaLoadingHandler()); } else { mediaPreview.setVisibility(View.GONE); quoteMediaPreview.setVisibility(View.GONE); if (textMediaSpace != null) { textMediaSpace.setVisibility( showCardActions && !status.is_quote ? View.GONE : View.VISIBLE); } if (quotedTextMediaSpace != null) { quotedTextMediaSpace.setVisibility(status.is_quote ? View.VISIBLE : View.GONE); } } if (adapter.getLinkHighlightingStyle() != VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE) { final SpannableStringBuilder text = SpannableStringBuilder.valueOf(status.text_unescaped); ParcelableStatusUtils.applySpans(text, status.spans); linkify.applyAllLinks( text, status.account_key, getLayoutPosition(), status.is_possibly_sensitive, adapter.getLinkHighlightingStyle(), skipLinksInText); textView.setText(text); } else { textView.setText(status.text_unescaped); } if (replyCount > 0) { replyCountView.setText(UnitConvertUtils.calculateProperCount(replyCount)); replyCountView.setVisibility(View.VISIBLE); } else { replyCountView.setText(null); replyCountView.setVisibility(View.GONE); } if (twitter.isDestroyingStatus(status.account_key, status.my_retweet_id)) { retweetIconView.setActivated(false); retweetCount = Math.max(0, status.retweet_count - 1); } else { final boolean creatingRetweet = twitter.isCreatingRetweet(status.account_key, status.id); retweetIconView.setActivated( creatingRetweet || status.retweeted || Utils.isMyRetweet( status.account_key, status.retweeted_by_user_key, status.my_retweet_id)); retweetCount = status.retweet_count + (creatingRetweet ? 1 : 0); } if (retweetCount > 0) { retweetCountView.setText(UnitConvertUtils.calculateProperCount(retweetCount)); retweetCountView.setVisibility(View.VISIBLE); } else { retweetCountView.setText(null); retweetCountView.setVisibility(View.GONE); } if (twitter.isDestroyingFavorite(status.account_key, status.id)) { favoriteIconView.setActivated(false); favoriteCount = Math.max(0, status.favorite_count - 1); } else { final boolean creatingFavorite = twitter.isCreatingFavorite(status.account_key, status.id); favoriteIconView.setActivated(creatingFavorite || status.is_favorite); favoriteCount = status.favorite_count + (creatingFavorite ? 1 : 0); } if (favoriteCount > 0) { favoriteCountView.setText(UnitConvertUtils.calculateProperCount(favoriteCount)); favoriteCountView.setVisibility(View.VISIBLE); } else { favoriteCountView.setText(null); favoriteCountView.setVisibility(View.GONE); } if (shouldDisplayExtraType) { displayExtraTypeIcon( status.card_name, status.media, status.location, status.place_full_name, status.is_possibly_sensitive); } else { extraTypeView.setVisibility(View.GONE); } nameView.updateText(formatter); quotedNameView.updateText(formatter); }