Showing toast message on error using live data and some LOG updates.
This commit is contained in:
@@ -132,23 +132,22 @@ class TestRightExpReference : Fragment() {
|
||||
} else if (stringData.contains("FINE", true)) {
|
||||
Log.d(TAG, "results = FINE")
|
||||
viewModel.progressBar.postValue(false)
|
||||
Toast.makeText(
|
||||
requireContext(),
|
||||
"Please try again this step",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
|
||||
viewModel.errorTriggered.postValue("Please Try Again this step")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
Log.e(TAG, "onUsbIoError() called in writeUsbFetchDeviceConstant() -> $e")
|
||||
Log.e(TAG, "onUsbIoError() called in sendCmdToFetchDeviceConstant() -> $e")
|
||||
viewModel.errorTriggered.postValue("Please Try Again this step")
|
||||
viewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun sendCmdToSetLed() {
|
||||
Log.d(TAG, "sendCmdToSetLed() called")
|
||||
viewModel.progressBar.postValue(true)
|
||||
val fullReadOutput = StringBuilder()
|
||||
(activity as TestRightActivity).mService.eventDrivenWrite(TestRightCommands.led2Set50,
|
||||
@@ -180,20 +179,18 @@ class TestRightExpReference : Fragment() {
|
||||
}
|
||||
|
||||
private fun sendCmdToAutoset() {
|
||||
Log.d(TAG, "sendCmdToAutoset() called")
|
||||
viewModel.progressBar.postValue(true)
|
||||
val fullReadOutput = StringBuilder()
|
||||
(activity as TestRightActivity).mService.eventDrivenWrite(TestRightCommands.autoset,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {
|
||||
// requireActivity().runOnUiThread {
|
||||
data?.let {
|
||||
val stringData = String(it)
|
||||
fullReadOutput.append(stringData)
|
||||
|
||||
if (stringData.contains("OK", true)) {
|
||||
Log.d(TAG, "onUsbRead() called in sendCmdToAutoset()")
|
||||
// viewModel.progressBar.postValue(false)
|
||||
// sendCmdToRun()
|
||||
|
||||
Handler(Looper.getMainLooper()).postDelayed(
|
||||
Runnable {
|
||||
@@ -205,11 +202,10 @@ class TestRightExpReference : Fragment() {
|
||||
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
Log.e(TAG, "onUsbIoError() called in writeUsbFetchDeviceConstant() -> $e")
|
||||
Log.e(TAG, "onUsbIoError() called in sendCmdToAutoset() -> $e")
|
||||
viewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
@@ -243,7 +239,7 @@ class TestRightExpReference : Fragment() {
|
||||
}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
Log.e(TAG, "onUsbIoError() called in writeUsbFetchDeviceConstant() -> $e")
|
||||
Log.e(TAG, "onUsbIoError() called in sendCmdToRun() -> $e")
|
||||
viewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
@@ -277,7 +273,8 @@ class TestRightExpReference : Fragment() {
|
||||
}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
Log.e(TAG, "onUsbIoError() called in writeUsbFetchDeviceConstant() -> $e")
|
||||
Log.e(TAG, "onUsbIoError() called in sendCmdToFetchLightIntensities() -> $e")
|
||||
viewModel.errorTriggered.postValue("Please Try Again this step")
|
||||
viewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -136,7 +136,7 @@ class TestRightExpSample : Fragment() {
|
||||
|
||||
if (stringData.contains("OK", true)) {
|
||||
// viewModel.progressBar.postValue(false)
|
||||
|
||||
Log.d(TAG, "onUsbRead() called in sendCmdToRun()")
|
||||
Handler(Looper.getMainLooper()).postDelayed(
|
||||
Runnable {
|
||||
viewModel.progressBar.postValue(false)
|
||||
@@ -150,7 +150,7 @@ class TestRightExpSample : Fragment() {
|
||||
}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
Log.e(TAG, "onUsbIoError() called in writeUsbFetchDeviceConstant() -> $e")
|
||||
Log.e(TAG, "onUsbIoError() called in sendCmdToRun() -> $e")
|
||||
viewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
@@ -166,8 +166,10 @@ class TestRightExpSample : Fragment() {
|
||||
data?.let {
|
||||
val stringData = String(it)
|
||||
fullReadOutput.append(stringData)
|
||||
// Log.d(TAG, "Values of print cmd -> $stringData")
|
||||
// Log.d(TAG, stringData)
|
||||
if (stringData.contains("OK", true)) {
|
||||
Log.d(TAG, "onUsbRead() called in sendCmdToFetchLightIntensities()")
|
||||
|
||||
viewModel.mapIntensityValues(fullReadOutput.toString(), false)
|
||||
// viewModel.progressBar.postValue(false)
|
||||
showResultsAfterAcquiring()
|
||||
@@ -176,7 +178,7 @@ class TestRightExpSample : Fragment() {
|
||||
}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
Log.e(TAG, "onUsbIoError() called in writeUsbFetchDeviceConstant() -> $e")
|
||||
Log.e(TAG, "onUsbIoError() called in sendCmdToFetchLightIntensities() -> $e")
|
||||
viewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user