|
|
@ -44,7 +44,6 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
private static final InputFilter[] COLLAPSE_INPUT_FILTER = new InputFilter[] { SmartLengthInputFilter.INSTANCE }; |
|
|
|
private static final InputFilter[] COLLAPSE_INPUT_FILTER = new InputFilter[] { SmartLengthInputFilter.INSTANCE }; |
|
|
|
private static final InputFilter[] NO_INPUT_FILTER = new InputFilter[0]; |
|
|
|
private static final InputFilter[] NO_INPUT_FILTER = new InputFilter[0]; |
|
|
|
|
|
|
|
|
|
|
|
private View container; |
|
|
|
|
|
|
|
private TextView displayName; |
|
|
|
private TextView displayName; |
|
|
|
private TextView username; |
|
|
|
private TextView username; |
|
|
|
private ImageButton replyButton; |
|
|
|
private ImageButton replyButton; |
|
|
@ -53,14 +52,8 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
private ImageButton moreButton; |
|
|
|
private ImageButton moreButton; |
|
|
|
private boolean favourited; |
|
|
|
private boolean favourited; |
|
|
|
private boolean reblogged; |
|
|
|
private boolean reblogged; |
|
|
|
private ImageView mediaPreview0; |
|
|
|
private ImageView[] mediaPreviews; |
|
|
|
private ImageView mediaPreview1; |
|
|
|
private ImageView[] mediaOverlays; |
|
|
|
private ImageView mediaPreview2; |
|
|
|
|
|
|
|
private ImageView mediaPreview3; |
|
|
|
|
|
|
|
private ImageView mediaOverlay0; |
|
|
|
|
|
|
|
private ImageView mediaOverlay1; |
|
|
|
|
|
|
|
private ImageView mediaOverlay2; |
|
|
|
|
|
|
|
private ImageView mediaOverlay3; |
|
|
|
|
|
|
|
private TextView sensitiveMediaWarning; |
|
|
|
private TextView sensitiveMediaWarning; |
|
|
|
private View sensitiveMediaShow; |
|
|
|
private View sensitiveMediaShow; |
|
|
|
private TextView mediaLabel; |
|
|
|
private TextView mediaLabel; |
|
|
@ -78,7 +71,6 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
|
|
|
|
|
|
|
StatusBaseViewHolder(View itemView, boolean useAbsoluteTime) { |
|
|
|
StatusBaseViewHolder(View itemView, boolean useAbsoluteTime) { |
|
|
|
super(itemView); |
|
|
|
super(itemView); |
|
|
|
container = itemView.findViewById(R.id.status_container); |
|
|
|
|
|
|
|
displayName = itemView.findViewById(R.id.status_display_name); |
|
|
|
displayName = itemView.findViewById(R.id.status_display_name); |
|
|
|
username = itemView.findViewById(R.id.status_username); |
|
|
|
username = itemView.findViewById(R.id.status_username); |
|
|
|
timestampInfo = itemView.findViewById(R.id.status_timestamp_info); |
|
|
|
timestampInfo = itemView.findViewById(R.id.status_timestamp_info); |
|
|
@ -90,14 +82,18 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
moreButton = itemView.findViewById(R.id.status_more); |
|
|
|
moreButton = itemView.findViewById(R.id.status_more); |
|
|
|
reblogged = false; |
|
|
|
reblogged = false; |
|
|
|
favourited = false; |
|
|
|
favourited = false; |
|
|
|
mediaPreview0 = itemView.findViewById(R.id.status_media_preview_0); |
|
|
|
mediaPreviews = new ImageView[] { |
|
|
|
mediaPreview1 = itemView.findViewById(R.id.status_media_preview_1); |
|
|
|
itemView.findViewById(R.id.status_media_preview_0), |
|
|
|
mediaPreview2 = itemView.findViewById(R.id.status_media_preview_2); |
|
|
|
itemView.findViewById(R.id.status_media_preview_1), |
|
|
|
mediaPreview3 = itemView.findViewById(R.id.status_media_preview_3); |
|
|
|
itemView.findViewById(R.id.status_media_preview_2), |
|
|
|
mediaOverlay0 = itemView.findViewById(R.id.status_media_overlay_0); |
|
|
|
itemView.findViewById(R.id.status_media_preview_3) |
|
|
|
mediaOverlay1 = itemView.findViewById(R.id.status_media_overlay_1); |
|
|
|
}; |
|
|
|
mediaOverlay2 = itemView.findViewById(R.id.status_media_overlay_2); |
|
|
|
mediaOverlays =new ImageView[] { |
|
|
|
mediaOverlay3 = itemView.findViewById(R.id.status_media_overlay_3); |
|
|
|
itemView.findViewById(R.id.status_media_overlay_0), |
|
|
|
|
|
|
|
itemView.findViewById(R.id.status_media_overlay_1), |
|
|
|
|
|
|
|
itemView.findViewById(R.id.status_media_overlay_2), |
|
|
|
|
|
|
|
itemView.findViewById(R.id.status_media_overlay_3) |
|
|
|
|
|
|
|
}; |
|
|
|
sensitiveMediaWarning = itemView.findViewById(R.id.status_sensitive_media_warning); |
|
|
|
sensitiveMediaWarning = itemView.findViewById(R.id.status_sensitive_media_warning); |
|
|
|
sensitiveMediaShow = itemView.findViewById(R.id.status_sensitive_media_button); |
|
|
|
sensitiveMediaShow = itemView.findViewById(R.id.status_sensitive_media_button); |
|
|
|
mediaLabel = itemView.findViewById(R.id.status_media_label); |
|
|
|
mediaLabel = itemView.findViewById(R.id.status_media_label); |
|
|
@ -180,11 +176,11 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
|
|
|
|
|
|
|
protected void showContent(boolean show) { |
|
|
|
protected void showContent(boolean show) { |
|
|
|
if (show) { |
|
|
|
if (show) { |
|
|
|
container.setVisibility(View.VISIBLE); |
|
|
|
itemView.setVisibility(View.VISIBLE); |
|
|
|
container.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; |
|
|
|
itemView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
container.setVisibility(View.INVISIBLE); |
|
|
|
itemView.setVisibility(View.INVISIBLE); |
|
|
|
container.getLayoutParams().height = Utils.convertDpToPx(container.getContext(), 24); |
|
|
|
itemView.getLayoutParams().height = Utils.convertDpToPx(itemView.getContext(), 24); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -241,13 +237,8 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
|
|
|
|
|
|
|
private void setMediaPreviews(final List<Attachment> attachments, boolean sensitive, |
|
|
|
private void setMediaPreviews(final List<Attachment> attachments, boolean sensitive, |
|
|
|
final StatusActionListener listener, boolean showingContent) { |
|
|
|
final StatusActionListener listener, boolean showingContent) { |
|
|
|
final ImageView[] previews = { |
|
|
|
|
|
|
|
mediaPreview0, mediaPreview1, mediaPreview2, mediaPreview3 |
|
|
|
Context context = itemView.getContext(); |
|
|
|
}; |
|
|
|
|
|
|
|
final ImageView[] overlays = { |
|
|
|
|
|
|
|
mediaOverlay0, mediaOverlay1, mediaOverlay2, mediaOverlay3 |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
Context context = mediaPreview0.getContext(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int mediaPreviewUnloadedId = |
|
|
|
int mediaPreviewUnloadedId = |
|
|
|
ThemeUtils.getDrawableId(itemView.getContext(), R.attr.media_preview_unloaded_drawable, |
|
|
|
ThemeUtils.getDrawableId(itemView.getContext(), R.attr.media_preview_unloaded_drawable, |
|
|
@ -260,46 +251,46 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
String description = attachments.get(i).getDescription(); |
|
|
|
String description = attachments.get(i).getDescription(); |
|
|
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(description)) { |
|
|
|
if (TextUtils.isEmpty(description)) { |
|
|
|
previews[i].setContentDescription(context.getString(R.string.action_view_media)); |
|
|
|
mediaPreviews[i].setContentDescription(context.getString(R.string.action_view_media)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
previews[i].setContentDescription(description); |
|
|
|
mediaPreviews[i].setContentDescription(description); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
previews[i].setVisibility(View.VISIBLE); |
|
|
|
mediaPreviews[i].setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(previewUrl)) { |
|
|
|
if (TextUtils.isEmpty(previewUrl)) { |
|
|
|
Picasso.with(context) |
|
|
|
Picasso.with(context) |
|
|
|
.load(mediaPreviewUnloadedId) |
|
|
|
.load(mediaPreviewUnloadedId) |
|
|
|
.into(previews[i]); |
|
|
|
.into(mediaPreviews[i]); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Picasso.with(context) |
|
|
|
Picasso.with(context) |
|
|
|
.load(previewUrl) |
|
|
|
.load(previewUrl) |
|
|
|
.placeholder(mediaPreviewUnloadedId) |
|
|
|
.placeholder(mediaPreviewUnloadedId) |
|
|
|
.into(previews[i]); |
|
|
|
.into(mediaPreviews[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final Attachment.Type type = attachments.get(i).getType(); |
|
|
|
final Attachment.Type type = attachments.get(i).getType(); |
|
|
|
if (type == Attachment.Type.VIDEO | type == Attachment.Type.GIFV) { |
|
|
|
if (type == Attachment.Type.VIDEO | type == Attachment.Type.GIFV) { |
|
|
|
overlays[i].setVisibility(View.VISIBLE); |
|
|
|
mediaOverlays[i].setVisibility(View.VISIBLE); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
overlays[i].setVisibility(View.GONE); |
|
|
|
mediaOverlays[i].setVisibility(View.GONE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final int urlIndex = i; |
|
|
|
final int urlIndex = i; |
|
|
|
previews[i].setOnClickListener(v -> { |
|
|
|
mediaPreviews[i].setOnClickListener(v -> { |
|
|
|
if (getAdapterPosition() != RecyclerView.NO_POSITION) { |
|
|
|
if (getAdapterPosition() != RecyclerView.NO_POSITION) { |
|
|
|
listener.onViewMedia(getAdapterPosition(), urlIndex, v); |
|
|
|
listener.onViewMedia(getAdapterPosition(), urlIndex, v); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (n <= 2) { |
|
|
|
if (n <= 2) { |
|
|
|
previews[0].getLayoutParams().height = getMediaPreviewHeight(context) * 2; |
|
|
|
mediaPreviews[0].getLayoutParams().height = getMediaPreviewHeight(context) * 2; |
|
|
|
previews[1].getLayoutParams().height = getMediaPreviewHeight(context) * 2; |
|
|
|
mediaPreviews[1].getLayoutParams().height = getMediaPreviewHeight(context) * 2; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
previews[0].getLayoutParams().height = getMediaPreviewHeight(context); |
|
|
|
mediaPreviews[0].getLayoutParams().height = getMediaPreviewHeight(context); |
|
|
|
previews[1].getLayoutParams().height = getMediaPreviewHeight(context); |
|
|
|
mediaPreviews[1].getLayoutParams().height = getMediaPreviewHeight(context); |
|
|
|
previews[2].getLayoutParams().height = getMediaPreviewHeight(context); |
|
|
|
mediaPreviews[2].getLayoutParams().height = getMediaPreviewHeight(context); |
|
|
|
previews[3].getLayoutParams().height = getMediaPreviewHeight(context); |
|
|
|
mediaPreviews[3].getLayoutParams().height = getMediaPreviewHeight(context); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -336,7 +327,7 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
|
|
|
|
|
|
|
// Hide any of the placeholder previews beyond the ones set.
|
|
|
|
// Hide any of the placeholder previews beyond the ones set.
|
|
|
|
for (int i = n; i < Status.MAX_MEDIA_ATTACHMENTS; i++) { |
|
|
|
for (int i = n; i < Status.MAX_MEDIA_ATTACHMENTS; i++) { |
|
|
|
previews[i].setVisibility(View.GONE); |
|
|
|
mediaPreviews[i].setVisibility(View.GONE); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -408,17 +399,11 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
if (getAdapterPosition() != RecyclerView.NO_POSITION) { |
|
|
|
if (getAdapterPosition() != RecyclerView.NO_POSITION) { |
|
|
|
listener.onExpandedChange(isChecked, getAdapterPosition()); |
|
|
|
listener.onExpandedChange(isChecked, getAdapterPosition()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (isChecked) { |
|
|
|
content.setVisibility(isChecked ? View.VISIBLE : View.GONE); |
|
|
|
content.setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
content.setVisibility(View.GONE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
if (expanded) { |
|
|
|
content.setVisibility(expanded ? View.VISIBLE : View.GONE); |
|
|
|
content.setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
content.setVisibility(View.GONE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void hideSpoilerText() { |
|
|
|
private void hideSpoilerText() { |
|
|
@ -490,7 +475,7 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
content.setOnClickListener(viewThreadListener); |
|
|
|
content.setOnClickListener(viewThreadListener); |
|
|
|
container.setOnClickListener(viewThreadListener); |
|
|
|
itemView.setOnClickListener(viewThreadListener); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void setupWithStatus(StatusViewData.Concrete status, final StatusActionListener listener, |
|
|
|
void setupWithStatus(StatusViewData.Concrete status, final StatusActionListener listener, |
|
|
@ -515,10 +500,10 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
setMediaLabel(attachments, sensitive, listener); |
|
|
|
setMediaLabel(attachments, sensitive, listener); |
|
|
|
// Hide all unused views.
|
|
|
|
// Hide all unused views.
|
|
|
|
mediaPreview0.setVisibility(View.GONE); |
|
|
|
mediaPreviews[0].setVisibility(View.GONE); |
|
|
|
mediaPreview1.setVisibility(View.GONE); |
|
|
|
mediaPreviews[1].setVisibility(View.GONE); |
|
|
|
mediaPreview2.setVisibility(View.GONE); |
|
|
|
mediaPreviews[2].setVisibility(View.GONE); |
|
|
|
mediaPreview3.setVisibility(View.GONE); |
|
|
|
mediaPreviews[3].setVisibility(View.GONE); |
|
|
|
hideSensitiveMediaWarning(); |
|
|
|
hideSensitiveMediaWarning(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|