react-native-mesmart 2.0.2 → 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.
@@ -112,8 +112,16 @@ dependencies {
112
112
  version: "v2.11.7.31",
113
113
  group: "paystore"
114
114
  )
115
- implementation files('libs/android-easy-layer-gpos780-2.1.4-debug.aar')
116
- implementation files('libs/libgedi-1.16.21-gpos780-payment-release.aar')
117
- // implementation files('libs/libppcomp-001.32-240506-gpos780-logs.aar')
118
- // implementation files('libs/hal-gertec-debug760.aar')
115
+ compileOnly(
116
+ name: "android-easy-layer-gpos780-2.1.4-debug",
117
+ ext: "aar",
118
+ version: "v2.1.4",
119
+ group: "gpos780"
120
+ )
121
+ compileOnly(
122
+ name: "libgedi-1.16.21-gpos780-payment-release",
123
+ ext: "aar",
124
+ version: "v1.16.21",
125
+ group: "gpos780"
126
+ )
119
127
  }
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mesmart",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Sunmi P2 utilities and Plugpag wrapper for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",