mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 07:53:15 +00:00
バージョンを遡れない不具合を修正
This commit is contained in:
parent
2fcab4e931
commit
0fe0f5dd00
|
@ -14,6 +14,8 @@ import android.widget.Toast;
|
|||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
|
@ -124,26 +126,41 @@ public class ViewerBodyFragment extends Fragment {
|
|||
builder.show();
|
||||
}
|
||||
});
|
||||
recyclerView.setAdapter(viewerBodyAdapter);
|
||||
|
||||
getActivity().runOnUiThread(() -> {
|
||||
recyclerView.setAdapter(viewerBodyAdapter);
|
||||
viewerBodyAdapter.notifyDataSetChanged();
|
||||
});
|
||||
|
||||
loadDocument(viewerBodyAdapter, documentId, revisionId);
|
||||
}
|
||||
|
||||
private void loadDocument(ViewerBodyAdapter adapter, String documentId, String revisionId) {
|
||||
if (revisionId == null) { // load latest revision
|
||||
document.getDocument(documentId).thenAccept(document -> {
|
||||
document.getDocument(documentId).thenApply(document -> {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
adapter.setPages(document.getPages());
|
||||
adapter.notifyDataSetChanged();
|
||||
});
|
||||
return null;
|
||||
});
|
||||
} else { // load specified revision
|
||||
LacertaVcs vcs = lacertaVcsFactory.create(documentId);
|
||||
document.getDocumentPageListByFileNameList(documentId, vcs.getDocumentPagePathListRev(revisionId).join()).thenAccept(documentPageList -> {
|
||||
// document.getDocumentPageListByFileNameList(documentId, vcs.getDocumentPagePathListRev(revisionId).join()).thenApply(documentPageList -> {
|
||||
// getActivity().runOnUiThread(() -> {
|
||||
// adapter.setPages(documentPageList);
|
||||
// adapter.notifyDataSetChanged();
|
||||
// });
|
||||
// return null;
|
||||
// });
|
||||
|
||||
ArrayList<String> fileNameList = vcs.getDocumentPagePathListRev(revisionId).join();
|
||||
document.getDocumentPageListByFileNameList(documentId, fileNameList).thenApply(documentPageList -> {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
adapter.setPages(documentPageList);
|
||||
adapter.notifyDataSetChanged();
|
||||
});
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,54 +145,44 @@ public class ViewerContainerFragment extends Fragment {
|
|||
|
||||
if (this.revId != null) { // Revが指定されている場合
|
||||
LacertaVcs lacertaVcs = lacertaVcsFactory.create(documentId);
|
||||
lacertaVcs.getDocumentPagePathListRev(this.revId).thenApply(pagePathList -> {
|
||||
logger.debug("ViewerContainerFragment", "pagePathList: " + pagePathList.size());
|
||||
document.getDocumentPageListByFileNameList(this.documentId, pagePathList).thenApply(pageList -> {
|
||||
logger.debug("ViewerContainerFragment", "pageList: " + pageList.size());
|
||||
// 暫定: 履歴を遡って表示している場合は結合を無視する(処理自体は単純だけどUI側の対応をする時間がないので)
|
||||
tabLayout.setVisibility(View.GONE);
|
||||
viewerViewPagerAdapter.setFragmentTargetIdList(new ArrayList<String>(){{add(documentId);}}); // TODO-rca: 読みにくいので直接追加できるようにする
|
||||
viewerViewPagerAdapter.setFragmentTitleList(new ArrayList<String>(){{add(documentName);}}); // TODO-rca: 読みにくいので直接追加できるようにする
|
||||
|
||||
viewerViewPagerAdapter.setFragmentRevisionList(new ArrayList<String>(){{add(revId);}}); // TODO-rca: 読みにくいので直接追加できるようにする
|
||||
viewerViewPagerAdapter.notifyItemRangeChanged(0, pageList.size());
|
||||
toolbar.setSubtitle("リビジョン: " + revId);
|
||||
return null;
|
||||
});
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
// Get document page
|
||||
if (this.hasCombined) { // 結合親の場合
|
||||
// バージョンを遡る操作を非表示
|
||||
toolbar.getMenu().findItem(R.id.action_open_vcs_rev_list).setVisible(false);
|
||||
logger.debug("ViewerContainerFragment", "hasCombined: " + hasCombined);
|
||||
lacertaLibrary.getCombinedDocumentToxiList(documentId).thenAccept(combinedDocumentToxiList -> {
|
||||
logger.debug("ViewerContainerFragment", "combinedDocumentToxiList: " + combinedDocumentToxiList.size());
|
||||
|
||||
viewerViewPagerAdapter.setFragmentTargetIdList(
|
||||
combinedDocumentToxiList.stream().map(ToxiDocumentModel::getChildDocumentId).collect(Collectors.toCollection(ArrayList::new)));
|
||||
viewerViewPagerAdapter.setFragmentTitleList(
|
||||
combinedDocumentToxiList.stream().map(ToxiDocumentModel::getTitleCache).collect(Collectors.toCollection(ArrayList::new)));
|
||||
|
||||
viewerViewPagerAdapter.notifyItemRangeChanged(0, combinedDocumentToxiList.size());
|
||||
toolbar.setSubtitle("結合ドキュメント");
|
||||
});
|
||||
} else { // それ以外の場合
|
||||
logger.debug("ViewerContainerFragment", "hasCombined: " + hasCombined);
|
||||
tabLayout.setVisibility(View.GONE);
|
||||
viewerViewPagerAdapter.setFragmentTargetIdList(new ArrayList<String>(){{add(documentId);}}); // TODO-rca: 読みにくいので直接追加できるようにする
|
||||
viewerViewPagerAdapter.setFragmentTitleList(new ArrayList<String>(){{add(documentName);}});
|
||||
viewerViewPagerAdapter.setFragmentTitleList(new ArrayList<String>(){{add(documentName);}}); // TODO-rca: 読みにくいので直接追加できるようにする
|
||||
viewerViewPagerAdapter.setFragmentRevisionList(new ArrayList<String>(){{add(revId);}}); // TODO-rca: 読みにくいので直接追加できるようにする
|
||||
viewerViewPagerAdapter.notifyItemRangeChanged(0, 1);
|
||||
tabLayout.setVisibility(View.GONE);
|
||||
toolbar.setSubtitle("リビジョン: " + revId);
|
||||
} else {
|
||||
// Get document page
|
||||
if (this.hasCombined) { // 結合親の場合
|
||||
// バージョンを遡る操作を非表示
|
||||
toolbar.getMenu().findItem(R.id.action_open_vcs_rev_list).setVisible(false);
|
||||
logger.debug("ViewerContainerFragment", "hasCombined: " + hasCombined);
|
||||
lacertaLibrary.getCombinedDocumentToxiList(documentId).thenAccept(combinedDocumentToxiList -> {
|
||||
logger.debug("ViewerContainerFragment", "combinedDocumentToxiList: " + combinedDocumentToxiList.size());
|
||||
|
||||
viewerViewPagerAdapter.setFragmentTargetIdList(
|
||||
combinedDocumentToxiList.stream().map(ToxiDocumentModel::getChildDocumentId).collect(Collectors.toCollection(ArrayList::new)));
|
||||
viewerViewPagerAdapter.setFragmentTitleList(
|
||||
combinedDocumentToxiList.stream().map(ToxiDocumentModel::getTitleCache).collect(Collectors.toCollection(ArrayList::new)));
|
||||
|
||||
viewerViewPagerAdapter.notifyItemRangeChanged(0, combinedDocumentToxiList.size());
|
||||
toolbar.setSubtitle("結合ドキュメント");
|
||||
});
|
||||
} else { // それ以外の場合
|
||||
logger.debug("ViewerContainerFragment", "hasCombined: " + hasCombined);
|
||||
tabLayout.setVisibility(View.GONE);
|
||||
viewerViewPagerAdapter.setFragmentTargetIdList(new ArrayList<String>(){{add(documentId);}}); // TODO-rca: 読みにくいので直接追加できるようにする
|
||||
viewerViewPagerAdapter.setFragmentTitleList(new ArrayList<String>(){{add(documentName);}});
|
||||
viewerViewPagerAdapter.notifyItemRangeChanged(0, 1);
|
||||
}
|
||||
|
||||
// サブタイトルとしてパスを表示(暫定)
|
||||
lacertaLibrary.getPublicPath(documentId, ListItemType.ITEM_TYPE_DOCUMENT).thenAccept(publicPath -> {
|
||||
logger.debug("ViewerContainerFragment", "publicPath: " + publicPath);
|
||||
toolbar.setSubtitle("/" + publicPath.parent().getStringPath());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// サブタイトルとしてパスを表示(暫定)
|
||||
lacertaLibrary.getPublicPath(documentId, ListItemType.ITEM_TYPE_DOCUMENT).thenAccept(publicPath -> {
|
||||
logger.debug("ViewerContainerFragment", "publicPath: " + publicPath);
|
||||
toolbar.setSubtitle("/" + publicPath.parent().getStringPath());
|
||||
});
|
||||
|
||||
// Attach tab layout to view pager
|
||||
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> {
|
||||
View customView = LayoutInflater.from(getContext()).inflate(R.layout.viewer_custom_tab, null);
|
||||
|
|
Loading…
Reference in New Issue
Block a user