Prevent crash when destroying GroupedCallLogData if lastCallLogViewModel wasn't created yet
This commit is contained in:
parent
890d217ab7
commit
083c1afa11
1 changed files with 10 additions and 2 deletions
|
@ -27,10 +27,18 @@ class GroupedCallLogData(callLog: CallLog) {
|
|||
val callLogs = arrayListOf(callLog)
|
||||
val lastCallLogViewModel: CallLogViewModel
|
||||
get() {
|
||||
return CallLogViewModel(lastCallLog)
|
||||
if (::_lastCallLogViewModel.isInitialized) {
|
||||
return _lastCallLogViewModel
|
||||
}
|
||||
_lastCallLogViewModel = CallLogViewModel(lastCallLog)
|
||||
return _lastCallLogViewModel
|
||||
}
|
||||
|
||||
private lateinit var _lastCallLogViewModel: CallLogViewModel
|
||||
|
||||
fun destroy() {
|
||||
lastCallLogViewModel.destroy()
|
||||
if (::_lastCallLogViewModel.isInitialized) {
|
||||
lastCallLogViewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue