From d1a799756d96a2f8c7f035cd16157089b3ba9ee2 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Wed, 14 Jun 2023 19:54:22 +0800 Subject: [PATCH] android: fix slider's item cannot call onClick after reloaded --- .../java/pub/doric/shader/slider/SlideAdapter.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doric-android/doric/src/main/java/pub/doric/shader/slider/SlideAdapter.java b/doric-android/doric/src/main/java/pub/doric/shader/slider/SlideAdapter.java index 62e79c1a..2bf75bd6 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/slider/SlideAdapter.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/slider/SlideAdapter.java @@ -117,9 +117,15 @@ class SlideAdapter extends RecyclerView.Adapter { String id = itemValues.get(index); if (TextUtils.isEmpty(id)) { + int batchCount = this.batchCount; + int start = position; + while (start > 0 && TextUtils.isEmpty(itemValues.get(start - 1))) { + start--; + batchCount++; + } AsyncResult asyncResult = sliderNode.pureCallJSResponse( "renderBunchedItems", - index, + start, batchCount); try { JSDecoder jsDecoder = asyncResult.synchronous().get(); @@ -129,7 +135,7 @@ class SlideAdapter extends RecyclerView.Adapter { for (int i = 0; i < jsArray.size(); i++) { JSObject itemModel = jsArray.get(i).asObject(); String itemId = itemModel.getProperty("id").asString().value(); - itemValues.put(i + index, itemId); + itemValues.put(i + start, itemId); sliderNode.setSubModel(itemId, itemModel); } return sliderNode.getSubModel(itemValues.get(index));