blob: 5d3d296328e37cb02a170ae2c9ae505007bd2092 (
plain)
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
|
package it.niedermann.owncloud.notes.shared.account;
import android.net.Uri;
import androidx.core.util.Consumer;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import it.niedermann.nextcloud.sso.glide.SingleSignOnUrl;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.databinding.ItemAccountChooseBinding;
import it.niedermann.owncloud.notes.persistence.entity.Account;
public class AccountChooserViewHolder extends RecyclerView.ViewHolder {
private final ItemAccountChooseBinding binding;
protected AccountChooserViewHolder(ItemAccountChooseBinding binding) {
super(binding.getRoot());
this.binding = binding;
}
public void bind(Account localAccount, Consumer<Account> targetAccountConsumer) {
Glide
.with(binding.accountItemAvatar.getContext())
.load(new SingleSignOnUrl(localAccount.getAccountName(), localAccount.getUrl() + "/index.php/avatar/" + Uri.encode(localAccount.getUserName()) + "/64"))
.placeholder(R.drawable.ic_account_circle_grey_24dp)
.error(R.drawable.ic_account_circle_grey_24dp)
.apply(RequestOptions.circleCropTransform())
.into(binding.accountItemAvatar);
binding.accountLayout.setOnClickListener((v) -> targetAccountConsumer.accept(localAccount));
binding.accountName.setText(localAccount.getDisplayName());
binding.accountHost.setText(Uri.parse(localAccount.getUrl()).getHost());
}
}
|