Some small changes
parent
0b2e301f8a
commit
a33e3be0cc
|
@ -19,13 +19,12 @@ data class Recipe(
|
|||
val lastModified: Long,
|
||||
val content: String
|
||||
) {
|
||||
fun mainImage(ctx: Context): Bitmap? {
|
||||
fun previewImage(ctx: Context): Bitmap? {
|
||||
if (this.preview != null) {
|
||||
val file = File(ctx.filesDir, this.preview)
|
||||
if (file.exists()) {
|
||||
ctx.contentResolver.openInputStream(file.toUri()).use {
|
||||
val bitmap: Bitmap? = BitmapFactory.decodeStream(it)
|
||||
return bitmap
|
||||
return BitmapFactory.decodeStream(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package xyz.pixelatedw.recipe.data
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
|
|
|
@ -73,7 +73,7 @@ fun MainScreen(ctx: MainActivity, padding: PaddingValues, view: RecipesView) {
|
|||
LazyColumn {
|
||||
items(recipes.value) { entry ->
|
||||
if (isInSearch(entry)) {
|
||||
val previewUri = entry.recipe.mainImage(LocalContext.current)
|
||||
val previewUri = entry.recipe.previewImage(LocalContext.current)
|
||||
RecipePreview(entry, previewUri, onClick = {
|
||||
view.setActive(entry)
|
||||
navController.navigate("info")
|
||||
|
|
Loading…
Reference in New Issue