タグリストの更新を切り出し, 追加後に更新するように

This commit is contained in:
ろむねこ 2024-01-26 15:28:41 +09:00
parent fad9fcc48a
commit 21b198bc35
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -32,6 +32,10 @@ public class SettingTagManageFragment extends Fragment {
@Inject
LacertaLibrary lacertaLibrary;
private RecyclerView recyclerView;
private TagListItemAdapter adapter;
public SettingTagManageFragment() {
// Required empty public constructor
}
@ -65,19 +69,22 @@ public class SettingTagManageFragment extends Fragment {
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
RecyclerView recyclerView = view.findViewById(R.id.tag_item_recycler_view);
TagListItemAdapter adapter = new TagListItemAdapter((tagId, tagName, tagColor) -> {
this.recyclerView = view.findViewById(R.id.tag_item_recycler_view);
this.adapter = new TagListItemAdapter((tagId, tagName, tagColor) -> {
Toast.makeText(getContext(), "Tag Clicked", Toast.LENGTH_SHORT).show();
});
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
lacertaLibrary.getTagList().thenAccept(documentTags -> {
adapter.setDocumentTags(documentTags);
adapter.notifyDataSetChanged();
});
updateTagList();
}
private void updateTagList() {
lacertaLibrary.getTagList().thenAccept(documentTags -> {
this.adapter.setDocumentTags(documentTags);
this.adapter.notifyDataSetChanged();
});
}
/**
@ -114,6 +121,7 @@ public class SettingTagManageFragment extends Fragment {
newTag.setName(tagName);
newTag.setColor(tagColor);
lacertaLibrary.createTag(newTag).join();
updateTagList();
}
@Override