|
|
|
@ -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[] NO_INPUT_FILTER = new InputFilter[0]; |
|
|
|
|
|
|
|
|
|
private View container; |
|
|
|
|
private TextView displayName; |
|
|
|
|
private TextView username; |
|
|
|
|
private ImageButton replyButton; |
|
|
|
@ -53,14 +52,8 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
private ImageButton moreButton; |
|
|
|
|
private boolean favourited; |
|
|
|
|
private boolean reblogged; |
|
|
|
|
private ImageView mediaPreview0; |
|
|
|
|
private ImageView mediaPreview1; |
|
|
|
|
private ImageView mediaPreview2; |
|
|
|
|
private ImageView mediaPreview3; |
|
|
|
|
private ImageView mediaOverlay0; |
|
|
|
|
private ImageView mediaOverlay1; |
|
|
|
|
private ImageView mediaOverlay2; |
|
|
|
|
private ImageView mediaOverlay3; |
|
|
|
|
private ImageView[] mediaPreviews; |
|
|
|
|
private ImageView[] mediaOverlays; |
|
|
|
|
private TextView sensitiveMediaWarning; |
|
|
|
|
private View sensitiveMediaShow; |
|
|
|
|
private TextView mediaLabel; |
|
|
|
@ -78,7 +71,6 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
|
|
|
|
|
StatusBaseViewHolder(View itemView, boolean useAbsoluteTime) { |
|
|
|
|
super(itemView); |
|
|
|
|
container = itemView.findViewById(R.id.status_container); |
|
|
|
|
displayName = itemView.findViewById(R.id.status_display_name); |
|
|
|
|
username = itemView.findViewById(R.id.status_username); |
|
|
|
|
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); |
|
|
|
|
reblogged = false; |
|
|
|
|
favourited = false; |
|
|
|
|
mediaPreview0 = itemView.findViewById(R.id.status_media_preview_0); |
|
|
|
|
mediaPreview1 = itemView.findViewById(R.id.status_media_preview_1); |
|
|
|
|
mediaPreview2 = itemView.findViewById(R.id.status_media_preview_2); |
|
|
|
|
mediaPreview3 = itemView.findViewById(R.id.status_media_preview_3); |
|
|
|
|
mediaOverlay0 = itemView.findViewById(R.id.status_media_overlay_0); |
|
|
|
|
mediaOverlay1 = itemView.findViewById(R.id.status_media_overlay_1); |
|
|
|
|
mediaOverlay2 = itemView.findViewById(R.id.status_media_overlay_2); |
|
|
|
|
mediaOverlay3 = itemView.findViewById(R.id.status_media_overlay_3); |
|
|
|
|
mediaPreviews = new ImageView[] { |
|
|
|
|
itemView.findViewById(R.id.status_media_preview_0), |
|
|
|
|
itemView.findViewById(R.id.status_media_preview_1), |
|
|
|
|
itemView.findViewById(R.id.status_media_preview_2), |
|
|
|
|
itemView.findViewById(R.id.status_media_preview_3) |
|
|
|
|
}; |
|
|
|
|
mediaOverlays =new ImageView[] { |
|
|
|
|
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); |
|
|
|
|
sensitiveMediaShow = itemView.findViewById(R.id.status_sensitive_media_button); |
|
|
|
|
mediaLabel = itemView.findViewById(R.id.status_media_label); |
|
|
|
@ -180,11 +176,11 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
|
|
|
|
|
protected void showContent(boolean show) { |
|
|
|
|
if (show) { |
|
|
|
|
container.setVisibility(View.VISIBLE); |
|
|
|
|
container.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; |
|
|
|
|
itemView.setVisibility(View.VISIBLE); |
|
|
|
|
itemView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; |
|
|
|
|
} else { |
|
|
|
|
container.setVisibility(View.INVISIBLE); |
|
|
|
|
container.getLayoutParams().height = Utils.convertDpToPx(container.getContext(), 24); |
|
|
|
|
itemView.setVisibility(View.INVISIBLE); |
|
|
|
|
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, |
|
|
|
|
final StatusActionListener listener, boolean showingContent) { |
|
|
|
|
final ImageView[] previews = { |
|
|
|
|
mediaPreview0, mediaPreview1, mediaPreview2, mediaPreview3 |
|
|
|
|
}; |
|
|
|
|
final ImageView[] overlays = { |
|
|
|
|
mediaOverlay0, mediaOverlay1, mediaOverlay2, mediaOverlay3 |
|
|
|
|
}; |
|
|
|
|
Context context = mediaPreview0.getContext(); |
|
|
|
|
|
|
|
|
|
Context context = itemView.getContext(); |
|
|
|
|
|
|
|
|
|
int mediaPreviewUnloadedId = |
|
|
|
|
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(); |
|
|
|
|
|
|
|
|
|
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 { |
|
|
|
|
previews[i].setContentDescription(description); |
|
|
|
|
mediaPreviews[i].setContentDescription(description); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
previews[i].setVisibility(View.VISIBLE); |
|
|
|
|
mediaPreviews[i].setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(previewUrl)) { |
|
|
|
|
Picasso.with(context) |
|
|
|
|
.load(mediaPreviewUnloadedId) |
|
|
|
|
.into(previews[i]); |
|
|
|
|
.into(mediaPreviews[i]); |
|
|
|
|
} else { |
|
|
|
|
Picasso.with(context) |
|
|
|
|
.load(previewUrl) |
|
|
|
|
.placeholder(mediaPreviewUnloadedId) |
|
|
|
|
.into(previews[i]); |
|
|
|
|
.into(mediaPreviews[i]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
final Attachment.Type type = attachments.get(i).getType(); |
|
|
|
|
if (type == Attachment.Type.VIDEO | type == Attachment.Type.GIFV) { |
|
|
|
|
overlays[i].setVisibility(View.VISIBLE); |
|
|
|
|
mediaOverlays[i].setVisibility(View.VISIBLE); |
|
|
|
|
} else { |
|
|
|
|
overlays[i].setVisibility(View.GONE); |
|
|
|
|
mediaOverlays[i].setVisibility(View.GONE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
final int urlIndex = i; |
|
|
|
|
previews[i].setOnClickListener(v -> { |
|
|
|
|
mediaPreviews[i].setOnClickListener(v -> { |
|
|
|
|
if (getAdapterPosition() != RecyclerView.NO_POSITION) { |
|
|
|
|
listener.onViewMedia(getAdapterPosition(), urlIndex, v); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (n <= 2) { |
|
|
|
|
previews[0].getLayoutParams().height = getMediaPreviewHeight(context) * 2; |
|
|
|
|
previews[1].getLayoutParams().height = getMediaPreviewHeight(context) * 2; |
|
|
|
|
mediaPreviews[0].getLayoutParams().height = getMediaPreviewHeight(context) * 2; |
|
|
|
|
mediaPreviews[1].getLayoutParams().height = getMediaPreviewHeight(context) * 2; |
|
|
|
|
} else { |
|
|
|
|
previews[0].getLayoutParams().height = getMediaPreviewHeight(context); |
|
|
|
|
previews[1].getLayoutParams().height = getMediaPreviewHeight(context); |
|
|
|
|
previews[2].getLayoutParams().height = getMediaPreviewHeight(context); |
|
|
|
|
previews[3].getLayoutParams().height = getMediaPreviewHeight(context); |
|
|
|
|
mediaPreviews[0].getLayoutParams().height = getMediaPreviewHeight(context); |
|
|
|
|
mediaPreviews[1].getLayoutParams().height = getMediaPreviewHeight(context); |
|
|
|
|
mediaPreviews[2].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.
|
|
|
|
|
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) { |
|
|
|
|
listener.onExpandedChange(isChecked, getAdapterPosition()); |
|
|
|
|
} |
|
|
|
|
if (isChecked) { |
|
|
|
|
content.setVisibility(View.VISIBLE); |
|
|
|
|
} else { |
|
|
|
|
content.setVisibility(View.GONE); |
|
|
|
|
} |
|
|
|
|
content.setVisibility(isChecked ? View.VISIBLE : View.GONE); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
if (expanded) { |
|
|
|
|
content.setVisibility(View.VISIBLE); |
|
|
|
|
} else { |
|
|
|
|
content.setVisibility(View.GONE); |
|
|
|
|
} |
|
|
|
|
content.setVisibility(expanded ? View.VISIBLE : View.GONE); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void hideSpoilerText() { |
|
|
|
@ -490,7 +475,7 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
content.setOnClickListener(viewThreadListener); |
|
|
|
|
container.setOnClickListener(viewThreadListener); |
|
|
|
|
itemView.setOnClickListener(viewThreadListener); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void setupWithStatus(StatusViewData.Concrete status, final StatusActionListener listener, |
|
|
|
@ -515,10 +500,10 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { |
|
|
|
|
} else { |
|
|
|
|
setMediaLabel(attachments, sensitive, listener); |
|
|
|
|
// Hide all unused views.
|
|
|
|
|
mediaPreview0.setVisibility(View.GONE); |
|
|
|
|
mediaPreview1.setVisibility(View.GONE); |
|
|
|
|
mediaPreview2.setVisibility(View.GONE); |
|
|
|
|
mediaPreview3.setVisibility(View.GONE); |
|
|
|
|
mediaPreviews[0].setVisibility(View.GONE); |
|
|
|
|
mediaPreviews[1].setVisibility(View.GONE); |
|
|
|
|
mediaPreviews[2].setVisibility(View.GONE); |
|
|
|
|
mediaPreviews[3].setVisibility(View.GONE); |
|
|
|
|
hideSensitiveMediaWarning(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|