mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +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,37 +8,56 @@ 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> {
|
||||||
|
|
||||||
@Override
|
ArrayList<ListItem> listItems;
|
||||||
public SelectDirDialogItemAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
LacertaSelectDirDialogEventListener listener;
|
||||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.common_list_item, parent, false);
|
|
||||||
return new SelectDirDialogItemAdapter.ViewHolder(view);
|
public SelectDirDialogItemAdapter(LacertaSelectDirDialogEventListener listener) {
|
||||||
}
|
this.listener = listener;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(SelectDirDialogItemAdapter.ViewHolder holder, int position) {
|
public void setListItems(ArrayList<ListItem> listItems) {
|
||||||
holder.title.setText("title");
|
this.listItems = listItems;
|
||||||
holder.description.setText("description");
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public SelectDirDialogItemAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
public int getItemCount() {
|
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.common_list_item, parent, false);
|
||||||
return 100;
|
return new SelectDirDialogItemAdapter.ViewHolder(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
@Override
|
||||||
|
public void onBindViewHolder(SelectDirDialogItemAdapter.ViewHolder holder, int position) {
|
||||||
TextView title;
|
ListItem listItem = listItems.get(position);
|
||||||
TextView description;
|
holder.title.setText(listItem.getTitle());
|
||||||
|
holder.description.setText(listItem.getDescription());
|
||||||
|
holder.itemView.setOnClickListener(v -> {
|
||||||
public ViewHolder(@NonNull View itemView) {
|
listener.onDirSelected(listItem.getTitle(), listItem.getItemId());
|
||||||
super(itemView);
|
});
|
||||||
|
}
|
||||||
title = itemView.findViewById(R.id.item_title);
|
|
||||||
description = itemView.findViewById(R.id.item_description);
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
}
|
return listItems.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
TextView title;
|
||||||
|
TextView description;
|
||||||
|
|
||||||
|
|
||||||
|
public ViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
title = itemView.findViewById(R.id.item_title);
|
||||||
|
description = itemView.findViewById(R.id.item_description);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user