feat:Fix List call onLoadMore multi times
This commit is contained in:
@@ -45,6 +45,7 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
|
||||
}
|
||||
|
||||
private int itemCount = 0;
|
||||
private int loadAnchor = 0;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
@@ -62,8 +63,8 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
|
||||
holder.listItemNode.setId(jsObject.getProperty("id").asString().value());
|
||||
holder.listItemNode.blend(jsObject.getProperty("props").asObject());
|
||||
}
|
||||
if (position >= this.listNode.itemCount) {
|
||||
this.listNode.callJSResponse(this.listNode.onLoadMoreFuncId);
|
||||
if (position >= this.listNode.itemCount && !TextUtils.isEmpty(this.listNode.onLoadMoreFuncId)) {
|
||||
callLoadMore();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,6 +143,13 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
|
||||
}
|
||||
}
|
||||
|
||||
private void callLoadMore() {
|
||||
if (loadAnchor != itemCount) {
|
||||
loadAnchor = itemCount;
|
||||
this.listNode.callJSResponse(this.listNode.onLoadMoreFuncId);
|
||||
}
|
||||
}
|
||||
|
||||
static class DoricViewHolder extends RecyclerView.ViewHolder {
|
||||
ListItemNode listItemNode;
|
||||
|
||||
|
@@ -16,7 +16,6 @@
|
||||
package pub.doric.shader.list;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
|
||||
@@ -63,7 +62,6 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
|
||||
private String onScrollFuncId;
|
||||
private String onScrollEndFuncId;
|
||||
private final DoricJSDispatcher jsDispatcher = new DoricJSDispatcher();
|
||||
|
||||
public ListNode(DoricContext doricContext) {
|
||||
super(doricContext);
|
||||
this.listAdapter = new ListAdapter(this);
|
||||
|
Reference in New Issue
Block a user