|
@@ -37,8 +37,8 @@ import butterknife.BindView;
|
|
|
|
|
|
public class IssueTicketsActivity extends BaseActivity {
|
|
public class IssueTicketsActivity extends BaseActivity {
|
|
|
|
|
|
- public static final Integer COUNTDOWN_TIME = 12000;
|
|
|
|
- private CountDownTimer timer;
|
|
|
|
|
|
+ public static final Integer COUNTDOWN_TIME = 30000;
|
|
|
|
+ private CountDownTimer timer = null;
|
|
private TitleBar titleBar;
|
|
private TitleBar titleBar;
|
|
|
|
|
|
// @BindView(R.id.print_num)
|
|
// @BindView(R.id.print_num)
|
|
@@ -54,9 +54,10 @@ public class IssueTicketsActivity extends BaseActivity {
|
|
@BindView(R.id.tx_issue_not)
|
|
@BindView(R.id.tx_issue_not)
|
|
TextView tx_issue_not;
|
|
TextView tx_issue_not;
|
|
|
|
|
|
- private ExtPrinterService ext;
|
|
|
|
|
|
+ private ExtPrinterService printService;
|
|
private int printNum = 1;
|
|
private int printNum = 1;
|
|
|
|
|
|
|
|
+
|
|
private JSONArray viewerList = new JSONArray();
|
|
private JSONArray viewerList = new JSONArray();
|
|
private JSONArray printInfo = new JSONArray();
|
|
private JSONArray printInfo = new JSONArray();
|
|
@Override
|
|
@Override
|
|
@@ -66,8 +67,7 @@ public class IssueTicketsActivity extends BaseActivity {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void onLeftClick(View v) {
|
|
public void onLeftClick(View v) {
|
|
- Intent i = new Intent (IssueTicketsActivity.this , MainActivity.class ).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
- startActivity(i);
|
|
|
|
|
|
+ jumpToMain();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -142,10 +142,15 @@ public class IssueTicketsActivity extends BaseActivity {
|
|
runOnUiThread(() -> {
|
|
runOnUiThread(() -> {
|
|
// 更新用户界面
|
|
// 更新用户界面
|
|
ToastUtils.showShortToast(this, "出票完成!");
|
|
ToastUtils.showShortToast(this, "出票完成!");
|
|
- tx_issue_status_text.setVisibility(View.VISIBLE);
|
|
|
|
- tx_issue_txt.setVisibility(View.VISIBLE);
|
|
|
|
- tx_issue_status_text.setText("出票完成~");
|
|
|
|
- tx_issue_txt.setText("请取票!");
|
|
|
|
|
|
+ if (tx_issue_status_text != null){
|
|
|
|
+ tx_issue_status_text.setVisibility(View.VISIBLE);
|
|
|
|
+ tx_issue_status_text.setText("出票完成~");
|
|
|
|
+ }
|
|
|
|
+ if (tx_issue_txt != null){
|
|
|
|
+ tx_issue_txt.setVisibility(View.VISIBLE);
|
|
|
|
+ tx_issue_txt.setText("请取票!");
|
|
|
|
+ }
|
|
|
|
+ startCountDownTimer();
|
|
});
|
|
});
|
|
logReport("出票完成");
|
|
logReport("出票完成");
|
|
}else {
|
|
}else {
|
|
@@ -153,8 +158,6 @@ public class IssueTicketsActivity extends BaseActivity {
|
|
// 更新用户界面
|
|
// 更新用户界面
|
|
ToastUtils.showShortToast(this, "出票失败!");
|
|
ToastUtils.showShortToast(this, "出票失败!");
|
|
});
|
|
});
|
|
-// tx_issue_status_text.setText("出票失败~");
|
|
|
|
-// tx_issue_txt.setText("即将退出!");
|
|
|
|
logReport("出票失败");
|
|
logReport("出票失败");
|
|
finish();
|
|
finish();
|
|
}
|
|
}
|
|
@@ -214,7 +217,7 @@ public class IssueTicketsActivity extends BaseActivity {
|
|
}
|
|
}
|
|
|
|
|
|
private void printListHandle(List<JSONObject> printList) throws RemoteException {
|
|
private void printListHandle(List<JSONObject> printList) throws RemoteException {
|
|
- if (ext == null){
|
|
|
|
|
|
+ if (printService == null){
|
|
finishView(true);
|
|
finishView(true);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -227,7 +230,7 @@ public class IssueTicketsActivity extends BaseActivity {
|
|
* 3 打印机即将缺纸
|
|
* 3 打印机即将缺纸
|
|
* 4 打印机过热
|
|
* 4 打印机过热
|
|
* */
|
|
* */
|
|
- int printerStatus = ext.getPrinterStatus(); //
|
|
|
|
|
|
+ int printerStatus = printService.getPrinterStatus(); //
|
|
runOnUiThread(() -> {
|
|
runOnUiThread(() -> {
|
|
// 更新用户界面
|
|
// 更新用户界面
|
|
ToastUtils.showShortToast(IssueTicketsActivity.this, "打印机状态:" + printerStatus);
|
|
ToastUtils.showShortToast(IssueTicketsActivity.this, "打印机状态:" + printerStatus);
|
|
@@ -252,7 +255,7 @@ public class IssueTicketsActivity extends BaseActivity {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
- ext.startTransBuffer(); //启⽤事务模式
|
|
|
|
|
|
+ printService.startTransBuffer(); //启⽤事务模式
|
|
int index = 1;
|
|
int index = 1;
|
|
for (JSONObject it : printList){
|
|
for (JSONObject it : printList){
|
|
logReport("开始打印:" + index);
|
|
logReport("开始打印:" + index);
|
|
@@ -260,7 +263,7 @@ public class IssueTicketsActivity extends BaseActivity {
|
|
logReport("打印结束:" + index);
|
|
logReport("打印结束:" + index);
|
|
index++;
|
|
index++;
|
|
}
|
|
}
|
|
- ext.endTransBuffer(); //结束事务模式
|
|
|
|
|
|
+ printService.endTransBuffer(); //结束事务模式
|
|
} catch (Exception ignored) {}
|
|
} catch (Exception ignored) {}
|
|
finishView(true);
|
|
finishView(true);
|
|
}
|
|
}
|
|
@@ -282,10 +285,10 @@ public class IssueTicketsActivity extends BaseActivity {
|
|
int alignMode =itemJson.get("alignMode") == null ? 1 : itemJson.getInteger("alignMode");
|
|
int alignMode =itemJson.get("alignMode") == null ? 1 : itemJson.getInteger("alignMode");
|
|
String printContent = itemJson.containsKey("printContent")?itemJson.getString("printContent"):"";
|
|
String printContent = itemJson.containsKey("printContent")?itemJson.getString("printContent"):"";
|
|
logReport("文本打印开始::hori:" + hori + " veri:" + veri + " alignMode:" + alignMode + " printContent:" + printContent);
|
|
logReport("文本打印开始::hori:" + hori + " veri:" + veri + " alignMode:" + alignMode + " printContent:" + printContent);
|
|
- ext.setFontZoom(hori, veri);
|
|
|
|
|
|
+ printService.setFontZoom(hori, veri);
|
|
// 对其方式
|
|
// 对其方式
|
|
- ext.setAlignMode(alignMode);
|
|
|
|
- ext.printText(printContent);
|
|
|
|
|
|
+ printService.setAlignMode(alignMode);
|
|
|
|
+ printService.printText(printContent);
|
|
logReport("文本打印结束");
|
|
logReport("文本打印结束");
|
|
}
|
|
}
|
|
// 打印二维码
|
|
// 打印二维码
|
|
@@ -295,8 +298,8 @@ public class IssueTicketsActivity extends BaseActivity {
|
|
String eqCode = itemJson.get("printContent") == null ? "" : itemJson.getString("printContent");
|
|
String eqCode = itemJson.get("printContent") == null ? "" : itemJson.getString("printContent");
|
|
int qrcodeSize = itemJson.get("qrcodeSize") == null ? 0 : itemJson.getInteger("qrcodeSize");
|
|
int qrcodeSize = itemJson.get("qrcodeSize") == null ? 0 : itemJson.getInteger("qrcodeSize");
|
|
logReport("二维码打印开始::alignMode:" + alignMode + " eqCode:" + eqCode + " qrcodeSize:" + qrcodeSize );
|
|
logReport("二维码打印开始::alignMode:" + alignMode + " eqCode:" + eqCode + " qrcodeSize:" + qrcodeSize );
|
|
- ext.setAlignMode(alignMode);
|
|
|
|
- ext.printQrCode(eqCode, qrcodeSize, 0);
|
|
|
|
|
|
+ printService.setAlignMode(alignMode);
|
|
|
|
+ printService.printQrCode(eqCode, qrcodeSize, 0);
|
|
logReport("二维码打印结束");
|
|
logReport("二维码打印结束");
|
|
}
|
|
}
|
|
// 打印条形码
|
|
// 打印条形码
|
|
@@ -309,8 +312,8 @@ public class IssueTicketsActivity extends BaseActivity {
|
|
int height = itemJson.get("height") == null ? 0 : itemJson.getInteger("height");
|
|
int height = itemJson.get("height") == null ? 0 : itemJson.getInteger("height");
|
|
logReport("条形码打印开始::alignMode:" + alignMode + " barCode:" + barCode + " barCodeType:" + barCodeType +
|
|
logReport("条形码打印开始::alignMode:" + alignMode + " barCode:" + barCode + " barCodeType:" + barCodeType +
|
|
" width:" + width + " height:" + height);
|
|
" width:" + width + " height:" + height);
|
|
- ext.setAlignMode(alignMode);
|
|
|
|
- ext.printBarCode(barCode, barCodeType, width, height, 1);
|
|
|
|
|
|
+ printService.setAlignMode(alignMode);
|
|
|
|
+ printService.printBarCode(barCode, barCodeType, width, height, 1);
|
|
logReport("条形码打印结束");
|
|
logReport("条形码打印结束");
|
|
}
|
|
}
|
|
// 打印走纸
|
|
// 打印走纸
|
|
@@ -320,9 +323,9 @@ public class IssueTicketsActivity extends BaseActivity {
|
|
int wrapLen = itemJson.get("wrapLen") == null ? 0 : itemJson.getInteger("wrapLen");
|
|
int wrapLen = itemJson.get("wrapLen") == null ? 0 : itemJson.getInteger("wrapLen");
|
|
logReport("打印走纸开始::wrapType:" + wrapType + " wrapLen:" + wrapLen );
|
|
logReport("打印走纸开始::wrapType:" + wrapType + " wrapLen:" + wrapLen );
|
|
if(wrapType == 1) {
|
|
if(wrapType == 1) {
|
|
- ext.lineWrap(wrapLen);
|
|
|
|
|
|
+ printService.lineWrap(wrapLen);
|
|
} else if (wrapType == 2) {
|
|
} else if (wrapType == 2) {
|
|
- ext.pixelWrap(wrapLen);
|
|
|
|
|
|
+ printService.pixelWrap(wrapLen);
|
|
}
|
|
}
|
|
logReport("打印走纸结束");
|
|
logReport("打印走纸结束");
|
|
}
|
|
}
|
|
@@ -331,7 +334,7 @@ public class IssueTicketsActivity extends BaseActivity {
|
|
int cutPx = itemJson.get("cutPx") == null ? 0 : itemJson.getInteger("cutPx");
|
|
int cutPx = itemJson.get("cutPx") == null ? 0 : itemJson.getInteger("cutPx");
|
|
int cutType = itemJson.get("cutType") == null ? 0 : itemJson.getInteger("cutType");
|
|
int cutType = itemJson.get("cutType") == null ? 0 : itemJson.getInteger("cutType");
|
|
logReport("打印切纸开始::cutPx:" + cutPx + " cutType:" + cutType );
|
|
logReport("打印切纸开始::cutPx:" + cutPx + " cutType:" + cutType );
|
|
- ext.cutPaper(cutType, cutPx);
|
|
|
|
|
|
+ printService.cutPaper(cutType, cutPx);
|
|
logReport("打印走纸结束");
|
|
logReport("打印走纸结束");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -364,7 +367,7 @@ public class IssueTicketsActivity extends BaseActivity {
|
|
ServiceConnection serviceConnection = new ServiceConnection() {
|
|
ServiceConnection serviceConnection = new ServiceConnection() {
|
|
@Override public void onServiceConnected(ComponentName name, IBinder
|
|
@Override public void onServiceConnected(ComponentName name, IBinder
|
|
service) {
|
|
service) {
|
|
- ext = ExtPrinterService.Stub.asInterface(service);
|
|
|
|
|
|
+ printService = ExtPrinterService.Stub.asInterface(service);
|
|
initPageView();
|
|
initPageView();
|
|
}
|
|
}
|
|
@Override public void onServiceDisconnected(ComponentName name) {
|
|
@Override public void onServiceDisconnected(ComponentName name) {
|
|
@@ -378,6 +381,37 @@ public class IssueTicketsActivity extends BaseActivity {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ private void stopCountDownTimer(){
|
|
|
|
+ if (timer != null){
|
|
|
|
+ timer.cancel();
|
|
|
|
+ timer = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private void startCountDownTimer(){
|
|
|
|
+ if (timer == null){
|
|
|
|
+ timer = new CountDownTimer(COUNTDOWN_TIME, 1000) {
|
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
|
+ @Override
|
|
|
|
+ public void onTick(long millisUntilFinished) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onFinish() {
|
|
|
|
+ jumpToMain();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ timer.start();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void jumpToMain(){
|
|
|
|
+ stopCountDownTimer();
|
|
|
|
+ Intent i = new Intent (IssueTicketsActivity.this , MainActivity.class )
|
|
|
|
+ .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
+ startActivity(i);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
@SuppressLint("CheckResult")
|
|
@SuppressLint("CheckResult")
|
|
private void logReport(String content){
|
|
private void logReport(String content){
|