mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
タグリストの更新を切り出し, 追加後に更新するように
This commit is contained in:
parent
fad9fcc48a
commit
21b198bc35
|
@ -32,6 +32,10 @@ public class SettingTagManageFragment extends Fragment {
|
||||||
@Inject
|
@Inject
|
||||||
LacertaLibrary lacertaLibrary;
|
LacertaLibrary lacertaLibrary;
|
||||||
|
|
||||||
|
private RecyclerView recyclerView;
|
||||||
|
|
||||||
|
private TagListItemAdapter adapter;
|
||||||
|
|
||||||
public SettingTagManageFragment() {
|
public SettingTagManageFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
}
|
}
|
||||||
|
@ -65,19 +69,22 @@ public class SettingTagManageFragment extends Fragment {
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
RecyclerView recyclerView = view.findViewById(R.id.tag_item_recycler_view);
|
this.recyclerView = view.findViewById(R.id.tag_item_recycler_view);
|
||||||
TagListItemAdapter adapter = new TagListItemAdapter((tagId, tagName, tagColor) -> {
|
this.adapter = new TagListItemAdapter((tagId, tagName, tagColor) -> {
|
||||||
Toast.makeText(getContext(), "Tag Clicked", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Tag Clicked", Toast.LENGTH_SHORT).show();
|
||||||
});
|
});
|
||||||
|
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
lacertaLibrary.getTagList().thenAccept(documentTags -> {
|
updateTagList();
|
||||||
adapter.setDocumentTags(documentTags);
|
}
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
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.setName(tagName);
|
||||||
newTag.setColor(tagColor);
|
newTag.setColor(tagColor);
|
||||||
lacertaLibrary.createTag(newTag).join();
|
lacertaLibrary.createTag(newTag).join();
|
||||||
|
updateTagList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue
Block a user