feat: add preloadItemCount for List, incase we need preload more items before scroll to end

This commit is contained in:
pengfei.zhou
2023-03-09 10:55:32 +08:00
committed by jingpeng
parent 4103704162
commit 0774df96e1
26 changed files with 4495 additions and 2639 deletions

View File

@@ -68,7 +68,7 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
holder.listItemNode.blend(jsObject.getProperty("props").asObject());
}
if (this.loadMore
&& position >= this.itemCount
&& position >= this.itemCount - this.listNode.preloadItemCount
&& !TextUtils.isEmpty(this.listNode.onLoadMoreFuncId)) {
callLoadMore();
}

View File

@@ -76,6 +76,8 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
private String onScrollEndFuncId;
private final DoricJSDispatcher jsDispatcher = new DoricJSDispatcher();
int preloadItemCount = 0;
public ListNode(DoricContext doricContext) {
super(doricContext);
this.listAdapter = new ListAdapter(this);
@@ -377,6 +379,12 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
}
this.onDraggedFuncId = prop.asString().value();
break;
case "preloadItemCount":
if (!prop.isNumber()) {
return;
}
this.preloadItemCount = prop.asNumber().toInt();
break;
default:
super.blend(view, name, prop);
break;