Skip to content

Commit

Permalink
set MapImages as loaded only after actually loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Helium314 authored and westnordost committed Aug 19, 2024
1 parent 9a73dc0 commit 1ee43c4
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class MapImages(private val resources: Resources, private val style: Style) {
if (id !in images) {
val name = resources.getResourceEntryName(id)
val (bitmap, sdf) = createBitmap(id)
withContext(Dispatchers.Main) { style.addImage(name, bitmap, sdf) }
images.add(id)
Log.v("MapImages", "Loaded 1 image")
withContext(Dispatchers.Main) { style.addImage(name, bitmap, sdf) }
}
}

Expand All @@ -38,13 +38,13 @@ class MapImages(private val resources: Resources, private val style: Style) {
val sdfImages = data.filter { it.sdf }.associateTo(HashMap()) { it.name to it.bitmap }
val nonSdfImages = data.filterNot { it.sdf }.associateTo(HashMap()) { it.name to it.bitmap }

images.addAll(loadIds)
Log.v("MapImages", "Loaded ${loadIds.size} images")

withContext(Dispatchers.Main) {
if (nonSdfImages.isNotEmpty()) style.addImages(nonSdfImages, false)
if (sdfImages.isNotEmpty()) style.addImages(sdfImages, true)
}

images.addAll(loadIds)
Log.v("MapImages", "Loaded ${loadIds.size} images")
}

private data class ImageWithMetadata(val name: String, val bitmap: Bitmap, val sdf: Boolean)
Expand Down

0 comments on commit 1ee43c4

Please sign in to comment.