IndexOutOfBoundsException 修正

This commit is contained in:
r-ca 2024-01-23 03:24:34 +09:00
parent 87099ae693
commit 32b238df58
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
2 changed files with 5 additions and 2 deletions

View File

@ -94,9 +94,12 @@ public class HomeTopFragment extends Fragment {
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> { lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> {
if (listItems == null) {
return;
}
listItemAdapter.setListItems(listItems); listItemAdapter.setListItems(listItems);
getActivity().runOnUiThread(() -> { getActivity().runOnUiThread(() -> {
listItemAdapter.notifyItemRangeInserted(0, listItems.size()); listItemAdapter.notifyItemRangeInserted(0, listItems.size() - 1);
}); });
}); });
} }

View File

@ -54,7 +54,7 @@ public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListIt
@Override @Override
public int getItemCount() { public int getItemCount() {
return listItems.size(); return listItems == null ? 0 : listItems.size();
} }
public static class ListItemViewHolder extends RecyclerView.ViewHolder{ public static class ListItemViewHolder extends RecyclerView.ViewHolder{