From 420197e5c3cdc52ac9fc8a9ac04695c18ee99d22 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 11:56:15 +0900 Subject: [PATCH] RecyclerViewDialog WIP --- .../component/viewer/ViewerListFragment.java | 6 +++- .../shared/ui/LacertaSelectDirDialog.java | 23 +++++++++++++++ .../shared/ui/SelectDirDialogItemAdapter.java | 2 +- .../res/layout/lacerta_dialog_select_dir.xml | 28 +++++++++++++++++-- 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java index 9cd49f37..dfb89289 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java @@ -22,6 +22,7 @@ import javax.inject.Inject; import dagger.hilt.android.AndroidEntryPoint; import one.nem.lacerta.data.Document; import one.nem.lacerta.model.document.page.Page; +import one.nem.lacerta.shared.ui.LacertaSelectDirDialog; import one.nem.lacerta.utils.FeatureSwitch; import one.nem.lacerta.utils.LacertaLogger; import one.nem.lacerta.vcs.LacertaVcs; @@ -204,7 +205,10 @@ public class ViewerListFragment extends Fragment { builder.show(); return true; } else if (item.getItemId() == R.id.action_move) { - Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show(); +// Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show(); + + LacertaSelectDirDialog lacertaSelectDirDialog = new LacertaSelectDirDialog(); + lacertaSelectDirDialog.show(getParentFragmentManager(), "selectDirDialog"); return true; } else { return false; diff --git a/shared/ui/src/main/java/one/nem/lacerta/shared/ui/LacertaSelectDirDialog.java b/shared/ui/src/main/java/one/nem/lacerta/shared/ui/LacertaSelectDirDialog.java index ac3734aa..ba85c49f 100644 --- a/shared/ui/src/main/java/one/nem/lacerta/shared/ui/LacertaSelectDirDialog.java +++ b/shared/ui/src/main/java/one/nem/lacerta/shared/ui/LacertaSelectDirDialog.java @@ -2,8 +2,13 @@ package one.nem.lacerta.shared.ui; import android.app.Dialog; import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.Toast; +import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.DialogFragment; +import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.dialog.MaterialAlertDialogBuilder; @@ -12,6 +17,24 @@ public class LacertaSelectDirDialog extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); + LayoutInflater inflater = requireActivity().getLayoutInflater(); + View view = inflater.inflate(R.layout.lacerta_dialog_select_dir, null); + + RecyclerView recyclerView = view.findViewById(R.id.select_dir_recycler_view); + recyclerView.setHasFixedSize(true); + + SelectDirDialogItemAdapter adapter = new SelectDirDialogItemAdapter(); + recyclerView.setAdapter(adapter); + recyclerView.setLayoutManager(new androidx.recyclerview.widget.LinearLayoutManager(getContext())); + + Toolbar toolbar = view.findViewById(R.id.select_dir_toolbar); + toolbar.setNavigationOnClickListener(v -> { + Toast.makeText(getContext(), "Called", Toast.LENGTH_SHORT).show(); + dismiss(); + }); + + builder.setView(view); + builder.setTitle("Select Directory"); builder.setMessage("Please select a directory."); builder.setPositiveButton("OK", null); diff --git a/shared/ui/src/main/java/one/nem/lacerta/shared/ui/SelectDirDialogItemAdapter.java b/shared/ui/src/main/java/one/nem/lacerta/shared/ui/SelectDirDialogItemAdapter.java index 661cba5d..ede9a51e 100644 --- a/shared/ui/src/main/java/one/nem/lacerta/shared/ui/SelectDirDialogItemAdapter.java +++ b/shared/ui/src/main/java/one/nem/lacerta/shared/ui/SelectDirDialogItemAdapter.java @@ -24,7 +24,7 @@ public class SelectDirDialogItemAdapter extends RecyclerView.Adapter - + android:layout_height="match_parent" + android:orientation="vertical"> - \ No newline at end of file + + + + + + \ No newline at end of file