編集に追従してタブのタイトルも正しく変わるように

This commit is contained in:
r-ca 2024-01-29 02:49:04 +09:00
parent d691ee0126
commit d393087ff6
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -148,14 +148,18 @@ public class ViewerContainerFragment extends Fragment {
ImageButton imageButton = customView.findViewById(R.id.tab_modify);
imageButton.setOnClickListener(v -> {
renameCombinedDocument(this.documentId, viewerViewPagerAdapter.getFragmentTargetId(position), viewerViewPagerAdapter.getFragmentTitle(position));
renameCombinedDocument(
this.documentId,
viewerViewPagerAdapter.getFragmentTargetId(position),
viewerViewPagerAdapter.getFragmentTitle(position),
position);
});
tab.setCustomView(customView);
}).attach();
}
private void renameCombinedDocument(String parentId, String childId, String current) {
private void renameCombinedDocument(String parentId, String childId, String current, int position) { // TODO-rca: 無理やりpositionを渡してるのでなんとかする
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext());
builder.setTitle("アイテム名の変更");
builder.setMessage("アイテム名を入力してください");
@ -172,6 +176,7 @@ public class ViewerContainerFragment extends Fragment {
lacertaLibrary.updateTitleCache(parentId, childId, textInputEditText.getText().toString()), (aVoid, aVoid2) -> {
getActivity().runOnUiThread(() -> {
Toast.makeText(getContext(), "変更しました", Toast.LENGTH_SHORT).show();
updateTabTitle(position, textInputEditText.getText().toString());
dialog.dismiss();
});
return null;