bugfix:fix Android List validateViewHolderForOffsetPosition error
This commit is contained in:
parent
13453f6a30
commit
c9dd90d19b
@ -88,6 +88,7 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> implements IDoricScr
|
||||
private String onScrollFuncId;
|
||||
private String onScrollEndFuncId;
|
||||
private DoricJSDispatcher jsDispatcher = new DoricJSDispatcher();
|
||||
private int itemCount = 0;
|
||||
|
||||
public FlowLayoutNode(DoricContext doricContext) {
|
||||
super(doricContext);
|
||||
@ -138,7 +139,7 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> implements IDoricScr
|
||||
if (!prop.isNumber()) {
|
||||
return;
|
||||
}
|
||||
this.flowAdapter.itemCount = prop.asNumber().toInt();
|
||||
this.itemCount = prop.asNumber().toInt();
|
||||
break;
|
||||
case "renderItem":
|
||||
if (!prop.isString()) {
|
||||
@ -220,6 +221,7 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> implements IDoricScr
|
||||
mView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
flowAdapter.itemCount = itemCount;
|
||||
flowAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
@ -44,6 +44,8 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
|
||||
this.listNode = listNode;
|
||||
}
|
||||
|
||||
private int itemCount = 0;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DoricViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
@ -67,7 +69,7 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return this.listNode.itemCount + (this.listNode.loadMore ? 1 : 0);
|
||||
return this.itemCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -84,6 +86,10 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
|
||||
return super.getItemViewType(position);
|
||||
}
|
||||
|
||||
public void setItemCount(int itemCount) {
|
||||
this.itemCount = itemCount;
|
||||
}
|
||||
|
||||
private JSValue getItemModel(int position) {
|
||||
if (position >= this.listNode.itemCount) {
|
||||
return this.listNode.getSubModel(this.listNode.loadMoreViewId);
|
||||
|
@ -59,10 +59,10 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
|
||||
SparseArray<String> itemValues = new SparseArray<>();
|
||||
boolean loadMore = false;
|
||||
String loadMoreViewId;
|
||||
private Set<DoricScrollChangeListener> listeners = new HashSet<>();
|
||||
private final Set<DoricScrollChangeListener> listeners = new HashSet<>();
|
||||
private String onScrollFuncId;
|
||||
private String onScrollEndFuncId;
|
||||
private DoricJSDispatcher jsDispatcher = new DoricJSDispatcher();
|
||||
private final DoricJSDispatcher jsDispatcher = new DoricJSDispatcher();
|
||||
|
||||
public ListNode(DoricContext doricContext) {
|
||||
super(doricContext);
|
||||
@ -137,6 +137,7 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
|
||||
mView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
listAdapter.setItemCount(itemCount + (loadMore ? 1 : 0));
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
@ -44,6 +44,7 @@ public class SliderNode extends SuperNode<RecyclerView> {
|
||||
private final SlideAdapter slideAdapter;
|
||||
private String onPageSlidedFuncId;
|
||||
private int lastPosition = 0;
|
||||
private int itemCount = 0;
|
||||
|
||||
public SliderNode(DoricContext doricContext) {
|
||||
super(doricContext);
|
||||
@ -135,6 +136,7 @@ public class SliderNode extends SuperNode<RecyclerView> {
|
||||
mView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
slideAdapter.itemCount = itemCount;
|
||||
slideAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
@ -145,7 +147,7 @@ public class SliderNode extends SuperNode<RecyclerView> {
|
||||
protected void blend(RecyclerView view, String name, JSValue prop) {
|
||||
switch (name) {
|
||||
case "itemCount":
|
||||
this.slideAdapter.itemCount = prop.asNumber().toInt();
|
||||
this.itemCount = prop.asNumber().toInt();
|
||||
break;
|
||||
case "renderPage":
|
||||
// If reset renderItem,should reset native cache.
|
||||
|
Reference in New Issue
Block a user