feat: refactorResponse WebFragment && sipExtension refs #7827
This commit is contained in:
parent
c20b7b1b5e
commit
d2e875c812
|
@ -8,7 +8,6 @@ import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemVie
|
|||
import es.verdnatura.presentation.view.feature.category.ChangeCategoryViewModel
|
||||
import es.verdnatura.presentation.view.feature.claim.fragment.ubication.ClaimViewModel
|
||||
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel
|
||||
import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorViewModel
|
||||
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoViewModel
|
||||
import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel
|
||||
import es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleViewModel
|
||||
|
@ -150,10 +149,6 @@ val viewModelModule = module {
|
|||
CollectionViewModel(androidContext())
|
||||
}
|
||||
|
||||
viewModel {
|
||||
ControladorViewModel(androidContext())
|
||||
}
|
||||
|
||||
viewModel {
|
||||
ParkingViewModel(androidContext())
|
||||
}
|
||||
|
|
|
@ -769,11 +769,6 @@ interface SalixService {
|
|||
@Path("id") id: Number
|
||||
): Call<Any>
|
||||
|
||||
@GET("Workers/{idWorker}/sip")
|
||||
fun sipGetExtension(
|
||||
@Path("idWorker") idWorker: Int,
|
||||
): Call<Any>
|
||||
|
||||
@PATCH("Items/{itemFk}")
|
||||
fun updateItem(
|
||||
@Path("itemFk") itemFk: Int, @Body params: Any
|
||||
|
|
|
@ -96,7 +96,6 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(
|
|||
R.drawable.ic_print_black_24dp -> getString(R.string.printTicket)
|
||||
R.drawable.ic_playlist_add_black_24dp -> getString(R.string.addItem)
|
||||
R.drawable.ic_worker -> getString(R.string.showFacePicker)
|
||||
R.drawable.phone_call -> getString(R.string.callPicker)
|
||||
R.drawable.car -> getString(R.string.allowSelectVehicle)
|
||||
R.drawable.car_off -> getString(R.string.allowTakeoffVehicle)
|
||||
//REPETIDO:R.drawable.ic_history_black_24dp->"Realiza llamada al sacador"
|
||||
|
|
|
@ -33,8 +33,6 @@ class ResponseItemNumber(
|
|||
|
||||
class ResponseItemMachineControl(
|
||||
var response: String = "",
|
||||
var isError: Boolean = false,
|
||||
var errorMessage: String = "",
|
||||
var type: String
|
||||
)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package es.verdnatura.presentation.view.feature.controlador.fragment
|
||||
package es.verdnatura.presentation.view.commom
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
|
@ -7,8 +7,10 @@ import android.os.Bundle
|
|||
import android.print.PrintAttributes
|
||||
import android.print.PrintManager
|
||||
import android.view.GestureDetector
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.webkit.WebChromeClient
|
||||
import android.webkit.WebResourceRequest
|
||||
import android.webkit.WebView
|
||||
|
@ -17,45 +19,54 @@ import android.widget.ImageView
|
|||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.OnBackPressedDispatcher
|
||||
import androidx.core.view.GestureDetectorCompat
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentWebBinding
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnBackPressedListener
|
||||
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||
import es.verdnatura.presentation.view.component.CustomDialog
|
||||
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||
import org.json.JSONObject
|
||||
import kotlin.math.abs
|
||||
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
class WebFragment(
|
||||
var entryPoint: String = ""
|
||||
) : BaseFragment<FragmentWebBinding, ControladorViewModel>(ControladorViewModel::class),
|
||||
OnBackPressedListener {
|
||||
) : Fragment(), OnBackPressedListener {
|
||||
private lateinit var gestureDetector: GestureDetectorCompat
|
||||
override fun getLayoutId(): Int = R.layout.fragment_web
|
||||
fun getLayoutId(): Int = R.layout.fragment_web
|
||||
private lateinit var customDialog: CustomDialog
|
||||
private lateinit var backDispatcher: OnBackPressedDispatcher
|
||||
private lateinit var binding: FragmentWebBinding
|
||||
|
||||
companion object {
|
||||
fun newInstance(entryPoint: String) = WebFragment(entryPoint)
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
|
||||
fun init() {
|
||||
customDialog = CustomDialog(requireContext())
|
||||
setToolbar()
|
||||
setWeb()
|
||||
super.init()
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View? {
|
||||
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_web, container, false)
|
||||
binding.lifecycleOwner = this
|
||||
return binding.root
|
||||
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
requireActivity().onBackPressedDispatcher.addCallback(
|
||||
viewLifecycleOwner,
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner,
|
||||
object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
if (!onBackPressedHandled()) {
|
||||
|
@ -65,14 +76,10 @@ class WebFragment(
|
|||
}
|
||||
})
|
||||
|
||||
gestureDetector = GestureDetectorCompat(
|
||||
requireActivity(),
|
||||
gestureDetector = GestureDetectorCompat(requireActivity(),
|
||||
object : GestureDetector.SimpleOnGestureListener() {
|
||||
override fun onFling(
|
||||
e1: MotionEvent?,
|
||||
e2: MotionEvent,
|
||||
velocityX: Float,
|
||||
velocityY: Float
|
||||
e1: MotionEvent?, e2: MotionEvent, velocityX: Float, velocityY: Float
|
||||
): Boolean {
|
||||
val deltaX = (e2.x - e1?.x!!)
|
||||
val deltaY = (e2.y - e1.y)
|
||||
|
@ -89,9 +96,8 @@ class WebFragment(
|
|||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
})
|
||||
init()
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
}
|
||||
|
||||
|
@ -117,8 +123,7 @@ class WebFragment(
|
|||
}
|
||||
binding.webView.webViewClient = object : WebViewClient() {
|
||||
override fun shouldOverrideUrlLoading(
|
||||
view: WebView?,
|
||||
request: WebResourceRequest?
|
||||
view: WebView?, request: WebResourceRequest?
|
||||
): Boolean {
|
||||
binding.webView.loadUrl(request?.url.toString())
|
||||
return true
|
||||
|
@ -139,16 +144,15 @@ class WebFragment(
|
|||
|
||||
private fun setToolbar() {
|
||||
|
||||
binding.mainToolbar.toolbarTitle.text =
|
||||
buildString {
|
||||
append(getString(R.string.item))
|
||||
append(JSONObject(entryPoint).get("entryPoint").toString())
|
||||
}
|
||||
binding.mainToolbar.toolbarTitle.text = buildString {
|
||||
append(getString(R.string.item))
|
||||
append(JSONObject(entryPoint).get("entryPoint").toString())
|
||||
}
|
||||
|
||||
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||
val iconPrint = ImageView(context)
|
||||
iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
|
||||
iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
|
||||
iconPrint.tooltipText = getString(R.string.print)
|
||||
|
||||
//listIcons.add(iconPrint)
|
||||
|
||||
|
@ -179,9 +183,7 @@ class WebFragment(
|
|||
|
||||
// Create a print job with name and adapter instance
|
||||
printManager.print(
|
||||
jobName,
|
||||
printAdapter,
|
||||
PrintAttributes.Builder().build()
|
||||
jobName, printAdapter, PrintAttributes.Builder().build()
|
||||
).also { printJob ->
|
||||
println("job printed")
|
||||
// Save the job object for later status checking
|
||||
|
@ -194,8 +196,8 @@ class WebFragment(
|
|||
|
||||
if (binding.webView.canGoBack()) {
|
||||
binding.webView.goBack()
|
||||
}else{
|
||||
ma.onMyBackPressed()
|
||||
} else {
|
||||
(context as MainActivity).onMyBackPressed()
|
||||
}
|
||||
|
||||
return true
|
|
@ -2,10 +2,8 @@ package es.verdnatura.presentation.view.feature.collection.fragment
|
|||
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.media.MediaPlayer
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
|
@ -221,8 +219,6 @@ class CollectionFragment(
|
|||
iconViewCollection.setImageResource(R.drawable.ic_collection)
|
||||
val iconWorker = ImageView(context)
|
||||
iconWorker.setImageResource(R.drawable.ic_worker)
|
||||
val iconPhone = ImageView(context)
|
||||
iconPhone.setImageResource(R.drawable.phone_call)
|
||||
val iconParking = ImageView(context)
|
||||
iconParking.setImageResource(R.drawable.ic_local_parking_black_24dp)
|
||||
val iconUpdate = ImageView(context)
|
||||
|
@ -232,7 +228,6 @@ class CollectionFragment(
|
|||
iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
|
||||
iconAdd.tooltipText = getTooltip(R.drawable.ic_playlist_add_black_24dp)
|
||||
iconViewCollection.tooltipText = getTooltip(R.drawable.ic_collection)
|
||||
iconPhone.tooltipText = getTooltip(R.drawable.phone_call)
|
||||
iconParking.tooltipText = getTooltip(R.drawable.ic_local_parking_black_24dp)
|
||||
iconUpdate.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
|
||||
|
||||
|
@ -726,22 +721,6 @@ class CollectionFragment(
|
|||
}
|
||||
})
|
||||
|
||||
responseGetExtensionFromUserId.observe(viewLifecycleOwner, Observer {
|
||||
|
||||
if (it.isError) {
|
||||
if (!goMistakeBack) ma.messageWithSound(
|
||||
getString(R.string.noSIP) + it.errorMessage + getString(R.string.user) + workerFkFromTicket,
|
||||
isError = true,
|
||||
true
|
||||
)
|
||||
|
||||
} else {
|
||||
if (!goMistakeBack) callPicker(it.response)
|
||||
|
||||
}
|
||||
goMistakeBack = true
|
||||
})
|
||||
|
||||
|
||||
mistakeList.observe(viewLifecycleOwner, Observer {
|
||||
|
||||
|
@ -922,19 +901,6 @@ class CollectionFragment(
|
|||
}
|
||||
}
|
||||
|
||||
private fun callPicker(extensionNumber: String) {
|
||||
|
||||
try {
|
||||
val intent = Intent(Intent.ACTION_DIAL).apply {
|
||||
data = Uri.parse("tel:$extensionNumber")
|
||||
}
|
||||
|
||||
startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
e.toast(requireContext())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//CREATE LIST
|
||||
private fun createCollectionList() {
|
||||
|
|
|
@ -2,10 +2,8 @@ package es.verdnatura.presentation.view.feature.collection.fragment
|
|||
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.media.MediaPlayer
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
|
@ -691,22 +689,6 @@ class CollectionFragmentPicker(
|
|||
}
|
||||
|
||||
})*/
|
||||
responseGetExtensionFromUserId.observe(viewLifecycleOwner, Observer {
|
||||
|
||||
if (it.isError) {
|
||||
if (!goMistakeBack) ma.messageWithSound(
|
||||
getString(R.string.noSIP) + it.errorMessage + getString(R.string.user) + workerFkFromTicket,
|
||||
isError = true,
|
||||
true
|
||||
)
|
||||
|
||||
} else {
|
||||
if (!goMistakeBack) callPicker(it.response)
|
||||
|
||||
}
|
||||
goMistakeBack = true
|
||||
})
|
||||
|
||||
|
||||
mistakeList.observe(viewLifecycleOwner, Observer {
|
||||
/*sergio:se quita y se pone esta comprobacion porque si no aparece de nuevo otra vez al volver atrás */
|
||||
|
@ -891,20 +873,6 @@ class CollectionFragmentPicker(
|
|||
|
||||
}
|
||||
|
||||
private fun callPicker(extensionNumber: String) {
|
||||
|
||||
try {
|
||||
val intent = Intent(Intent.ACTION_DIAL).apply {
|
||||
data = Uri.parse("tel:$extensionNumber")
|
||||
}
|
||||
|
||||
startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
e.toast(requireContext())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//CREATE LIST
|
||||
private fun createCollectionList() {
|
||||
|
||||
|
|
|
@ -2,14 +2,11 @@ package es.verdnatura.presentation.view.feature.collection.fragment
|
|||
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.media.MediaPlayer
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.text.InputType
|
||||
import android.text.InputType.TYPE_CLASS_NUMBER
|
||||
import android.text.InputType.TYPE_CLASS_TEXT
|
||||
import android.view.KeyEvent
|
||||
|
@ -734,24 +731,6 @@ class CollectionFragmentPreChecker(
|
|||
}
|
||||
|
||||
})*/
|
||||
responseGetExtensionFromUserId.observe(viewLifecycleOwner, Observer {
|
||||
|
||||
if (it.isError) {
|
||||
if (!goMistakeBack)
|
||||
ma.messageWithSound(
|
||||
getString(R.string.noSIP) + it.errorMessage + getString(R.string.user) + workerFkFromTicket,
|
||||
isError = true,
|
||||
true
|
||||
)
|
||||
|
||||
} else {
|
||||
if (!goMistakeBack)
|
||||
callPicker(it.response)
|
||||
|
||||
}
|
||||
goMistakeBack = true
|
||||
})
|
||||
|
||||
|
||||
mistakeList.observe(viewLifecycleOwner, Observer {
|
||||
|
||||
|
@ -944,20 +923,6 @@ class CollectionFragmentPreChecker(
|
|||
|
||||
}
|
||||
|
||||
private fun callPicker(extensionNumber: String) {
|
||||
|
||||
try {
|
||||
val intent = Intent(Intent.ACTION_DIAL).apply {
|
||||
data = Uri.parse("tel:$extensionNumber")
|
||||
}
|
||||
|
||||
startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
// d("VERDNATURA::" + e.message)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//CREATE LIST
|
||||
private fun createCollectionList() {
|
||||
|
||||
|
|
|
@ -185,10 +185,6 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
val item: LiveData<ItemVO>
|
||||
get() = _item
|
||||
|
||||
private val _responseGetExtensionFromUserId by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
val responseGetExtensionFromUserId: LiveData<ResponseItemVO>
|
||||
get() = _responseGetExtensionFromUserId
|
||||
|
||||
val loadResponseDel: LiveData<Event<ResponseItemVO>> = _responseDel.map { Event(it) }
|
||||
|
||||
val loadResponseAddItem: LiveData<Event<ResponseItemVO>> =
|
||||
|
|
|
@ -3,7 +3,6 @@ package es.verdnatura.presentation.view.feature.controlador.fragment
|
|||
import android.content.Context
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import androidx.lifecycle.Observer
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentGeneralBlackBinding
|
||||
import es.verdnatura.domain.ConstAndValues
|
||||
|
@ -16,11 +15,10 @@ import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
|||
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
class ControladorFragment :
|
||||
BaseFragment<FragmentGeneralBlackBinding, ControladorViewModel>(ControladorViewModel::class) {
|
||||
BaseFragment<FragmentGeneralBlackBinding, CollectionViewModel>(CollectionViewModel::class) {
|
||||
|
||||
private var goBack: Boolean = false
|
||||
private var onCollectionSelectedListener: OnCollectionSelectedListener? = null
|
||||
private var collectionViewModel: CollectionViewModel? = null
|
||||
override fun getLayoutId(): Int = R.layout.fragment_general_black
|
||||
|
||||
companion object {
|
||||
|
@ -75,9 +73,9 @@ class ControladorFragment :
|
|||
)
|
||||
}
|
||||
//Tarea 6458 descomentar si ok
|
||||
collectionViewModel = CollectionViewModel(mobileApplication)
|
||||
|
||||
try {
|
||||
collectionViewModel!!.ticketState(
|
||||
viewModel.ticketState(
|
||||
itemScanValue(
|
||||
binding.scanInput.text.toString(),
|
||||
arrayOf("ticket", "saleGroup"),
|
||||
|
@ -91,75 +89,6 @@ class ControladorFragment :
|
|||
isError = true
|
||||
)
|
||||
}
|
||||
|
||||
collectionViewModel!!.responseTicketState.observe(
|
||||
viewLifecycleOwner,
|
||||
Observer { it ->
|
||||
|
||||
if ((it.code == "ON_CHECKING" || it.code == "CHECKED") && it.user.id != mobileApplication.userId) {
|
||||
var customDialogWarning = CustomDialog(requireContext())
|
||||
customDialogWarning.setTitle(getString(R.string.info))
|
||||
customDialogWarning.setDescription(
|
||||
if (it.code == "ON_CHECKING") {
|
||||
getString(R.string.checkingByUser, it.user.username)
|
||||
} else {
|
||||
getString(R.string.checkedByUser, it.user.username)
|
||||
}
|
||||
)
|
||||
.setOkButton(getString(R.string.aware)) {
|
||||
customDialogWarning.dismiss()
|
||||
|
||||
try {
|
||||
viewModel.getSales(
|
||||
collectionFk = itemScanValue(
|
||||
binding.scanInput.text.toString(),
|
||||
arrayOf("ticket", "saleGroup"),
|
||||
"id"
|
||||
).toString().toInt(),
|
||||
print = false,
|
||||
source = ConstAndValues.ON_CHECKING
|
||||
)
|
||||
|
||||
} catch (ex: Exception) {
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.errorScanItem),
|
||||
isError = true,
|
||||
isToasted = true,
|
||||
isPlayed = true
|
||||
)
|
||||
}
|
||||
|
||||
/* viewModel.getSales(
|
||||
collectionFk = binding.scanInput.text.toString()
|
||||
.toInt(),
|
||||
print = false,
|
||||
source = ConstAndValues.ON_CHECKING
|
||||
)*/
|
||||
}.setKoButton(getString(R.string.cancel)) {
|
||||
binding.scanInput.setText("")
|
||||
binding.scanInput.requestFocus()
|
||||
customDialogWarning.dismiss()
|
||||
}.show()
|
||||
customDialogWarning.currentFocus
|
||||
} else {
|
||||
viewModel.getSales(
|
||||
collectionFk = itemScanValue(
|
||||
binding.scanInput.text.toString(),
|
||||
arrayOf("ticket", "saleGRoup"),
|
||||
"id"
|
||||
).toString().toInt(),
|
||||
print = false,
|
||||
source = ConstAndValues.ON_CHECKING
|
||||
)
|
||||
|
||||
/* viewModel.getSales(
|
||||
collectionFk = binding.scanInput.text.toString().toInt(),
|
||||
print = false,
|
||||
source = ConstAndValues.ON_CHECKING
|
||||
)*/
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
ma.hideKeyboard(binding.scanInput)
|
||||
|
@ -177,7 +106,61 @@ class ControladorFragment :
|
|||
goBack = false
|
||||
|
||||
}
|
||||
responseTicketState.observe(
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
if ((it.code == "ON_CHECKING" || it.code == "CHECKED") && it.user.id != mobileApplication.userId) {
|
||||
val customDialogWarning = CustomDialog(requireContext())
|
||||
customDialogWarning.setTitle(getString(R.string.info))
|
||||
customDialogWarning.setDescription(
|
||||
if (it.code == "ON_CHECKING") {
|
||||
getString(R.string.checkingByUser, it.user.username)
|
||||
} else {
|
||||
getString(R.string.checkedByUser, it.user.username)
|
||||
}
|
||||
)
|
||||
.setOkButton(getString(R.string.aware)) {
|
||||
customDialogWarning.dismiss()
|
||||
|
||||
try {
|
||||
viewModel.getSales(
|
||||
collectionFk = itemScanValue(
|
||||
binding.scanInput.text.toString(),
|
||||
arrayOf("ticket", "saleGroup"),
|
||||
"id"
|
||||
).toString().toInt(),
|
||||
print = "0",
|
||||
source = ConstAndValues.ON_CHECKING
|
||||
)
|
||||
|
||||
} catch (ex: Exception) {
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.errorScanItem),
|
||||
isError = true,
|
||||
isToasted = true,
|
||||
isPlayed = true
|
||||
)
|
||||
}
|
||||
|
||||
}.setKoButton(getString(R.string.cancel)) {
|
||||
binding.scanInput.setText("")
|
||||
binding.scanInput.requestFocus()
|
||||
customDialogWarning.dismiss()
|
||||
}.show()
|
||||
customDialogWarning.currentFocus
|
||||
} else {
|
||||
viewModel.getSales(
|
||||
collectionFk = itemScanValue(
|
||||
binding.scanInput.text.toString(),
|
||||
arrayOf("ticket", "saleGRoup"),
|
||||
"id"
|
||||
).toString().toInt(),
|
||||
print = "0",
|
||||
source = ConstAndValues.ON_CHECKING
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
package es.verdnatura.presentation.view.feature.controlador.fragment
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.common.ResponseItemVO
|
||||
import es.verdnatura.presentation.view.feature.collection.mapper.map
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
||||
import retrofit2.Response
|
||||
|
||||
class ControladorViewModel(var context: Context) : BaseViewModel(context) {
|
||||
|
||||
private val contextApp = context
|
||||
private val _collectionTicketList by lazy { MutableLiveData<CollectionVO>() }
|
||||
|
||||
/* private val getSacadorControladorUserCase: GetSacadorControladorUserCase =
|
||||
GetSacadorControladorUserCase(context)
|
||||
*/
|
||||
private val _response by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
val response: LiveData<ResponseItemVO>
|
||||
get() = _response
|
||||
|
||||
val collectionTicketList: LiveData<CollectionVO>
|
||||
get() = _collectionTicketList
|
||||
|
||||
fun getSales(collectionFk: Int, print: Boolean, source: String) {
|
||||
|
||||
salix.getSalesFromTicketOrCollection(collectionFk, print, source)
|
||||
.enqueue(object :
|
||||
SalixCallback<CollectionVO>(context) {
|
||||
|
||||
override fun onSuccess(response: Response<CollectionVO>) {
|
||||
_collectionTicketList.value = response.body()?.let { it.map(context) }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
|
@ -1,21 +1,13 @@
|
|||
package es.verdnatura.presentation.view.feature.controlvehiculo.fragment
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.view.View.INVISIBLE
|
||||
import android.view.View.VISIBLE
|
||||
import android.widget.ImageView
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentVehiclecontrolUserBinding
|
||||
import es.verdnatura.domain.ConstAndValues
|
||||
import es.verdnatura.domain.ConstAndValues.ANDROID_ID
|
||||
import es.verdnatura.domain.ConstAndValues.TOKEN
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||
import es.verdnatura.presentation.common.loadUrl
|
||||
|
||||
class ControlVehiculoUsuarioFragment(
|
||||
|
@ -46,30 +38,6 @@ class ControlVehiculoUsuarioFragment(
|
|||
binding.mainToolbar.toolbarSubtitle.visibility = VISIBLE
|
||||
binding.mainToolbar.toolbarIcons.visibility = VISIBLE
|
||||
binding.mainToolbar.backButton.visibility = VISIBLE
|
||||
|
||||
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||
val iconPhone = ImageView(context)
|
||||
iconPhone.setImageResource(R.drawable.phone_call)
|
||||
|
||||
iconPhone.tooltipText = getTooltip(R.drawable.phone_call)
|
||||
listIcons.add(iconPhone)
|
||||
binding.mainToolbar.toolbarIcons.adapter =
|
||||
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
||||
override fun onOptionsItemSelected(item: Drawable) {
|
||||
|
||||
when (item) {
|
||||
iconPhone.drawable -> getExtensionFromUser()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
binding.mainToolbar.toolbarIcons.layoutManager =
|
||||
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||
}
|
||||
|
||||
private fun getExtensionFromUser() {
|
||||
viewModel.sipGetExtensionSalix(vUserFK)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
@ -109,12 +77,15 @@ class ControlVehiculoUsuarioFragment(
|
|||
)
|
||||
}"
|
||||
)
|
||||
}catch (ex:Exception) {
|
||||
ma.messageWithSound(message = getString(R.string.errorUserId), isError = true, isToasted = true, isPlayed = true)
|
||||
} catch (ex: Exception) {
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.errorUserId),
|
||||
isError = true,
|
||||
isToasted = true,
|
||||
isPlayed = true
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun setEvents() {
|
||||
|
@ -128,19 +99,17 @@ class ControlVehiculoUsuarioFragment(
|
|||
|
||||
with(viewModel) {
|
||||
|
||||
responsemachine.observe(viewLifecycleOwner) {
|
||||
responseMachine.observe(viewLifecycleOwner) {
|
||||
|
||||
if (it.response == "false") {
|
||||
if (it.type == "getWorker") {
|
||||
binding.assignedDevicename.text =
|
||||
getString(R.string.noAssigned)
|
||||
binding.assignedDevicename.text = getString(R.string.noAssigned)
|
||||
}
|
||||
} else {
|
||||
|
||||
when (it.type) {
|
||||
"getnameDevice" -> binding.deviceName.text = it.response
|
||||
"getWorker" -> binding.assignedDevicename.text =
|
||||
it.response
|
||||
"getWorker" -> binding.assignedDevicename.text = it.response
|
||||
|
||||
"getWorkerPlate" -> binding.registeredVehiclecontrol.text = it.response
|
||||
}
|
||||
|
@ -148,26 +117,10 @@ class ControlVehiculoUsuarioFragment(
|
|||
}
|
||||
|
||||
}
|
||||
responseGetExtensionFromUserId.observe(viewLifecycleOwner) {
|
||||
|
||||
if (it != "") {
|
||||
ma.messageWithSound(
|
||||
getString(R.string.noSIP) + "." + getString(R.string.user) + vUserFK,
|
||||
isError = true,
|
||||
true
|
||||
)
|
||||
|
||||
} else {
|
||||
callPicker(it.toString())
|
||||
}
|
||||
|
||||
}
|
||||
responseGetName.observe(viewLifecycleOwner) {
|
||||
binding.nameVehiclecontrol.text =
|
||||
getString(
|
||||
R.string.txtName,
|
||||
it.firstName,
|
||||
it.lastName
|
||||
binding.nameVehiclecontrol.text = getString(
|
||||
R.string.txtName, it.firstName, it.lastName
|
||||
)
|
||||
binding.nameVehiclecontrol.visibility = VISIBLE
|
||||
|
||||
|
@ -177,17 +130,4 @@ class ControlVehiculoUsuarioFragment(
|
|||
|
||||
}
|
||||
|
||||
private fun callPicker(extensionNumber: String) {
|
||||
|
||||
try {
|
||||
val intent = Intent(Intent.ACTION_DIAL).apply {
|
||||
data = Uri.parse("tel:$extensionNumber")
|
||||
}
|
||||
|
||||
startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
getString(R.string.errorOperation).toast(requireContext())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFra
|
|||
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPreCheckerNew
|
||||
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionShowTicketFragment
|
||||
import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorFragment
|
||||
import es.verdnatura.presentation.view.feature.controlador.fragment.WebFragment
|
||||
import es.verdnatura.presentation.view.commom.WebFragment
|
||||
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoFragment
|
||||
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoUsuarioFragment
|
||||
import es.verdnatura.presentation.view.feature.delivery.fragments.InfoFragment
|
||||
|
|
|
@ -165,7 +165,6 @@
|
|||
<string name="printTicket">Imprime ticket</string>
|
||||
<string name="addItem">Añade ítem</string>
|
||||
<string name="showFacePicker">Visualiza la foto del sacador</string>
|
||||
<string name="callPicker">Realiza llamada al sacador</string>
|
||||
<string name="allowSelectVehicle">Permite coger vehículo</string>
|
||||
<string name="closeSession">Cerrar Sesión</string>
|
||||
<string name="stickers">Stickers</string>
|
||||
|
@ -379,7 +378,6 @@
|
|||
<string name="errorCauseRegistered">Causa del error registrada</string>
|
||||
<string name="itemPoints">Artículo: </string>
|
||||
<string name="originalQuantity">"Cantidad original: "</string>
|
||||
<string name="noSIP">No se puede realizar la llamada. El usuario no tiene la extensión configurada. Solicítelo a informática.</string>
|
||||
<string name="titleHistoricalHide">Historico Vehículo</string>
|
||||
<string name="timeFormat">HH:mm</string>
|
||||
<string name="dateCompleteFormat">yyyy-mm-dd HH:mm</string>
|
||||
|
|
|
@ -165,7 +165,6 @@
|
|||
<string name="printTicket">Imprime ticket</string>
|
||||
<string name="addItem">Añade ítem</string>
|
||||
<string name="showFacePicker">Visualiza la foto del sacador</string>
|
||||
<string name="callPicker">Realiza llamada al sacador</string>
|
||||
<string name="allowSelectVehicle">Permite coger vehículo</string>
|
||||
<string name="closeSession">Cerrar Sesión</string>
|
||||
<string name="stickers">Stickers</string>
|
||||
|
@ -379,7 +378,6 @@
|
|||
<string name="errorCauseRegistered">Causa del error registrada</string>
|
||||
<string name="itemPoints">Artículo: </string>
|
||||
<string name="originalQuantity">"Cantidad original: "</string>
|
||||
<string name="noSIP">No se puede realizar la llamada. El usuario no tiene la extensión configurada. Solicítelo a informática.</string>
|
||||
<string name="titleHistoricalHide">Historico Vehículo</string>
|
||||
<string name="timeFormat">HH:mm</string>
|
||||
<string name="dateCompleteFormat">yyyy-mm-dd HH:mm</string>
|
||||
|
|
|
@ -165,7 +165,6 @@
|
|||
<string name="printTicket">Imprime ticket</string>
|
||||
<string name="addItem">Añade ítem</string>
|
||||
<string name="showFacePicker">Visualiza la foto del sacador</string>
|
||||
<string name="callPicker">Realiza llamada al sacador</string>
|
||||
<string name="allowSelectVehicle">Permite coger vehículo</string>
|
||||
<string name="closeSession">Cerrar Sesión</string>
|
||||
<string name="stickers">Stickers</string>
|
||||
|
@ -379,7 +378,6 @@
|
|||
<string name="errorCauseRegistered">Causa del error registrada</string>
|
||||
<string name="itemPoints">Artículo: </string>
|
||||
<string name="originalQuantity">"Cantidad original: "</string>
|
||||
<string name="noSIP">No se puede realizar la llamada. El usuario no tiene la extensión configurada. Solicítelo a informática.</string>
|
||||
<string name="titleHistoricalHide">Historico Vehículo</string>
|
||||
<string name="timeFormat">HH:mm</string>
|
||||
<string name="dateCompleteFormat">yyyy-mm-dd HH:mm</string>
|
||||
|
|
|
@ -197,7 +197,6 @@
|
|||
<string name="printTicket">Print ticket</string>
|
||||
<string name="addItem">Add item</string>
|
||||
<string name="showFacePicker">Show face picker</string>
|
||||
<string name="callPicker">Call picker</string>
|
||||
<string name="allowSelectVehicle">Allows to select a vehicle</string>
|
||||
<string name="closeSession">Close session</string>
|
||||
<string name="stickers">Stickers</string>
|
||||
|
@ -438,7 +437,6 @@
|
|||
<string name="errorCauseRegistered">Error cause logged</string>
|
||||
<string name="itemPoints">"Item: "</string>
|
||||
<string name="originalQuantity">Original amount: "</string>
|
||||
<string name="noSIP">" The call cannot be made. The user does not have the extension configured. Request it from IT."</string>
|
||||
<string name="titleHistoricalHide">Vehicle historical</string>
|
||||
<string name="timeFormat">HH:mm</string>
|
||||
<string name="dateCompleteFormat">yyyy-mm-dd HH:mm</string>
|
||||
|
|
Loading…
Reference in New Issue