From f812e6c38edd208371fb32be680f2a20bab3a6b0 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sat, 27 Jan 2024 16:09:26 +0900 Subject: [PATCH] =?UTF-8?q?=E5=AE=9F=E9=9A=9B=E3=81=ABRevision=E3=82=92?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B=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/LacertaSelectRevDialog.java | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaSelectRevDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaSelectRevDialog.java index 2989e9b5..2bc571a0 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaSelectRevDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaSelectRevDialog.java @@ -12,9 +12,26 @@ import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.dialog.MaterialAlertDialogBuilder; +import javax.inject.Inject; + +import dagger.hilt.android.AndroidEntryPoint; +import one.nem.lacerta.data.LacertaLibrary; +import one.nem.lacerta.utils.LacertaLogger; +import one.nem.lacerta.vcs.LacertaVcs; +import one.nem.lacerta.vcs.factory.LacertaVcsFactory; + + +@AndroidEntryPoint public class LacertaSelectRevDialog extends DialogFragment { + @Inject + LacertaVcsFactory lacertaVcsFactory; + + @Inject + LacertaLogger logger; + String title; + String documentId; String message; String negativeButtonText; @@ -25,6 +42,11 @@ public class LacertaSelectRevDialog extends DialogFragment { return this; } + public LacertaSelectRevDialog setDocumentId(String documentId) { + this.documentId = documentId; + return this; + } + public LacertaSelectRevDialog setMessage(String message) { this.message = message; return this; @@ -62,8 +84,21 @@ public class LacertaSelectRevDialog extends DialogFragment { recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - builder.setView(view); + + if (this.documentId == null) { + logger.error("SelectRevDialog", "documentId is null"); + logger.e_code("0296fb0c-07a3-4971-a280-bd1a61461bb7"); + Toast.makeText(getContext(), "Sorry, something went wrong", Toast.LENGTH_SHORT).show(); + dismiss(); + } + LacertaVcs lacertaVcs = lacertaVcsFactory.create(this.documentId); + lacertaVcs.getRevisionHistory().thenAccept(revList -> { + adapter.setRevList(revList); + adapter.notifyDataSetChanged(); // TODO-rca:時間に応じてアニメーションをつける + }); + + builder.setTitle(title == null ? "Select Rev" : title); builder.setMessage(message == null ? "Select Rev" : message); builder.setNegativeButton(negativeButtonText, (dialog, which) -> {