connector retry reconnect
This commit is contained in:
@@ -63,8 +63,23 @@ public class PrinterConnector implements IPOSListener {
|
|||||||
return (int) (inches * this.PRINTER_DPI);
|
return (int) (inches * this.PRINTER_DPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printBitmap(Bitmap bitmap) {
|
static final int RETRY_COUNT = 5;
|
||||||
|
|
||||||
|
public void printBitmap(Bitmap bitmap) {
|
||||||
|
if (printer == null) {
|
||||||
|
this.reconnect();
|
||||||
|
int iteration = 0;
|
||||||
|
while (true) {
|
||||||
|
if (printer != null) break;
|
||||||
|
if (iteration > RETRY_COUNT) return;
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
iteration++;
|
||||||
|
}
|
||||||
|
}
|
||||||
Dimensions dimensions = this.config.getDimensions();
|
Dimensions dimensions = this.config.getDimensions();
|
||||||
|
|
||||||
int widthInDots = mmToDots(dimensions.getWidth());
|
int widthInDots = mmToDots(dimensions.getWidth());
|
||||||
|
|||||||
Reference in New Issue
Block a user