@Override public View getView(final int position, final View convertView, final ViewGroup parent) { final View view = super.getView(position, convertView, parent); final Object tag = view.getTag(); final ActivityViewHolder holder = tag instanceof ActivityViewHolder ? (ActivityViewHolder) tag : new ActivityViewHolder(view); if (!(tag instanceof ActivityViewHolder)) { view.setTag(holder); } holder.reset(); holder.setTextSize(mTextSize); final ParcelableActivity item = getItem(position); if (mShowAbsoluteTime) { holder.time.setText(formatSameDayTime(mContext, item.activity_timestamp)); } else { holder.time.setText(getRelativeTimeSpanString(item.activity_timestamp)); } if (isMyActivity(item)) { showActivityAboutMe(holder, item); } else { showActivityByFriends(holder, item); } return view; }
@Override public View getView(final int position, final View convertView, final ViewGroup parent) { final View view = convertView != null ? convertView : mInflater.inflate(R.layout.activity_list_item, null); final Object tag = view.getTag(); final ActivityViewHolder holder = tag instanceof ActivityViewHolder ? (ActivityViewHolder) tag : new ActivityViewHolder(view); if (!(tag instanceof ActivityViewHolder)) { view.setTag(holder); } holder.reset(); holder.setTextSize(mTextSize); final twitter4j.Activity item = getItem(position); final Date created_at = item.getCreatedAt(); if (created_at != null) { if (mShowAbsoluteTime) { holder.time.setText(formatSameDayTime(mContext, created_at.getTime())); } else { holder.time.setText(getRelativeTimeSpanString(created_at.getTime())); } } final User[] sources = item.getSources(); final Status[] target_statuses = item.getTargetStatuses(); final int sources_length = sources != null ? sources.length : 0; final int target_statuses_length = target_statuses != null ? target_statuses.length : 0; final Action action = item.getAction(); holder.profile_image.setVisibility(mDisplayProfileImage ? View.VISIBLE : View.GONE); if (sources_length > 0) { final User first_source = sources[0]; final Status[] target_objects = item.getTargetObjectStatuses(); final String name = mDisplayName ? first_source.getName() : first_source.getScreenName(); switch (action.getActionId()) { case Action.ACTION_FAVORITE: { if (target_statuses_length > 0) { final Status status = target_statuses[0]; holder.text.setSingleLine(true); holder.text.setEllipsize(TruncateAt.END); holder.text.setText(status.getText()); } if (sources_length == 1) { holder.title.setText(mContext.getString(R.string.activity_about_me_favorite, name)); } else { holder.title.setText( mContext.getString( R.string.activity_about_me_favorite_multi, name, sources_length - 1)); } holder.activity_profile_image_container.setVisibility( mDisplayProfileImage ? View.VISIBLE : View.GONE); setUserProfileImages(sources, holder); break; } case Action.ACTION_FOLLOW: { holder.text.setVisibility(View.GONE); if (sources_length == 1) { holder.title.setText(mContext.getString(R.string.activity_about_me_follow, name)); } else { holder.title.setText( mContext.getString( R.string.activity_about_me_follow_multi, name, sources_length - 1)); } holder.activity_profile_image_container.setVisibility( mDisplayProfileImage ? View.VISIBLE : View.GONE); setUserProfileImages(sources, holder); break; } case Action.ACTION_MENTION: { holder.title.setText(name); if (target_objects != null && target_objects.length > 0) { final Status status = target_objects[0]; holder.text.setText(status.getText()); if (status.getInReplyToStatusId() > 0 && status.getInReplyToScreenName() != null) { holder.reply_status.setVisibility(View.VISIBLE); holder.reply_status.setText( mContext.getString(R.string.in_reply_to, status.getInReplyToScreenName())); holder.reply_status.setCompoundDrawablesWithIntrinsicBounds( R.drawable.ic_indicator_reply, 0, 0, 0); } } setProfileImage(first_source.getProfileImageURL(), holder); break; } case Action.ACTION_REPLY: { holder.title.setText(name); if (target_statuses_length > 0) { final Status status = target_statuses[0]; holder.text.setText(status.getText()); if (status.getInReplyToStatusId() > 0 && status.getInReplyToScreenName() != null) { holder.reply_status.setVisibility(View.VISIBLE); holder.reply_status.setText( mContext.getString(R.string.in_reply_to, status.getInReplyToScreenName())); holder.reply_status.setCompoundDrawablesWithIntrinsicBounds( R.drawable.ic_indicator_reply, 0, 0, 0); } } setProfileImage(first_source.getProfileImageURL(), holder); break; } case Action.ACTION_RETWEET: { if (target_objects != null && target_objects.length > 0) { final Status status = target_objects[0]; holder.text.setSingleLine(true); holder.text.setEllipsize(TruncateAt.END); holder.text.setText(status.getText()); } if (sources_length == 1) { holder.title.setText(mContext.getString(R.string.activity_about_me_retweet, name)); } else { holder.title.setText( mContext.getString( R.string.activity_about_me_retweet_multi, name, sources_length - 1)); } holder.activity_profile_image_container.setVisibility( mDisplayProfileImage ? View.VISIBLE : View.GONE); setUserProfileImages(sources, holder); break; } case Action.ACTION_LIST_MEMBER_ADDED: { holder.text.setVisibility(View.GONE); if (sources_length == 1) { holder.title.setText( mContext.getString(R.string.activity_about_me_list_member_added, name)); } else { holder.title.setText( mContext.getString( R.string.activity_about_me_list_member_added_multi, name, sources_length - 1)); } holder.activity_profile_image_container.setVisibility( mDisplayProfileImage ? View.VISIBLE : View.GONE); setUserProfileImages(sources, holder); break; } } } return view; }