mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-26 09:43: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 recyclerView = view.findViewById(R.id.select_dir_recycler_view);
|
||||||
recyclerView.setHasFixedSize(true);
|
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.setAdapter(adapter);
|
||||||
recyclerView.setLayoutManager(new androidx.recyclerview.widget.LinearLayoutManager(getContext()));
|
recyclerView.setLayoutManager(new androidx.recyclerview.widget.LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,23 @@ import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import one.nem.lacerta.model.ListItem;
|
||||||
|
|
||||||
public class SelectDirDialogItemAdapter extends RecyclerView.Adapter<SelectDirDialogItemAdapter.ViewHolder> {
|
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
|
@Override
|
||||||
public SelectDirDialogItemAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public SelectDirDialogItemAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.common_list_item, parent, false);
|
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
|
@Override
|
||||||
public void onBindViewHolder(SelectDirDialogItemAdapter.ViewHolder holder, int position) {
|
public void onBindViewHolder(SelectDirDialogItemAdapter.ViewHolder holder, int position) {
|
||||||
holder.title.setText("title");
|
ListItem listItem = listItems.get(position);
|
||||||
holder.description.setText("description");
|
holder.title.setText(listItem.getTitle());
|
||||||
|
holder.description.setText(listItem.getDescription());
|
||||||
|
holder.itemView.setOnClickListener(v -> {
|
||||||
|
listener.onDirSelected(listItem.getTitle(), listItem.getItemId());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return 100;
|
return listItems.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user