mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
イベントリスナに対応した実装を作成 WIP
This commit is contained in:
parent
a815d3b1b4
commit
03d78b1200
|
@ -23,7 +23,10 @@ public class LacertaSelectDirDialog extends DialogFragment {
|
|||
RecyclerView recyclerView = view.findViewById(R.id.select_dir_recycler_view);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
|
||||
SelectDirDialogItemAdapter adapter = new SelectDirDialogItemAdapter();
|
||||
SelectDirDialogItemAdapter adapter = new SelectDirDialogItemAdapter((name, itemId) -> {
|
||||
Toast.makeText(getContext(), "Called", Toast.LENGTH_SHORT).show();
|
||||
dismiss();
|
||||
});
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setLayoutManager(new androidx.recyclerview.widget.LinearLayoutManager(getContext()));
|
||||
|
||||
|
|
|
@ -8,8 +8,23 @@ import android.widget.TextView;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import one.nem.lacerta.model.ListItem;
|
||||
|
||||
public class SelectDirDialogItemAdapter extends RecyclerView.Adapter<SelectDirDialogItemAdapter.ViewHolder> {
|
||||
|
||||
ArrayList<ListItem> listItems;
|
||||
LacertaSelectDirDialogEventListener listener;
|
||||
|
||||
public SelectDirDialogItemAdapter(LacertaSelectDirDialogEventListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void setListItems(ArrayList<ListItem> listItems) {
|
||||
this.listItems = listItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectDirDialogItemAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.common_list_item, parent, false);
|
||||
|
@ -18,13 +33,17 @@ public class SelectDirDialogItemAdapter extends RecyclerView.Adapter<SelectDirDi
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(SelectDirDialogItemAdapter.ViewHolder holder, int position) {
|
||||
holder.title.setText("title");
|
||||
holder.description.setText("description");
|
||||
ListItem listItem = listItems.get(position);
|
||||
holder.title.setText(listItem.getTitle());
|
||||
holder.description.setText(listItem.getDescription());
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
listener.onDirSelected(listItem.getTitle(), listItem.getItemId());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 100;
|
||||
return listItems.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
|
Loading…
Reference in New Issue
Block a user