Some small changes
parent
0b2e301f8a
commit
a33e3be0cc
|
@ -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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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")
|
||||||
|
|
Loading…
Reference in New Issue