Skip to content

Commit e8b5ae2

Browse files
committed
Remove unnecessary non-null assertions
1 parent ba57f97 commit e8b5ae2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

app/src/main/java/ai/elimu/content_provider/ui/letter_sound/LetterSoundsFragment.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class LetterSoundsFragment : Fragment() {
3333
inflater: LayoutInflater,
3434
container: ViewGroup?,
3535
savedInstanceState: Bundle?
36-
): View? {
36+
): View {
3737
Log.i(TAG, "onCreateView")
3838

3939
letterSoundsViewModel = ViewModelProvider(this)[LetterSoundsViewModel::class.java]
@@ -50,7 +50,7 @@ class LetterSoundsFragment : Fragment() {
5050
super.onStart()
5151

5252
// Download LetterSounds from REST API, and store them in the database
53-
val baseApplication = activity!!.application as BaseApplication
53+
val baseApplication = activity?.application as? BaseApplication ?: return
5454
val retrofit = baseApplication.retrofit
5555
val letterSoundsService = retrofit.create(
5656
LetterSoundsService::class.java
@@ -66,7 +66,7 @@ class LetterSoundsFragment : Fragment() {
6666

6767
Log.i(TAG, "response: $response")
6868
if (response.isSuccessful) {
69-
val letterSoundGsons = response.body()!!
69+
val letterSoundGsons = response.body() ?: return
7070
Log.i(TAG, "letterSoundGsons.size(): " + letterSoundGsons.size)
7171

7272
if (letterSoundGsons.size > 0) {
@@ -162,7 +162,7 @@ class LetterSoundsFragment : Fragment() {
162162
// Update the UI
163163
val letterSounds = letterSoundDao.loadAll()
164164
Log.i(TAG, "letterSounds.size(): " + letterSounds.size)
165-
activity!!.runOnUiThread {
165+
activity?.runOnUiThread {
166166
binding.textLetterSounds.text = "letterSounds.size(): " + letterSounds.size
167167
Snackbar.make(
168168
binding.textLetterSounds,

0 commit comments

Comments
 (0)