From 9861dfe5b6f2734218f9d99de253c1fafdbc176d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 29 Jan 2024 10:42:20 +0900 Subject: [PATCH] =?UTF-8?q?deleteDocument=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../viewer/ViewerContainerFragment.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index 6ccd0b7c..b74d75d2 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -244,7 +244,7 @@ public class ViewerContainerFragment extends Fragment { renameDocument(); return true; } else if (item.getItemId() == R.id.action_delete) { - Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show(); + deleteDocument(); return true; } else if (item.getItemId() == R.id.action_move) { Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show(); @@ -281,6 +281,26 @@ public class ViewerContainerFragment extends Fragment { lacertaSelectRevDialog.show(getParentFragmentManager(), "select_rev_dialog"); } + private void deleteDocument() { + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext()); + builder.setTitle("ファイルの削除"); + builder.setMessage("ファイルを削除しますか?"); + + builder.setPositiveButton("削除", (dialog, which) -> { + document.deleteDocument(documentId).thenAccept(aVoid -> { + getActivity().runOnUiThread(() -> { + Toast.makeText(getContext(), "削除しました", Toast.LENGTH_SHORT).show(); + getActivity().finish(); // TODO-rca: 終了させずにUIを更新したい + }); + }); + }); + builder.setNegativeButton("キャンセル", (dialog, which) -> { + dialog.cancel(); + }); + + builder.show(); + } + private void applyTag() { LacertaApplyTagDialog lacertaApplyTagDialog = new LacertaApplyTagDialog(); lacertaApplyTagDialog