Revert "WIP"

This reverts commit 0c27cf6b24.
This commit is contained in:
ろむねこ 2024-01-29 11:45:41 +09:00
parent 0c27cf6b24
commit c3e1825542
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168
2 changed files with 1 additions and 55 deletions

View File

@ -4,10 +4,8 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.widget.ViewPager2;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -51,12 +49,6 @@ public class ViewerBodyFragment extends Fragment {
private String documentName; private String documentName;
private String revisionId; private String revisionId;
private SharedViewModel sharedViewModel;
private RecyclerView recyclerView;
private int maxPage = 0;
public ViewerBodyFragment() { public ViewerBodyFragment() {
// Required empty public constructor // Required empty public constructor
} }
@ -102,33 +94,9 @@ public class ViewerBodyFragment extends Fragment {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
logger.debug("ViewerBodyFragment", "ViewerBodyFragment.onViewCreated"); 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())); 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() { ViewerBodyAdapter viewerBodyAdapter = new ViewerBodyAdapter(new ItemClickListener() {
@Override @Override
public void onItemClick(String fileName) { public void onItemClick(String fileName) {
@ -161,19 +129,9 @@ public class ViewerBodyFragment extends Fragment {
loadDocument(viewerBodyAdapter, documentId, revisionId); 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) { private void loadDocument(ViewerBodyAdapter adapter, String documentId, String revisionId) {
if (revisionId == null) { // load latest revision if (revisionId == null) { // load latest revision
document.getDocument(documentId).thenAccept(document -> { document.getDocument(documentId).thenAccept(document -> {
this.maxPage = document.getPages().size();
getActivity().runOnUiThread(() -> { getActivity().runOnUiThread(() -> {
adapter.setPages(document.getPages()); adapter.setPages(document.getPages());
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();

View File

@ -224,18 +224,6 @@ public class ViewerContainerFragment extends Fragment {
tab.setCustomView(customView); tab.setCustomView(customView);
}).attach(); }).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を渡してるのでなんとかする private void renameCombinedDocument(String parentId, String childId, String current, int position) { // TODO-rca: 無理やりpositionを渡してるのでなんとかする