mirror of
https://github.com/Skysamara/android-kotlin-fundamentals-apps.git
synced 2025-12-06 06:16:03 +00:00
Fix: KotlinNullPointerException in LiveData when attempting to get a value
Adding a null check to avoid KotlinNullPointerException. Replacing isEmpty() call with isNullOrEmpty().
This commit is contained in:
parent
d70a45c3a1
commit
57995e8080
@ -114,7 +114,7 @@ class DevByteViewModel(application: Application) : AndroidViewModel(application)
|
|||||||
|
|
||||||
} catch (networkError: IOException) {
|
} catch (networkError: IOException) {
|
||||||
// Show a Toast error message and hide the progress bar.
|
// Show a Toast error message and hide the progress bar.
|
||||||
if(playlist.value!!.isEmpty())
|
if(playlist.value.isNullOrEmpty())
|
||||||
_eventNetworkError.value = true
|
_eventNetworkError.value = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,7 +114,7 @@ class DevByteViewModel(application: Application) : AndroidViewModel(application)
|
|||||||
|
|
||||||
} catch (networkError: IOException) {
|
} catch (networkError: IOException) {
|
||||||
// Show a Toast error message and hide the progress bar.
|
// Show a Toast error message and hide the progress bar.
|
||||||
if(playlist.value!!.isEmpty())
|
if(playlist.value.isNullOrEmpty())
|
||||||
_eventNetworkError.value = true
|
_eventNetworkError.value = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user