From 74ee492b49e8d5e1db70380087a422b50cd61fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Thu, 25 Jan 2024 15:10:42 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=88=E3=83=AB,=20?= =?UTF-8?q?=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8,=20=E9=81=B8?= =?UTF-8?q?=E6=8A=9E=E8=82=A2=E3=81=AE=E3=83=86=E3=82=AD=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB,=20=E6=B1=BA=E5=AE=9A=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=9F=E3=82=89=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88=E3=82=92?= =?UTF-8?q?=E5=91=BC=E3=81=B6=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/LacertaSelectDirDialog.java | 55 +++++++++++++++++-- .../common/SelectDirDialogItemAdapter.java | 12 ++++ 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaSelectDirDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaSelectDirDialog.java index a43e2724..7d3d4b81 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaSelectDirDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaSelectDirDialog.java @@ -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(); } diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/SelectDirDialogItemAdapter.java b/component/common/src/main/java/one/nem/lacerta/component/common/SelectDirDialogItemAdapter.java index 439cb717..31884e01 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/SelectDirDialogItemAdapter.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/SelectDirDialogItemAdapter.java @@ -67,6 +67,18 @@ public class SelectDirDialogItemAdapter extends RecyclerView.Adapter