feat embalajes #refs 4021
This commit is contained in:
parent
050e7d1dab
commit
413f9b767e
|
@ -7,12 +7,11 @@ import android.graphics.Color
|
|||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.util.Log.d
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.esafirm.imagepicker.features.ImagePickerConfig
|
||||
import com.esafirm.imagepicker.features.registerImagePicker
|
||||
|
@ -21,10 +20,11 @@ import es.verdnatura.R
|
|||
import es.verdnatura.databinding.FragmentPackagingObsBinding
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYID
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYNUMBERIMAGES
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONORIGINAL
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONS
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYTYPE
|
||||
import es.verdnatura.domain.ConstAndValues.SUPPLIERNAME
|
||||
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
|
||||
import es.verdnatura.domain.notNull
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnImageTrashClickListener
|
||||
import es.verdnatura.presentation.common.OnImageUpdateClickListener
|
||||
|
@ -37,6 +37,7 @@ import es.verdnatura.presentation.view.feature.packaging.adapter.ListImageAdapte
|
|||
import es.verdnatura.presentation.view.feature.packaging.fragment.ObservFragment.ImageUtils.getDrawableFromImageUri
|
||||
import es.verdnatura.presentation.view.feature.packaging.fragment.PackagingViewModel.PackagingViewModel
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
|
@ -46,7 +47,6 @@ import java.text.SimpleDateFormat
|
|||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
class ObservFragment(
|
||||
var entryPoint: String = ""
|
||||
|
||||
|
@ -56,6 +56,7 @@ class ObservFragment(
|
|||
|
||||
private var adapterListImage: ListImageAdapter? = null
|
||||
private var listImages: MutableList<Image>? = null
|
||||
private var listImagesOriginal: MutableList<Image>? = mutableListOf()
|
||||
private lateinit var customDialog: CustomDialog
|
||||
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||
private var layoutManager: LinearLayoutManager? = null
|
||||
|
@ -77,82 +78,122 @@ class ObservFragment(
|
|||
ma.hideBottomNavigation(View.GONE)
|
||||
setToolBar()
|
||||
setEvents()
|
||||
setObservations()
|
||||
loadImages()
|
||||
super.init()
|
||||
}
|
||||
|
||||
private fun setObservations() {
|
||||
binding.observations.setText(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||
ENTRYOBSERVATIONS
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun setToolBar() {
|
||||
|
||||
binding.mainToolbar.toolbarTitle.text = buildString {
|
||||
append(mobileApplication.dataStoreApp.readDataStoreKey<String>(ENTRYTYPE))
|
||||
append(": ")
|
||||
append(mobileApplication.dataStoreApp.readDataStoreKey<String>(SUPPLIERNAME))
|
||||
}
|
||||
|
||||
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||
val iconNext = ImageView(context)
|
||||
iconNext.setImageResource(R.drawable.ic_chevron_right_black_24dp)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
iconNext.tooltipText = getString(R.string.nextEntrySummary)
|
||||
}
|
||||
iconNext.tooltipText = getString(R.string.nextEntrySummary)
|
||||
|
||||
listIcons.add(iconNext)
|
||||
binding.mainToolbar.toolbarIcons.adapter =
|
||||
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
||||
override fun onOptionsItemSelected(item: Drawable) {
|
||||
when (item) {
|
||||
iconNext.drawable -> {
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
ENTRYNUMBERIMAGES,
|
||||
if (listImages.isNullOrEmpty()) 0 else {
|
||||
listImages!!.size
|
||||
}
|
||||
)
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
ENTRYOBSERVATIONS,
|
||||
binding.observations.text.toString()
|
||||
|
||||
if (listImages == null || listImages!!.isEmpty()) {
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.entryInputImage),
|
||||
isError = true,
|
||||
isPlayed = true
|
||||
)
|
||||
} else {
|
||||
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
ENTRYNUMBERIMAGES,
|
||||
if (listImages.isNullOrEmpty()) 0 else {
|
||||
listImages!!.size
|
||||
}
|
||||
)
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
ENTRYOBSERVATIONS,
|
||||
binding.observations.text.toString()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
if (!binding.observations.text.isNullOrBlank()) {
|
||||
val originalObservation =
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||
ENTRYOBSERVATIONORIGINAL
|
||||
)
|
||||
|
||||
viewModel.entryUpdateObserv(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(
|
||||
ENTRYID
|
||||
),
|
||||
originalObservation + " " + binding.observations.text.toString()
|
||||
)
|
||||
|
||||
} else {
|
||||
openSummary()
|
||||
}
|
||||
}
|
||||
viewModel.entry_updateObserv(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(
|
||||
ENTRYID
|
||||
), binding.observations.text.toString()
|
||||
)
|
||||
ma.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(title = getString(R.string.titlePackagingSummary)),
|
||||
getString(R.string.titlePackagingSummary)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
binding.mainToolbar.toolbarIcons.layoutManager =
|
||||
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||
|
||||
}
|
||||
|
||||
private fun openSummary() {
|
||||
ma.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(title = getString(R.string.titlePackagingSummary)),
|
||||
getString(R.string.titlePackagingSummary)
|
||||
)
|
||||
}
|
||||
|
||||
private fun setEvents() {
|
||||
|
||||
val launcher = registerImagePicker {
|
||||
for (image in it) {
|
||||
d("VERDNATURA::", "el nombre es " + image.name)
|
||||
d("VERDNATURA::", "el nombre es " + image.uri)
|
||||
//binding.imageView30.setImageURI(image.uri)
|
||||
}
|
||||
listImages?.clear()
|
||||
listImages = it as MutableList<Image>
|
||||
|
||||
setAdapter(listImages!!)
|
||||
// listImages?.clear()
|
||||
try {
|
||||
listImages = it as? MutableList<Image>
|
||||
// listImagesOriginal = it as? MutableList<Image>
|
||||
} catch (ex: Exception) {
|
||||
|
||||
}
|
||||
if (listImages != null && listImages!!.isNotEmpty()) {
|
||||
//setAdapter(listImages!!)
|
||||
// listImagesOriginal?.clear()
|
||||
// listImagesOriginal?.addAll(listImages!!)
|
||||
runBlocking { mobileApplication.dataStoreApp.saveImages(listImages) }
|
||||
loadImages()
|
||||
uploadImages(listImages!!)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
binding.mainToolbar.backButton.setOnClickListener {
|
||||
requireActivity().onBackPressed()
|
||||
ma.onMyBackPressed()
|
||||
}
|
||||
binding.openPickerImages.setOnClickListener {
|
||||
val config = ImagePickerConfig {
|
||||
doneButtonText = "HECHO" // done button text
|
||||
doneButtonText = getString(R.string.done) // done button text
|
||||
language = "es" // Set image picker language
|
||||
arrowColor = Color.WHITE // set toolbar arrow up color
|
||||
theme = R.style.ToolPickerImage
|
||||
|
@ -175,32 +216,71 @@ class ObservFragment(
|
|||
excludedImages = images.toFiles() // don't show anything on this selected images
|
||||
selectedImages = images // original selected images, used in multi mode*/
|
||||
}
|
||||
|
||||
launcher.launch(config)
|
||||
listImages?.let { images ->
|
||||
listImagesOriginal?.addAll(images)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun loadImages() {
|
||||
lifecycleScope.launch {
|
||||
mobileApplication.dataStoreApp.getImages().collect { images ->
|
||||
listImages = images.toMutableList()
|
||||
setAdapter(listImages!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun uploadImages(listImages: MutableList<Image>) {
|
||||
|
||||
for (item in listImages) {
|
||||
val drawable = getDrawableFromImageUri(requireContext(), (item as Image).uri)
|
||||
val bitmap = drawable!!.toBitmap()
|
||||
|
||||
viewModel.entry_uploadPhotoSalix(
|
||||
idEntry = mobileApplication.dataStoreApp.readDataStoreKey<Int>(ENTRYID),
|
||||
warehouseId = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
WAREHOUSEFK
|
||||
),
|
||||
companyId = 442,
|
||||
dmsTypeId = 27,
|
||||
reference = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
ENTRYID
|
||||
).toString(),
|
||||
description = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
ENTRYID
|
||||
).toString(),
|
||||
hasFile = false,
|
||||
urlImage = saveBitmapAsTempFile(requireContext(), bitmap)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun observeViewModel() {
|
||||
with(viewModel) {
|
||||
|
||||
loadEntryUpdate.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
openSummary()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setAdapter(list: MutableList<Image>) {
|
||||
private fun setAdapter(list: MutableList<Image>) {
|
||||
adapterListImage =
|
||||
ListImageAdapter(list, object : OnImageUpdateClickListener {
|
||||
|
||||
//http://localhost:3000/api/Entries/1/uploadFile?warehouseId=1&companyId=442&dmsTypeId=21&reference=1&description
|
||||
// ="Example description"&hasFile=false (tiene que ser de tipo Multipart y llevar adjunto un fichero)
|
||||
|
||||
override fun OnImageUpdateClickListener(item: Any) {
|
||||
println("a subir imagen")
|
||||
|
||||
val drawable = getDrawableFromImageUri(requireContext(), (item as Image).uri)
|
||||
val bitmap = drawable!!.toBitmap()
|
||||
|
||||
viewModel.entry_uploadPhotoSalix(
|
||||
idEntry = mobileApplication.dataStoreApp.readDataStoreKey<Int>("ENTRYID"),
|
||||
idEntry = mobileApplication.dataStoreApp.readDataStoreKey<Int>(ENTRYID),
|
||||
warehouseId = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
WAREHOUSEFK
|
||||
),
|
||||
|
@ -209,7 +289,9 @@ class ObservFragment(
|
|||
reference = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
ENTRYID
|
||||
).toString(),
|
||||
description = "Entry id",
|
||||
description = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
ENTRYID
|
||||
).toString(),
|
||||
hasFile = false,
|
||||
urlImage = saveBitmapAsTempFile(requireContext(), bitmap)
|
||||
)
|
||||
|
@ -217,8 +299,8 @@ class ObservFragment(
|
|||
}
|
||||
|
||||
}, object : OnImageTrashClickListener {
|
||||
override fun OnImageTrashClickListener(item: Any) {
|
||||
d("VERDNATURA::", "Seleccionado trash" + (item as Image).name)
|
||||
|
||||
override fun onImageTrashClickListener(item: Any) {
|
||||
list.remove(item)
|
||||
adapterListImage!!.notifyDataSetChanged()
|
||||
}
|
||||
|
@ -235,18 +317,13 @@ class ObservFragment(
|
|||
val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date())
|
||||
val fileName = "IMG_$timeStamp"
|
||||
|
||||
println("urlImage tmp fileName ${fileName}")
|
||||
|
||||
val storageDir = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
|
||||
val tempFile = File.createTempFile(fileName, ".jpg", storageDir)
|
||||
|
||||
println("urlImage tmp ${tempFile}")
|
||||
|
||||
return try {
|
||||
val fileOutputStream = FileOutputStream(tempFile)
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream)
|
||||
fileOutputStream.close()
|
||||
println("urlImage tmp Absol ${tempFile.absolutePath}")
|
||||
tempFile.absolutePath
|
||||
|
||||
} catch (e: IOException) {
|
||||
|
|
|
@ -1,29 +1,33 @@
|
|||
package es.verdnatura.presentation.view.feature.packaging.fragment
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Build
|
||||
import android.text.InputType
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentPackagingCountBinding
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYID
|
||||
import es.verdnatura.domain.ConstAndValues.SUPPLIERID
|
||||
import es.verdnatura.domain.ConstAndValues.SUPPLIERNAME
|
||||
import es.verdnatura.domain.notNull
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnEditSubQuantityListener
|
||||
import es.verdnatura.presentation.common.OnImageTrashClickListener
|
||||
import es.verdnatura.presentation.common.OnImageUpdateClickListener
|
||||
import es.verdnatura.presentation.common.OnItemClickListener
|
||||
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||
import es.verdnatura.presentation.common.hideKeyboard
|
||||
import es.verdnatura.presentation.view.component.CustomDialog
|
||||
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||
import es.verdnatura.presentation.view.feature.articulo.fragment.ImageViewActivity
|
||||
import es.verdnatura.presentation.view.feature.packaging.adapter.ItemSupplierAdapter
|
||||
import es.verdnatura.presentation.view.feature.packaging.fragment.PackagingViewModel.PackagingViewModel
|
||||
import es.verdnatura.presentation.view.feature.packaging.model.ItemSupplier
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
class PackagingCountFragment(
|
||||
var entryPoint: String = ""
|
||||
|
||||
|
@ -46,8 +50,8 @@ class PackagingCountFragment(
|
|||
override fun init() {
|
||||
|
||||
viewModel.getItemsPackaging(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey("SUPPLIERID"),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey("ENTRYID")
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(SUPPLIERID),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(ENTRYID)
|
||||
)
|
||||
customDialogInput = CustomDialogInput(requireContext())
|
||||
customDialog = CustomDialog(requireContext())
|
||||
|
@ -60,15 +64,12 @@ class PackagingCountFragment(
|
|||
private fun setToolBar() {
|
||||
|
||||
binding.mainToolbar.toolbarTitle.text =
|
||||
"${mobileApplication.dataStoreApp.readDataStoreKey<String>("ENTRYTYPE")}:" +
|
||||
" ${mobileApplication.dataStoreApp.readDataStoreKey<String>("SUPPLIERNAME")}"
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(SUPPLIERNAME)
|
||||
|
||||
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||
val iconNext = ImageView(context)
|
||||
iconNext.setImageResource(R.drawable.ic_chevron_right_black_24dp)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
iconNext.tooltipText = getString(R.string.entryNextObsers)
|
||||
}
|
||||
iconNext.tooltipText = getString(R.string.entryNextObsers)
|
||||
listIcons.add(iconNext)
|
||||
binding.mainToolbar.toolbarIcons.adapter =
|
||||
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
||||
|
@ -108,13 +109,18 @@ class PackagingCountFragment(
|
|||
//entryAdd.observe(viewLifecycleOwner) {
|
||||
|
||||
if (it.isError) {
|
||||
ma.messageWithSound(it.errorMessage, true, true)
|
||||
ma.messageWithSound(it.errorMessage, isError = true, isPlayed = true)
|
||||
|
||||
} else {
|
||||
ma.messageWithSound(it.errorMessage, false, true, isToasted = false)
|
||||
ma.messageWithSound(
|
||||
it.errorMessage,
|
||||
isError = false,
|
||||
isPlayed = true,
|
||||
isToasted = false
|
||||
)
|
||||
viewModel.getItemsPackaging(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey("SUPPLIERID"),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey("ENTRYID")
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(SUPPLIERID),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(ENTRYID)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +136,7 @@ class PackagingCountFragment(
|
|||
}
|
||||
|
||||
}, object : OnImageTrashClickListener {
|
||||
override fun OnImageTrashClickListener(item: Any) {
|
||||
override fun onImageTrashClickListener(item: Any) {
|
||||
showCustomDialog("delete", item as ItemSupplier)
|
||||
}
|
||||
|
||||
|
@ -138,8 +144,17 @@ class PackagingCountFragment(
|
|||
override fun OnEditSubQuantityListener(item: Any, text: String) {
|
||||
hideKeyboard()
|
||||
}
|
||||
})
|
||||
|
||||
}, object : OnItemClickListener {
|
||||
override fun onItemClickListener(item: ItemSupplier) {
|
||||
if (!item.url.isNullOrBlank()) {
|
||||
val i = Intent(activity, ImageViewActivity::class.java)
|
||||
i.putExtra(getString(R.string.url), "http:${item.url}/catalog/1600x900/${item.id}")
|
||||
i.putExtra(getString(R.string.title), item.name)
|
||||
startActivity(i)
|
||||
}
|
||||
}
|
||||
})
|
||||
binding.itemsupplierRecyclerview.adapter = adapteritemsupplier
|
||||
layoutManager =
|
||||
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||
|
@ -155,6 +170,7 @@ class PackagingCountFragment(
|
|||
when (action) {
|
||||
"quantity" -> {
|
||||
customDialogInput.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER)
|
||||
customDialogInput.setVisibilityPlusButtons(View.VISIBLE)
|
||||
customDialogInput.setTitle(getString(R.string.quantityReviewed))
|
||||
.setDescription(getString(R.string.Indicanuevacantidad))
|
||||
.setOkButton(getString(R.string.accept)) {
|
||||
|
@ -162,14 +178,16 @@ class PackagingCountFragment(
|
|||
requireActivity().hideKeyboard()
|
||||
}
|
||||
viewModel.entry_addFromBuy(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<Int>("ENTRYID"),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<Int>(ENTRYID),
|
||||
item = item.id!!.toInt(),
|
||||
(if (mobileApplication.dataStoreApp.readDataStoreKey<String>("ENTRYTYPE") == "Rec") {
|
||||
(item.printedStickers.plus(customDialogInput.getValue().toInt()))
|
||||
} else {
|
||||
item.printedStickers.plus(customDialogInput.getValue().toInt())
|
||||
}) as Number
|
||||
item.printedStickers.plus(customDialogInput.getValue().toInt())
|
||||
)
|
||||
/* (if (mobileApplication.dataStoreApp.readDataStoreKey<String>("ENTRYTYPE") == "Rec") {
|
||||
(item.printedStickers.plus(customDialogInput.getValue().toInt()))
|
||||
} else {
|
||||
item.printedStickers.plus(customDialogInput.getValue().toInt())
|
||||
}) as Number
|
||||
)*/
|
||||
customDialog.cancel()
|
||||
customDialogInput.dismiss()
|
||||
customDialogInput.setValue("")
|
||||
|
@ -196,8 +214,6 @@ class PackagingCountFragment(
|
|||
) {
|
||||
customDialog.cancel()
|
||||
customDialog.dismiss()
|
||||
println("entryID - ")
|
||||
println("entryID ${item.id}")
|
||||
|
||||
viewModel.entry_addFromBuy(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<Int>("ENTRYID"),
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package es.verdnatura.presentation.view.feature.packaging.fragment
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
|
@ -10,18 +9,20 @@ import es.verdnatura.databinding.FragmentPackagingSummaryBinding
|
|||
import es.verdnatura.domain.ConstAndValues.ENTRYID
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYNUMBERIMAGES
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONS
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYTYPE
|
||||
import es.verdnatura.domain.ConstAndValues.SUPPLIERID
|
||||
import es.verdnatura.domain.ConstAndValues.SUPPLIERNAME
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.common.TAG
|
||||
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||
import es.verdnatura.presentation.common.addFragment
|
||||
import es.verdnatura.presentation.view.component.CustomDialog
|
||||
import es.verdnatura.presentation.view.feature.packaging.adapter.ItemSupplierAdapter
|
||||
import es.verdnatura.presentation.view.feature.packaging.fragment.PackagingViewModel.PackagingViewModel
|
||||
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroFragment
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
class PackagingSummaryFragment(
|
||||
var entryPoint: String = ""
|
||||
|
||||
|
@ -41,12 +42,15 @@ class PackagingSummaryFragment(
|
|||
|
||||
override fun init() {
|
||||
customDialog = CustomDialog(requireContext())
|
||||
binding.totalImages.text = mobileApplication.dataStoreApp.readDataStoreKey<Int>(ENTRYNUMBERIMAGES).toString()
|
||||
binding.observations.text = mobileApplication.dataStoreApp.readDataStoreKey<String>(ENTRYOBSERVATIONS)
|
||||
binding.totalImages.text =
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<Int>(ENTRYNUMBERIMAGES).toString()
|
||||
binding.observations.text =
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(ENTRYOBSERVATIONS)
|
||||
|
||||
|
||||
viewModel.getItemsPackaging(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(SUPPLIERID), mobileApplication.dataStoreApp.readDataStoreKey(ENTRYID)
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(SUPPLIERID),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(ENTRYID)
|
||||
)
|
||||
|
||||
ma.hideBottomNavigation(View.GONE)
|
||||
|
@ -58,18 +62,13 @@ class PackagingSummaryFragment(
|
|||
|
||||
private fun setToolBar() {
|
||||
|
||||
binding.mainToolbar.toolbarTitle.text = buildString {
|
||||
append(mobileApplication.dataStoreApp.readDataStoreKey<String>(ENTRYTYPE))
|
||||
append(": ")
|
||||
append(mobileApplication.dataStoreApp.readDataStoreKey<String>(SUPPLIERNAME))
|
||||
}
|
||||
binding.mainToolbar.toolbarTitle.text =
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(SUPPLIERNAME)
|
||||
|
||||
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||
val iconConfirm = ImageView(context)
|
||||
iconConfirm.setImageResource(R.drawable.check)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
iconConfirm.tooltipText = getString(R.string.confirmEntry)
|
||||
}
|
||||
iconConfirm.tooltipText = getString(R.string.confirmEntry)
|
||||
|
||||
listIcons.add(iconConfirm)
|
||||
binding.mainToolbar.toolbarIcons.adapter =
|
||||
|
@ -90,20 +89,18 @@ class PackagingSummaryFragment(
|
|||
|
||||
private fun setEvents() {
|
||||
|
||||
|
||||
binding.mainToolbar.backButton.setOnClickListener {
|
||||
ma.onMyBackPressed()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
override fun observeViewModel() {
|
||||
with(viewModel) {
|
||||
|
||||
itemSupplierList.observe(viewLifecycleOwner) {
|
||||
|
||||
var mySummaryList = it.list.filter { it.printedStickers > 0 }
|
||||
val mySummaryList = it.list.filter { it.printedStickers > 0 }
|
||||
adapteritemsupplier =
|
||||
ItemSupplierAdapter(mySummaryList, null, null, null, showItems = false)
|
||||
binding.itemsupplierRecyclerview.adapter = adapteritemsupplier
|
||||
|
@ -111,9 +108,28 @@ class PackagingSummaryFragment(
|
|||
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||
binding.itemsupplierRecyclerview.layoutManager = layoutManager
|
||||
}
|
||||
response.observe(viewLifecycleOwner) {
|
||||
|
||||
deleteDataEntry()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun deleteDataEntry() {
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.deleteEntryPackaging()
|
||||
mobileApplication.dataStoreApp.deleteImages()
|
||||
}
|
||||
|
||||
ma.addFragment(
|
||||
PasilleroFragment.newInstance(getString(R.string.main), true),
|
||||
R.id.main_frame_layout,
|
||||
PasilleroFragment.TAG,
|
||||
false
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
private fun showWarning() {
|
||||
|
||||
|
@ -124,7 +140,13 @@ class PackagingSummaryFragment(
|
|||
R.string.accept
|
||||
)
|
||||
) {
|
||||
viewModel.notificationQueues("modified-entry",mobileApplication.userId!!,"""{"url":"${mobileApplication.dataStoreApp.readDataStoreKey<String>("base_urlSalix")}/#!/entry/${mobileApplication.dataStoreApp.readDataStoreKey<Int>("ENTRYID")}/summary"}""")
|
||||
viewModel.notificationQueues(
|
||||
"modified-entry",
|
||||
mobileApplication.userId!!,
|
||||
"""{"url":"${mobileApplication.dataStoreApp.getServerLilium()}/#/entry/${
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<Int>("ENTRYID")
|
||||
}/summary"}"""
|
||||
)
|
||||
customDialog.dismiss()
|
||||
}
|
||||
|
||||
|
@ -136,9 +158,7 @@ class PackagingSummaryFragment(
|
|||
customDialog.dismiss()
|
||||
}.show()
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue