Welcome to mirror list, hosted at ThFree Co, Russian Federation.

AccountChooserAdapter.java « account « shared « notes « owncloud « niedermann « it « java « main « src « app - github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6804ee6214b532d4f47476a294c3e2f6b7121f90 (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
38
39
40
41
42
43
44
package it.niedermann.owncloud.notes.shared.account;

import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.core.util.Consumer;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

import it.niedermann.owncloud.notes.databinding.ItemAccountChooseBinding;
import it.niedermann.owncloud.notes.persistence.entity.Account;

public class AccountChooserAdapter extends RecyclerView.Adapter<AccountChooserViewHolder> {

    @NonNull
    private final List<Account> localAccounts;
    @NonNull
    private final Consumer<Account> targetAccountConsumer;

    public AccountChooserAdapter(@NonNull List<Account> localAccounts, @NonNull Consumer<Account> targetAccountConsumer) {
        super();
        this.localAccounts = localAccounts;
        this.targetAccountConsumer = targetAccountConsumer;
    }

    @NonNull
    @Override
    public AccountChooserViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new AccountChooserViewHolder(ItemAccountChooseBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull AccountChooserViewHolder holder, int position) {
        holder.bind(localAccounts.get(position), targetAccountConsumer);
    }

    @Override
    public int getItemCount() {
        return localAccounts.size();
    }

}