2014-07-03 07:48:39 +02:00
|
|
|
package org.mariotaku.twidere.view.holder;
|
|
|
|
|
|
|
|
import android.content.Context;
|
2014-12-03 11:27:11 +01:00
|
|
|
import android.database.Cursor;
|
2014-12-13 16:14:47 +01:00
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import android.support.annotation.Nullable;
|
2014-12-03 11:27:11 +01:00
|
|
|
import android.support.v7.widget.CardView;
|
2014-11-21 04:00:46 +01:00
|
|
|
import android.support.v7.widget.RecyclerView;
|
2015-04-05 19:58:10 +02:00
|
|
|
import android.support.v7.widget.RecyclerView.ViewHolder;
|
|
|
|
import android.text.Html;
|
|
|
|
import android.text.TextUtils;
|
2014-07-03 07:48:39 +02:00
|
|
|
import android.view.View;
|
2014-11-21 04:00:46 +01:00
|
|
|
import android.view.View.OnClickListener;
|
2014-07-03 07:48:39 +02:00
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2015-03-20 13:40:27 +01:00
|
|
|
import org.mariotaku.twidere.Constants;
|
2014-07-03 07:48:39 +02:00
|
|
|
import org.mariotaku.twidere.R;
|
2015-01-06 16:46:07 +01:00
|
|
|
import org.mariotaku.twidere.adapter.iface.ContentCardClickListener;
|
2014-11-21 04:00:46 +01:00
|
|
|
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
|
2015-04-05 19:58:10 +02:00
|
|
|
import org.mariotaku.twidere.app.TwidereApplication;
|
2015-03-14 16:11:20 +01:00
|
|
|
import org.mariotaku.twidere.model.ParcelableLocation;
|
2014-11-21 04:00:46 +01:00
|
|
|
import org.mariotaku.twidere.model.ParcelableMedia;
|
|
|
|
import org.mariotaku.twidere.model.ParcelableStatus;
|
2014-12-03 11:27:11 +01:00
|
|
|
import org.mariotaku.twidere.model.ParcelableStatus.CursorIndices;
|
2014-12-12 14:53:18 +01:00
|
|
|
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
2014-12-10 13:15:09 +01:00
|
|
|
import org.mariotaku.twidere.util.ImageLoadingHandler;
|
2015-03-24 16:40:47 +01:00
|
|
|
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
2015-04-05 19:58:10 +02:00
|
|
|
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
|
2015-02-17 06:49:23 +01:00
|
|
|
import org.mariotaku.twidere.util.SimpleValueSerializer;
|
2015-04-05 19:58:10 +02:00
|
|
|
import org.mariotaku.twidere.util.TwidereLinkify;
|
2015-01-19 18:46:14 +01:00
|
|
|
import org.mariotaku.twidere.util.TwitterCardUtils;
|
2015-01-03 16:16:50 +01:00
|
|
|
import org.mariotaku.twidere.util.UserColorNameUtils;
|
2014-07-03 07:48:39 +02:00
|
|
|
import org.mariotaku.twidere.util.Utils;
|
2015-03-29 09:17:42 +02:00
|
|
|
import org.mariotaku.twidere.util.Utils.OnMediaClickListener;
|
2014-12-24 05:39:21 +01:00
|
|
|
import org.mariotaku.twidere.view.CardMediaContainer;
|
2015-04-07 17:43:03 +02:00
|
|
|
import org.mariotaku.twidere.view.ForegroundColorView;
|
2014-12-24 05:39:21 +01:00
|
|
|
import org.mariotaku.twidere.view.ShapedImageView;
|
2014-07-03 07:48:39 +02:00
|
|
|
import org.mariotaku.twidere.view.ShortTimeView;
|
2015-01-14 09:47:51 +01:00
|
|
|
import org.mariotaku.twidere.view.iface.IColorLabelView;
|
2014-07-03 07:48:39 +02:00
|
|
|
|
2014-11-21 04:00:46 +01:00
|
|
|
import java.util.Locale;
|
|
|
|
|
2014-12-13 16:14:47 +01:00
|
|
|
import twitter4j.TranslationResult;
|
|
|
|
|
2015-03-20 13:40:27 +01:00
|
|
|
import static org.mariotaku.twidere.util.HtmlEscapeHelper.toPlainText;
|
2015-04-07 18:36:54 +02:00
|
|
|
import static org.mariotaku.twidere.util.UserColorNameUtils.getUserNickname;
|
2014-11-22 15:12:54 +01:00
|
|
|
import static org.mariotaku.twidere.util.Utils.getUserTypeIconRes;
|
|
|
|
|
2014-11-21 04:00:46 +01:00
|
|
|
/**
|
2015-03-12 16:04:45 +01:00
|
|
|
* IDE gives me warning if I don't change default comment, so I write this XD
|
2015-03-14 16:11:20 +01:00
|
|
|
* <p/>
|
2014-11-21 04:00:46 +01:00
|
|
|
* Created by mariotaku on 14/11/19.
|
|
|
|
*/
|
2015-03-29 09:17:42 +02:00
|
|
|
public class StatusViewHolder extends RecyclerView.ViewHolder implements Constants, OnClickListener,
|
|
|
|
OnMediaClickListener {
|
2014-11-21 04:00:46 +01:00
|
|
|
|
2015-04-05 19:58:10 +02:00
|
|
|
@NonNull
|
2014-12-04 15:31:29 +01:00
|
|
|
private final IStatusesAdapter<?> adapter;
|
2014-11-21 04:00:46 +01:00
|
|
|
|
2015-01-14 09:47:51 +01:00
|
|
|
private final ImageView replyRetweetIcon;
|
2014-12-24 05:39:21 +01:00
|
|
|
private final ShapedImageView profileImageView;
|
2014-11-21 04:00:46 +01:00
|
|
|
private final ImageView profileTypeView;
|
2015-01-19 18:46:14 +01:00
|
|
|
private final ImageView extraTypeView;
|
2014-11-21 04:00:46 +01:00
|
|
|
private final TextView textView;
|
2015-04-07 17:43:03 +02:00
|
|
|
private final TextView quoteTextView;
|
2014-11-21 04:00:46 +01:00
|
|
|
private final TextView nameView, screenNameView;
|
2015-04-07 17:43:03 +02:00
|
|
|
private final TextView quotedNameView, quotedScreenNameView;
|
2014-11-21 04:00:46 +01:00
|
|
|
private final TextView replyRetweetView;
|
|
|
|
private final ShortTimeView timeView;
|
2015-04-07 17:43:03 +02:00
|
|
|
private final CardMediaContainer mediaPreview;
|
2014-11-21 04:00:46 +01:00
|
|
|
private final TextView replyCountView, retweetCountView, favoriteCountView;
|
2015-04-07 17:43:03 +02:00
|
|
|
private final View quotedNameContainer;
|
2015-01-14 09:47:51 +01:00
|
|
|
private final IColorLabelView itemContent;
|
2015-04-07 17:43:03 +02:00
|
|
|
private final ForegroundColorView quoteIndicator;
|
2015-04-08 18:33:10 +02:00
|
|
|
private final View actionButtons;
|
|
|
|
private final View itemMenu;
|
2014-11-21 04:00:46 +01:00
|
|
|
|
2015-01-06 16:46:07 +01:00
|
|
|
private StatusClickListener statusClickListener;
|
|
|
|
|
2015-04-05 19:58:10 +02:00
|
|
|
public StatusViewHolder(@NonNull final IStatusesAdapter<?> adapter, @NonNull final View itemView) {
|
2014-11-21 04:00:46 +01:00
|
|
|
super(itemView);
|
|
|
|
this.adapter = adapter;
|
2015-01-14 09:47:51 +01:00
|
|
|
itemContent = (IColorLabelView) itemView.findViewById(R.id.item_content);
|
2014-12-24 05:39:21 +01:00
|
|
|
profileImageView = (ShapedImageView) itemView.findViewById(R.id.profile_image);
|
2014-11-21 04:00:46 +01:00
|
|
|
profileTypeView = (ImageView) itemView.findViewById(R.id.profile_type);
|
2015-01-19 18:46:14 +01:00
|
|
|
extraTypeView = (ImageView) itemView.findViewById(R.id.extra_type);
|
2014-11-21 04:00:46 +01:00
|
|
|
textView = (TextView) itemView.findViewById(R.id.text);
|
2015-04-07 17:43:03 +02:00
|
|
|
quoteTextView = (TextView) itemView.findViewById(R.id.quote_text);
|
2014-11-21 04:00:46 +01:00
|
|
|
nameView = (TextView) itemView.findViewById(R.id.name);
|
|
|
|
screenNameView = (TextView) itemView.findViewById(R.id.screen_name);
|
2015-04-07 17:43:03 +02:00
|
|
|
quotedNameView = (TextView) itemView.findViewById(R.id.quoted_name);
|
|
|
|
quotedScreenNameView = (TextView) itemView.findViewById(R.id.quoted_screen_name);
|
2015-01-14 09:47:51 +01:00
|
|
|
replyRetweetIcon = (ImageView) itemView.findViewById(R.id.reply_retweet_icon);
|
2014-11-21 04:00:46 +01:00
|
|
|
replyRetweetView = (TextView) itemView.findViewById(R.id.reply_retweet_status);
|
|
|
|
timeView = (ShortTimeView) itemView.findViewById(R.id.time);
|
|
|
|
|
2015-04-07 17:43:03 +02:00
|
|
|
mediaPreview = (CardMediaContainer) itemView.findViewById(R.id.media_preview);
|
|
|
|
quotedNameContainer = itemView.findViewById(R.id.quoted_name_container);
|
|
|
|
|
|
|
|
quoteIndicator = (ForegroundColorView) itemView.findViewById(R.id.quote_indicator);
|
2014-11-21 04:00:46 +01:00
|
|
|
|
2015-04-08 18:33:10 +02:00
|
|
|
itemMenu = itemView.findViewById(R.id.item_menu);
|
|
|
|
actionButtons = itemView.findViewById(R.id.action_buttons);
|
|
|
|
|
2014-11-21 04:00:46 +01:00
|
|
|
replyCountView = (TextView) itemView.findViewById(R.id.reply_count);
|
|
|
|
retweetCountView = (TextView) itemView.findViewById(R.id.retweet_count);
|
|
|
|
favoriteCountView = (TextView) itemView.findViewById(R.id.favorite_count);
|
2014-12-03 11:27:11 +01:00
|
|
|
//TODO
|
|
|
|
// profileImageView.setSelectorColor(ThemeUtils.getUserHighlightColor(itemView.getContext()));
|
2014-12-10 13:15:09 +01:00
|
|
|
}
|
|
|
|
|
2015-01-30 15:27:22 +01:00
|
|
|
public void displaySampleStatus() {
|
2015-04-08 18:33:10 +02:00
|
|
|
profileImageView.setVisibility(adapter.isProfileImageEnabled() ? View.VISIBLE : View.GONE);
|
2015-03-20 13:40:27 +01:00
|
|
|
profileImageView.setImageResource(R.mipmap.ic_launcher);
|
|
|
|
nameView.setText(TWIDERE_PREVIEW_NAME);
|
|
|
|
screenNameView.setText("@" + TWIDERE_PREVIEW_SCREEN_NAME);
|
2015-04-08 18:33:10 +02:00
|
|
|
if (adapter.getLinkHighlightingStyle() == VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE) {
|
|
|
|
textView.setText(Html.fromHtml(TWIDERE_PREVIEW_TEXT_HTML));
|
|
|
|
adapter.getTwidereLinkify().applyAllLinks(textView, -1, -1, false, adapter.getLinkHighlightingStyle());
|
|
|
|
} else {
|
|
|
|
textView.setText(toPlainText(TWIDERE_PREVIEW_TEXT_HTML));
|
|
|
|
}
|
|
|
|
textView.setMovementMethod(null);
|
2015-01-30 15:27:22 +01:00
|
|
|
timeView.setTime(System.currentTimeMillis());
|
2015-04-08 18:33:10 +02:00
|
|
|
mediaPreview.setVisibility(adapter.isMediaPreviewEnabled() ? View.VISIBLE : View.GONE);
|
2015-04-07 17:43:03 +02:00
|
|
|
mediaPreview.displayMedia(R.drawable.nyan_stars_background);
|
2014-12-24 05:39:21 +01:00
|
|
|
}
|
|
|
|
|
2015-01-14 09:47:51 +01:00
|
|
|
public void displayStatus(final ParcelableStatus status, final boolean displayInReplyTo) {
|
2015-04-05 19:58:10 +02:00
|
|
|
displayStatus(status, null, displayInReplyTo, true);
|
2014-12-13 16:14:47 +01:00
|
|
|
}
|
|
|
|
|
2015-04-05 19:58:10 +02:00
|
|
|
public void displayStatus(@NonNull final ParcelableStatus status, @Nullable final TranslationResult translation,
|
|
|
|
final boolean displayInReplyTo, final boolean shouldDisplayExtraType) {
|
|
|
|
final MediaLoaderWrapper loader = adapter.getImageLoader();
|
|
|
|
final AsyncTwitterWrapper twitter = adapter.getTwitterWrapper();
|
|
|
|
final TwidereLinkify linkify = adapter.getTwidereLinkify();
|
2015-04-07 17:43:03 +02:00
|
|
|
final Context context = adapter.getContext();
|
2015-04-05 19:58:10 +02:00
|
|
|
final boolean nameFirst = adapter.isNameFirst();
|
2014-11-21 04:00:46 +01:00
|
|
|
|
2015-04-07 17:43:03 +02:00
|
|
|
final long reply_count = status.reply_count;
|
|
|
|
final long retweet_count;
|
|
|
|
final long favorite_count;
|
|
|
|
|
2014-11-21 04:00:46 +01:00
|
|
|
if (status.retweet_id > 0) {
|
2015-01-19 18:46:14 +01:00
|
|
|
final String retweetedBy = UserColorNameUtils.getDisplayName(context, status.retweeted_by_id,
|
2015-03-24 16:40:47 +01:00
|
|
|
status.retweeted_by_name, status.retweeted_by_screen_name, nameFirst);
|
2015-01-19 18:46:14 +01:00
|
|
|
replyRetweetView.setText(context.getString(R.string.name_retweeted, retweetedBy));
|
2015-01-14 09:47:51 +01:00
|
|
|
replyRetweetIcon.setImageResource(R.drawable.ic_activity_action_retweet);
|
2014-11-21 04:00:46 +01:00
|
|
|
replyRetweetView.setVisibility(View.VISIBLE);
|
2015-01-14 09:47:51 +01:00
|
|
|
replyRetweetIcon.setVisibility(View.VISIBLE);
|
2015-04-07 17:43:03 +02:00
|
|
|
} else if (status.in_reply_to_status_id > 0 && status.in_reply_to_user_id > 0 && displayInReplyTo) {
|
2015-01-19 18:46:14 +01:00
|
|
|
final String inReplyTo = UserColorNameUtils.getDisplayName(context, status.in_reply_to_user_id,
|
2015-03-24 16:40:47 +01:00
|
|
|
status.in_reply_to_name, status.in_reply_to_screen_name, nameFirst);
|
2015-01-19 18:46:14 +01:00
|
|
|
replyRetweetView.setText(context.getString(R.string.in_reply_to_name, inReplyTo));
|
2015-01-14 09:47:51 +01:00
|
|
|
replyRetweetIcon.setImageResource(R.drawable.ic_activity_action_reply);
|
2015-04-07 17:43:03 +02:00
|
|
|
replyRetweetView.setVisibility(View.VISIBLE);
|
|
|
|
replyRetweetIcon.setVisibility(View.VISIBLE);
|
2014-11-21 04:00:46 +01:00
|
|
|
} else {
|
|
|
|
replyRetweetView.setVisibility(View.GONE);
|
2015-01-14 09:47:51 +01:00
|
|
|
replyRetweetIcon.setVisibility(View.GONE);
|
2014-11-21 04:00:46 +01:00
|
|
|
}
|
|
|
|
|
2014-11-22 15:12:54 +01:00
|
|
|
final int typeIconRes = getUserTypeIconRes(status.user_is_verified, status.user_is_protected);
|
|
|
|
if (typeIconRes != 0) {
|
|
|
|
profileTypeView.setImageResource(typeIconRes);
|
|
|
|
profileTypeView.setVisibility(View.VISIBLE);
|
2014-11-21 04:00:46 +01:00
|
|
|
} else {
|
|
|
|
profileTypeView.setImageDrawable(null);
|
2014-11-22 15:12:54 +01:00
|
|
|
profileTypeView.setVisibility(View.GONE);
|
2014-11-21 04:00:46 +01:00
|
|
|
}
|
|
|
|
|
2015-04-07 17:43:03 +02:00
|
|
|
if (status.is_quote) {
|
2015-04-07 18:36:54 +02:00
|
|
|
quotedNameView.setText(getUserNickname(context, status.user_id, status.user_name, true));
|
2015-04-07 17:43:03 +02:00
|
|
|
quotedScreenNameView.setText("@" + status.user_screen_name);
|
|
|
|
timeView.setTime(status.quote_timestamp);
|
2015-04-07 18:36:54 +02:00
|
|
|
nameView.setText(getUserNickname(context, status.quoted_by_user_id, status.quoted_by_user_name, true));
|
2015-04-07 17:43:03 +02:00
|
|
|
screenNameView.setText("@" + status.quoted_by_user_screen_name);
|
2014-11-21 04:00:46 +01:00
|
|
|
|
2015-04-07 17:43:03 +02:00
|
|
|
if (adapter.getLinkHighlightingStyle() == VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE) {
|
|
|
|
quoteTextView.setText(status.quote_text_unescaped);
|
|
|
|
} else {
|
|
|
|
quoteTextView.setText(Html.fromHtml(status.quote_text_html));
|
|
|
|
linkify.applyAllLinks(quoteTextView, status.account_id, getLayoutPosition(),
|
|
|
|
status.is_possibly_sensitive, adapter.getLinkHighlightingStyle());
|
|
|
|
quoteTextView.setMovementMethod(null);
|
|
|
|
}
|
2015-01-17 19:58:29 +01:00
|
|
|
|
2015-04-07 17:43:03 +02:00
|
|
|
quotedNameContainer.setVisibility(View.VISIBLE);
|
|
|
|
quoteTextView.setVisibility(View.VISIBLE);
|
|
|
|
quoteIndicator.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
quoteIndicator.setColor(UserColorNameUtils.getUserColor(context, status.user_id));
|
|
|
|
|
|
|
|
if (adapter.isProfileImageEnabled()) {
|
|
|
|
profileTypeView.setVisibility(View.VISIBLE);
|
|
|
|
profileImageView.setVisibility(View.VISIBLE);
|
|
|
|
loader.displayProfileImage(profileImageView, status.quoted_by_user_profile_image);
|
|
|
|
} else {
|
|
|
|
profileTypeView.setVisibility(View.GONE);
|
|
|
|
profileImageView.setVisibility(View.GONE);
|
|
|
|
loader.cancelDisplayTask(profileImageView);
|
|
|
|
}
|
|
|
|
|
|
|
|
final int userColor = UserColorNameUtils.getUserColor(context, status.quoted_by_user_id);
|
|
|
|
itemContent.drawStart(userColor);
|
2015-01-17 19:58:29 +01:00
|
|
|
} else {
|
2015-04-07 18:36:54 +02:00
|
|
|
nameView.setText(getUserNickname(context, status.user_id, status.user_name, true));
|
2015-04-07 17:43:03 +02:00
|
|
|
screenNameView.setText("@" + status.user_screen_name);
|
|
|
|
timeView.setTime(status.timestamp);
|
|
|
|
|
|
|
|
quotedNameContainer.setVisibility(View.GONE);
|
|
|
|
quoteTextView.setVisibility(View.GONE);
|
|
|
|
quoteIndicator.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
if (adapter.isProfileImageEnabled()) {
|
|
|
|
final String user_profile_image_url = status.user_profile_image_url;
|
|
|
|
profileTypeView.setVisibility(View.VISIBLE);
|
|
|
|
profileImageView.setVisibility(View.VISIBLE);
|
|
|
|
loader.displayProfileImage(profileImageView, user_profile_image_url);
|
|
|
|
} else {
|
|
|
|
profileTypeView.setVisibility(View.GONE);
|
|
|
|
profileImageView.setVisibility(View.GONE);
|
|
|
|
loader.cancelDisplayTask(profileImageView);
|
|
|
|
}
|
|
|
|
final int userColor = UserColorNameUtils.getUserColor(context, status.user_id);
|
|
|
|
itemContent.drawStart(userColor);
|
2015-01-17 19:58:29 +01:00
|
|
|
}
|
2014-11-21 04:00:46 +01:00
|
|
|
|
2015-04-07 17:43:03 +02:00
|
|
|
|
|
|
|
if (adapter.shouldShowAccountsColor()) {
|
|
|
|
itemContent.drawEnd(Utils.getAccountColor(context, status.account_id));
|
2015-03-30 14:24:51 +02:00
|
|
|
} else {
|
2015-04-07 17:43:03 +02:00
|
|
|
itemContent.drawEnd();
|
2015-03-30 14:24:51 +02:00
|
|
|
}
|
2014-11-21 04:00:46 +01:00
|
|
|
|
2015-04-07 17:43:03 +02:00
|
|
|
|
|
|
|
if (adapter.isMediaPreviewEnabled()) {
|
|
|
|
mediaPreview.setStyle(adapter.getMediaPreviewStyle());
|
2015-04-08 15:26:44 +02:00
|
|
|
final boolean hasMedia = status.media != null && status.media.length > 0;
|
|
|
|
if (hasMedia && (adapter.isSensitiveContentEnabled() || !status.is_possibly_sensitive)) {
|
|
|
|
mediaPreview.setVisibility(hasMedia ? View.VISIBLE : View.GONE);
|
|
|
|
mediaPreview.displayMedia(status.media, loader, status.account_id, this,
|
|
|
|
adapter.getImageLoadingHandler());
|
|
|
|
} else {
|
|
|
|
mediaPreview.setVisibility(View.GONE);
|
|
|
|
}
|
2015-01-19 18:46:14 +01:00
|
|
|
} else {
|
2015-04-07 17:43:03 +02:00
|
|
|
mediaPreview.setVisibility(View.GONE);
|
2015-01-19 18:46:14 +01:00
|
|
|
}
|
2015-04-07 17:43:03 +02:00
|
|
|
if (adapter.getLinkHighlightingStyle() == VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE) {
|
2014-12-13 16:14:47 +01:00
|
|
|
textView.setText(status.text_unescaped);
|
2015-04-05 19:58:10 +02:00
|
|
|
} else {
|
|
|
|
textView.setText(Html.fromHtml(status.text_html));
|
2015-04-06 18:42:09 +02:00
|
|
|
linkify.applyAllLinks(textView, status.account_id, getLayoutPosition(),
|
2015-04-07 17:43:03 +02:00
|
|
|
status.is_possibly_sensitive,
|
|
|
|
adapter.getLinkHighlightingStyle());
|
|
|
|
textView.setMovementMethod(null);
|
2014-12-13 16:14:47 +01:00
|
|
|
}
|
2014-11-21 04:00:46 +01:00
|
|
|
|
2015-04-07 17:43:03 +02:00
|
|
|
if (reply_count > 0) {
|
|
|
|
replyCountView.setText(Utils.getLocalizedNumber(Locale.getDefault(), reply_count));
|
2014-11-21 04:00:46 +01:00
|
|
|
} else {
|
|
|
|
replyCountView.setText(null);
|
|
|
|
}
|
2014-12-13 16:14:47 +01:00
|
|
|
|
|
|
|
if (twitter.isDestroyingStatus(status.account_id, status.my_retweet_id)) {
|
|
|
|
retweetCountView.setActivated(false);
|
2015-04-07 17:43:03 +02:00
|
|
|
retweet_count = Math.max(0, status.retweet_count - 1);
|
2014-11-21 04:00:46 +01:00
|
|
|
} else {
|
2014-12-13 16:14:47 +01:00
|
|
|
final boolean creatingRetweet = twitter.isCreatingRetweet(status.account_id, status.id);
|
2015-04-07 17:43:03 +02:00
|
|
|
retweetCountView.setActivated(creatingRetweet || Utils.isMyRetweet(status.account_id,
|
|
|
|
status.retweeted_by_id, status.my_retweet_id));
|
2014-12-13 16:14:47 +01:00
|
|
|
retweet_count = status.retweet_count + (creatingRetweet ? 1 : 0);
|
2014-11-21 04:00:46 +01:00
|
|
|
}
|
2014-12-13 16:14:47 +01:00
|
|
|
if (retweet_count > 0) {
|
|
|
|
retweetCountView.setText(Utils.getLocalizedNumber(Locale.getDefault(), retweet_count));
|
2014-11-21 04:00:46 +01:00
|
|
|
} else {
|
2014-12-13 16:14:47 +01:00
|
|
|
retweetCountView.setText(null);
|
2014-11-21 04:00:46 +01:00
|
|
|
}
|
2014-12-12 14:53:18 +01:00
|
|
|
if (twitter.isDestroyingFavorite(status.account_id, status.id)) {
|
|
|
|
favoriteCountView.setActivated(false);
|
2014-12-13 16:14:47 +01:00
|
|
|
favorite_count = Math.max(0, status.favorite_count - 1);
|
2014-12-12 14:53:18 +01:00
|
|
|
} else {
|
2014-12-13 16:14:47 +01:00
|
|
|
final boolean creatingFavorite = twitter.isCreatingFavorite(status.account_id, status.id);
|
|
|
|
favoriteCountView.setActivated(creatingFavorite || status.is_favorite);
|
|
|
|
favorite_count = status.favorite_count + (creatingFavorite ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (favorite_count > 0) {
|
|
|
|
favoriteCountView.setText(Utils.getLocalizedNumber(Locale.getDefault(), favorite_count));
|
|
|
|
} else {
|
|
|
|
favoriteCountView.setText(null);
|
2014-12-12 14:53:18 +01:00
|
|
|
}
|
2015-03-18 08:34:23 +01:00
|
|
|
if (shouldDisplayExtraType) {
|
2015-04-08 15:26:44 +02:00
|
|
|
displayExtraTypeIcon(status.card_name, status.media, status.location, status.place_full_name,
|
|
|
|
status.is_possibly_sensitive);
|
2015-03-18 08:34:23 +01:00
|
|
|
} else {
|
|
|
|
extraTypeView.setVisibility(View.GONE);
|
|
|
|
}
|
2015-01-19 18:46:14 +01:00
|
|
|
}
|
|
|
|
|
2015-01-14 09:47:51 +01:00
|
|
|
public void displayStatus(@NonNull Cursor cursor, @NonNull CursorIndices indices,
|
|
|
|
final boolean displayInReplyTo) {
|
2015-03-22 18:06:25 +01:00
|
|
|
final MediaLoaderWrapper loader = adapter.getImageLoader();
|
2014-12-12 14:53:18 +01:00
|
|
|
final AsyncTwitterWrapper twitter = adapter.getTwitterWrapper();
|
2015-04-05 19:58:10 +02:00
|
|
|
final TwidereLinkify linkify = adapter.getTwidereLinkify();
|
2014-12-03 11:27:11 +01:00
|
|
|
final Context context = adapter.getContext();
|
2015-01-19 18:46:14 +01:00
|
|
|
final boolean nameFirst = adapter.isNameFirst();
|
2014-12-03 11:27:11 +01:00
|
|
|
|
2014-12-13 16:14:47 +01:00
|
|
|
final long reply_count = cursor.getLong(indices.reply_count);
|
|
|
|
final long retweet_count;
|
|
|
|
final long favorite_count;
|
2014-12-03 11:27:11 +01:00
|
|
|
|
|
|
|
final long account_id = cursor.getLong(indices.account_id);
|
|
|
|
final long user_id = cursor.getLong(indices.user_id);
|
2014-12-12 14:53:18 +01:00
|
|
|
final long status_id = cursor.getLong(indices.status_id);
|
2014-12-03 11:27:11 +01:00
|
|
|
final long retweet_id = cursor.getLong(indices.retweet_id);
|
|
|
|
final long my_retweet_id = cursor.getLong(indices.my_retweet_id);
|
|
|
|
final long in_reply_to_status_id = cursor.getLong(indices.in_reply_to_status_id);
|
|
|
|
final long in_reply_to_user_id = cursor.getLong(indices.in_reply_to_user_id);
|
|
|
|
|
|
|
|
final String user_name = cursor.getString(indices.user_name);
|
|
|
|
final String user_screen_name = cursor.getString(indices.user_screen_name);
|
2015-01-19 18:46:14 +01:00
|
|
|
final String card_name = cursor.getString(indices.card_name);
|
2015-04-03 19:22:00 +02:00
|
|
|
final String place_full_name = cursor.getString(indices.place_full_name);
|
2014-12-03 11:27:11 +01:00
|
|
|
|
2015-04-08 15:26:44 +02:00
|
|
|
final boolean sensitive = cursor.getShort(indices.is_possibly_sensitive) == 1;
|
|
|
|
|
2015-03-14 16:11:20 +01:00
|
|
|
final ParcelableMedia[] media = SimpleValueSerializer.fromSerializedString(
|
|
|
|
cursor.getString(indices.media), ParcelableMedia.SIMPLE_CREATOR);
|
|
|
|
final ParcelableLocation location = ParcelableLocation.fromString(
|
|
|
|
cursor.getString(indices.location));
|
2014-12-03 11:27:11 +01:00
|
|
|
|
|
|
|
if (retweet_id > 0) {
|
2015-04-08 15:26:44 +02:00
|
|
|
final long retweeted_by_id = cursor.getLong(indices.retweeted_by_user_id);
|
2015-04-07 17:43:03 +02:00
|
|
|
final String retweeted_by_name = cursor.getString(indices.retweeted_by_user_name);
|
|
|
|
final String retweeted_by_screen_name = cursor.getString(indices.retweeted_by_user_screen_name);
|
2015-01-19 18:46:14 +01:00
|
|
|
final String retweetedBy = UserColorNameUtils.getDisplayName(context, retweeted_by_id,
|
2015-03-24 16:40:47 +01:00
|
|
|
retweeted_by_name, retweeted_by_screen_name, nameFirst);
|
2015-01-19 18:46:14 +01:00
|
|
|
replyRetweetView.setText(context.getString(R.string.name_retweeted, retweetedBy));
|
2015-01-14 09:47:51 +01:00
|
|
|
replyRetweetIcon.setImageResource(R.drawable.ic_activity_action_retweet);
|
2014-12-03 11:27:11 +01:00
|
|
|
replyRetweetView.setVisibility(View.VISIBLE);
|
2015-01-14 09:47:51 +01:00
|
|
|
replyRetweetIcon.setVisibility(View.VISIBLE);
|
|
|
|
} else if (in_reply_to_status_id > 0 && in_reply_to_user_id > 0 && displayInReplyTo) {
|
2015-04-07 17:43:03 +02:00
|
|
|
final String in_reply_to_name = cursor.getString(indices.in_reply_to_user_name);
|
|
|
|
final String in_reply_to_screen_name = cursor.getString(indices.in_reply_to_user_screen_name);
|
2015-01-19 18:46:14 +01:00
|
|
|
final String inReplyTo = UserColorNameUtils.getDisplayName(context, in_reply_to_user_id,
|
2015-03-24 16:40:47 +01:00
|
|
|
in_reply_to_name, in_reply_to_screen_name, nameFirst);
|
2015-01-19 18:46:14 +01:00
|
|
|
replyRetweetView.setText(context.getString(R.string.in_reply_to_name, inReplyTo));
|
2015-01-14 09:47:51 +01:00
|
|
|
replyRetweetIcon.setImageResource(R.drawable.ic_activity_action_reply);
|
2014-12-03 11:27:11 +01:00
|
|
|
replyRetweetView.setVisibility(View.VISIBLE);
|
2015-01-14 09:47:51 +01:00
|
|
|
replyRetweetIcon.setVisibility(View.VISIBLE);
|
2014-12-03 11:27:11 +01:00
|
|
|
} else {
|
|
|
|
replyRetweetView.setVisibility(View.GONE);
|
2015-01-14 09:47:51 +01:00
|
|
|
replyRetweetIcon.setVisibility(View.GONE);
|
2014-12-03 11:27:11 +01:00
|
|
|
}
|
|
|
|
|
2015-04-08 08:33:07 +02:00
|
|
|
final int typeIconRes;
|
2014-12-03 11:27:11 +01:00
|
|
|
|
2015-04-07 17:43:03 +02:00
|
|
|
if (cursor.getShort(indices.is_quote) == 1) {
|
|
|
|
quotedNameView.setText(user_name);
|
|
|
|
quotedScreenNameView.setText("@" + user_screen_name);
|
|
|
|
timeView.setTime(cursor.getLong(indices.quote_timestamp));
|
|
|
|
nameView.setText(cursor.getString(indices.quoted_by_user_name));
|
|
|
|
screenNameView.setText("@" + cursor.getString(indices.quoted_by_user_screen_name));
|
|
|
|
|
|
|
|
if (adapter.getLinkHighlightingStyle() == VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE) {
|
|
|
|
quoteTextView.setText(cursor.getString(indices.quote_text_unescaped));
|
|
|
|
} else {
|
|
|
|
quoteTextView.setText(Html.fromHtml(cursor.getString(indices.quote_text_html)));
|
|
|
|
linkify.applyAllLinks(quoteTextView, account_id, getLayoutPosition(),
|
|
|
|
cursor.getShort(indices.is_possibly_sensitive) == 1,
|
|
|
|
adapter.getLinkHighlightingStyle());
|
|
|
|
quoteTextView.setMovementMethod(null);
|
|
|
|
}
|
2014-12-03 11:27:11 +01:00
|
|
|
|
2015-04-07 17:43:03 +02:00
|
|
|
quotedNameContainer.setVisibility(View.VISIBLE);
|
|
|
|
quoteTextView.setVisibility(View.VISIBLE);
|
|
|
|
quoteIndicator.setVisibility(View.VISIBLE);
|
2015-01-17 19:58:29 +01:00
|
|
|
|
2015-04-07 17:43:03 +02:00
|
|
|
quoteIndicator.setColor(UserColorNameUtils.getUserColor(context, user_id));
|
|
|
|
|
|
|
|
if (adapter.isProfileImageEnabled()) {
|
|
|
|
profileTypeView.setVisibility(View.VISIBLE);
|
|
|
|
profileImageView.setVisibility(View.VISIBLE);
|
|
|
|
loader.displayProfileImage(profileImageView, cursor.getString(indices.quoted_by_user_profile_image));
|
|
|
|
} else {
|
|
|
|
profileTypeView.setVisibility(View.GONE);
|
|
|
|
profileImageView.setVisibility(View.GONE);
|
|
|
|
loader.cancelDisplayTask(profileImageView);
|
|
|
|
}
|
|
|
|
|
|
|
|
final int userColor = UserColorNameUtils.getUserColor(context, cursor.getLong(indices.quoted_by_user_id));
|
|
|
|
itemContent.drawStart(userColor);
|
2015-04-08 08:33:07 +02:00
|
|
|
|
|
|
|
typeIconRes = getUserTypeIconRes(cursor.getShort(indices.quoted_by_user_is_verified) == 1,
|
|
|
|
cursor.getShort(indices.quoted_by_user_is_protected) == 1);
|
2015-01-17 19:58:29 +01:00
|
|
|
} else {
|
2015-04-07 17:43:03 +02:00
|
|
|
nameView.setText(user_name);
|
|
|
|
screenNameView.setText("@" + user_screen_name);
|
|
|
|
timeView.setTime(cursor.getLong(indices.status_timestamp));
|
|
|
|
|
|
|
|
quotedNameContainer.setVisibility(View.GONE);
|
|
|
|
quoteTextView.setVisibility(View.GONE);
|
|
|
|
quoteIndicator.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
if (adapter.isProfileImageEnabled()) {
|
|
|
|
final String user_profile_image_url = cursor.getString(indices.user_profile_image_url);
|
|
|
|
profileTypeView.setVisibility(View.VISIBLE);
|
|
|
|
profileImageView.setVisibility(View.VISIBLE);
|
|
|
|
loader.displayProfileImage(profileImageView, user_profile_image_url);
|
|
|
|
} else {
|
|
|
|
profileTypeView.setVisibility(View.GONE);
|
|
|
|
profileImageView.setVisibility(View.GONE);
|
|
|
|
loader.cancelDisplayTask(profileImageView);
|
|
|
|
}
|
|
|
|
final int userColor = UserColorNameUtils.getUserColor(context, user_id);
|
|
|
|
itemContent.drawStart(userColor);
|
2015-04-08 08:33:07 +02:00
|
|
|
|
|
|
|
typeIconRes = getUserTypeIconRes(cursor.getShort(indices.is_verified) == 1,
|
|
|
|
cursor.getShort(indices.is_protected) == 1);
|
2015-01-17 19:58:29 +01:00
|
|
|
}
|
|
|
|
|
2015-04-08 08:33:07 +02:00
|
|
|
if (typeIconRes != 0) {
|
|
|
|
profileTypeView.setImageResource(typeIconRes);
|
|
|
|
profileTypeView.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
profileTypeView.setImageDrawable(null);
|
|
|
|
profileTypeView.setVisibility(View.GONE);
|
|
|
|
}
|
2014-12-03 11:27:11 +01:00
|
|
|
|
2015-04-07 17:43:03 +02:00
|
|
|
if (adapter.shouldShowAccountsColor()) {
|
|
|
|
itemContent.drawEnd(Utils.getAccountColor(context, account_id));
|
2015-03-30 14:24:51 +02:00
|
|
|
} else {
|
2015-04-07 17:43:03 +02:00
|
|
|
itemContent.drawEnd();
|
2015-03-30 14:24:51 +02:00
|
|
|
}
|
2014-12-03 11:27:11 +01:00
|
|
|
|
2015-04-07 17:43:03 +02:00
|
|
|
|
2015-01-19 18:46:14 +01:00
|
|
|
if (adapter.isMediaPreviewEnabled()) {
|
2015-04-08 15:26:44 +02:00
|
|
|
final boolean hasMedia = media != null && media.length > 0;
|
|
|
|
if (hasMedia && (adapter.isSensitiveContentEnabled() || !sensitive)) {
|
|
|
|
mediaPreview.setVisibility(hasMedia ? View.VISIBLE : View.GONE);
|
|
|
|
mediaPreview.displayMedia(media, loader, account_id, this, adapter.getImageLoadingHandler());
|
|
|
|
} else {
|
|
|
|
mediaPreview.setVisibility(View.GONE);
|
|
|
|
}
|
2015-01-19 18:46:14 +01:00
|
|
|
} else {
|
2015-04-07 17:43:03 +02:00
|
|
|
mediaPreview.setVisibility(View.GONE);
|
2015-01-19 18:46:14 +01:00
|
|
|
}
|
2015-04-05 19:58:10 +02:00
|
|
|
if (adapter.getLinkHighlightingStyle() == VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE) {
|
|
|
|
textView.setText(cursor.getString(indices.text_unescaped));
|
|
|
|
} else {
|
|
|
|
textView.setText(Html.fromHtml(cursor.getString(indices.text_html)));
|
2015-04-06 18:42:09 +02:00
|
|
|
linkify.applyAllLinks(textView, account_id, getLayoutPosition(),
|
|
|
|
cursor.getShort(indices.is_possibly_sensitive) == 1,
|
|
|
|
adapter.getLinkHighlightingStyle());
|
2015-04-07 17:43:03 +02:00
|
|
|
textView.setMovementMethod(null);
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
2014-12-03 11:27:11 +01:00
|
|
|
|
|
|
|
if (reply_count > 0) {
|
|
|
|
replyCountView.setText(Utils.getLocalizedNumber(Locale.getDefault(), reply_count));
|
|
|
|
} else {
|
|
|
|
replyCountView.setText(null);
|
|
|
|
}
|
2014-12-13 16:14:47 +01:00
|
|
|
|
|
|
|
if (twitter.isDestroyingStatus(account_id, my_retweet_id)) {
|
|
|
|
retweetCountView.setActivated(false);
|
|
|
|
retweet_count = Math.max(0, cursor.getLong(indices.retweet_count) - 1);
|
|
|
|
} else {
|
|
|
|
final boolean creatingRetweet = twitter.isCreatingRetweet(account_id, status_id);
|
2015-04-08 15:26:44 +02:00
|
|
|
final long retweeted_by_id = cursor.getLong(indices.retweeted_by_user_id);
|
2014-12-13 16:14:47 +01:00
|
|
|
retweetCountView.setActivated(creatingRetweet || Utils.isMyRetweet(account_id,
|
|
|
|
retweeted_by_id, my_retweet_id));
|
|
|
|
retweet_count = cursor.getLong(indices.retweet_count) + (creatingRetweet ? 1 : 0);
|
|
|
|
}
|
2014-12-03 11:27:11 +01:00
|
|
|
if (retweet_count > 0) {
|
|
|
|
retweetCountView.setText(Utils.getLocalizedNumber(Locale.getDefault(), retweet_count));
|
|
|
|
} else {
|
|
|
|
retweetCountView.setText(null);
|
|
|
|
}
|
2014-12-12 14:53:18 +01:00
|
|
|
if (twitter.isDestroyingFavorite(account_id, status_id)) {
|
|
|
|
favoriteCountView.setActivated(false);
|
2014-12-13 16:14:47 +01:00
|
|
|
favorite_count = Math.max(0, cursor.getLong(indices.favorite_count) - 1);
|
2014-12-12 14:53:18 +01:00
|
|
|
} else {
|
2014-12-13 16:14:47 +01:00
|
|
|
final boolean creatingFavorite = twitter.isCreatingFavorite(account_id, status_id);
|
2015-04-07 17:43:03 +02:00
|
|
|
favoriteCountView.setActivated(creatingFavorite || cursor.getShort(indices.is_favorite) == 1);
|
2014-12-13 16:14:47 +01:00
|
|
|
favorite_count = cursor.getLong(indices.favorite_count) + (creatingFavorite ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (favorite_count > 0) {
|
|
|
|
favoriteCountView.setText(Utils.getLocalizedNumber(Locale.getDefault(), favorite_count));
|
|
|
|
} else {
|
|
|
|
favoriteCountView.setText(null);
|
2014-12-12 14:53:18 +01:00
|
|
|
}
|
2015-04-08 15:26:44 +02:00
|
|
|
displayExtraTypeIcon(card_name, media, location, place_full_name, sensitive);
|
2014-12-03 11:27:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public CardView getCardView() {
|
|
|
|
return (CardView) itemView.findViewById(R.id.card);
|
|
|
|
}
|
|
|
|
|
2014-12-24 05:39:21 +01:00
|
|
|
public ShapedImageView getProfileImageView() {
|
2014-12-03 11:27:11 +01:00
|
|
|
return profileImageView;
|
|
|
|
}
|
|
|
|
|
2014-12-07 16:13:07 +01:00
|
|
|
public ImageView getProfileTypeView() {
|
|
|
|
return profileTypeView;
|
|
|
|
}
|
|
|
|
|
2014-11-21 04:00:46 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2015-01-06 16:46:07 +01:00
|
|
|
if (statusClickListener == null) return;
|
2015-03-24 16:40:47 +01:00
|
|
|
final int position = getAdapterPosition();
|
2014-11-21 04:00:46 +01:00
|
|
|
switch (v.getId()) {
|
|
|
|
case R.id.item_content: {
|
2015-01-06 16:46:07 +01:00
|
|
|
statusClickListener.onStatusClick(this, position);
|
2014-11-21 04:00:46 +01:00
|
|
|
break;
|
|
|
|
}
|
2014-12-10 13:15:09 +01:00
|
|
|
case R.id.item_menu: {
|
2015-01-14 09:47:51 +01:00
|
|
|
statusClickListener.onItemMenuClick(this, v, position);
|
2014-11-21 04:00:46 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case R.id.profile_image: {
|
2015-01-06 16:46:07 +01:00
|
|
|
statusClickListener.onUserProfileClick(this, position);
|
2014-11-21 04:00:46 +01:00
|
|
|
break;
|
|
|
|
}
|
2014-12-10 13:15:09 +01:00
|
|
|
case R.id.reply_count:
|
|
|
|
case R.id.retweet_count:
|
|
|
|
case R.id.favorite_count: {
|
2015-01-06 16:46:07 +01:00
|
|
|
statusClickListener.onItemActionClick(this, v.getId(), position);
|
2014-11-21 04:00:46 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-01-30 15:27:22 +01:00
|
|
|
|
2015-03-29 09:17:42 +02:00
|
|
|
@Override
|
|
|
|
public void onMediaClick(View view, ParcelableMedia media, long accountId) {
|
|
|
|
if (statusClickListener == null) return;
|
|
|
|
final int position = getAdapterPosition();
|
|
|
|
statusClickListener.onMediaClick(this, media, position);
|
|
|
|
}
|
|
|
|
|
2015-01-30 15:27:22 +01:00
|
|
|
public void setOnClickListeners() {
|
|
|
|
setStatusClickListener(adapter);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setStatusClickListener(StatusClickListener listener) {
|
|
|
|
statusClickListener = listener;
|
|
|
|
itemView.findViewById(R.id.item_content).setOnClickListener(this);
|
|
|
|
|
2015-04-08 18:33:10 +02:00
|
|
|
itemMenu.setOnClickListener(this);
|
2015-01-30 15:27:22 +01:00
|
|
|
itemView.setOnClickListener(this);
|
|
|
|
profileImageView.setOnClickListener(this);
|
|
|
|
replyCountView.setOnClickListener(this);
|
|
|
|
retweetCountView.setOnClickListener(this);
|
|
|
|
favoriteCountView.setOnClickListener(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTextSize(final float textSize) {
|
|
|
|
nameView.setTextSize(textSize);
|
2015-04-07 17:43:03 +02:00
|
|
|
quotedNameView.setTextSize(textSize);
|
2015-01-30 15:27:22 +01:00
|
|
|
textView.setTextSize(textSize);
|
2015-04-07 17:43:03 +02:00
|
|
|
quoteTextView.setTextSize(textSize);
|
2015-01-30 15:27:22 +01:00
|
|
|
screenNameView.setTextSize(textSize * 0.85f);
|
2015-04-07 17:43:03 +02:00
|
|
|
quotedScreenNameView.setTextSize(textSize * 0.85f);
|
2015-01-30 15:27:22 +01:00
|
|
|
timeView.setTextSize(textSize * 0.85f);
|
|
|
|
replyRetweetView.setTextSize(textSize * 0.75f);
|
|
|
|
replyCountView.setTextSize(textSize);
|
|
|
|
replyCountView.setTextSize(textSize);
|
|
|
|
favoriteCountView.setTextSize(textSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setupViewOptions() {
|
|
|
|
setTextSize(adapter.getTextSize());
|
2015-04-07 17:43:03 +02:00
|
|
|
mediaPreview.setStyle(adapter.getMediaPreviewStyle());
|
|
|
|
profileImageView.setStyle(adapter.getProfileImageStyle());
|
2015-04-08 18:33:10 +02:00
|
|
|
actionButtons.setVisibility(adapter.isCardActionsHidden() ? View.GONE : View.VISIBLE);
|
|
|
|
itemMenu.setVisibility(adapter.isCardActionsHidden() ? View.GONE : View.VISIBLE);
|
2015-01-30 15:27:22 +01:00
|
|
|
}
|
|
|
|
|
2015-04-08 15:26:44 +02:00
|
|
|
private void displayExtraTypeIcon(String cardName, ParcelableMedia[] media, ParcelableLocation location, String placeFullName, boolean sensitive) {
|
2015-01-30 15:27:22 +01:00
|
|
|
if (TwitterCardUtils.CARD_NAME_AUDIO.equals(cardName)) {
|
2015-04-08 15:26:44 +02:00
|
|
|
extraTypeView.setImageResource(sensitive ? R.drawable.ic_action_warning : R.drawable.ic_action_music);
|
2015-01-30 15:27:22 +01:00
|
|
|
extraTypeView.setVisibility(View.VISIBLE);
|
|
|
|
} else if (TwitterCardUtils.CARD_NAME_ANIMATED_GIF.equals(cardName)) {
|
2015-04-08 15:26:44 +02:00
|
|
|
extraTypeView.setImageResource(sensitive ? R.drawable.ic_action_warning : R.drawable.ic_action_movie);
|
2015-01-30 15:27:22 +01:00
|
|
|
extraTypeView.setVisibility(View.VISIBLE);
|
|
|
|
} else if (TwitterCardUtils.CARD_NAME_PLAYER.equals(cardName)) {
|
2015-04-08 15:26:44 +02:00
|
|
|
extraTypeView.setImageResource(sensitive ? R.drawable.ic_action_warning : R.drawable.ic_action_play_circle);
|
2015-01-30 15:27:22 +01:00
|
|
|
extraTypeView.setVisibility(View.VISIBLE);
|
2015-03-14 16:11:20 +01:00
|
|
|
} else if (media != null && media.length > 0) {
|
2015-03-22 18:06:25 +01:00
|
|
|
if (hasVideo(media)) {
|
2015-04-08 15:26:44 +02:00
|
|
|
extraTypeView.setImageResource(sensitive ? R.drawable.ic_action_warning : R.drawable.ic_action_movie);
|
2015-03-22 18:06:25 +01:00
|
|
|
} else {
|
2015-04-08 15:26:44 +02:00
|
|
|
extraTypeView.setImageResource(sensitive ? R.drawable.ic_action_warning : R.drawable.ic_action_gallery);
|
2015-03-22 18:06:25 +01:00
|
|
|
}
|
2015-01-30 15:27:22 +01:00
|
|
|
extraTypeView.setVisibility(View.VISIBLE);
|
2015-04-05 19:58:10 +02:00
|
|
|
} else if (ParcelableLocation.isValidLocation(location) || !TextUtils.isEmpty(placeFullName)) {
|
2015-03-14 16:11:20 +01:00
|
|
|
extraTypeView.setImageResource(R.drawable.ic_action_location);
|
|
|
|
extraTypeView.setVisibility(View.VISIBLE);
|
2015-01-30 15:27:22 +01:00
|
|
|
} else {
|
|
|
|
extraTypeView.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-22 18:06:25 +01:00
|
|
|
private boolean hasVideo(ParcelableMedia[] media) {
|
|
|
|
for (ParcelableMedia mediaItem : media) {
|
|
|
|
if (mediaItem.type == ParcelableMedia.TYPE_VIDEO) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-01-30 15:27:22 +01:00
|
|
|
public static interface StatusClickListener extends ContentCardClickListener {
|
|
|
|
|
2015-03-30 14:24:51 +02:00
|
|
|
boolean isProfileImageEnabled();
|
|
|
|
|
2015-03-29 09:17:42 +02:00
|
|
|
void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position);
|
|
|
|
|
2015-04-08 18:33:10 +02:00
|
|
|
void onStatusClick(StatusViewHolder holder, int position);
|
|
|
|
|
2015-01-30 15:27:22 +01:00
|
|
|
void onUserProfileClick(StatusViewHolder holder, int position);
|
|
|
|
}
|
2015-04-05 19:58:10 +02:00
|
|
|
|
|
|
|
public static final class DummyStatusHolderAdapter implements IStatusesAdapter<Object> {
|
|
|
|
|
|
|
|
private final Context context;
|
2015-04-08 18:33:10 +02:00
|
|
|
private final SharedPreferencesWrapper preferences;
|
2015-04-05 19:58:10 +02:00
|
|
|
private final MediaLoaderWrapper loader;
|
|
|
|
private final ImageLoadingHandler handler;
|
|
|
|
private final AsyncTwitterWrapper twitter;
|
|
|
|
private final TwidereLinkify linkify;
|
2015-04-08 18:33:10 +02:00
|
|
|
private int profileImageStyle;
|
|
|
|
private int mediaPreviewStyle;
|
|
|
|
private int textSize;
|
|
|
|
private int linkHighlightStyle;
|
|
|
|
private boolean nameFirst;
|
|
|
|
private boolean displayProfileImage;
|
|
|
|
private boolean sensitiveContentEnabled;
|
|
|
|
private boolean hideCardActions;
|
2015-04-05 19:58:10 +02:00
|
|
|
private boolean displayMediaPreview;
|
|
|
|
|
|
|
|
public DummyStatusHolderAdapter(Context context) {
|
|
|
|
this.context = context;
|
2015-04-08 18:33:10 +02:00
|
|
|
preferences = SharedPreferencesWrapper.getInstance(context, SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
2015-04-06 07:58:25 +02:00
|
|
|
final TwidereApplication app = TwidereApplication.getInstance(context);
|
|
|
|
loader = app.getMediaLoaderWrapper();
|
2015-04-05 19:58:10 +02:00
|
|
|
handler = new ImageLoadingHandler(R.id.media_preview_progress);
|
2015-04-06 07:58:25 +02:00
|
|
|
twitter = app.getTwitterWrapper();
|
2015-04-05 19:58:10 +02:00
|
|
|
linkify = new TwidereLinkify(null);
|
2015-04-08 18:33:10 +02:00
|
|
|
updateOptions();
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public MediaLoaderWrapper getImageLoader() {
|
|
|
|
return loader;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Context getContext() {
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ImageLoadingHandler getImageLoadingHandler() {
|
|
|
|
return handler;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemCount() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getProfileImageStyle() {
|
|
|
|
return profileImageStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getMediaPreviewStyle() {
|
|
|
|
return mediaPreviewStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public AsyncTwitterWrapper getTwitterWrapper() {
|
|
|
|
return twitter;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getTextSize() {
|
2015-04-08 18:33:10 +02:00
|
|
|
return textSize;
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isLoadMoreIndicatorVisible() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isLoadMoreSupported() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public void setLoadMoreSupported(boolean supported) {
|
|
|
|
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public void setLoadMoreIndicatorVisible(boolean enabled) {
|
2015-04-05 19:58:10 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public ParcelableStatus getStatus(int position) {
|
|
|
|
return null;
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public int getStatusesCount() {
|
|
|
|
return 0;
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public long getStatusId(int position) {
|
|
|
|
return 0;
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public TwidereLinkify getTwidereLinkify() {
|
|
|
|
return linkify;
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public boolean isMediaPreviewEnabled() {
|
|
|
|
return displayMediaPreview;
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public int getLinkHighlightingStyle() {
|
|
|
|
return linkHighlightStyle;
|
|
|
|
}
|
2015-04-05 19:58:10 +02:00
|
|
|
|
2015-04-08 18:33:10 +02:00
|
|
|
@Override
|
|
|
|
public boolean isNameFirst() {
|
|
|
|
return nameFirst;
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public boolean isSensitiveContentEnabled() {
|
|
|
|
return sensitiveContentEnabled;
|
|
|
|
}
|
2015-04-05 19:58:10 +02:00
|
|
|
|
2015-04-08 18:33:10 +02:00
|
|
|
@Override
|
|
|
|
public boolean isCardActionsHidden() {
|
|
|
|
return hideCardActions;
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public void setData(Object o) {
|
2015-04-05 19:58:10 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public boolean shouldShowAccountsColor() {
|
|
|
|
return false;
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
2015-04-08 18:33:10 +02:00
|
|
|
public void setMediaPreviewEnabled(boolean enabled) {
|
|
|
|
displayMediaPreview = enabled;
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public boolean isGapItem(int position) {
|
|
|
|
return false;
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public void onGapClick(ViewHolder holder, int position) {
|
|
|
|
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public boolean isProfileImageEnabled() {
|
|
|
|
return displayProfileImage;
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public void onStatusClick(StatusViewHolder holder, int position) {
|
|
|
|
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position) {
|
|
|
|
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
2015-04-08 15:26:44 +02:00
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public void onUserProfileClick(StatusViewHolder holder, int position) {
|
|
|
|
|
2015-04-08 15:26:44 +02:00
|
|
|
}
|
|
|
|
|
2015-04-05 19:58:10 +02:00
|
|
|
@Override
|
2015-04-08 18:33:10 +02:00
|
|
|
public void onItemActionClick(ViewHolder holder, int id, int position) {
|
2015-04-05 19:58:10 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-04-08 18:33:10 +02:00
|
|
|
@Override
|
|
|
|
public void onItemMenuClick(ViewHolder holder, View menuView, int position) {
|
|
|
|
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
|
2015-04-08 18:33:10 +02:00
|
|
|
public void updateOptions() {
|
|
|
|
profileImageStyle = Utils.getProfileImageStyle(preferences.getString(KEY_PROFILE_IMAGE_STYLE, null));
|
|
|
|
mediaPreviewStyle = Utils.getMediaPreviewStyle(preferences.getString(KEY_MEDIA_PREVIEW_STYLE, null));
|
|
|
|
textSize = preferences.getInt(KEY_TEXT_SIZE, context.getResources().getInteger(R.integer.default_text_size));
|
|
|
|
nameFirst = preferences.getBoolean(KEY_NAME_FIRST, true);
|
|
|
|
displayProfileImage = preferences.getBoolean(KEY_DISPLAY_PROFILE_IMAGE, true);
|
|
|
|
displayMediaPreview = preferences.getBoolean(KEY_MEDIA_PREVIEW, false);
|
|
|
|
sensitiveContentEnabled = preferences.getBoolean(KEY_DISPLAY_SENSITIVE_CONTENTS, false);
|
|
|
|
hideCardActions = preferences.getBoolean(KEY_HIDE_CARD_ACTIONS, false);
|
|
|
|
linkHighlightStyle = Utils.getLinkHighlightingStyleInt(preferences.getString(KEY_LINK_HIGHLIGHT_OPTION, null));
|
2015-04-05 19:58:10 +02:00
|
|
|
}
|
|
|
|
}
|
2014-07-03 07:48:39 +02:00
|
|
|
}
|