refs #5322 NaturePhotos

This commit is contained in:
Sergio De la torre 2023-06-06 08:48:55 +02:00
parent f292de3db0
commit cf28002926
3 changed files with 14 additions and 22 deletions

View File

@ -117,17 +117,21 @@
responseinsert.observe(viewLifecycleOwner, Observer { responseinsert.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE binding.splashProgress.visibility = GONE
if (it.isError) { if (it.isError) {
ma.messageWithSound( ma.messageWithSound(
getString(R.string.noSIP) + it.errorMessage + getString(R.string.user) + title, it.errorMessage + getString(R.string.user) + title,
isError = true, isError = true,
true true
) )
} else { } else {
ma.messageWithSound(
getString(R.string.itemUpdated),
isError = it.isError,
true, isToasted = null,
)
} }
}) })
@ -138,11 +142,11 @@
private fun upLoadPhoto() { private fun upLoadPhoto() {
println("llamada")
val drawable = binding.userImage.drawable val drawable = binding.userImage.drawable
if (drawable is BitmapDrawable) { if (drawable is BitmapDrawable) {
val bitmap = drawable.bitmap val bitmap = drawable.bitmap
println("Ruta"+saveBitmapAsTempFile(requireContext(),bitmap))
viewModel.uploadPhoto(saveBitmapAsTempFile(requireContext(),bitmap)) viewModel.uploadPhoto(saveBitmapAsTempFile(requireContext(),bitmap))
} }

View File

@ -30,8 +30,8 @@ class PhotosViewModel(val context: Context) : BaseViewModel(context) {
fun uploadPhoto( fun uploadPhoto(
// val img = dataURItoBlob(cropper.getCroppedCanvas().toDataURL("image/png")) // val img = dataURItoBlob(cropper.getCroppedCanvas().toDataURL("image/png"))
urlImage:String, urlImage:String,
itemFK:Int = 10 , itemFK:Int = 11 ,
itemId:String = "10" , itemId:String = "11" ,
date: Date = Date(), date: Date = Date(),
timestamp: Long = date.time, timestamp: Long = date.time,
fileName: String = "${itemFK}_$timestamp", fileName: String = "${itemFK}_$timestamp",
@ -53,10 +53,6 @@ class PhotosViewModel(val context: Context) : BaseViewModel(context) {
} }
override fun onSuccess(response: Response<Any>) { override fun onSuccess(response: Response<Any>) {
//sergio devuelve true o false
if (response.body().toString() == "false") {
_responseinsert.value = ResponseItemVO( _responseinsert.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = getMessageFromAllResponse( errorMessage = getMessageFromAllResponse(
@ -64,14 +60,6 @@ class PhotosViewModel(val context: Context) : BaseViewModel(context) {
response.message() response.message()
) )
) )
} else {
_responseinsert.value =
ResponseItemVO(isError = false, response = response.body()!!.toString())
}
} }
}) })

View File

@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp" android:height="24dp"
android:width="24dp" android:width="24dp"
android:viewportWidth="24" android:viewportWidth="960"
android:viewportHeight="24" android:viewportHeight="960"
android:tint="#F7931E"> android:tint="#FFF">
<path android:fillColor="#F7931E" <path android:fillColor="#FFF"
android:pathData="M479.5,694q72.5,0 121.5,-49t49,-121.5q0,-72.5 -49,-121T479.5,354q-72.5,0 -121,48.5t-48.5,121q0,72.5 48.5,121.5t121,49ZM479.5,634q-47.5,0 -78.5,-31.5t-31,-79q0,-47.5 31,-78.5t78.5,-31q47.5,0 79,31t31.5,78.5q0,47.5 -31.5,79t-79,31.5ZM140,840q-24,0 -42,-18t-18,-42v-513q0,-23 18,-41.5t42,-18.5h147l73,-87h240l73,87h147q23,0 41.5,18.5T880,267v513q0,24 -18.5,42T820,840L140,840ZM820,780v-513L645,267l-73,-87L388,180l-73,87L140,267v513h680ZM480,524Z"/> android:pathData="M479.5,694q72.5,0 121.5,-49t49,-121.5q0,-72.5 -49,-121T479.5,354q-72.5,0 -121,48.5t-48.5,121q0,72.5 48.5,121.5t121,49ZM479.5,634q-47.5,0 -78.5,-31.5t-31,-79q0,-47.5 31,-78.5t78.5,-31q47.5,0 79,31t31.5,78.5q0,47.5 -31.5,79t-79,31.5ZM140,840q-24,0 -42,-18t-18,-42v-513q0,-23 18,-41.5t42,-18.5h147l73,-87h240l73,87h147q23,0 41.5,18.5T880,267v513q0,24 -18.5,42T820,840L140,840ZM820,780v-513L645,267l-73,-87L388,180l-73,87L140,267v513h680ZM480,524Z"/>
</vector> </vector>