fix crash when looped slider with item count zero
This commit is contained in:
parent
e6595d5c51
commit
98f2d29cee
@ -62,7 +62,7 @@ class SlideAdapter extends RecyclerView.Adapter<SlideAdapter.DoricViewHolder> {
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DoricViewHolder holder, int position) {
|
||||
JSValue jsValue = getItemModel(position);
|
||||
if (jsValue.isObject()) {
|
||||
if (jsValue != null && jsValue.isObject()) {
|
||||
JSObject jsObject = jsValue.asObject();
|
||||
holder.slideItemNode.setId(jsObject.getProperty("id").asString().value());
|
||||
holder.slideItemNode.blend(jsObject.getProperty("props").asObject());
|
||||
@ -71,7 +71,7 @@ class SlideAdapter extends RecyclerView.Adapter<SlideAdapter.DoricViewHolder> {
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (loop) {
|
||||
if (loop && itemCount > 0) {
|
||||
return itemCount + 2;
|
||||
} else {
|
||||
return itemCount;
|
||||
@ -81,7 +81,7 @@ class SlideAdapter extends RecyclerView.Adapter<SlideAdapter.DoricViewHolder> {
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
JSValue value = getItemModel(position);
|
||||
if (value.isObject()) {
|
||||
if (value != null && value.isObject()) {
|
||||
if (value.asObject().getProperty("identifier").isString()) {
|
||||
return value.asObject().getProperty("identifier").asString().value().hashCode();
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ - (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValu
|
||||
}
|
||||
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
||||
if (self.loop) {
|
||||
if (self.loop && self.itemCount > 0) {
|
||||
return self.itemCount + 2;
|
||||
} else {
|
||||
return self.itemCount;
|
||||
|
Reference in New Issue
Block a user