mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-26 17:53:14 +00:00
タイトル, メッセージ, 選択肢のテキストを指定できるように, 決定されたらイベントを呼ぶように
This commit is contained in:
parent
4f864eb57d
commit
74ee492b49
|
@ -27,12 +27,49 @@ public class LacertaSelectDirDialog extends DialogFragment {
|
|||
@Inject
|
||||
LacertaLogger logger;
|
||||
|
||||
private LacertaSelectDirDialogListener listener;
|
||||
|
||||
private String title;
|
||||
|
||||
private String message;
|
||||
|
||||
private String positiveButtonText;
|
||||
|
||||
private String negativeButtonText;
|
||||
|
||||
private SelectDirDialogItemAdapter adapter;
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
|
||||
private TextView current_dir_text_view;
|
||||
|
||||
// Setter
|
||||
|
||||
public LacertaSelectDirDialog setListener(LacertaSelectDirDialogListener listener) {
|
||||
this.listener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LacertaSelectDirDialog setTitle(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LacertaSelectDirDialog setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LacertaSelectDirDialog setPositiveButtonText(String positiveButtonText) {
|
||||
this.positiveButtonText = positiveButtonText;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LacertaSelectDirDialog setNegativeButtonText(String negativeButtonText) {
|
||||
this.negativeButtonText = negativeButtonText;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
|
||||
|
@ -66,10 +103,20 @@ public class LacertaSelectDirDialog extends DialogFragment {
|
|||
|
||||
showRecyclerViewItem(null); // get root folder
|
||||
|
||||
builder.setTitle("Select Directory");
|
||||
builder.setMessage("Please select a directory.");
|
||||
builder.setPositiveButton("OK", null);
|
||||
builder.setNegativeButton("Cancel", null);
|
||||
builder.setTitle(this.title == null ? "Select a directory" : this.title);
|
||||
builder.setMessage(this.message == null ? "Select a directory" : this.message);
|
||||
builder.setPositiveButton(this.positiveButtonText == null ? "OK" : this.positiveButtonText, (dialog, which) -> {
|
||||
if (listener != null) {
|
||||
listener.onDirSelected(
|
||||
adapter.getCurrentPageTitle() == null ? null : adapter.getCurrentPageTitle(),
|
||||
adapter.getCurrentId() == null ? null : adapter.getCurrentId());
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(this.negativeButtonText == null ? "Cancel" : this.negativeButtonText, (dialog, which) -> {
|
||||
if (listener != null) {
|
||||
listener.onCanceled();
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,18 @@ public class SelectDirDialogItemAdapter extends RecyclerView.Adapter<SelectDirDi
|
|||
}
|
||||
}
|
||||
|
||||
public String getCurrentPageTitle() {
|
||||
if (this.libraryItemPage == null) {
|
||||
return null;
|
||||
} else {
|
||||
if (this.libraryItemPage.getPageId() == null) {
|
||||
return null;
|
||||
} else {
|
||||
return this.libraryItemPage.getPageTitle()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SelectDirDialogItemViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView title;
|
||||
|
|
Loading…
Reference in New Issue
Block a user