mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
IndexOutOfBoundsException 修正
This commit is contained in:
parent
87099ae693
commit
32b238df58
|
@ -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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -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{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user