Adds ability to page between multiple images in a status by swiping from left to right. Closes #66

This commit is contained in:
Vavassor 2017-06-25 01:07:41 -04:00
commit e3745ebd6b
15 changed files with 361 additions and 147 deletions

View file

@ -202,6 +202,11 @@ class StatusViewHolder extends RecyclerView.ViewHolder {
final int n = Math.min(attachments.length, Status.MAX_MEDIA_ATTACHMENTS);
final String[] urls = new String[n];
for (int i = 0; i < n; i++) {
urls[i] = attachments[i].url;
}
for (int i = 0; i < n; i++) {
String previewUrl = attachments[i].previewUrl;
@ -218,16 +223,15 @@ class StatusViewHolder extends RecyclerView.ViewHolder {
.into(previews[i]);
}
final String url = attachments[i].url;
final Status.MediaAttachment.Type type = attachments[i].type;
if(url == null || url.isEmpty()) {
if (urls[i] == null || urls[i].isEmpty()) {
previews[i].setOnClickListener(null);
} else {
final int urlIndex = i;
final Status.MediaAttachment.Type type = attachments[i].type;
previews[i].setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onViewMedia(url, type);
listener.onViewMedia(urls, urlIndex, type);
}
});
}