armutyus / VideoGamesProject

0 stars 0 forks source link

Video game list request from room may crash the app #1

Open HasimD opened 2 years ago

HasimD commented 2 years ago

List size can be smaller than 3 or empty. We should consider this. Otherwise it can cause an error like this:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.armutyus.videogamesproject, PID: 12959
    java.lang.IndexOutOfBoundsException: fromIndex: 3, toIndex: 0
        at kotlin.collections.EmptyList.subList(Collections.kt:49)
        at com.armutyus.videogamesproject.view.HomeFragment.listsFromRoom$lambda-2(HomeFragment.kt:175)
        at com.armutyus.videogamesproject.view.HomeFragment.$r8$lambda$8FPE2h4pea1ry1BQCjCJq1GAHow(Unknown Source:0)
        at com.armutyus.videogamesproject.view.HomeFragment$$ExternalSyntheticLambda1.onChanged(Unknown Source:4)
        at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
        at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:146)
        at androidx.lifecycle.LiveData$ObserverWrapper.activeStateChanged(LiveData.java:468)
        at androidx.lifecycle.LiveData$LifecycleBoundObserver.onStateChanged(LiveData.java:425)
        at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)
        at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:196)
        at androidx.lifecycle.LiveData.observe(LiveData.java:205)
        at com.armutyus.videogamesproject.view.HomeFragment.listsFromRoom(HomeFragment.kt:173)
        at com.armutyus.videogamesproject.view.HomeFragment.observeLiveData$lambda-0(HomeFragment.kt:71)
        at com.armutyus.videogamesproject.view.HomeFragment.$r8$lambda$OHrAwapv03H_oCh0ysgNuupYP8o(Unknown Source:0)
        at com.armutyus.videogamesproject.view.HomeFragment$$ExternalSyntheticLambda0.onChanged(Unknown Source:4)
        at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
        at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
        at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
        at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
        at com.armutyus.videogamesproject.viewmodel.HomeViewModel$makeGamesResponse$1.invokeSuspend(HomeViewModel.kt:38)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7842)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
HasimD commented 2 years ago

It's happening on install. So to get this error, you should delete the app and install again. @armutyus