2017-01-23 16:19:30 +11:00
|
|
|
/* Copyright 2017 Andrew Dawson
|
|
|
|
*
|
|
|
|
* This file is part of Tusky.
|
|
|
|
*
|
|
|
|
* Tusky is free software: you can redistribute it and/or modify it under the terms of the GNU
|
|
|
|
* General Public License as published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
|
|
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
|
|
* Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with Tusky. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
package com.keylesspalace.tusky;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.support.annotation.Nullable;
|
|
|
|
import android.support.v7.widget.RecyclerView;
|
2017-01-27 11:34:32 +11:00
|
|
|
import android.text.SpannableStringBuilder;
|
2017-01-23 16:19:30 +11:00
|
|
|
import android.text.Spanned;
|
2017-01-27 11:34:32 +11:00
|
|
|
import android.text.method.LinkMovementMethod;
|
|
|
|
import android.text.style.ClickableSpan;
|
|
|
|
import android.text.style.URLSpan;
|
2017-01-23 16:19:30 +11:00
|
|
|
import android.view.View;
|
2017-02-01 10:42:05 +11:00
|
|
|
import android.widget.CompoundButton;
|
2017-01-23 16:19:30 +11:00
|
|
|
import android.widget.ImageButton;
|
2017-03-07 11:31:05 +11:00
|
|
|
import android.widget.ImageView;
|
2017-01-23 16:19:30 +11:00
|
|
|
import android.widget.TextView;
|
2017-02-01 10:42:05 +11:00
|
|
|
import android.widget.ToggleButton;
|
2017-01-23 16:19:30 +11:00
|
|
|
|
2017-03-09 10:27:37 +11:00
|
|
|
import com.keylesspalace.tusky.entity.Status;
|
2017-03-07 11:31:05 +11:00
|
|
|
import com.squareup.picasso.Picasso;
|
2017-03-08 08:23:17 +11:00
|
|
|
import com.varunest.sparkbutton.SparkButton;
|
|
|
|
import com.varunest.sparkbutton.SparkEventListener;
|
2017-01-23 16:19:30 +11:00
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
2017-02-23 06:13:51 +11:00
|
|
|
class StatusViewHolder extends RecyclerView.ViewHolder {
|
2017-01-23 16:19:30 +11:00
|
|
|
private View container;
|
|
|
|
private TextView displayName;
|
|
|
|
private TextView username;
|
|
|
|
private TextView sinceCreated;
|
|
|
|
private TextView content;
|
2017-03-07 11:31:05 +11:00
|
|
|
private ImageView avatar;
|
2017-02-13 16:18:17 +11:00
|
|
|
private View rebloggedBar;
|
2017-02-17 05:52:55 +11:00
|
|
|
private TextView rebloggedByDisplayName;
|
2017-01-23 16:19:30 +11:00
|
|
|
private ImageButton replyButton;
|
2017-03-08 08:23:17 +11:00
|
|
|
private SparkButton reblogButton;
|
|
|
|
private SparkButton favouriteButton;
|
2017-01-23 16:19:30 +11:00
|
|
|
private ImageButton moreButton;
|
|
|
|
private boolean favourited;
|
|
|
|
private boolean reblogged;
|
2017-03-07 21:59:54 +11:00
|
|
|
private ImageView mediaPreview0;
|
|
|
|
private ImageView mediaPreview1;
|
|
|
|
private ImageView mediaPreview2;
|
|
|
|
private ImageView mediaPreview3;
|
2017-01-23 16:19:30 +11:00
|
|
|
private View sensitiveMediaWarning;
|
2017-02-01 10:42:05 +11:00
|
|
|
private View contentWarningBar;
|
|
|
|
private TextView contentWarningDescription;
|
|
|
|
private ToggleButton contentWarningButton;
|
2017-01-23 16:19:30 +11:00
|
|
|
|
2017-02-23 06:13:51 +11:00
|
|
|
StatusViewHolder(View itemView) {
|
2017-01-23 16:19:30 +11:00
|
|
|
super(itemView);
|
|
|
|
container = itemView.findViewById(R.id.status_container);
|
|
|
|
displayName = (TextView) itemView.findViewById(R.id.status_display_name);
|
|
|
|
username = (TextView) itemView.findViewById(R.id.status_username);
|
|
|
|
sinceCreated = (TextView) itemView.findViewById(R.id.status_since_created);
|
|
|
|
content = (TextView) itemView.findViewById(R.id.status_content);
|
2017-03-07 11:31:05 +11:00
|
|
|
avatar = (ImageView) itemView.findViewById(R.id.status_avatar);
|
2017-02-13 16:18:17 +11:00
|
|
|
rebloggedBar = itemView.findViewById(R.id.status_reblogged_bar);
|
2017-02-17 05:52:55 +11:00
|
|
|
rebloggedByDisplayName = (TextView) itemView.findViewById(R.id.status_reblogged);
|
2017-01-23 16:19:30 +11:00
|
|
|
replyButton = (ImageButton) itemView.findViewById(R.id.status_reply);
|
2017-03-08 08:23:17 +11:00
|
|
|
reblogButton = (SparkButton) itemView.findViewById(R.id.status_reblog);
|
|
|
|
favouriteButton = (SparkButton) itemView.findViewById(R.id.status_favourite);
|
2017-01-23 16:19:30 +11:00
|
|
|
moreButton = (ImageButton) itemView.findViewById(R.id.status_more);
|
|
|
|
reblogged = false;
|
|
|
|
favourited = false;
|
2017-03-07 21:59:54 +11:00
|
|
|
mediaPreview0 = (ImageView) itemView.findViewById(R.id.status_media_preview_0);
|
|
|
|
mediaPreview1 = (ImageView) itemView.findViewById(R.id.status_media_preview_1);
|
|
|
|
mediaPreview2 = (ImageView) itemView.findViewById(R.id.status_media_preview_2);
|
|
|
|
mediaPreview3 = (ImageView) itemView.findViewById(R.id.status_media_preview_3);
|
2017-01-23 16:19:30 +11:00
|
|
|
sensitiveMediaWarning = itemView.findViewById(R.id.status_sensitive_media_warning);
|
2017-02-01 10:42:05 +11:00
|
|
|
contentWarningBar = itemView.findViewById(R.id.status_content_warning_bar);
|
|
|
|
contentWarningDescription =
|
|
|
|
(TextView) itemView.findViewById(R.id.status_content_warning_description);
|
|
|
|
contentWarningButton =
|
|
|
|
(ToggleButton) itemView.findViewById(R.id.status_content_warning_button);
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
|
|
|
|
2017-02-23 06:13:51 +11:00
|
|
|
private void setDisplayName(String name) {
|
2017-01-23 16:19:30 +11:00
|
|
|
displayName.setText(name);
|
|
|
|
}
|
|
|
|
|
2017-03-03 11:25:35 +11:00
|
|
|
private void setUsername(String name) {
|
2017-01-23 16:19:30 +11:00
|
|
|
Context context = username.getContext();
|
|
|
|
String format = context.getString(R.string.status_username_format);
|
|
|
|
String usernameText = String.format(format, name);
|
|
|
|
username.setText(usernameText);
|
|
|
|
}
|
|
|
|
|
2017-02-23 06:13:51 +11:00
|
|
|
private void setContent(Spanned content, Status.Mention[] mentions,
|
2017-01-28 14:33:43 +11:00
|
|
|
final StatusActionListener listener) {
|
2017-02-02 07:20:39 +11:00
|
|
|
/* Redirect URLSpan's in the status content to the listener for viewing tag pages and
|
|
|
|
* account pages. */
|
2017-01-27 11:34:32 +11:00
|
|
|
SpannableStringBuilder builder = new SpannableStringBuilder(content);
|
|
|
|
URLSpan[] urlSpans = content.getSpans(0, content.length(), URLSpan.class);
|
|
|
|
for (URLSpan span : urlSpans) {
|
|
|
|
int start = builder.getSpanStart(span);
|
|
|
|
int end = builder.getSpanEnd(span);
|
|
|
|
int flags = builder.getSpanFlags(span);
|
2017-01-28 14:33:43 +11:00
|
|
|
CharSequence text = builder.subSequence(start, end);
|
|
|
|
if (text.charAt(0) == '#') {
|
|
|
|
final String tag = text.subSequence(1, text.length()).toString();
|
2017-01-27 11:34:32 +11:00
|
|
|
ClickableSpan newSpan = new ClickableSpan() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View widget) {
|
2017-01-28 14:33:43 +11:00
|
|
|
listener.onViewTag(tag);
|
2017-01-27 11:34:32 +11:00
|
|
|
}
|
|
|
|
};
|
|
|
|
builder.removeSpan(span);
|
|
|
|
builder.setSpan(newSpan, start, end, flags);
|
2017-01-28 14:33:43 +11:00
|
|
|
} else if (text.charAt(0) == '@') {
|
|
|
|
final String accountUsername = text.subSequence(1, text.length()).toString();
|
|
|
|
String id = null;
|
|
|
|
for (Status.Mention mention: mentions) {
|
2017-03-09 10:27:37 +11:00
|
|
|
if (mention.username.equals(accountUsername)) {
|
|
|
|
id = mention.id;
|
2017-01-28 14:33:43 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (id != null) {
|
|
|
|
final String accountId = id;
|
|
|
|
ClickableSpan newSpan = new ClickableSpan() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View widget) {
|
2017-03-03 11:25:35 +11:00
|
|
|
listener.onViewAccount(accountId);
|
2017-01-28 14:33:43 +11:00
|
|
|
}
|
|
|
|
};
|
|
|
|
builder.removeSpan(span);
|
|
|
|
builder.setSpan(newSpan, start, end, flags);
|
|
|
|
}
|
2017-01-27 11:34:32 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Set the contents.
|
|
|
|
this.content.setText(builder);
|
|
|
|
// Make links clickable.
|
|
|
|
this.content.setLinksClickable(true);
|
|
|
|
this.content.setMovementMethod(LinkMovementMethod.getInstance());
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
|
|
|
|
2017-02-23 06:13:51 +11:00
|
|
|
private void setAvatar(String url) {
|
2017-01-31 15:51:02 +11:00
|
|
|
if (url.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
2017-01-23 16:19:30 +11:00
|
|
|
Context context = avatar.getContext();
|
2017-03-07 11:31:05 +11:00
|
|
|
Picasso.with(context)
|
|
|
|
.load(url)
|
|
|
|
.placeholder(R.drawable.avatar_default)
|
|
|
|
.error(R.drawable.avatar_error)
|
2017-03-14 02:19:34 +11:00
|
|
|
.transform(new RoundedTransformation(7, 0))
|
2017-03-07 11:31:05 +11:00
|
|
|
.into(avatar);
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
|
|
|
|
2017-02-23 06:13:51 +11:00
|
|
|
private void setCreatedAt(@Nullable Date createdAt) {
|
2017-01-23 16:19:30 +11:00
|
|
|
String readout;
|
|
|
|
if (createdAt != null) {
|
|
|
|
long then = createdAt.getTime();
|
|
|
|
long now = new Date().getTime();
|
|
|
|
readout = DateUtils.getRelativeTimeSpanString(then, now);
|
|
|
|
} else {
|
|
|
|
readout = "?m"; // unknown minutes~
|
|
|
|
}
|
|
|
|
sinceCreated.setText(readout);
|
|
|
|
}
|
|
|
|
|
2017-02-23 06:13:51 +11:00
|
|
|
private void setRebloggedByDisplayName(String name) {
|
2017-02-17 05:52:55 +11:00
|
|
|
Context context = rebloggedByDisplayName.getContext();
|
2017-01-23 16:19:30 +11:00
|
|
|
String format = context.getString(R.string.status_boosted_format);
|
|
|
|
String boostedText = String.format(format, name);
|
2017-02-17 05:52:55 +11:00
|
|
|
rebloggedByDisplayName.setText(boostedText);
|
2017-02-13 16:18:17 +11:00
|
|
|
rebloggedBar.setVisibility(View.VISIBLE);
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
|
|
|
|
2017-02-23 06:13:51 +11:00
|
|
|
private void hideRebloggedByDisplayName() {
|
2017-02-13 16:18:17 +11:00
|
|
|
rebloggedBar.setVisibility(View.GONE);
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
|
|
|
|
2017-02-23 06:13:51 +11:00
|
|
|
private void setReblogged(boolean reblogged) {
|
2017-01-23 16:19:30 +11:00
|
|
|
this.reblogged = reblogged;
|
2017-03-08 08:23:17 +11:00
|
|
|
reblogButton.setChecked(reblogged);
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
|
|
|
|
2017-02-18 15:10:46 +11:00
|
|
|
/** This should only be called after setReblogged, in order to override the tint correctly. */
|
2017-02-23 06:13:51 +11:00
|
|
|
private void setRebloggingEnabled(boolean enabled) {
|
2017-02-13 16:18:17 +11:00
|
|
|
reblogButton.setEnabled(enabled);
|
2017-03-08 08:23:17 +11:00
|
|
|
|
2017-02-18 15:33:10 +11:00
|
|
|
if (enabled) {
|
2017-03-08 15:52:17 +11:00
|
|
|
int inactiveId = ThemeUtils.getDrawableId(reblogButton.getContext(),
|
|
|
|
R.attr.status_reblog_inactive_drawable, R.drawable.reblog_inactive_dark);
|
|
|
|
reblogButton.setInactiveImage(inactiveId);
|
2017-03-08 08:23:17 +11:00
|
|
|
reblogButton.setActiveImage(R.drawable.reblog_active);
|
2017-02-18 15:33:10 +11:00
|
|
|
} else {
|
2017-03-08 15:52:17 +11:00
|
|
|
int disabledId = ThemeUtils.getDrawableId(reblogButton.getContext(),
|
|
|
|
R.attr.status_reblog_disabled_drawable, R.drawable.reblog_disabled_dark);
|
|
|
|
reblogButton.setInactiveImage(disabledId);
|
|
|
|
reblogButton.setActiveImage(disabledId);
|
2017-02-13 16:18:17 +11:00
|
|
|
}
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
|
|
|
|
2017-02-23 06:13:51 +11:00
|
|
|
private void setFavourited(boolean favourited) {
|
2017-01-23 16:19:30 +11:00
|
|
|
this.favourited = favourited;
|
2017-03-08 08:23:17 +11:00
|
|
|
favouriteButton.setChecked(favourited);
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
|
|
|
|
2017-02-23 06:13:51 +11:00
|
|
|
private void setMediaPreviews(final Status.MediaAttachment[] attachments,
|
2017-01-23 16:19:30 +11:00
|
|
|
boolean sensitive, final StatusActionListener listener) {
|
2017-03-07 21:59:54 +11:00
|
|
|
final ImageView[] previews = {
|
2017-01-23 16:19:30 +11:00
|
|
|
mediaPreview0,
|
|
|
|
mediaPreview1,
|
|
|
|
mediaPreview2,
|
|
|
|
mediaPreview3
|
|
|
|
};
|
|
|
|
Context context = mediaPreview0.getContext();
|
2017-03-07 21:59:54 +11:00
|
|
|
|
|
|
|
int mediaPreviewUnloadedId = ThemeUtils.getDrawableId(itemView.getContext(),
|
|
|
|
R.attr.media_preview_unloaded_drawable, android.R.color.black);
|
|
|
|
|
2017-01-23 16:19:30 +11:00
|
|
|
final int n = Math.min(attachments.length, Status.MAX_MEDIA_ATTACHMENTS);
|
2017-03-07 21:59:54 +11:00
|
|
|
|
2017-01-23 16:19:30 +11:00
|
|
|
for (int i = 0; i < n; i++) {
|
2017-03-09 10:27:37 +11:00
|
|
|
String previewUrl = attachments[i].previewUrl;
|
2017-03-07 21:59:54 +11:00
|
|
|
|
|
|
|
previews[i].setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
Picasso.with(context)
|
2017-03-11 04:38:49 +11:00
|
|
|
.load(previewUrl)
|
|
|
|
.placeholder(mediaPreviewUnloadedId)
|
|
|
|
.into(previews[i]);
|
2017-03-07 21:59:54 +11:00
|
|
|
|
2017-03-09 10:27:37 +11:00
|
|
|
final String url = attachments[i].url;
|
|
|
|
final Status.MediaAttachment.Type type = attachments[i].type;
|
2017-03-11 04:38:49 +11:00
|
|
|
|
2017-01-23 16:19:30 +11:00
|
|
|
previews[i].setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
listener.onViewMedia(url, type);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2017-03-07 21:59:54 +11:00
|
|
|
|
2017-01-23 16:19:30 +11:00
|
|
|
if (sensitive) {
|
|
|
|
sensitiveMediaWarning.setVisibility(View.VISIBLE);
|
|
|
|
sensitiveMediaWarning.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
v.setVisibility(View.GONE);
|
|
|
|
v.setOnClickListener(null);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2017-03-07 21:59:54 +11:00
|
|
|
|
2017-01-23 16:19:30 +11:00
|
|
|
// Hide any of the placeholder previews beyond the ones set.
|
|
|
|
for (int i = n; i < Status.MAX_MEDIA_ATTACHMENTS; i++) {
|
|
|
|
previews[i].setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-23 06:13:51 +11:00
|
|
|
private void hideSensitiveMediaWarning() {
|
2017-01-23 16:19:30 +11:00
|
|
|
sensitiveMediaWarning.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
2017-02-23 06:13:51 +11:00
|
|
|
private void setSpoilerText(String spoilerText) {
|
2017-02-01 10:42:05 +11:00
|
|
|
contentWarningDescription.setText(spoilerText);
|
|
|
|
contentWarningBar.setVisibility(View.VISIBLE);
|
|
|
|
content.setVisibility(View.GONE);
|
|
|
|
contentWarningButton.setOnCheckedChangeListener(
|
|
|
|
new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
|
if (isChecked) {
|
|
|
|
content.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
content.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-02-23 06:13:51 +11:00
|
|
|
private void hideSpoilerText() {
|
2017-02-01 20:25:22 +11:00
|
|
|
contentWarningBar.setVisibility(View.GONE);
|
|
|
|
content.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
|
2017-03-03 11:25:35 +11:00
|
|
|
private void setupButtons(final StatusActionListener listener, final String accountId) {
|
2017-03-04 12:44:44 +11:00
|
|
|
/* Originally position was passed through to all these listeners, but it caused several
|
|
|
|
* bugs where other statuses in the list would be removed or added and cause the position
|
|
|
|
* here to become outdated. So, getting the adapter position at the time the listener is
|
|
|
|
* actually called is the appropriate solution. */
|
2017-01-28 14:33:43 +11:00
|
|
|
avatar.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2017-03-03 11:25:35 +11:00
|
|
|
listener.onViewAccount(accountId);
|
2017-01-28 14:33:43 +11:00
|
|
|
}
|
|
|
|
});
|
2017-01-23 16:19:30 +11:00
|
|
|
replyButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2017-03-03 11:25:35 +11:00
|
|
|
listener.onReply(getAdapterPosition());
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
|
|
|
});
|
2017-03-08 08:23:17 +11:00
|
|
|
reblogButton.setEventListener(new SparkEventListener() {
|
2017-01-23 16:19:30 +11:00
|
|
|
@Override
|
2017-03-08 08:23:17 +11:00
|
|
|
public void onEvent(ImageView button, boolean buttonState) {
|
2017-03-03 11:25:35 +11:00
|
|
|
listener.onReblog(!reblogged, getAdapterPosition());
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
|
|
|
});
|
2017-03-08 08:23:17 +11:00
|
|
|
favouriteButton.setEventListener(new SparkEventListener() {
|
2017-01-23 16:19:30 +11:00
|
|
|
@Override
|
2017-03-08 08:23:17 +11:00
|
|
|
public void onEvent(ImageView button, boolean buttonState) {
|
2017-03-03 11:25:35 +11:00
|
|
|
listener.onFavourite(!favourited, getAdapterPosition());
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
|
|
|
});
|
|
|
|
moreButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2017-03-03 11:25:35 +11:00
|
|
|
listener.onMore(v, getAdapterPosition());
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
|
|
|
});
|
2017-01-28 14:33:43 +11:00
|
|
|
/* Even though the content TextView is a child of the container, it won't respond to clicks
|
|
|
|
* if it contains URLSpans without also setting its listener. The surrounding spans will
|
|
|
|
* just eat the clicks instead of deferring to the parent listener, but WILL respond to a
|
|
|
|
* listener directly on the TextView, for whatever reason. */
|
|
|
|
View.OnClickListener viewThreadListener = new View.OnClickListener() {
|
2017-01-23 16:19:30 +11:00
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2017-03-03 11:25:35 +11:00
|
|
|
listener.onViewThread(getAdapterPosition());
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
2017-01-28 14:33:43 +11:00
|
|
|
};
|
|
|
|
content.setOnClickListener(viewThreadListener);
|
|
|
|
container.setOnClickListener(viewThreadListener);
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
|
|
|
|
2017-03-08 15:52:17 +11:00
|
|
|
void setupWithStatus(Status status, StatusActionListener listener) {
|
2017-03-09 10:27:37 +11:00
|
|
|
Status realStatus = status.getActionableStatus();
|
|
|
|
|
2017-03-11 09:31:08 +11:00
|
|
|
setDisplayName(realStatus.account.getDisplayName());
|
2017-03-09 10:27:37 +11:00
|
|
|
setUsername(realStatus.account.username);
|
|
|
|
setCreatedAt(realStatus.createdAt);
|
|
|
|
setContent(realStatus.content, realStatus.mentions, listener);
|
|
|
|
setAvatar(realStatus.account.avatar);
|
|
|
|
setReblogged(realStatus.reblogged);
|
|
|
|
setFavourited(realStatus.favourited);
|
2017-03-11 09:31:08 +11:00
|
|
|
String rebloggedByDisplayName = status.account.getDisplayName();
|
2017-03-09 10:27:37 +11:00
|
|
|
if (status.reblog == null) {
|
2017-02-17 05:52:55 +11:00
|
|
|
hideRebloggedByDisplayName();
|
2017-01-23 16:19:30 +11:00
|
|
|
} else {
|
2017-02-17 05:52:55 +11:00
|
|
|
setRebloggedByDisplayName(rebloggedByDisplayName);
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
2017-03-09 10:27:37 +11:00
|
|
|
Status.MediaAttachment[] attachments = realStatus.attachments;
|
|
|
|
boolean sensitive = realStatus.sensitive;
|
2017-01-23 16:19:30 +11:00
|
|
|
setMediaPreviews(attachments, sensitive, listener);
|
|
|
|
/* A status without attachments is sometimes still marked sensitive, so it's necessary to
|
|
|
|
* check both whether there are any attachments and if it's marked sensitive. */
|
|
|
|
if (!sensitive || attachments.length == 0) {
|
|
|
|
hideSensitiveMediaWarning();
|
|
|
|
}
|
2017-03-09 10:27:37 +11:00
|
|
|
setupButtons(listener, realStatus.account.id);
|
|
|
|
setRebloggingEnabled(realStatus.visibility != Status.Visibility.PRIVATE);
|
|
|
|
if (realStatus.spoilerText.isEmpty()) {
|
2017-02-01 20:25:22 +11:00
|
|
|
hideSpoilerText();
|
|
|
|
} else {
|
2017-03-09 10:27:37 +11:00
|
|
|
setSpoilerText(realStatus.spoilerText);
|
2017-02-01 10:42:05 +11:00
|
|
|
}
|
2017-01-23 16:19:30 +11:00
|
|
|
}
|
|
|
|
}
|