@Override public boolean printText(String textStr) { byte[] buffer = printservice.getText(textStr); if (buffer.length <= 100) { write(buffer); return true; } int sendSize = 100; int issendfull = 0; for (int j = 0; j < buffer.length; j += sendSize) { if (PrintService.isFUll) { Log.i("BUFFER", "BUFFER FULL"); int index = 0; while (index++ < 800) { if (!PrintService.isFUll) { issendfull = 0; Log.i("BUFFER", "BUFFER NULL" + index); break; } try { Thread.sleep(1); } catch (InterruptedException e) { Log.e(TAG, e.getMessage()); } } } byte[] btPackage = new byte[sendSize]; if (buffer.length - j < sendSize) { btPackage = new byte[buffer.length - j]; } System.arraycopy(buffer, j, btPackage, 0, btPackage.length); write(btPackage); } return true; }
@Override public boolean printUnicode(String textStr) { return write(printservice.getTextUnicode(textStr)); }
@Override public boolean printImage(Bitmap bitmap) { write(printservice.getImage(bitmap)); return write(new byte[] {0x0a}); }