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