diff --git a/modules/android/pool/src/main/java/com/openhippy/pool/RecycleViewPool.java b/modules/android/pool/src/main/java/com/openhippy/pool/RecycleViewPool.java index 1814d054265..83b31470812 100644 --- a/modules/android/pool/src/main/java/com/openhippy/pool/RecycleViewPool.java +++ b/modules/android/pool/src/main/java/com/openhippy/pool/RecycleViewPool.java @@ -17,6 +17,7 @@ package com.openhippy.pool; import android.view.View; +import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.util.Pools; @@ -51,6 +52,10 @@ public View acquire(@NonNull String key) { @Override public void release(@NonNull View instance) { + if (instance.getParent() instanceof ViewGroup) { + ViewGroup parent = (ViewGroup) instance.getParent(); + parent.removeView(instance); + } String className = instance.getClass().getName(); release(className, instance); } diff --git a/renderer/native/android/src/main/java/com/tencent/mtt/hippy/uimanager/ControllerManager.java b/renderer/native/android/src/main/java/com/tencent/mtt/hippy/uimanager/ControllerManager.java index d67d77df63c..74bd90fdaaf 100644 --- a/renderer/native/android/src/main/java/com/tencent/mtt/hippy/uimanager/ControllerManager.java +++ b/renderer/native/android/src/main/java/com/tencent/mtt/hippy/uimanager/ControllerManager.java @@ -35,6 +35,7 @@ import com.tencent.mtt.hippy.modules.Promise; import com.tencent.mtt.hippy.views.custom.HippyCustomPropsController; import com.tencent.mtt.hippy.views.hippylist.HippyRecyclerViewController; +import com.tencent.mtt.hippy.views.hippylist.HippyRecyclerViewWrapper; import com.tencent.mtt.hippy.views.image.HippyImageViewController; import com.tencent.mtt.hippy.views.list.HippyListItemViewController; import com.tencent.mtt.hippy.views.modal.HippyModalHostManager; diff --git a/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/hippylist/HippyRecyclerView.java b/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/hippylist/HippyRecyclerView.java index 2ae0483dbc2..7a6f1372bc2 100644 --- a/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/hippylist/HippyRecyclerView.java +++ b/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/hippylist/HippyRecyclerView.java @@ -90,6 +90,11 @@ public void onDestroy() { } } + protected void deleteChild(View childView) { + removeView(childView); + disableRecycle(childView); + } + public ADP getAdapter() { return listAdapter; } diff --git a/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/hippylist/HippyRecyclerViewController.java b/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/hippylist/HippyRecyclerViewController.java index d922c379be4..2837f88daeb 100644 --- a/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/hippylist/HippyRecyclerViewController.java +++ b/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/hippylist/HippyRecyclerViewController.java @@ -64,7 +64,7 @@ public class HippyRecyclerViewController e @Override public void onViewDestroy(HRW viewGroup) { - ((HRW) viewGroup).getRecyclerView().onDestroy(); + ((HRW) viewGroup).onDestroy(); } @Override @@ -84,8 +84,7 @@ public View getChildAt(HRW viewGroup, int index) { */ @Override protected void deleteChild(ViewGroup parentView, View childView) { - super.deleteChild(parentView, childView); - ((HRW) parentView).getRecyclerView().disableRecycle(childView); + ((HRW) parentView).getRecyclerView().deleteChild(childView); } @Override @@ -101,6 +100,11 @@ public void onBatchComplete(@NonNull HRW view) { view.setListData(); } + @Override + public boolean isRecyclable() { + return false; + } + @Override protected View createViewImpl(Context context) { return createViewImpl(context, null); @@ -115,6 +119,7 @@ protected View createViewImpl(@NonNull Context context, @Nullable Map props, HippyRecyclerView recyclerView) { LinearLayoutManager layoutManager = new HippyLinearLayoutManager(context); + layoutManager.setItemPrefetchEnabled(false); recyclerView.setItemAnimator(null); boolean enableOverPull = true; boolean hasStableIds = true; diff --git a/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/hippylist/HippyRecyclerViewWrapper.java b/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/hippylist/HippyRecyclerViewWrapper.java index bd4c654d255..853b7eeffe7 100644 --- a/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/hippylist/HippyRecyclerViewWrapper.java +++ b/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/hippylist/HippyRecyclerViewWrapper.java @@ -142,6 +142,10 @@ public void onBatchComplete() { recyclerView.onBatchComplete(); } + public void onDestroy() { + recyclerView.onDestroy(); + } + @Override public void setNestedScrollPriority(int direction, Priority priority) { recyclerView.setNestedScrollPriority(direction, priority);