From 615d58f3cae96d8f9eeb2312b151c6bcd58af5e6 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 17:43:10 +0900 Subject: [PATCH] WIP --- .../component/viewer/ViewerListFragment.java | 4 ++-- .../viewer/ViewerVcsRevListFragment.java | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 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 09343c94..4c306755 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 @@ -98,7 +98,7 @@ public class ViewerListFragment extends Fragment { }); recyclerView.setAdapter(viewerBodyAdapter); - if (revisionId.isEmpty()) { + if (revisionId == null) { logger.debug(TAG, "revisionId is empty, loading latest revision"); if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.VISIBLE); document.getDocument(documentId).thenAccept(documentDetail -> { @@ -154,7 +154,7 @@ public class ViewerListFragment extends Fragment { if (item.getItemId() == R.id.action_open_vcs_rev_list) { // Open vcs rev list getParentFragmentManager().beginTransaction() - .replace(R.id.nav_host_fragment, ViewerVcsRevListFragment.newInstance(documentId)) + .replace(R.id.nav_host_fragment, ViewerVcsRevListFragment.newInstance(documentId, documentName)) .commit(); return true; } else if (item.getItemId() == R.id.action_rename) { diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java index 237c1564..a86d7e88 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java @@ -34,15 +34,17 @@ public class ViewerVcsRevListFragment extends Fragment { LacertaVcs lacertaVcs; private String documentId; + private String documentName; public ViewerVcsRevListFragment() { // Required empty public constructor } - public static ViewerVcsRevListFragment newInstance(String documentId) { + public static ViewerVcsRevListFragment newInstance(String documentId, String documentName) { ViewerVcsRevListFragment fragment = new ViewerVcsRevListFragment(); Bundle args = new Bundle(); args.putString("documentId", documentId); + args.putString("documentName", documentName); fragment.setArguments(args); return fragment; } @@ -66,17 +68,22 @@ public class ViewerVcsRevListFragment extends Fragment { // Init arg if (getArguments() != null) { this.documentId = getArguments().getString("documentId"); - logger.debug("ViewerVcsRevListFragment", "documentId: " + documentId); + logger.debug("ViewerVcsRevListFragment", "documentId: " + this.documentId); } // Init vcs - lacertaVcs = lacertaVcsFactory.create(documentId); + lacertaVcs = lacertaVcsFactory.create(this.documentId); // Init view RecyclerView recyclerView = view.findViewById(R.id.rev_list); // Init adapter - RevAdapter revAdapter = new RevAdapter(); + RevAdapter revAdapter = new RevAdapter(revisionId -> { + logger.debug("ViewerVcsRevListFragment", "Selected revisionId: " + revisionId); + getParentFragmentManager().beginTransaction() + .replace(R.id.nav_host_fragment, ViewerListFragment.newInstance(this.documentId, this.documentName, revisionId)) + .commit(); + }); // Set adapter recyclerView.setAdapter(revAdapter);