表示アニメーションを500ms以上かかった場合のみに

This commit is contained in:
ろむねこ 2024-01-26 18:41:05 +09:00
parent 58e74dbb16
commit 8a2b4ed12d
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -106,20 +106,22 @@ public class HomeTopFragment extends Fragment {
} }
private void updateList() { private void updateList() {
long startTime = System.currentTimeMillis();
lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> { lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> {
long endTime = System.currentTimeMillis();
if (listItems == null) { if (listItems == null) {
return; return;
} }
this.listItemAdapter.setListItems(listItems); this.listItemAdapter.setListItems(listItems);
if (endTime - startTime > 500) { // 500ms以上かかった場合は表示アニメーションをする
getActivity().runOnUiThread(() -> { getActivity().runOnUiThread(() -> {
Log.d("HomeTopFragment", "onViewCreated: " + listItems.size()); this.listItemAdapter.notifyItemRangeInserted(0, listItems.size());
if (FeatureSwitch.RecyclerView.useSimpleNotifyMethod) {
this.listItemAdapter.notifyDataSetChanged();
} else {
// IndexOutOfBoundsExceptionを吐くことがあったので いったん
this.listItemAdapter.notifyItemRangeInserted(0, listItems.size() - 1);
}
}); });
} else {
getActivity().runOnUiThread(() -> {
this.listItemAdapter.notifyDataSetChanged();
});
}
}); });
} }