diff --git a/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowAdapter.java b/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowAdapter.java index ea9001e0..6ae155cb 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowAdapter.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowAdapter.java @@ -45,6 +45,7 @@ class FlowAdapter extends RecyclerView.Adapter { int itemCount = 0; int batchCount = 15; SparseArray itemValues = new SparseArray<>(); + private int loadAnchor = 0; FlowAdapter(FlowLayoutNode flowLayoutNode) { this.flowLayoutNode = flowLayoutNode; @@ -66,9 +67,8 @@ class FlowAdapter extends RecyclerView.Adapter { holder.flowLayoutItemNode.setId(jsObject.getProperty("id").asString().value()); holder.flowLayoutItemNode.blend(jsObject.getProperty("props").asObject()); } - if (position >= this.itemCount) { - this.flowLayoutNode.callJSResponse(this.flowLayoutNode.onLoadMoreFuncId); - + if (position >= this.itemCount && !TextUtils.isEmpty(this.flowLayoutNode.onLoadMoreFuncId)) { + callLoadMore(); StaggeredGridLayoutManager.LayoutParams layoutParams = new StaggeredGridLayoutManager.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, holder.itemView.getLayoutParams().height @@ -143,6 +143,14 @@ class FlowAdapter extends RecyclerView.Adapter { } } + + private void callLoadMore() { + if (loadAnchor != itemCount) { + loadAnchor = itemCount; + this.flowLayoutNode.callJSResponse(this.flowLayoutNode.onLoadMoreFuncId); + } + } + static class DoricViewHolder extends RecyclerView.ViewHolder { FlowLayoutItemNode flowLayoutItemNode; diff --git a/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m b/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m index 232f2fca..56c3b883 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m @@ -158,6 +158,7 @@ @interface DoricFlowLayoutNode () 0 && position >= self.itemCount && self.onLoadMoreFuncId) { - [self callJSResponse:self.onLoadMoreFuncId, nil]; + [self callLoadMore]; } [node.view.doricLayout apply]; [node requestLayout];