android: fix slider's item cannot call onClick after reloaded

This commit is contained in:
pengfei.zhou 2023-06-14 19:54:22 +08:00 committed by jingpeng
parent 0a9ababc2d
commit d1a799756d

View File

@ -117,9 +117,15 @@ class SlideAdapter extends RecyclerView.Adapter<SlideAdapter.DoricViewHolder> {
String id = itemValues.get(index); String id = itemValues.get(index);
if (TextUtils.isEmpty(id)) { if (TextUtils.isEmpty(id)) {
int batchCount = this.batchCount;
int start = position;
while (start > 0 && TextUtils.isEmpty(itemValues.get(start - 1))) {
start--;
batchCount++;
}
AsyncResult<JSDecoder> asyncResult = sliderNode.pureCallJSResponse( AsyncResult<JSDecoder> asyncResult = sliderNode.pureCallJSResponse(
"renderBunchedItems", "renderBunchedItems",
index, start,
batchCount); batchCount);
try { try {
JSDecoder jsDecoder = asyncResult.synchronous().get(); JSDecoder jsDecoder = asyncResult.synchronous().get();
@ -129,7 +135,7 @@ class SlideAdapter extends RecyclerView.Adapter<SlideAdapter.DoricViewHolder> {
for (int i = 0; i < jsArray.size(); i++) { for (int i = 0; i < jsArray.size(); i++) {
JSObject itemModel = jsArray.get(i).asObject(); JSObject itemModel = jsArray.get(i).asObject();
String itemId = itemModel.getProperty("id").asString().value(); String itemId = itemModel.getProperty("id").asString().value();
itemValues.put(i + index, itemId); itemValues.put(i + start, itemId);
sliderNode.setSubModel(itemId, itemModel); sliderNode.setSubModel(itemId, itemModel);
} }
return sliderNode.getSubModel(itemValues.get(index)); return sliderNode.getSubModel(itemValues.get(index));