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