boolder-org / boolder-android

Boolder Android app https://www.boolder.com/en/app
MIT License
28 stars 12 forks source link

Attempt to fix crash in `LocationProvider` #61

Closed wang-li closed 1 year ago

wang-li commented 1 year ago

The following crash was happening:

Exception java.lang.NullPointerException:
  at com.boolder.boolder.utils.LocationProvider$moveCameraToUserPosition$2.invoke (LocationProvider.kt:101)
  at com.boolder.boolder.utils.LocationProvider$moveCameraToUserPosition$2.invoke (LocationProvider.kt:100)
  at com.boolder.boolder.utils.LocationProvider.moveCameraToUserPosition$lambda$3 (LocationProvider.kt:100)
  at com.boolder.boolder.utils.LocationProvider.$r8$lambda$BBoJsjHP34LgiCfb3988sXjVoq4
  at com.boolder.boolder.utils.LocationProvider$$ExternalSyntheticLambda0.onSuccess
  at com.google.android.gms.tasks.zzm.run (com.google.android.gms:play-services-tasks@@18.0.2:1)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:210)
  at android.os.Looper.loop (Looper.java:299)
  at android.app.ActivityThread.main (ActivityThread.java:8337)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:556)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1037)

Apparently, this was due to the invocation of a null callback. In order to fix this crash, the callback mechanism has been replaced by a flow collection, that should not be active when the activity is destroyed.