mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-26 17:53:14 +00:00
Resume時に更新されるように
This commit is contained in:
parent
09c6d47a47
commit
06771d2e74
|
@ -51,6 +51,8 @@ public class HomeTopFragment extends Fragment {
|
||||||
@Inject
|
@Inject
|
||||||
LacertaLibrary lacertaLibrary;
|
LacertaLibrary lacertaLibrary;
|
||||||
|
|
||||||
|
private ListItemAdapter listItemAdapter;
|
||||||
|
|
||||||
public HomeTopFragment() {
|
public HomeTopFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
}
|
}
|
||||||
|
@ -85,7 +87,7 @@ public class HomeTopFragment extends Fragment {
|
||||||
Toolbar toolbar = view.findViewById(R.id.home_toolbar);
|
Toolbar toolbar = view.findViewById(R.id.home_toolbar);
|
||||||
toolbarSetup(toolbar, false, "ホーム");
|
toolbarSetup(toolbar, false, "ホーム");
|
||||||
|
|
||||||
ListItemAdapter listItemAdapter = new ListItemAdapter(new DocumentSelectListener() {
|
this.listItemAdapter = new ListItemAdapter(new DocumentSelectListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDocumentSelect(String documentId, String documentName) {
|
public void onDocumentSelect(String documentId, String documentName) {
|
||||||
Intent intent = new Intent(getContext(), ViewerMainActivity.class);
|
Intent intent = new Intent(getContext(), ViewerMainActivity.class);
|
||||||
|
@ -98,18 +100,29 @@ public class HomeTopFragment extends Fragment {
|
||||||
recyclerView.setAdapter(listItemAdapter);
|
recyclerView.setAdapter(listItemAdapter);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
|
updateList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
updateList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateList() {
|
||||||
lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> {
|
lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> {
|
||||||
if (listItems == null) {
|
if (listItems == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
listItemAdapter.setListItems(listItems);
|
this.listItemAdapter.setListItems(listItems);
|
||||||
getActivity().runOnUiThread(() -> {
|
getActivity().runOnUiThread(() -> {
|
||||||
Log.d("HomeTopFragment", "onViewCreated: " + listItems.size());
|
Log.d("HomeTopFragment", "onViewCreated: " + listItems.size());
|
||||||
if (FeatureSwitch.RecyclerView.useSimpleNotifyMethod) {
|
if (FeatureSwitch.RecyclerView.useSimpleNotifyMethod) {
|
||||||
listItemAdapter.notifyDataSetChanged();
|
this.listItemAdapter.notifyDataSetChanged();
|
||||||
} else {
|
} else {
|
||||||
// IndexOutOfBoundsExceptionを吐くことがあったので いったん
|
// IndexOutOfBoundsExceptionを吐くことがあったので いったん
|
||||||
listItemAdapter.notifyItemRangeInserted(0, listItems.size() - 1);
|
this.listItemAdapter.notifyItemRangeInserted(0, listItems.size() - 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user