3a7fb73353c43f4c4c744f96bc18553L128">128
139
|
esc.addSelectErrorCorrectionLevelForQRCode((byte) 0x31); //设置纠错等级
|
|
129
|
|
- esc.addSelectSizeOfModuleForQRCode((byte) 3);//设置qrcode模块大小
|
|
|
140
|
+ esc.addSelectSizeOfModuleForQRCode((byte)10);//设置qrcode模块大小
|
|
130
|
141
|
esc.addStoreQRCodeData(sessionBean.sessionId);//设置qrcode内容
|
|
|
142
|
+ esc.addSelectJustification(EscCommand.JUSTIFICATION.CENTER);//设置打印中心对齐
|
|
131
|
143
|
esc.addPrintQRCode();//打印QRCode
|
|
132
|
|
- esc.addPrintAndLineFeed();
|
|
|
144
|
+ esc.addSelectJustification(EscCommand.JUSTIFICATION.LEFT);//设置打印左对齐
|
|
|
145
|
+ esc.addText("拍摄日期 "+new SimpleDateFormat("yy/MM/dd HH:mm").format(new Date()));
|
|
|
146
|
+ esc.addPrintAndFeedLines((byte) 3);
|
|
133
|
147
|
|
|
134
|
148
|
Vector<Byte> datas = esc.getCommand(); //发送数据
|
|
135
|
149
|
Byte[] Bytes = datas.toArray(new Byte[datas.size()]);
|
|
|
|
@@ -147,6 +161,34 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
|
|
147
|
161
|
}
|
|
148
|
162
|
}
|
|
149
|
163
|
|
|
|
164
|
+ private void checkPrinter(){
|
|
|
165
|
+ sessionView.showToast(App.getAppContext().getString(R.string.connecting));
|
|
|
166
|
+ try{
|
|
|
167
|
+ int status = mGpService.queryPrinterStatus(0, 10000);
|
|
|
168
|
+ if (status != GpCom.STATE_NO_ERR) {
|
|
|
169
|
+ connectPrinter();
|
|
|
170
|
+ }
|
|
|
171
|
+ }catch (Exception e){
|
|
|
172
|
+ sessionView.showToast(App.getAppContext().getString(R.string.go_check_printer));
|
|
|
173
|
+ return;
|
|
|
174
|
+ }
|
|
|
175
|
+ printQR();
|
|
|
176
|
+ }
|
|
|
177
|
+
|
|
|
178
|
+ public void connectPrinter() {
|
|
|
179
|
+ if(mGpService==null){
|
|
|
180
|
+ sessionView.showToast(App.getAppContext().getString(R.string.printer_service_boot_fail));
|
|
|
181
|
+ return;
|
|
|
182
|
+ }
|
|
|
183
|
+ try {
|
|
|
184
|
+ int code = mGpService.openPort(0, PortParameters.BLUETOOTH, Preferences.getInstance().getPrinterMac(), 0);
|
|
|
185
|
+ LogHelper.d("czy111","open port return code ="+code);
|
|
|
186
|
+ } catch (Exception e) {
|
|
|
187
|
+ sessionView.showToast(App.getAppContext().getString(R.string.printer_port_open_fail));
|
|
|
188
|
+ }
|
|
|
189
|
+
|
|
|
190
|
+ }
|
|
|
191
|
+
|
|
150
|
192
|
private void startAndBindPrintService() {
|
|
151
|
193
|
Intent intent = new Intent(App.getAppContext(), GpPrintService.class);
|
|
152
|
194
|
App.getAppContext().startService(intent);
|
|
|
|
@@ -110,4 +110,6 @@
|
|
110
|
110
|
<string name="printer_status_query_fail">打印机状态查询失败</string>
|
|
111
|
111
|
|
|
112
|
112
|
<string name="printer_service_boot_fail">打印机服务连接失败,请退出应用重试</string>
|
|
|
113
|
+
|
|
|
114
|
+ <string name="not_set_printer_yet">尚未设置打印机,去设置</string>
|
|
113
|
115
|
</resources>
|
|
|
|
@@ -5,7 +5,7 @@ buildscript {
|
|
5
|
5
|
jcenter()
|
|
6
|
6
|
}
|
|
7
|
7
|
dependencies {
|
|
8
|
|
- classpath 'com.android.tools.build:gradle:2.1.3'
|
|
|
8
|
+ classpath 'com.android.tools.build:gradle:2.2.0-rc1'
|
|
9
|
9
|
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
|
|
10
|
10
|
// NOTE: Do not place your application dependencies here; they belong
|
|
11
|
11
|
// in the individual module build.gradle files
|