Skip to content

Commit 3d0ac88

Browse files
fix: shutdown ImageLoader onDropViewInstance on android (#311)
* fix: shutdown ImageLoader when onDropViewInstance * Create lucky-dots-cheat.md --------- Co-authored-by: Oskar Kwaśniewski <oskarkwasniewski@icloud.com>
1 parent 464a791 commit 3d0ac88

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

.changeset/lucky-dots-cheat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-native-bottom-tabs": patch
3+
---
4+
5+
fix: propery destroy image loader on Android

packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview/RCTTabView.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,10 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
384384
updateTextAppearance()
385385
}
386386

387+
fun onDropViewInstance() {
388+
imageLoader.shutdown()
389+
}
390+
387391
private fun updateTextAppearance() {
388392
if (fontSize != null || fontFamily != null || fontWeight != null) {
389393
val menuView = bottomNavigation.getChildAt(0) as? ViewGroup ?: return
@@ -455,9 +459,4 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
455459
updateItems(items)
456460
uiModeConfiguration = newConfig?.uiMode ?: uiModeConfiguration
457461
}
458-
459-
override fun onDetachedFromWindow() {
460-
super.onDetachedFromWindow()
461-
imageLoader.shutdown()
462-
}
463462
}

packages/react-native-bottom-tabs/android/src/newarch/RCTTabViewManager.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class RCTTabViewManager(context: ReactApplicationContext) :
4343

4444
}
4545

46+
override fun onDropViewInstance(view: ReactBottomNavigationView) {
47+
super.onDropViewInstance(view)
48+
view.onDropViewInstance()
49+
}
50+
4651
override fun getName(): String {
4752
return tabViewImpl.getName()
4853
}

packages/react-native-bottom-tabs/android/src/oldarch/RCTTabViewManager.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ class RCTTabViewManager(context: ReactApplicationContext) : ViewGroupManager<Rea
3939
return view
4040
}
4141

42+
override fun onDropViewInstance(view: ReactBottomNavigationView) {
43+
super.onDropViewInstance(view)
44+
view.onDropViewInstance()
45+
}
46+
4247
override fun getChildCount(parent: ReactBottomNavigationView): Int {
4348
return tabViewImpl.getChildCount(parent)
4449
}

0 commit comments

Comments
 (0)