Skip to content

Commit

Permalink
Fix crash when a request of TrackMaps of user are null
Browse files Browse the repository at this point in the history
  • Loading branch information
davidasensio committed Sep 4, 2020
1 parent 40b2ee4 commit f6bea7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Expand Up @@ -18,7 +18,11 @@ class ServerDataSource(private val service: TrackMapService) : RemoteDataSource
}

override suspend fun getUserTrackMaps(userId: String): Map<String, TrackMap> {
return service.getUserTrackMaps(userId)
return try {
service.getUserTrackMaps(userId)
} catch (e: Exception) {
HashMap() // Return an empty HashMap when a request returns null
}
}

override suspend fun saveTrackMap(userId: String, trackMapId: String, trackMap: TrackMap) {
Expand Down
Expand Up @@ -9,5 +9,5 @@ class UserHandler @Inject constructor(private val context: Context) {

@SuppressLint("HardwareIds")
fun getUserId() =
Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)
Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID) +"_"
}

0 comments on commit f6bea7c

Please sign in to comment.