Some small changes

master
Wynd 2025-08-10 02:07:45 +03:00
parent 0b2e301f8a
commit a33e3be0cc
3 changed files with 4 additions and 4 deletions

View File

@ -19,13 +19,12 @@ data class Recipe(
val lastModified: Long, val lastModified: Long,
val content: String val content: String
) { ) {
fun mainImage(ctx: Context): Bitmap? { fun previewImage(ctx: Context): Bitmap? {
if (this.preview != null) { if (this.preview != null) {
val file = File(ctx.filesDir, this.preview) val file = File(ctx.filesDir, this.preview)
if (file.exists()) { if (file.exists()) {
ctx.contentResolver.openInputStream(file.toUri()).use { ctx.contentResolver.openInputStream(file.toUri()).use {
val bitmap: Bitmap? = BitmapFactory.decodeStream(it) return BitmapFactory.decodeStream(it)
return bitmap
} }
} }
} }

View File

@ -1,5 +1,6 @@
package xyz.pixelatedw.recipe.data package xyz.pixelatedw.recipe.data
import android.os.Parcelable
import androidx.room.Dao import androidx.room.Dao
import androidx.room.Embedded import androidx.room.Embedded
import androidx.room.Entity import androidx.room.Entity

View File

@ -73,7 +73,7 @@ fun MainScreen(ctx: MainActivity, padding: PaddingValues, view: RecipesView) {
LazyColumn { LazyColumn {
items(recipes.value) { entry -> items(recipes.value) { entry ->
if (isInSearch(entry)) { if (isInSearch(entry)) {
val previewUri = entry.recipe.mainImage(LocalContext.current) val previewUri = entry.recipe.previewImage(LocalContext.current)
RecipePreview(entry, previewUri, onClick = { RecipePreview(entry, previewUri, onClick = {
view.setActive(entry) view.setActive(entry)
navController.navigate("info") navController.navigate("info")