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 6e8f77a1..b9500423 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 @@ -46,6 +46,7 @@ class FlowAdapter extends RecyclerView.Adapter { int batchCount = 15; SparseArray itemValues = new SparseArray<>(); int loadAnchor = -1; + boolean loadMore = false; FlowAdapter(FlowLayoutNode flowLayoutNode) { this.flowLayoutNode = flowLayoutNode; @@ -62,7 +63,7 @@ class FlowAdapter extends RecyclerView.Adapter { @Override public void onBindViewHolder(@NonNull DoricViewHolder holder, int position) { JSValue jsValue = getItemModel(position); - boolean fullSpan = this.flowLayoutNode.loadMore && position >= this.itemCount; + boolean fullSpan = this.loadMore && position >= this.itemCount; if (jsValue != null && jsValue.isObject()) { JSObject jsObject = jsValue.asObject(); holder.flowLayoutItemNode.setId(jsObject.getProperty("id").asString().value()); @@ -84,7 +85,7 @@ class FlowAdapter extends RecyclerView.Adapter { layoutParams.setFullSpan(true); holder.itemView.setLayoutParams(layoutParams); } - if (this.flowLayoutNode.loadMore + if (this.loadMore && position >= this.itemCount && !TextUtils.isEmpty(this.flowLayoutNode.onLoadMoreFuncId)) { callLoadMore(); @@ -93,7 +94,7 @@ class FlowAdapter extends RecyclerView.Adapter { @Override public int getItemCount() { - return this.itemCount + (this.flowLayoutNode.loadMore ? 1 : 0); + return this.itemCount + (this.loadMore ? 1 : 0); } @Override diff --git a/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutNode.java b/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutNode.java index 2610d6a5..c791fbec 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutNode.java @@ -93,7 +93,7 @@ public class FlowLayoutNode extends SuperNode implements IDoricScr } }; String onLoadMoreFuncId; - boolean loadMore = false; + private boolean loadMore = false; String loadMoreViewId; private final Set listeners = new HashSet<>(); private String onScrollFuncId; @@ -241,6 +241,7 @@ public class FlowLayoutNode extends SuperNode implements IDoricScr mView.post(new Runnable() { @Override public void run() { + flowAdapter.loadMore = loadMore; flowAdapter.itemCount = itemCount; flowAdapter.notifyDataSetChanged(); } diff --git a/doric-android/doric/src/main/java/pub/doric/shader/list/ListAdapter.java b/doric-android/doric/src/main/java/pub/doric/shader/list/ListAdapter.java index 8243c4c7..8a95ca5d 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/list/ListAdapter.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/list/ListAdapter.java @@ -48,7 +48,7 @@ class ListAdapter extends RecyclerView.Adapter { int itemCount = 0; int loadAnchor = -1; - + boolean loadMore = false; @NonNull @Override public DoricViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { @@ -66,7 +66,7 @@ class ListAdapter extends RecyclerView.Adapter { holder.listItemNode.reset(); holder.listItemNode.blend(jsObject.getProperty("props").asObject()); } - if (this.listNode.loadMore + if (this.loadMore && position >= this.itemCount && !TextUtils.isEmpty(this.listNode.onLoadMoreFuncId)) { callLoadMore(); @@ -75,7 +75,7 @@ class ListAdapter extends RecyclerView.Adapter { @Override public int getItemCount() { - return this.itemCount + (this.listNode.loadMore ? 1 : 0); + return this.itemCount + (this.loadMore ? 1 : 0); } @Override diff --git a/doric-android/doric/src/main/java/pub/doric/shader/list/ListNode.java b/doric-android/doric/src/main/java/pub/doric/shader/list/ListNode.java index 1fe63ac6..46ff57d3 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/list/ListNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/list/ListNode.java @@ -64,7 +64,7 @@ public class ListNode extends SuperNode implements IDoricScrollabl int itemCount = 0; int batchCount = 15; SparseArray itemValues = new SparseArray<>(); - boolean loadMore = false; + private boolean loadMore = false; String loadMoreViewId; private final Set listeners = new HashSet<>(); private String onScrollFuncId; @@ -214,6 +214,7 @@ public class ListNode extends SuperNode implements IDoricScrollabl @SuppressLint("NotifyDataSetChanged") @Override public void run() { + listAdapter.loadMore = loadMore; listAdapter.itemCount = itemCount; listAdapter.notifyDataSetChanged(); }