remade scaling, fixed updating
This commit is contained in:
parent
6ce23c2081
commit
54693ff15d
|
@ -5,11 +5,11 @@ import android.content.Context
|
|||
import android.content.ContextWrapper
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Matrix
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.graphics.scale
|
||||
import com.google.firebase.components.BuildConfig
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
|
@ -33,8 +33,12 @@ fun generateThumbnailForImage(context: Context, imageHash: String) {
|
|||
val imageFile = File(picturesDir, "$imageHash.png")
|
||||
val imageContent = imageFile.inputStream().readBytes()
|
||||
var img = BitmapFactory.decodeByteArray(imageContent, 0, imageContent.size)
|
||||
img = img.scale(img.width/4,img.height/4)
|
||||
img.compress(Bitmap.CompressFormat.WEBP_LOSSY, 25, FileOutputStream(thumbnailFile))
|
||||
|
||||
val matrix = Matrix();
|
||||
matrix.postRotate(90f)
|
||||
val scaled = Bitmap.createScaledBitmap(img, img.width/4, img.height/4, true)
|
||||
val rotated = Bitmap.createBitmap(scaled, 0, 0, scaled.width, scaled.height, matrix, true)
|
||||
rotated.compress(Bitmap.CompressFormat.WEBP_LOSSY, 25, FileOutputStream(thumbnailFile))
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
|
|
|
@ -81,25 +81,21 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
|||
this.barcode = barcodeText.text.toString()
|
||||
}
|
||||
|
||||
if (abstractProduct != null) {
|
||||
if (abstractProduct != null && abstractProduct!!.barcode != "" && abstractProduct!!.name == "") {
|
||||
barcode = abstractProduct!!.barcode
|
||||
updatingExisting = false
|
||||
performRequest(abstractProduct!!.barcode)
|
||||
} else {
|
||||
} else if (abstractProduct != null && abstractProduct!!.barcode == ""){
|
||||
updatingExisting = true
|
||||
} else if (abstractProduct == null) {
|
||||
updatingExisting = false
|
||||
}
|
||||
|
||||
|
||||
// if (abstractProduct?.name == "" && abstractProduct?.barcode != "") {
|
||||
// updatingExisting = true
|
||||
// performRequest(abstractProduct?.barcode!!)
|
||||
// }
|
||||
|
||||
if (abstractProduct != null) {
|
||||
val imageThumbnailUri = getImageUri(this, File(thumbnailsDir, "${abstractProduct!!.imageHash}.webp"))
|
||||
pictureFile = File(picturesPath, "${abstractProduct!!.imageHash}.png]")
|
||||
imageView.setImageURI(imageThumbnailUri)
|
||||
imageView.rotation = 90f
|
||||
// imageView.rotation = 90f
|
||||
barcodeText.setText(abstractProduct!!.barcode)
|
||||
productNameText.text = abstractProduct!!.name
|
||||
netWeightText.text = abstractProduct!!.netWeight.toString()
|
||||
|
|
|
@ -80,7 +80,7 @@ class AbstractProductView: LinearLayout {
|
|||
thumbnailsDir.mkdirs()
|
||||
val imageUri = getImageUri(activity, File(thumbnailsDir, "${abstractProduct.imageHash}.webp"))
|
||||
productPicture!!.setImageURI(imageUri)
|
||||
productPicture!!.rotation = 90f
|
||||
// productPicture!!.rotation = 90f
|
||||
|
||||
productNameField!!.text = abstractProduct.name
|
||||
netWeightField!!.text = abstractProduct.netWeight.toString()
|
||||
|
|
|
@ -95,7 +95,7 @@ class ProductView: LinearLayout {
|
|||
val pictureFile = File(thumbnailsDir, "${linkedAbstractProduct.imageHash}.webp")
|
||||
val imageUri = getImageUri(activity, pictureFile)
|
||||
productImageView.setImageURI(imageUri)
|
||||
productImageView.rotation = 90f
|
||||
// productImageView.rotation = 90f
|
||||
|
||||
productNameTextView.text = linkedAbstractProduct.name
|
||||
productNetWeightTextView.text = linkedAbstractProduct.netWeight.toString()
|
||||
|
|
Loading…
Reference in New Issue