From 778473f89879b6c6a49a720fa5df1f32d6cbfa89 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 17:09:32 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AA=E3=83=93=E3=82=B8=E3=83=A7=E3=83=B3ID?= =?UTF-8?q?=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=97=E3=81=A6=E5=91=BC=E3=81=B3?= =?UTF-8?q?=E5=87=BA=E3=81=97=E3=81=9F=E5=A0=B4=E5=90=88=E3=81=AB=E3=81=9D?= =?UTF-8?q?=E3=81=AE=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3=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 --- .../viewer/ViewerPrimaryFragment.java | 43 +++++++++++++++---- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java index 740be76f..34696b6a 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java @@ -22,6 +22,8 @@ import one.nem.lacerta.data.Document; import one.nem.lacerta.model.document.page.Page; import one.nem.lacerta.utils.FeatureSwitch; import one.nem.lacerta.utils.LacertaLogger; +import one.nem.lacerta.vcs.LacertaVcs; +import one.nem.lacerta.vcs.factory.LacertaVcsFactory; /** * A simple {@link Fragment} subclass. @@ -37,10 +39,14 @@ public class ViewerPrimaryFragment extends Fragment { @Inject LacertaLogger logger; + @Inject + LacertaVcsFactory lacertaVcsFactory; + private static final String TAG = "ComponentViewerTopFragment"; private String documentId; private String documentName; + private String revisionId; public ViewerPrimaryFragment() { // Required empty public constructor @@ -71,6 +77,7 @@ public class ViewerPrimaryFragment extends Fragment { if (getArguments() != null) { documentId = getArguments().getString("documentId"); documentName = getArguments().getString("documentName"); + revisionId = getArguments().getString("revisionId"); } } @@ -91,16 +98,34 @@ public class ViewerPrimaryFragment extends Fragment { }); recyclerView.setAdapter(viewerBodyAdapter); - if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.VISIBLE); - document.getDocument(documentId).thenAccept(documentDetail -> { - ArrayList pages = documentDetail.getPages(); - logger.debug(TAG, "pages.size(): " + pages.size()); - viewerBodyAdapter.setPages(pages); - getActivity().runOnUiThread(() -> { - viewerBodyAdapter.notifyItemRangeChanged(0, pages.size()); - if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.GONE); + if (revisionId.isEmpty()) { + 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 -> { + ArrayList pages = documentDetail.getPages(); + logger.debug(TAG, "pages.size(): " + pages.size()); + viewerBodyAdapter.setPages(pages); + getActivity().runOnUiThread(() -> { + viewerBodyAdapter.notifyItemRangeChanged(0, pages.size()); + if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.GONE); + }); }); - }); + } else { + logger.debug(TAG, "revisionId: " + revisionId); + if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.VISIBLE); + LacertaVcs lacertaVcs = lacertaVcsFactory.create(documentId); + lacertaVcs.getDocumentPagePathListRev(revisionId).thenAccept(documentPathList -> { + logger.debug(TAG, "documentPathList.size(): " + documentPathList.size()); + document.getDocumentPageListByFileNameList(documentId, documentPathList).thenAccept(pages -> { + logger.debug(TAG, "pages.size(): " + pages.size()); + viewerBodyAdapter.setPages(pages); + getActivity().runOnUiThread(() -> { + viewerBodyAdapter.notifyItemRangeChanged(0, pages.size()); + if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.GONE); + }); + }); + }); + } return view; }