File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
packages/react-native-nitro-image
android/src/main/java/com/margelo/nitro/image Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,14 @@ import android.widget.ImageView
77import androidx.annotation.Keep
88import androidx.core.view.isVisible
99import com.facebook.common.internal.DoNotStrip
10+ import com.margelo.nitro.views.RecyclableView
1011import kotlinx.coroutines.CoroutineScope
1112import kotlinx.coroutines.Dispatchers
1213import kotlinx.coroutines.launch
1314
1415@DoNotStrip
1516@Keep
16- class HybridImageView (context : Context ): HybridNitroImageViewSpec() {
17+ class HybridImageView (context : Context ): HybridNitroImageViewSpec(), RecyclableView {
1718 companion object {
1819 private const val TAG = " HybridImageView"
1920 }
@@ -48,6 +49,11 @@ class HybridImageView(context: Context): HybridNitroImageViewSpec() {
4849 field = value
4950 }
5051
52+ override fun prepareForRecycle () {
53+ onDisappear()
54+ imageView.setImageBitmap(null )
55+ }
56+
5157 private fun updateResizeMode () {
5258 imageView.scaleType = when (resizeMode) {
5359 ResizeMode .COVER -> ImageView .ScaleType .CENTER_CROP
Original file line number Diff line number Diff line change @@ -110,3 +110,11 @@ extension HybridImageView: ViewLifecycleDelegate {
110110 }
111111}
112112
113+ // Implementation to allow view recycling
114+ extension HybridImageView : RecyclableView {
115+ func prepareForRecycle( ) {
116+ willHide ( )
117+ imageView. image = nil
118+ }
119+ }
120+
You can’t perform that action at this time.
0 commit comments