Skip to content

Commit 9f90ff3

Browse files
committed
#155 fix android potential memory leak in databinding
1 parent d229cfe commit 9f90ff3

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

mvvm-databinding/src/main/kotlin/dev/icerock/moko/mvvm/MvvmEventsFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ abstract class MvvmEventsFragment<DB : ViewDataBinding, VM, Listener : Any> :
1515
super.onCreate(savedInstanceState)
1616

1717
@Suppress("UNCHECKED_CAST")
18-
viewModel.eventsDispatcher.bind(this, this as Listener)
18+
viewModel.eventsDispatcher.bind(viewLifecycleOwner, this as Listener)
1919
}
2020
}

mvvm-databinding/src/main/kotlin/dev/icerock/moko/mvvm/MvvmFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ abstract class MvvmFragment<DB : ViewDataBinding, VM : ViewModel> : Fragment() {
4343
savedInstanceState: Bundle?
4444
): View? {
4545
_binding = DataBindingUtil.inflate(inflater, layoutId, container, false)
46-
binding.lifecycleOwner = this
46+
binding.lifecycleOwner = viewLifecycleOwner
4747
return binding.root
4848
}
4949

mvvm-viewbinding/src/main/kotlin/dev/icerock/moko/mvvm/viewbinding/MvvmEventsFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ abstract class MvvmEventsFragment<VB : ViewBinding, VM, Listener : Any> :
1515
super.onCreate(savedInstanceState)
1616

1717
@Suppress("UNCHECKED_CAST")
18-
viewModel.eventsDispatcher.bind(this, this as Listener)
18+
viewModel.eventsDispatcher.bind(viewLifecycleOwner, this as Listener)
1919
}
2020
}

0 commit comments

Comments
 (0)