Split dialog shells into ui/; move image fetchers to app.net; use shared LastLocationStore; clean imports

- Move Nearby/Username/About shells to app.klottr.ui.CommonDialogsShell
- Move Wiki/Fornsok/DM shells to app.klottr.ui.DetailDialogsShell
- Extract fetchWikiThumbBitmap to app.klottr.net.WikiThumb
- Add app.klottr.net.HttpImage (fetchBitmapFromUrl) and use it from DM dialog
- Switch detail dialogs to LastLocationStore.lastKnown (GeoPoint) from shared API
- Remove unused imports from MainActivity
This commit is contained in:
2025-09-20 00:18:24 +02:00
parent 8580ff198c
commit 2bfec2d737
5 changed files with 850 additions and 530 deletions

View File

@@ -0,0 +1,24 @@
package app.klottr.net
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import java.io.BufferedInputStream
import java.net.HttpURLConnection
import java.net.URL
// Enkel (blockerande) hämtning av bitmap från URL. Kör detta på Dispatchers.IO i anroparen.
suspend fun fetchBitmapFromUrl(url: String): Bitmap? {
return try {
val conn = (URL(url).openConnection() as HttpURLConnection).apply {
connectTimeout = 7000
readTimeout = 7000
}
conn.inputStream.use { ins ->
BufferedInputStream(ins).use { bis ->
BitmapFactory.decodeStream(bis)
}
}
} catch (_: Throwable) {
null
}
}