} 110
+                if ((byte) (status & GpCom.STATE_TIMES_OUT) > 0) {
111
+                    str += "查询超时";
112
+                }
113
+            }
114
+            view.showToast( "打印机:"  + " 状态:" + str);
115
+            view.onPrinterError(str);
53 116
 
117
+        } catch (RemoteException e1) {
118
+            e1.printStackTrace();
119
+        }
54 120
     }
55 121
 
56 122
     @Override
57 123
     public void printTestPage() {
58
-
124
+        try {
125
+            int rel = mGpService.printeTestPage(0); //
126
+            Log.i("ServiceConnection", "rel " + rel);
127
+            GpCom.ERROR_CODE r = GpCom.ERROR_CODE.values()[rel];
128
+            if (r != GpCom.ERROR_CODE.SUCCESS) {
129
+                view.showToast( GpCom.getErrorText(r));
130
+            }
131
+        } catch (RemoteException e1) {
132
+            // TODO Auto-generated catch block
133
+            e1.printStackTrace();
134
+        }
59 135
     }
60 136
 
61 137
     @Override
@@ -89,8 +165,13 @@ public class PrinterSettingPresenter implements PrinterSettingContract.Presenter
89 165
     }
90 166
 
91 167
     @Override
92
-    public void connectPrinter() {
93
-
168
+    public void connectPrinter(BluetoothDevice device) {
169
+        try {
170
+            int code = mGpService.openPort(0, PortParameters.BLUETOOTH, device.getAddress(), 0);
171
+            LogHelper.d("czy","open port return code ="+code);
172
+        } catch (RemoteException e) {
173
+            e.printStackTrace();
174
+        }
94 175
     }
95 176
 
96 177
     @Override
@@ -103,9 +184,11 @@ public class PrinterSettingPresenter implements PrinterSettingContract.Presenter
103 184
         }
104 185
     }
105 186
 
106
-    @Override
107
-    public void connectBluetooth(BluetoothDevice device) {
108
-
187
+    private void startAndBindPrintService() {
188
+        Intent intent = new Intent(App.getAppContext(), GpPrintService.class);
189
+        App.getAppContext().startService(intent);
190
+        conn = new PrinterServiceConnection();
191
+        App.getAppContext().bindService(intent, conn, Context.BIND_AUTO_CREATE);
109 192
     }
110 193
 
111 194
     // changes the title when discovery is finished
@@ -131,6 +214,30 @@ public class PrinterSettingPresenter implements PrinterSettingContract.Presenter
131 214
         }
132 215
     };
133 216
 
217
+    private void registerPrinterBroadcast() {
218
+        IntentFilter filter = new IntentFilter();
219
+        filter.addAction(GpCom.ACTION_CONNECT_STATUS);
220
+        context.registerReceiver(PrinterStatusBroadcastReceiver, filter);
221
+    }
222
+
223
+    private BroadcastReceiver PrinterStatusBroadcastReceiver = new BroadcastReceiver() {
224
+        @Override
225
+        public void onReceive(Context context, Intent intent) {
226
+            if (GpCom.ACTION_CONNECT_STATUS.equals(intent.getAction())) {
227
+                int type = intent.getIntExtra(GpPrintService.CONNECT_STATUS, 0);
228
+                int id = intent.getIntExtra(GpPrintService.PRINTER_ID, 0);
229
+                Log.d("czy", "connect status " + type);
230
+                if (type == GpDevice.STATE_CONNECTING) {
231
+
232
+                } else if (type == GpDevice.STATE_NONE) {
233
+
234
+                } else if (type == GpDevice.STATE_VALID_PRINTER) {
235
+
236
+                } else if (type == GpDevice.STATE_INVALID_PRINTER) {
134 237
 
238
+                }
239
+            }
240
+        }
241
+    };
135 242
 
136 243
 }

kodo - Gogs: Go Git Service

Нет описания

models.py 2.6KB

    # -*- coding: utf-8 -*- from django.db import models from django.utils.translation import ugettext_lazy as _ from django_models_ext import BaseModelMixin, SexModelMixin from shortuuidfield import ShortUUIDField class ScreenAdminInfo(BaseModelMixin): ACTIVATED = 1 DISABLED = 2 DELETED = 3 USER_STATUS_TUPLE = ( (ACTIVATED, u'已激活'), (DISABLED, u'已禁用'), (DELETED, u'已删除'), ) admin_id = ShortUUIDField(_(u'admin_id'), max_length=32, blank=True, null=True, help_text=u'大屏管理员唯一标识', db_index=True, unique=True) unionid = models.CharField(_(u'unionid'), max_length=32, blank=True, null=True, help_text=u'微信 Union ID', db_index=True) openid = models.CharField(_(u'openid'), max_length=32, blank=True, null=True, help_text=u'微信 Open ID', db_index=True) name = models.CharField(_(u'name'), max_length=8, blank=True, null=True, help_text=u'用户姓名') sex = models.IntegerField(_(u'sex'), choices=SexModelMixin.SEX_TUPLE, default=SexModelMixin.UNKNOWN, help_text=u'用户性别') nickname = models.CharField(_(u'nickname'), max_length=255, blank=True, null=True, help_text=u'用户昵称') avatar = models.CharField(_(u'avatar'), max_length=255, blank=True, null=True, help_text=u'用户头像') phone = models.CharField(_(u'phone'), max_length=11, blank=True, null=True, help_text=u'用户电话', db_index=True) country = models.CharField(_(u'country'), max_length=16, blank=True, null=True, help_text=u'用户国家') province = models.CharField(_(u'province'), max_length=16, blank=True, null=True, help_text=u'用户省份') city = models.CharField(_(u'city'), max_length=16, blank=True, null=True, help_text=u'用户城市') location = models.CharField(_(u'location'), max_length=255, blank=True, null=True, help_text=u'用户地址') brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True) brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称') user_status = models.IntegerField(_(u'user_status'), choices=USER_STATUS_TUPLE, default=ACTIVATED, help_text=u'管理员状态', db_index=True) class Meta: verbose_name = _(u'ScreenAdminInfo') verbose_name_plural = _(u'ScreenAdminInfo') unique_together = ( ('brand_id', 'unionid', 'openid'), ) def __unicode__(self): return '%d' % self.pk @property def data(self): return { 'admin_id': self.admin_id, 'nickname': self.nickname, 'avatar': self.avatar, }