1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
package it.niedermann.nextcloud.deck.ui.card.attachments;
import android.view.MenuInflater;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentManager;
import com.bumptech.glide.Glide;
import it.niedermann.nextcloud.deck.R;
import it.niedermann.nextcloud.deck.databinding.ItemAttachmentImageBinding;
import it.niedermann.nextcloud.deck.model.Account;
import it.niedermann.nextcloud.deck.model.Attachment;
import it.niedermann.nextcloud.deck.util.AttachmentUtil;
public class ImageAttachmentViewHolder extends AttachmentViewHolder {
private final ItemAttachmentImageBinding binding;
@SuppressWarnings("WeakerAccess")
public ImageAttachmentViewHolder(ItemAttachmentImageBinding binding) {
super(binding.getRoot());
this.binding = binding;
}
@Override
protected ImageView getPreview() {
return binding.preview;
}
@Override
protected ImageView getNotSyncedYetStatusIcon() {
return binding.notSyncedYet;
}
public void bind(@NonNull Account account, @NonNull MenuInflater menuInflater, @NonNull FragmentManager fragmentManager, Long cardRemoteId, Attachment attachment, @Nullable View.OnClickListener onClickListener, @ColorInt int mainColor) {
final String downloadUrl = (attachment.getId() == null || cardRemoteId == null)
? attachment.getLocalPath()
: AttachmentUtil.getCopyDownloadUrl(account, cardRemoteId, attachment);
super.bind(menuInflater, fragmentManager, cardRemoteId, attachment, onClickListener, mainColor, downloadUrl);
getPreview().post(() -> {
@Nullable final String uri = AttachmentUtil.getThumbnailUrl(account, cardRemoteId, attachment, getPreview().getWidth());
Glide.with(getPreview().getContext())
.load(uri)
.placeholder(R.drawable.ic_image_grey600_24dp)
.error(R.drawable.ic_image_grey600_24dp)
.into(getPreview());
});
itemView.setOnClickListener(onClickListener);
}
}
|