diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerBodyFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerBodyFragment.java index 334a7e97..f52576d4 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerBodyFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerBodyFragment.java @@ -4,10 +4,8 @@ import android.content.Intent; import android.os.Bundle; import androidx.fragment.app.Fragment; -import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import androidx.viewpager2.widget.ViewPager2; import android.view.LayoutInflater; import android.view.View; @@ -51,12 +49,6 @@ public class ViewerBodyFragment extends Fragment { private String documentName; private String revisionId; - private SharedViewModel sharedViewModel; - - private RecyclerView recyclerView; - - private int maxPage = 0; - public ViewerBodyFragment() { // Required empty public constructor } @@ -102,33 +94,9 @@ public class ViewerBodyFragment extends Fragment { super.onViewCreated(view, savedInstanceState); logger.debug("ViewerBodyFragment", "ViewerBodyFragment.onViewCreated"); - this.recyclerView = view.findViewById(R.id.recycler_view); + RecyclerView recyclerView = view.findViewById(R.id.recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - sharedViewModel = new ViewModelProvider(requireActivity()).get(SharedViewModel.class); - - ViewPager2 viewPager2 = getActivity().findViewById(R.id.view_pager); - viewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { - @Override - public void onPageSelected(int position) { - super.onPageSelected(position); - sharedViewModel.setCurrentFragmentPosition(position); - - if (maxPage > 0 && position >= maxPage) { - // out of range - } else { - try { - recyclerView.scrollToPosition(position); - } catch (Exception e) { - logger.error("ViewerBodyFragment", "recyclerView.scrollToPosition"); - logger.error("ViewerBodyFragment", e.getMessage()); - logger.e_code("8beec84b-1f7d-4e1e-9364-9fcf00f3509a"); - - } - } - } - }); - ViewerBodyAdapter viewerBodyAdapter = new ViewerBodyAdapter(new ItemClickListener() { @Override public void onItemClick(String fileName) { @@ -161,19 +129,9 @@ public class ViewerBodyFragment extends Fragment { loadDocument(viewerBodyAdapter, documentId, revisionId); } - @Override - public void onResume() { - super.onResume(); - logger.debug("ViewerBodyFragment", "ViewerBodyFragment.onResume"); - - this.sharedViewModel = new ViewModelProvider(requireActivity()).get(SharedViewModel.class); - this.recyclerView.scrollToPosition(sharedViewModel.getCurrentFragmentPosition()); - } - private void loadDocument(ViewerBodyAdapter adapter, String documentId, String revisionId) { if (revisionId == null) { // load latest revision document.getDocument(documentId).thenAccept(document -> { - this.maxPage = document.getPages().size(); getActivity().runOnUiThread(() -> { adapter.setPages(document.getPages()); adapter.notifyDataSetChanged(); 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 3bfe11ab..f5fd50b0 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 @@ -224,18 +224,6 @@ public class ViewerContainerFragment extends Fragment { tab.setCustomView(customView); }).attach(); - - // Sync position between pages - viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { - @Override - public void onPageSelected(int position) { - logger.debug("ViewerContainerFragment", "onPageSelected: " + position); - super.onPageSelected(position); - if (hasCombined) { - toolbar.setTitle(viewerViewPagerAdapter.getFragmentTitle(position)); - } - } - }); } private void renameCombinedDocument(String parentId, String childId, String current, int position) { // TODO-rca: 無理やりpositionを渡してるのでなんとかする