react-native-mesmart 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -72,6 +72,8 @@ class PrinterSunmiP2(
|
|
|
72
72
|
if (sunmiPrinterService == null)
|
|
73
73
|
throw Exception("Sunmi P2 InnerPrinter Service is null.")
|
|
74
74
|
|
|
75
|
+
if (!isPaperAvailable()) throw Exception("Impressora sem papel. Verifique a bobina.")
|
|
76
|
+
|
|
75
77
|
try {
|
|
76
78
|
try {
|
|
77
79
|
sunmiPrinterService!!.setPrinterStyle(
|
|
@@ -118,6 +120,8 @@ class PrinterSunmiP2(
|
|
|
118
120
|
if (sunmiPrinterService == null)
|
|
119
121
|
throw Exception("Sunmi P2 InnerPrinter Service is null.")
|
|
120
122
|
|
|
123
|
+
if (!isPaperAvailable()) throw Exception("Impressora sem papel. Verifique a bobina.")
|
|
124
|
+
|
|
121
125
|
try {
|
|
122
126
|
if (orientation == 0) {
|
|
123
127
|
sunmiPrinterService!!.printBitmap(bitmap, null)
|
|
@@ -141,4 +145,17 @@ class PrinterSunmiP2(
|
|
|
141
145
|
throw e
|
|
142
146
|
}
|
|
143
147
|
}
|
|
148
|
+
|
|
149
|
+
fun isPaperAvailable(): Boolean {
|
|
150
|
+
if (sunmiPrinterService == null) return false
|
|
151
|
+
return try {
|
|
152
|
+
val status = sunmiPrinterService!!.updatePrinterState()
|
|
153
|
+
// status == 1 → OK
|
|
154
|
+
// status == 3 → sem papel
|
|
155
|
+
// status == 4 → tampa aberta
|
|
156
|
+
status == 1
|
|
157
|
+
} catch (e: RemoteException) {
|
|
158
|
+
false
|
|
159
|
+
}
|
|
160
|
+
}
|
|
144
161
|
}
|