fixes crash when media url is empty
This commit is contained in:
parent
a33c259760
commit
2e3d8b8cae
1 changed files with 24 additions and 12 deletions
|
@ -102,7 +102,7 @@ class StatusViewHolder extends RecyclerView.ViewHolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setContent(Spanned content, Status.Mention[] mentions,
|
private void setContent(Spanned content, Status.Mention[] mentions,
|
||||||
final StatusActionListener listener) {
|
final StatusActionListener listener) {
|
||||||
/* Redirect URLSpan's in the status content to the listener for viewing tag pages and
|
/* Redirect URLSpan's in the status content to the listener for viewing tag pages and
|
||||||
* account pages. */
|
* account pages. */
|
||||||
SpannableStringBuilder builder = new SpannableStringBuilder(content);
|
SpannableStringBuilder builder = new SpannableStringBuilder(content);
|
||||||
|
@ -230,7 +230,7 @@ class StatusViewHolder extends RecyclerView.ViewHolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMediaPreviews(final Status.MediaAttachment[] attachments,
|
private void setMediaPreviews(final Status.MediaAttachment[] attachments,
|
||||||
boolean sensitive, final StatusActionListener listener) {
|
boolean sensitive, final StatusActionListener listener) {
|
||||||
final ImageView[] previews = {
|
final ImageView[] previews = {
|
||||||
mediaPreview0,
|
mediaPreview0,
|
||||||
mediaPreview1,
|
mediaPreview1,
|
||||||
|
@ -249,20 +249,32 @@ class StatusViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
previews[i].setVisibility(View.VISIBLE);
|
previews[i].setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
Picasso.with(context)
|
if(previewUrl == null || previewUrl.isEmpty()) {
|
||||||
.load(previewUrl)
|
Picasso.with(context)
|
||||||
.placeholder(mediaPreviewUnloadedId)
|
.load(mediaPreviewUnloadedId)
|
||||||
.into(previews[i]);
|
.into(previews[i]);
|
||||||
|
} else {
|
||||||
|
Picasso.with(context)
|
||||||
|
.load(previewUrl)
|
||||||
|
.placeholder(mediaPreviewUnloadedId)
|
||||||
|
.into(previews[i]);
|
||||||
|
}
|
||||||
|
|
||||||
final String url = attachments[i].url;
|
final String url = attachments[i].url;
|
||||||
final Status.MediaAttachment.Type type = attachments[i].type;
|
final Status.MediaAttachment.Type type = attachments[i].type;
|
||||||
|
|
||||||
previews[i].setOnClickListener(new View.OnClickListener() {
|
if(url == null || url.isEmpty()) {
|
||||||
@Override
|
previews[i].setOnClickListener(null);
|
||||||
public void onClick(View v) {
|
} else {
|
||||||
listener.onViewMedia(url, type);
|
previews[i].setOnClickListener(new View.OnClickListener() {
|
||||||
}
|
@Override
|
||||||
});
|
public void onClick(View v) {
|
||||||
|
listener.onViewMedia(url, type);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sensitive) {
|
if (sensitive) {
|
||||||
|
|
Loading…
Reference in a new issue