Commit 94237477b96d8d0204aab532faa43c073b4f515a

Authored by 孙向锦
1 parent 6d9503bc

修改整个sdk

C5/app/build.gradle
@@ -94,6 +94,7 @@ dependencies { @@ -94,6 +94,7 @@ dependencies {
94 compile 'com.github.barteksc:android-pdf-viewer:2.7.0' 94 compile 'com.github.barteksc:android-pdf-viewer:2.7.0'
95 compile 'cn.yipianfengye.android:zxing-library:2.2' 95 compile 'cn.yipianfengye.android:zxing-library:2.2'
96 compile 'com.jaredrummler:android-processes:1.1.1' 96 compile 'com.jaredrummler:android-processes:1.1.1'
  97 + implementation project(':xpadapi')
97 } 98 }
98 99
99 //#解决某些输入文件使用或覆盖了已过时的 API 100 //#解决某些输入文件使用或覆盖了已过时的 API
C5/app/src/main/java/com/sunvote/xpadapp/MainActivity.java
1 package com.sunvote.xpadapp; 1 package com.sunvote.xpadapp;
2 2
3 -import android.Manifest;  
4 -import android.annotation.SuppressLint;  
5 import android.app.Fragment; 3 import android.app.Fragment;
6 import android.app.FragmentManager; 4 import android.app.FragmentManager;
7 import android.app.FragmentTransaction; 5 import android.app.FragmentTransaction;
8 -import android.app.ProgressDialog;  
9 -import android.content.BroadcastReceiver;  
10 -import android.content.DialogInterface;  
11 import android.content.Intent; 6 import android.content.Intent;
12 -import android.content.pm.PackageManager;  
13 -import android.graphics.Color;  
14 -import android.net.Uri;  
15 -import android.os.Build;  
16 import android.os.Bundle; 7 import android.os.Bundle;
17 -import android.os.Environment;  
18 import android.os.Handler; 8 import android.os.Handler;
19 -import android.os.Message;  
20 -import android.support.v4.app.ActivityCompat;  
21 -import android.support.v4.content.FileProvider;  
22 -import android.telephony.TelephonyManager;  
23 -import android.util.Log;  
24 -import android.view.KeyEvent;  
25 -import android.view.MotionEvent;  
26 -import android.view.View;  
27 -import android.widget.FrameLayout;  
28 -import android.widget.ImageView;  
29 import android.widget.TextView; 9 import android.widget.TextView;
30 -import android.widget.Toast;  
31 10
32 -import com.sunvote.udptransfer.Config;  
33 -import com.sunvote.util.EncryptUtils;  
34 -import com.sunvote.util.LogUtil;  
35 -import com.sunvote.util.SPUtils;  
36 -import com.sunvote.util.StringUtils; 11 +import com.sunvote.xpadapi.service.XpadApiService;
  12 +import com.sunvote.xpadapi.service.logic.XpadApiServiceInfoProxyManager;
  13 +import com.sunvote.xpadapi.service.bean.BaseInfo;
  14 +import com.sunvote.xpadapi.service.bean.BaseVoteInfo;
  15 +import com.sunvote.xpadapi.service.bean.OnLineInfo;
  16 +import com.sunvote.xpadapi.service.listener.BaseInfoChanageListener;
  17 +import com.sunvote.xpadapi.service.listener.BaseVoteInfoChanageListener;
  18 +import com.sunvote.xpadapi.service.listener.OnlineInfoChanageListener;
37 import com.sunvote.xpadapp.base.BaseActivity; 19 import com.sunvote.xpadapp.base.BaseActivity;
38 -import com.sunvote.xpadapp.base.BaseFragment;  
39 -import com.sunvote.xpadapp.db.DBManager;  
40 -import com.sunvote.xpadapp.db.modal.BillInfo;  
41 -import com.sunvote.xpadapp.db.modal.MeetingInfo;  
42 -import com.sunvote.xpadapp.db.modal.MultiTitleItem;  
43 -import com.sunvote.xpadapp.fragments.AdminFragment;  
44 -import com.sunvote.xpadapp.fragments.AuthorizationFragment;  
45 -import com.sunvote.xpadapp.fragments.ComErrorFragment;  
46 -import com.sunvote.xpadapp.fragments.CommunicationTestFragment;  
47 -import com.sunvote.xpadapp.fragments.ContentVoteFragment;  
48 -import com.sunvote.xpadapp.fragments.DocumentBrowserFragment;  
49 -import com.sunvote.xpadapp.fragments.DownloadFragment;  
50 -import com.sunvote.xpadapp.fragments.ElectionCustomFragment;  
51 -import com.sunvote.xpadapp.fragments.ElectionFragment;  
52 -import com.sunvote.xpadapp.fragments.FirmUpdateFragment;  
53 -import com.sunvote.xpadapp.fragments.KeypadTestChoice10Fragment;  
54 -import com.sunvote.xpadapp.fragments.KeypadTestFragment;  
55 -import com.sunvote.xpadapp.fragments.MeetingWelcomeFragment;  
56 -import com.sunvote.xpadapp.fragments.MultiContentDetailFragment;  
57 -import com.sunvote.xpadapp.fragments.MultiContentFragment;  
58 -import com.sunvote.xpadapp.fragments.MultiPingshengFragment;  
59 -import com.sunvote.xpadapp.fragments.MultiTitleFragment;  
60 -import com.sunvote.xpadapp.fragments.UserResultVoteFragment;  
61 -import com.sunvote.xpadapp.fragments.NoFileFragment;  
62 -import com.sunvote.xpadapp.fragments.OfflineFragment;  
63 -import com.sunvote.xpadapp.fragments.OnLineFragment;  
64 -import com.sunvote.xpadapp.fragments.PDFContextShowFragment;  
65 -import com.sunvote.xpadapp.fragments.ResultElectionFragment;  
66 -import com.sunvote.xpadapp.fragments.ResultMultiVoteFragment;  
67 -import com.sunvote.xpadapp.fragments.ResultVoteFragment;  
68 -import com.sunvote.xpadapp.fragments.ShowIdFragment;  
69 -import com.sunvote.xpadapp.fragments.SigninFragment;  
70 -import com.sunvote.xpadapp.fragments.SinginResultFragment;  
71 -import com.sunvote.xpadapp.fragments.SingleTitleFragment;  
72 -import com.sunvote.xpadapp.presenter.ServicePresent;  
73 -import com.sunvote.xpadapp.presenter.XPadPresenter;  
74 -import com.sunvote.xpadapp.server.MoniService;  
75 -import com.sunvote.xpadapp.utils.FileUtil;  
76 -import com.sunvote.xpadapp.utils.SharedPreferencesUtil;  
77 -import com.sunvote.xpadcomm.ComListener;  
78 -import com.sunvote.xpadcomm.FileRecver;  
79 -import com.sunvote.xpadcomm.ScreenUtil;  
80 -import com.sunvote.xpadcomm.XPadApi;  
81 -import com.sunvote.xpadcomm.XPadApiInterface.BaseInfo;  
82 -import com.sunvote.xpadcomm.XPadApiInterface.CmdDataInfo;  
83 -import com.sunvote.xpadcomm.XPadApiInterface.KeypadInfo;  
84 -import com.sunvote.xpadcomm.XPadApiInterface.ModelInfo;  
85 -import com.sunvote.xpadcomm.XPadApiInterface.OnLineInfo;  
86 -import com.sunvote.xpadcomm.XPadApiInterface.VoteInfo;  
87 -import com.sunvote.xpadcomm.XPadSystem;  
88 20
89 -import java.io.File;  
90 -import java.io.UnsupportedEncodingException;  
91 -import java.util.ArrayList;  
92 -import java.util.Arrays;  
93 -import java.util.Timer;  
94 -import java.util.TimerTask;  
95 -import java.util.UUID;  
96 -  
97 -@SuppressLint("NewApi")  
98 -public class MainActivity extends BaseActivity implements ComListener {  
99 -  
100 - private final int Msg_ComError = 0;  
101 - private final int Msg_Offline = 1;  
102 - private final int Msg_Online = 2;  
103 - private final int Msg_Download = 3;  
104 - private final int Msg_Welcome = 4;  
105 -  
106 -// private final int Msg_Signin = 5;  
107 -// private final int Msg_QuickVote = 6;  
108 -// private final int Msg_SingleTitleVote = 7;  
109 -// private final int Msg_MultiTitleVote = 8;  
110 -// private final int Msg_SingleContentVote = 9;  
111 -// private final int Msg_MultiContentVote = 10;  
112 -// private final int Msg_ElectionVote = 11;  
113 - public static final int Msg_StopDownload = 12;  
114 -  
115 - // private final int Msg_KeypadTest = 13;  
116 - private final int Msg_CommunicationTest = 14;//100次成功率  
117 - private final int Msg_ShowID = 15;  
118 - private final int Msg_HideShowID = 17;  
119 -  
120 -// private final int Msg_MultiPingShengVote = 16;  
121 -  
122 - private final int Msg_onVoteEvent = 20;  
123 - private final int Msg_onCommitSuccessEvent = 21;  
124 - private final int Msg_onCommitAllOkSuccessEvent = 22;  
125 - private final int Msg_onMultiPackageData = 23;//显示结果  
126 - private final int Msg_HideVoteResult = 24;  
127 - private final int Msg_ShowMultiVoteResult = 25;  
128 - private final int Msg_DBfileNotExist = 30;  
129 -  
130 - private final int Msg_MatchInfo = 31;  
131 - private final int Msg_CommunicationTestHideResult = 32;  
132 -  
133 - private final int Msg_onCommitErrorEvent = 33;  
134 -  
135 - public static final int Msg_DocumentBroswer = 40;  
136 - private final int Msg_ShowBill = 41;  
137 -  
138 - private final int Msg_ScreenDark = 50;  
139 - private final int Msg_ChangeBright = 51;  
140 -// private final int Msg_ChangeOffTime = 52;  
141 -  
142 - private final int Msg_FirmUpdate = 53;  
143 - private final int Msg_HideFirmUpdate = 54;  
144 -  
145 - public static final int MSG_DELAY_TO_VIEW = 56;  
146 -  
147 - private final int Msg_ShowElectionVoteResult = 60;  
148 - private final int Msg_ShowCustomTitleResult = 61;  
149 - private final int MSG_SHOW_ADMIN = 100;  
150 - private final int MSG_CLEAN_FILE = 101;  
151 -  
152 - public BroadcastReceiver batteryLevelRcvr;  
153 -  
154 - // WifiManager wifiManager;  
155 - // WiFiConnecter wac;  
156 - private String TAG = "MainActivity";  
157 - FragmentManager fm = getFragmentManager();  
158 - private FileRecver cs = null;  
159 - private String ip = "192.168.0.105";  
160 - private int port = 15154;  
161 -  
162 - private BaseFragment billFragment;  
163 - private BaseFragment currFragment;  
164 - public BaseFragment multiContentFragment;  
165 - private DownloadFragment downloadFragment;  
166 - private DocumentBrowserFragment docFragment;  
167 - public BaseFragment pdfFragment;  
168 - private Fragment showIdFragment;  
169 - public Fragment resultFragment;  
170 - private FirmUpdateFragment firmFragment;  
171 -  
172 - private String wifiSsid;  
173 - private String wifiPwd;  
174 - private String serverIp;  
175 - private int serverPort;  
176 -  
177 - public XPadPresenter presenter;  
178 - public OnLineInfo mOnlineInfo;  
179 - public BaseInfo mBaseInfo;  
180 - public KeypadInfo mKeypadInfo;  
181 - public VoteInfo mVoteInfo;  
182 - public ModelInfo mModelInfo;  
183 -  
184 - public String meetingDir;  
185 -  
186 - public MeetingInfo meetingInfo;  
187 - public BillInfo currBillInfo;  
188 - public BillInfo subBillInfo;  
189 - public DBManager dbm;  
190 - public int meetingId;  
191 - public int roleType;//1 正式代表 , 2 列席代表 0 未配置  
192 -  
193 - private boolean inKeyTesting = false;  
194 - private boolean isChair=false;  
195 -  
196 - private long lastTouchTime;  
197 - private Timer screenTimer;  
198 - private long scrTimerCnt;  
199 - private Integer brigntLevel;  
200 - private Integer darkTime;// minit  
201 -  
202 - public long startVoteTime;// 启动投票时间 用于测试10选1 功能  
203 - public boolean isLoadPDF;  
204 -  
205 - private boolean downloading = false;  
206 -  
207 - public AdminFragment adminFragment;  
208 - private FrameLayout lockscreen; 21 +public class MainActivity extends BaseActivity {
209 22
  23 + private Handler handler;
210 private TextView terminalId; 24 private TextView terminalId;
211 - private ImageView service; 25 + private Fragment fragment;
212 26
213 @Override 27 @Override
214 protected void onCreate(Bundle savedInstanceState) { 28 protected void onCreate(Bundle savedInstanceState) {
215 super.onCreate(savedInstanceState); 29 super.onCreate(savedInstanceState);
  30 + Intent intent = new Intent(this, XpadApiService.class);
  31 + startService(intent);
216 setContentView(R.layout.activity_main); 32 setContentView(R.layout.activity_main);
217 terminalId = findViewById(R.id.terminal_id); 33 terminalId = findViewById(R.id.terminal_id);
218 - service = findViewById(R.id.service);  
219 - lockscreen = findViewById(R.id.lockscreen);  
220 - if (service != null) {  
221 - service.setOnClickListener(new View.OnClickListener() {  
222 - @Override  
223 - public void onClick(View v) {  
224 - if (mOnlineInfo.onLine == 1) {  
225 - showServiceDialog();  
226 - service.setVisibility(View.GONE);  
227 - } else {  
228 - Intent intent = new Intent(MainActivity.this, ConnectWifiActivity.class);  
229 - startActivity(intent);  
230 - }  
231 - }  
232 - });  
233 - }  
234 -  
235 - mOnlineInfo = new OnLineInfo();  
236 - mOnlineInfo.onLine = 0;  
237 -  
238 - presenter = new XPadPresenter(this);  
239 - setOnlineFragment();  
240 - darkTime = (Integer) SharedPreferencesUtil.getData(MainActivity.this, "darkTime", 3);  
241 - brigntLevel = (Integer) SharedPreferencesUtil.getData(MainActivity.this, "bright", 30);  
242 - ScreenUtil.setNormalMode(MainActivity.this, brigntLevel);  
243 - screenTimer = new Timer(true);  
244 - screenTimer.schedule(screenTask, 1000, 1000); // 延时1000ms后执行,1000ms执行一次  
245 -  
246 - clearApkFile();  
247 - FirmUpdateFragment.clearUpdateFile();  
248 -  
249 - if(!isUnlock()){  
250 - setUnlockScreen();  
251 - }  
252 - }  
253 -  
254 - public void setTerminalId(int id) {  
255 - terminalId.setText(getString(R.string.terminal_id) + id);  
256 - }  
257 -  
258 - @Override  
259 - public void onAttachedToWindow() {  
260 - hideBottomUIMenu();  
261 - super.onAttachedToWindow();  
262 - }  
263 -  
264 - public void hideBottomUIMenu() {  
265 -  
266 - // 隐藏虚拟按键,并且全屏  
267 - if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower  
268 - // api  
269 - View v = this.getWindow().getDecorView();  
270 - v.setSystemUiVisibility(View.GONE);  
271 - } else if (Build.VERSION.SDK_INT >= 19) {  
272 - // for new api versions.  
273 - View decorView = getWindow().getDecorView();  
274 -  
275 - int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | 0x00002000;  
276 - decorView.setSystemUiVisibility(uiOptions);  
277 - }  
278 - }  
279 -  
280 - public void showBottomUIMenu() {  
281 - // 隐藏虚拟按键,并且全屏  
282 - if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower  
283 - // api  
284 - View v = this.getWindow().getDecorView();  
285 - v.setSystemUiVisibility(View.GONE);  
286 - } else if (Build.VERSION.SDK_INT >= 19) {  
287 - // for new api versions.  
288 - View decorView = getWindow().getDecorView();  
289 - int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION  
290 - | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY //| View.SYSTEM_UI_FLAG_FULLSCREEN  
291 - & ~0x00002000;  
292 - decorView.setSystemUiVisibility(uiOptions);  
293 - }  
294 - XPadSystem.setNavgationVisible(this);  
295 - }  
296 -  
297 - @Override  
298 - protected void onResume() {  
299 - hideBottomUIMenu();  
300 - setTerminalId(XPadApi.getInstance().getClient().getUdpModuleNO());  
301 - super.onResume();  
302 - }  
303 -  
304 - public void setBackgroundColor(int color){  
305 - findViewById(R.id.root).setBackgroundColor(color); 34 + handler = new Handler();
  35 + XpadApiServiceInfoProxyManager.getInstance().setOnlineInfoChanageListener(onlineInfoChanageListener);
  36 + XpadApiServiceInfoProxyManager.getInstance().setBaseInfoListener(onBaseInfoListener);
  37 + XpadApiServiceInfoProxyManager.getInstance().setBaseVoteInfoListener(baseVoteInfoChanageListener);
306 } 38 }
307 39
308 - @Override  
309 - protected void onPause() {  
310 - LogUtil.i(TAG, "onPause");  
311 - super.onPause();  
312 - }  
313 -  
314 - @Override  
315 - protected void onStop() {  
316 - LogUtil.i(TAG, "onstop");  
317 - XPadSystem.setNavgationVisible(this);  
318 - super.onStop();  
319 - }  
320 -  
321 - @Override  
322 - protected void onDestroy() {  
323 - super.onDestroy();  
324 - showBottomUIMenu();  
325 - XPadApi.getInstance().closeCom();  
326 - if (batteryLevelRcvr != null) {  
327 - unregisterReceiver(batteryLevelRcvr);  
328 - }  
329 -  
330 - System.exit(0);  
331 - }  
332 -  
333 - public Handler myHandler = new Handler() { 40 + private BaseVoteInfoChanageListener baseVoteInfoChanageListener = new BaseVoteInfoChanageListener() {
334 @Override 41 @Override
335 - public void handleMessage(Message msg) {  
336 - switch (msg.what) {  
337 - case Msg_ComError:  
338 - setComErrorFragment();  
339 - break;  
340 - case Msg_Offline:  
341 - setOfflineFragment();  
342 - break;  
343 - case Msg_Online:  
344 - setOnlineFragment();  
345 - break;  
346 - case Msg_Download:  
347 - if (!downloading) {  
348 - clearApkFile();  
349 - FirmUpdateFragment.clearUpdateFile();  
350 - downloading = true;  
351 - setDownloadFragment();  
352 - }  
353 - break;  
354 - case Msg_StopDownload:  
355 - downloading = false;  
356 - if (downloadFragment != null) {  
357 - downloadFragment.stopDownload();  
358 - hideDownloadFragment();  
359 - }  
360 -  
361 - if (dbm != null) {  
362 - try {  
363 - dbm.closeDB();  
364 - dbm = null;  
365 - } catch (Exception e) {  
366 - LogUtil.e(TAG, e);  
367 - }  
368 - }  
369 - docFragment = null;  
370 - File apkFile = checkUpdateApkFile();  
371 - File firmFile = FirmUpdateFragment.checkFirmFile();  
372 - String str = String.format("Msg_StopDownload apkFile:%s ,firmFile:%s", apkFile != null ? "Y" : "N", firmFile != null ? "Y" : "N");  
373 - //Toast.makeText(MainActivity.this,str,Toast.LENGTH_SHORT).show();  
374 - LogUtil.d(TAG, "handleMessage: " + str);  
375 -  
376 - if (firmFile != null) {  
377 - LogUtil.i(TAG, "handleMessage: firm update");  
378 - setFirmUpdateFragment();  
379 - } else if (apkFile != null) {  
380 - LogUtil.i(TAG, "handleMessage: install apk");  
381 - Intent intent1 = new Intent(MainActivity.this,MoniService.class);  
382 - stopService(intent1);  
383 - myHandler.removeCallbacks(installTask);  
384 - myHandler.postDelayed(installTask,2000);  
385 -// installApk(apkFile);  
386 - } else {  
387 - LogUtil.i(TAG, "handleMessage: stop download and getBaseStatus");  
388 - presenter.getBaseStatus();  
389 - }  
390 - // dbm.closeDB();  
391 - // if (meetingInfo != null) {  
392 - // setWelcomeFragment();  
393 - // } else {  
394 - // setOnlineFragment();  
395 - // }  
396 - break;  
397 - case Msg_Welcome:  
398 - setWelcomeFragment();  
399 - break;  
400 - case Msg_ShowBill:  
401 - BaseInfo baseInfo = (BaseInfo) msg.obj;  
402 - if (baseInfo.pageNo > 0) {  
403 - setPDFContextShowFragment(baseInfo);  
404 - } else {  
405 - showBill(null, baseInfo.pageNo);  
406 - }  
407 - break;  
408 - case Msg_DocumentBroswer:  
409 - setDocumentBrowserFragment();  
410 - break; 42 + public void onBaseVoteInfoListener(BaseVoteInfo newBaseVoteInfo) {
411 43
412 - case MSG_DELAY_TO_VIEW:  
413 - if (mBaseInfo != null && mBaseInfo.billId == 255 &&(mVoteInfo.mode == 0 || mVoteInfo.mode == 1)) { // 自由浏览  
414 - freeBrowsing();  
415 - }  
416 - break;  
417 - case Msg_onVoteEvent:  
418 - VoteInfo vote = (VoteInfo) msg.obj;  
419 - doVote(vote);  
420 - break;  
421 - case Msg_onCommitSuccessEvent:  
422 - if (multiContentFragment != null) {  
423 - multiContentFragment.onVoteSubmitSuccess();  
424 - }  
425 - if (currFragment != null) {  
426 - XPadApi.VoteResultItem item = (XPadApi.VoteResultItem) msg.obj;  
427 - currFragment.onVoteSubmitSuccess(item);  
428 - }  
429 - break;  
430 - case Msg_onCommitErrorEvent:  
431 - if (multiContentFragment != null) {  
432 - multiContentFragment.onVoteSubmitError();  
433 - } else {  
434 - XPadApi.VoteResultItem item = (XPadApi.VoteResultItem) msg.obj;  
435 - if (currFragment != null) {  
436 - currFragment.onVoteSubmitError(item);  
437 - }  
438 - }  
439 - break;  
440 - case Msg_onCommitAllOkSuccessEvent:  
441 - if (multiContentFragment != null) {  
442 - multiContentFragment.onVoteSubmitAllOkSuccess();  
443 - }  
444 - if (currFragment != null) {  
445 - currFragment.onVoteSubmitAllOkSuccess();  
446 - }  
447 - break;  
448 - case Msg_onMultiPackageData:// 显示结果  
449 -  
450 - break;  
451 - case Msg_ShowMultiVoteResult:  
452 -  
453 - showMultiVoteResultFragment((byte[]) msg.obj);  
454 - break;  
455 - case Msg_ShowElectionVoteResult:  
456 - showResultElectionFragment((byte[]) msg.obj);  
457 - break;  
458 - case Msg_ShowCustomTitleResult:  
459 - showVoteResultFragment((byte[]) msg.obj);  
460 - break;  
461 - case Msg_HideVoteResult:// 隐藏结果  
462 - hideResultFragment();  
463 - break;  
464 - case Msg_DBfileNotExist:  
465 - setNoFileFragment();  
466 - break;  
467 -  
468 - case Msg_CommunicationTest:  
469 - showCommucationFragment((byte[]) msg.obj);  
470 - break;  
471 - case Msg_ShowID:  
472 - setShowIdFragment();  
473 - break;  
474 - case Msg_HideShowID:  
475 - hideShowIdFragment();  
476 - break;  
477 - case Msg_MatchInfo:  
478 - KeypadInfo info = (KeypadInfo) msg.obj;  
479 - mKeypadInfo = info;  
480 - ShowMatchInfo(info);  
481 - break;  
482 - case Msg_CommunicationTestHideResult:  
483 - dlg.dismiss();  
484 - break;  
485 - case Msg_ScreenDark:  
486 - if (!App.isBackground(MainActivity.this)) {  
487 - ScreenUtil.setDarkMode(MainActivity.this);  
488 - }  
489 - break;  
490 - case Msg_ChangeBright:  
491 - brigntLevel = msg.arg1;  
492 - LogUtil.d(TAG, "-----change bright percent :" + brigntLevel);  
493 - ScreenUtil.setNormalMode(MainActivity.this, brigntLevel);  
494 - break;  
495 - case Msg_FirmUpdate:  
496 - setFirmUpdateFragment();  
497 - break;  
498 - case Msg_HideFirmUpdate:  
499 - hideFirmUpdateFragment();  
500 - break;  
501 - case MSG_SHOW_ADMIN:  
502 - showAdmin();  
503 - break;  
504 - case MSG_CLEAN_FILE:  
505 - Toast.makeText(MainActivity.this, "文件清除完成!", Toast.LENGTH_SHORT).show();  
506 - break;  
507 - default:  
508 -  
509 - }  
510 -  
511 - super.handleMessage(msg);  
512 } 44 }
513 }; 45 };
514 46
515 - public void showAdmin() {  
516 - FragmentManager fm = getFragmentManager();  
517 - FragmentTransaction tx = fm.beginTransaction();  
518 - if (adminFragment == null) {  
519 - adminFragment = new AdminFragment();  
520 - tx.add(R.id.frame_content, adminFragment, "admin");  
521 - tx.addToBackStack("admin");  
522 - tx.commitAllowingStateLoss();  
523 - LogUtil.i(TAG, "showAdmin");  
524 - }  
525 - }  
526 -  
527 -  
528 - private void ShowMatchInfo(KeypadInfo info) {  
529 - if (info.cmd1 == 8) { // 配对  
530 - String strMsg = null;  
531 - if (info.ok == 1) {  
532 - strMsg = "键盘编号:" + info.keyId;  
533 - } else {  
534 - strMsg = "配对失败";  
535 - }  
536 - Toast.makeText(this, strMsg, Toast.LENGTH_SHORT).show();  
537 - } else if (info.cmd1 == 9) {  
538 - String strMsg = null;  
539 - if (info.ok == 1) {  
540 - strMsg = "键盘编号:" + info.keyId;  
541 - } else {  
542 - strMsg = "配置失败";  
543 - }  
544 - Toast.makeText(this, strMsg, Toast.LENGTH_SHORT).show();  
545 - }  
546 - setTerminalId(info.keyId);  
547 - }  
548 -  
549 - private void hideResultFragment() {  
550 - setBackgroundColor(Color.parseColor("#720600"));  
551 - if (resultFragment == null) {  
552 - return;  
553 - }  
554 - FragmentManager fm = getFragmentManager();  
555 - FragmentTransaction tx = fm.beginTransaction();  
556 - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
557 - fm.popBackStack();  
558 - tx.remove(resultFragment);  
559 - tx.commitAllowingStateLoss();  
560 - resultFragment = null;  
561 - } 47 + private BaseInfoChanageListener onBaseInfoListener = new BaseInfoChanageListener() {
562 48
563 - private ProgressDialog dlg = null;  
564 - private CommunicationTestFragment commFragment;  
565 -  
566 - private void showCommucationFragment(byte[] info) {  
567 - if (dlg == null) {  
568 - dlg = new ProgressDialog(MainActivity.this);  
569 - dlg.setCancelable(true);// 设置是否可以通过点击Back键取消  
570 - dlg.setCanceledOnTouchOutside(true);// 设置在点击Dialog外是否取消Dialog进度条  
571 - }  
572 - if (!dlg.isShowing()) {  
573 - dlg.show();  
574 - }  
575 - dlg.setTitle("通讯测试");  
576 - dlg.setMessage("通讯测试 次数:" + info[0] + " 成功次数:" + info[1] + " 基站信号:" + info[2] + " 键盘信号:" + info[3]);  
577 - myHandler.removeCallbacks(closeDlg);  
578 - myHandler.postDelayed(closeDlg, 20 * 1000);  
579 -  
580 - }  
581 -  
582 - private Runnable closeDlg = new Runnable() {  
583 @Override 49 @Override
584 - public void run() {  
585 - Message message = new Message();  
586 - message.what = Msg_CommunicationTestHideResult;  
587 - myHandler.sendMessage(message);  
588 - }  
589 - };  
590 -  
591 - public void removePDFContextShowFragment() {  
592 - if (pdfFragment != null) {  
593 - PDFContextShowFragment fr = (PDFContextShowFragment) pdfFragment;  
594 - fr.setCloseFile();  
595 - pdfFragment = null;  
596 - }  
597 - }  
598 -  
599 - private void setPDFContextShowFragment(BaseInfo baseInfo) {  
600 - if (currBillInfo == null) {  
601 - Toast.makeText(this, "没找到议案信息", Toast.LENGTH_LONG).show();  
602 - return;  
603 - }  
604 - String dataPath = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();  
605 - String filePath = dataPath + "/sunvote/" + meetingId + "/" + currBillInfo.billFile;  
606 - File file = new File(filePath);  
607 - if (!file.exists()) {  
608 - Toast.makeText(this, "议案文件未找到", Toast.LENGTH_LONG).show();  
609 - return;  
610 - }  
611 - FragmentManager fm = getFragmentManager();  
612 - FragmentTransaction tx = fm.beginTransaction();  
613 - PDFContextShowFragment fr = new PDFContextShowFragment();  
614 - fr.setInfo(filePath, currBillInfo.billFile, baseInfo.pageNo + "", "1", true);  
615 - if (isLoadPDF) {  
616 - if (!fr.PDFLastOpenFilename.equals(currBillInfo.billFile)) {  
617 - removePDFContextShowFragment();  
618 - isLoadPDF = false;  
619 - } else {  
620 - fr.setTopBarstate();  
621 - fr.setPageIndex(baseInfo.pageNo);  
622 - fr.lockPageState(1);  
623 - }  
624 - }  
625 - pdfFragment = fr;  
626 - tx.add(R.id.frame_content, fr, "PDF");  
627 - tx.addToBackStack("PDF");  
628 - tx.commitAllowingStateLoss();  
629 - }  
630 -  
631 - private void showVoteResultFragment(VoteInfo vote) {  
632 - hideResultFragment();  
633 - FragmentManager fm = getFragmentManager();  
634 - FragmentTransaction transaction = fm.beginTransaction();  
635 - ResultVoteFragment fr = new ResultVoteFragment();  
636 -// fr.voteInfo = vote;  
637 -// fr.bill = currBillInfo;  
638 - fr.setVoteInfo(vote);  
639 - resultFragment = fr;  
640 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
641 - transaction.add(R.id.frame_content, fr);  
642 - transaction.addToBackStack("voteresult");  
643 - transaction.commitAllowingStateLoss();  
644 - LogUtil.i(TAG, "showVoteResultFragment 信标");  
645 - }  
646 -  
647 - private void showSigninResultFragment(VoteInfo vote) {  
648 - hideResultFragment();  
649 - FragmentManager fm = getFragmentManager();  
650 - FragmentTransaction transaction = fm.beginTransaction();  
651 - SinginResultFragment fr = new SinginResultFragment();  
652 - fr.setResultInfo(vote.resultInfo);  
653 - resultFragment = fr;  
654 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
655 - transaction.add(R.id.frame_content, fr);  
656 - transaction.addToBackStack("signinresult");  
657 - transaction.commitAllowingStateLoss();  
658 - LogUtil.i(TAG, "showSigninResultFragment 信标");  
659 - }  
660 -  
661 - private void showResultElectionFragment(byte[] buffer) {  
662 -  
663 - int voteId = buffer[3] & 0xff;  
664 - if (dbm == null) {  
665 - Toast.makeText(this, "请先开始会议", Toast.LENGTH_LONG).show();  
666 - return;  
667 - } 50 + public void onBaseInfoChange(BaseInfo newBaseInfo) {
668 51
669 - currBillInfo = dbm.getBillInfo(meetingId, voteId);  
670 - if (currBillInfo == null) {  
671 - Toast.makeText(this, "显示选举结果失败,没有找到会议资料", Toast.LENGTH_LONG).show();  
672 - return;  
673 - }  
674 -  
675 - if (currBillInfo.billNo == 0 && currBillInfo.billId == 0) {  
676 - Toast.makeText(this, "没找到议案信息", Toast.LENGTH_LONG).show();  
677 - return;  
678 - }  
679 - hideCurrFragment();  
680 - hideResultFragment();  
681 -  
682 - FragmentTransaction transaction = fm.beginTransaction();  
683 - ResultElectionFragment fr = new ResultElectionFragment();  
684 - fr.data = buffer;  
685 - fr.bill = currBillInfo;  
686 - resultFragment = fr;  
687 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
688 - transaction.add(R.id.frame_content, fr);  
689 - transaction.addToBackStack("PDF");  
690 - transaction.commitAllowingStateLoss();  
691 - LogUtil.i(TAG, "showResultElectionFragment buffer");  
692 - }  
693 -  
694 - private void showVoteResultFragment(byte[] buffer) {  
695 - int voteId = buffer[3] & 0xff;  
696 - if (dbm == null) {  
697 - Toast.makeText(this, "请先开始会议", Toast.LENGTH_LONG).show();  
698 - return;  
699 - }  
700 - currBillInfo = dbm.getBillInfo(meetingId, voteId);  
701 - roleType = dbm.getKeypadRole(XPadApi.getInstance().getClient().getUdpModuleNO());  
702 - if (currBillInfo == null) {  
703 - Toast.makeText(this, "显示批次结果失败,没有找到会议资料", Toast.LENGTH_LONG).show();  
704 - return;  
705 - }  
706 - if (currBillInfo.billOptions == null) {  
707 - Toast.makeText(this, "显示结果失败,选项为空", Toast.LENGTH_LONG).show();  
708 - return;  
709 - }  
710 -  
711 - hideCurrFragment();  
712 - hideResultFragment();  
713 -  
714 - FragmentTransaction transaction = fm.beginTransaction();  
715 - UserResultVoteFragment fr = new UserResultVoteFragment();  
716 - fr.setData(buffer);  
717 - fr.setOptions(currBillInfo.billOptions.split("/"));  
718 - resultFragment = fr;  
719 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
720 - transaction.add(R.id.frame_content, fr);  
721 - transaction.addToBackStack("voteresult");  
722 - transaction.commitAllowingStateLoss();  
723 - LogUtil.i(TAG, "showVoteResultFragment buffer");  
724 - }  
725 -  
726 -  
727 - private void showMultiVoteResultFragment(byte[] buffer) {  
728 - int voteId = buffer[3] & 0xff;  
729 - if (dbm == null) {  
730 - Toast.makeText(this, "请先开始会议", Toast.LENGTH_SHORT).show();  
731 - return;  
732 - }  
733 -  
734 - currBillInfo = dbm.getBillInfo(meetingId, voteId);  
735 - if (currBillInfo == null) {  
736 - Toast.makeText(this, "显示批次结果失败,没有找到会议资料", Toast.LENGTH_SHORT).show();  
737 - return;  
738 - }  
739 - if (currBillInfo.billOptions == null) {  
740 - Toast.makeText(this, "显示批次结果失败,选项为空", Toast.LENGTH_SHORT).show();  
741 - return;  
742 - }  
743 -  
744 - hideCurrFragment();  
745 - hideResultFragment();  
746 - FragmentManager fm = getFragmentManager();  
747 - FragmentTransaction transaction = fm.beginTransaction();  
748 - ResultMultiVoteFragment fr = new ResultMultiVoteFragment();  
749 - fr.bill = currBillInfo;  
750 - fr.data = buffer;  
751 - resultFragment = fr;  
752 - // transaction.setCustomAnimations(android.R.animator.fade_in,android.R.animator.fade_out);  
753 - transaction.add(R.id.frame_content, fr);  
754 - transaction.addToBackStack("multivote");  
755 - transaction.commitAllowingStateLoss();  
756 - LogUtil.i(TAG, "showMultiVoteResultFragment buffer");  
757 - }  
758 -  
759 - private void setFirmUpdateFragment() {  
760 - LogUtil.i(TAG, "setFirmUpdateFragment: ");  
761 - FragmentManager fm = getFragmentManager();  
762 - FragmentTransaction transaction = fm.beginTransaction();  
763 - if (firmFragment == null) {  
764 - firmFragment = new FirmUpdateFragment();  
765 - }  
766 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
767 - transaction.replace(R.id.frame_content, firmFragment);  
768 - // transaction.addToBackStack(null);  
769 - transaction.commitAllowingStateLoss();  
770 - }  
771 -  
772 - private void hideFirmUpdateFragment() {  
773 - if (firmFragment != null) {  
774 - FragmentManager fm = getFragmentManager();  
775 - FragmentTransaction tx = fm.beginTransaction();  
776 - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
777 - tx.remove(firmFragment);  
778 - tx.commitAllowingStateLoss();  
779 - firmFragment = null;  
780 - }  
781 - }  
782 -  
783 - private OfflineFragment offlineFragment;  
784 -  
785 - private void setOfflineFragment() {  
786 - service.setImageResource(R.drawable.scan_qrcode);  
787 - FragmentManager fm = getFragmentManager();  
788 - FragmentTransaction transaction = fm.beginTransaction();  
789 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
790 - if (offlineFragment == null) {  
791 - offlineFragment = new OfflineFragment();  
792 - transaction.add(R.id.frame_content, offlineFragment);  
793 - transaction.addToBackStack("offlineFragment");  
794 - LogUtil.i(TAG, "setOfflineFragment");  
795 - } else {  
796 - transaction.replace(R.id.frame_content, offlineFragment);  
797 - }  
798 - transaction.commitAllowingStateLoss();  
799 - Intent intent = new Intent(this,MoniService.class);  
800 - stopService(intent);  
801 - }  
802 -  
803 - private ComErrorFragment comErrorFragment;  
804 -  
805 - private void setComErrorFragment() {  
806 - FragmentManager fm = getFragmentManager();  
807 - FragmentTransaction transaction = fm.beginTransaction();  
808 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
809 - if (comErrorFragment == null) {  
810 - comErrorFragment = new ComErrorFragment();  
811 - transaction.add(R.id.frame_content, comErrorFragment);  
812 - transaction.addToBackStack("comErrorFragment");  
813 - } else {  
814 - transaction.replace(R.id.frame_content, comErrorFragment);  
815 - }  
816 - transaction.commitAllowingStateLoss();  
817 - LogUtil.i(TAG, "setComErrorFragment");  
818 - }  
819 -  
820 - private OnLineFragment onLineFragment;  
821 -  
822 - private void setOnlineFragment() {  
823 - FragmentManager fm = getFragmentManager();  
824 - FragmentTransaction transaction = fm.beginTransaction();  
825 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
826 - if (onLineFragment == null) {  
827 - onLineFragment = new OnLineFragment();  
828 - transaction.add(R.id.frame_content, onLineFragment);  
829 - transaction.addToBackStack("onLineFragment");  
830 - } else {  
831 - transaction.replace(R.id.frame_content, onLineFragment);  
832 - }  
833 - transaction.commitAllowingStateLoss();  
834 - LogUtil.i(TAG, "setOnlineFragment");  
835 - presenter.getBaseStatus();  
836 - service.setImageResource(R.drawable.service_server);  
837 - Intent intent = new Intent(this,MoniService.class);  
838 - startService(intent);  
839 - }  
840 -  
841 - private void setShowIdFragment() {  
842 - FragmentManager fm = getFragmentManager();  
843 - FragmentTransaction transaction = fm.beginTransaction();  
844 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
845 - if (showIdFragment == null) {  
846 - showIdFragment = new ShowIdFragment();  
847 - transaction.add(R.id.frame_content, showIdFragment);  
848 - transaction.addToBackStack("showIdFragment");  
849 - transaction.commitAllowingStateLoss();  
850 - LogUtil.i(TAG, "showIdFragment");  
851 - }  
852 - }  
853 -  
854 - private void hideShowIdFragment() {  
855 - if (showIdFragment != null) {  
856 - FragmentManager fm = getFragmentManager();  
857 - FragmentTransaction tx = fm.beginTransaction();  
858 - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
859 - tx.remove(showIdFragment);  
860 - tx.commitAllowingStateLoss();  
861 - showIdFragment = null;  
862 - }  
863 - }  
864 -  
865 - private KeypadTestFragment keypadTestFragment;  
866 -  
867 - private void setKeypadTestFragment() {  
868 - if (keypadTestFragment == null) {  
869 - inKeyTesting = true;  
870 - FragmentManager fm = getFragmentManager();  
871 - FragmentTransaction tx = fm.beginTransaction();  
872 - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
873 - keypadTestFragment = new KeypadTestFragment();  
874 - tx.add(R.id.frame_content, keypadTestFragment);  
875 - tx.addToBackStack("keypadTestFragment");  
876 - tx.commitAllowingStateLoss();  
877 - LogUtil.i(TAG, "keypadTestFragment");  
878 - }  
879 - }  
880 -  
881 - private KeypadTestChoice10Fragment keypadTestChoice10Fragment;  
882 -  
883 - private void setChoice10Fragment() {  
884 - inKeyTesting = true;  
885 - FragmentManager fm = getFragmentManager();  
886 - FragmentTransaction tx = fm.beginTransaction();  
887 - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
888 - if (keypadTestChoice10Fragment == null) {  
889 - keypadTestChoice10Fragment = new KeypadTestChoice10Fragment();  
890 - tx.add(R.id.frame_content, keypadTestChoice10Fragment);  
891 - tx.addToBackStack("setChoice10Fragment");  
892 - } else {  
893 - tx.replace(R.id.frame_content, keypadTestChoice10Fragment);  
894 - }  
895 - tx.commitAllowingStateLoss();  
896 - LogUtil.i(TAG, "setChoice10Fragment");  
897 - }  
898 -  
899 - private void hideKeypadTestFragment() {  
900 - inKeyTesting = false;  
901 - if (keypadTestFragment != null) {  
902 - FragmentManager fm = getFragmentManager();  
903 - FragmentTransaction tx = fm.beginTransaction();  
904 - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
905 - tx.remove(keypadTestFragment);  
906 - tx.commitAllowingStateLoss();  
907 - keypadTestFragment = null;  
908 - }  
909 - LogUtil.i(TAG, "hideKeypadTestFragment");  
910 - }  
911 -  
912 - private long lastSetDownloadTime = 0;  
913 -  
914 - private void setDownloadFragment() {  
915 - if (System.currentTimeMillis() - lastSetDownloadTime < 5000) {  
916 - LogUtil.i(TAG, "ignore redownload");  
917 - return;  
918 - }  
919 - if (mKeypadInfo == null) {  
920 - presenter.getKeypadParam();  
921 - }  
922 - if (wifiSsid == null || wifiSsid.length() == 0) {  
923 -// Toast.makeText(this, "wifiSsid is null ", Toast.LENGTH_SHORT).show();  
924 -// return;  
925 - }  
926 - if (wifiPwd == null || wifiPwd.length() == 0) {  
927 -// Toast.makeText(this, "wifiPwd is null ", Toast.LENGTH_SHORT).show();  
928 -// return;  
929 - }  
930 - if (serverIp == null || serverIp.length() == 0) {  
931 -// Toast.makeText(this, "serverIp is null ", Toast.LENGTH_SHORT).show();  
932 -// return;  
933 - serverIp = Config.getInstance().serverIP;  
934 - }  
935 - // if(serverPort == 0){  
936 - // Toast.makeText(this, "serverPort is 0 ", Toast.LENGTH_SHORT);  
937 - // return;  
938 - // }  
939 - lastSetDownloadTime = System.currentTimeMillis();  
940 - FragmentTransaction transaction = fm.beginTransaction();  
941 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
942 - if (downloadFragment == null) {  
943 - downloadFragment = new DownloadFragment();  
944 - serverPort = 4002;  
945 - downloadFragment.setInfo(wifiSsid, wifiPwd, serverIp, serverPort, XPadApi.getInstance().getClient().getUdpModuleNO());  
946 - transaction.add(R.id.frame_content, downloadFragment);  
947 - transaction.addToBackStack("downloadFragment");  
948 - } else {  
949 - serverPort = 4002;  
950 - downloadFragment.setInfo(wifiSsid, wifiPwd, serverIp, serverPort, XPadApi.getInstance().getClient().getUdpModuleNO());  
951 - transaction.replace(R.id.frame_content, downloadFragment);  
952 - }  
953 - transaction.commitAllowingStateLoss();  
954 - LogUtil.i(TAG, "downloadFragment");  
955 - }  
956 -  
957 - private void hideDownloadFragment() {  
958 - if (downloadFragment != null) {  
959 - FragmentTransaction tx = fm.beginTransaction();  
960 - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
961 - tx.remove(downloadFragment);  
962 - tx.commitAllowingStateLoss();  
963 - downloadFragment = null;  
964 - LogUtil.i(TAG, "hideDownloadFragment");  
965 - }  
966 - }  
967 -  
968 - private MeetingWelcomeFragment meetingWelcomeFragment;  
969 -  
970 - private void setWelcomeFragment() {  
971 - // if (mBaseInfo == null) {  
972 - // mBaseInfo = new BaseInfo();  
973 - // mBaseInfo.confId = 1;  
974 - // }  
975 - FragmentTransaction transaction = fm.beginTransaction();  
976 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
977 - if (meetingWelcomeFragment == null) {  
978 - meetingWelcomeFragment = new MeetingWelcomeFragment();  
979 - }  
980 - meetingWelcomeFragment.setMeeting();  
981 - transaction.replace(R.id.frame_content, meetingWelcomeFragment);  
982 - transaction.commitAllowingStateLoss();  
983 - LogUtil.i(TAG, "setWelcomeFragment");  
984 - }  
985 -  
986 - private NoFileFragment noFileFragment;  
987 -  
988 - private void setNoFileFragment() {  
989 - FragmentTransaction transaction = fm.beginTransaction();  
990 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
991 - if (noFileFragment == null) {  
992 - noFileFragment = new NoFileFragment();  
993 - noFileFragment.setMeetingId(meetingId);  
994 - transaction.add(R.id.frame_content, noFileFragment);  
995 - transaction.addToBackStack("setNoFileFragment");  
996 - } else {  
997 - transaction.replace(R.id.frame_content, noFileFragment);  
998 - }  
999 - transaction.commitAllowingStateLoss();  
1000 - LogUtil.i(TAG,"setNoFileFragment");  
1001 - }  
1002 -  
1003 - private SigninFragment signinFragment;  
1004 -  
1005 - private void setSigninFragment(VoteInfo info) {  
1006 - hideDownloadFragment();  
1007 - FragmentTransaction transaction = fm.beginTransaction();  
1008 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
1009 - signinFragment = new SigninFragment();  
1010 - signinFragment.setInfo(info);  
1011 - currFragment = signinFragment;  
1012 - transaction.add(R.id.frame_content, currFragment);  
1013 - transaction.commitAllowingStateLoss();  
1014 - LogUtil.i(TAG,"setSigninFragment");  
1015 - }  
1016 -  
1017 - private void setQuickVoteFragment() {  
1018 - FragmentTransaction transaction = fm.beginTransaction();  
1019 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
1020 - SingleTitleFragment fr = new SingleTitleFragment();  
1021 - fr.setInfo(currBillInfo);  
1022 - currFragment = fr;  
1023 - transaction.add(R.id.frame_content, currFragment);  
1024 - transaction.addToBackStack("setQuickVoteFragment");  
1025 - transaction.commitAllowingStateLoss();  
1026 - LogUtil.i(TAG,"setQuickVoteFragment");  
1027 - }  
1028 -  
1029 - private void setTitleVoteFragment(VoteInfo vote) {  
1030 - hideDownloadFragment();  
1031 - FragmentTransaction transaction = fm.beginTransaction();  
1032 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
1033 - SingleTitleFragment fr = new SingleTitleFragment();  
1034 - fr.setInfo(currBillInfo, vote);  
1035 - currFragment = fr;  
1036 - transaction.add(R.id.frame_content, currFragment);  
1037 - transaction.addToBackStack("titleVote");  
1038 - transaction.commitAllowingStateLoss();  
1039 - LogUtil.i(TAG,"setTitleVoteFragment");  
1040 - }  
1041 -  
1042 - private void setMultiTitleVoteFragment(VoteInfo vote) {  
1043 -  
1044 - if (currBillInfo == null) {  
1045 - Toast.makeText(this, "没找到议案信息", Toast.LENGTH_SHORT).show();  
1046 - return;  
1047 - }  
1048 - ArrayList<MultiTitleItem> list = dbm.getMultiTitleItems(meetingId, currBillInfo.billId);  
1049 - FragmentTransaction transaction = fm.beginTransaction();  
1050 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
1051 - MultiTitleFragment fr = new MultiTitleFragment();  
1052 - fr.setInfo(currBillInfo, vote, list);  
1053 - currFragment = fr;  
1054 - transaction.add(R.id.frame_content, currFragment);  
1055 - transaction.addToBackStack("multititleVote");  
1056 - transaction.commitAllowingStateLoss();  
1057 - LogUtil.i(TAG, "setMultiTitleVoteFragment");  
1058 - }  
1059 -  
1060 -  
1061 - private void setSingleContentVoteFragment() {  
1062 - FragmentTransaction transaction = fm.beginTransaction();  
1063 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
1064 - ContentVoteFragment fr = new ContentVoteFragment();  
1065 - fr.setInfo(currBillInfo);  
1066 - currFragment = fr;  
1067 - transaction.replace(R.id.frame_content, currFragment);  
1068 - transaction.commitAllowingStateLoss();  
1069 - LogUtil.i(TAG, "setSingleContentVoteFragment");  
1070 - }  
1071 -  
1072 - private void setMultiContentVoteFragment() {  
1073 - ArrayList<MultiTitleItem> list = dbm.getMultiTitleItems(meetingId, currBillInfo.billId);  
1074 - FragmentTransaction transaction = fm.beginTransaction();  
1075 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
1076 - MultiContentFragment fr = new MultiContentFragment();  
1077 - fr.setInfo(currBillInfo, list);  
1078 - currFragment = fr;  
1079 - transaction.replace(R.id.frame_content, currFragment);  
1080 - transaction.commitAllowingStateLoss();  
1081 - LogUtil.i(TAG, "setMultiContentVoteFragment");  
1082 - }  
1083 -  
1084 -  
1085 - private void setDocumentBrowserFragment() {  
1086 - ArrayList<BillInfo> list = dbm.getBillItemsMain(meetingId);  
1087 - FragmentTransaction transaction = fm.beginTransaction();  
1088 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
1089 - if (docFragment == null) {  
1090 - docFragment = new DocumentBrowserFragment();  
1091 - docFragment.setInfo(list, false);  
1092 - }  
1093 - transaction.replace(R.id.frame_content, docFragment);  
1094 - transaction.commitAllowingStateLoss();  
1095 - LogUtil.i(TAG, "setDocumentBrowserFragment");  
1096 - }  
1097 -  
1098 - private void showBill(VoteInfo vInfo, final int pageNo) {  
1099 -  
1100 - if (currBillInfo.billFile == null) {  
1101 - return;  
1102 - }  
1103 - hideDownloadFragment();  
1104 - FragmentManager fm = getFragmentManager();  
1105 - FragmentTransaction tx = fm.beginTransaction();  
1106 - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
1107 - if (vInfo != null) {  
1108 - MultiContentDetailFragment fr = new MultiContentDetailFragment();  
1109 - fr.setInfo(currBillInfo, vInfo, false, pageNo, 1);  
1110 - currFragment = fr;  
1111 - tx.add(R.id.frame_content, currFragment, "fDetail");  
1112 - tx.addToBackStack("fDetail");  
1113 - tx.commitAllowingStateLoss();  
1114 - LogUtil.i(TAG, "fDetail");  
1115 - } else {  
1116 - if (currFragment instanceof MultiContentDetailFragment) {  
1117 - ((MultiContentDetailFragment) currFragment).setPdfPage(pageNo);  
1118 - LogUtil.i(TAG, "fDetail setPdfPage");  
1119 - } else {  
1120 - MultiContentDetailFragment fDetail = new MultiContentDetailFragment();  
1121 - fDetail.setInfo(currBillInfo, vInfo, false, pageNo, 1);  
1122 - currFragment = fDetail;  
1123 - tx.add(R.id.frame_content, fDetail, "fDetail");  
1124 - tx.addToBackStack("fDetail");  
1125 - tx.commitAllowingStateLoss();  
1126 - LogUtil.i(TAG, "MultiContentDetailFragment setPdfPage");  
1127 - }  
1128 - }  
1129 -  
1130 - }  
1131 -  
1132 - private void setMultiPinsShengFragment() {  
1133 - ArrayList<MultiTitleItem> list = dbm.getMultiTitleItems(meetingId, currBillInfo.billId);  
1134 - FragmentTransaction transaction = fm.beginTransaction();  
1135 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
1136 - MultiPingshengFragment fr = new MultiPingshengFragment();  
1137 - fr.setInfo(currBillInfo, list);  
1138 - currFragment = fr;  
1139 - transaction.replace(R.id.frame_content, currFragment);  
1140 - transaction.commitAllowingStateLoss();  
1141 - LogUtil.i(TAG, "setMultiPinsShengFragment");  
1142 - }  
1143 -  
1144 - private void setElectionVoteFragment(VoteInfo vote) {  
1145 - if (dbm == null) {  
1146 - Toast.makeText(this, "请先开始会议", Toast.LENGTH_LONG).show();  
1147 - return;  
1148 - }  
1149 - currBillInfo = dbm.getBillInfo(meetingId, vote.electInfo.voteid);  
1150 - roleType = dbm.getKeypadRole(XPadApi.getInstance().getClient().getUdpModuleNO());  
1151 - if (currBillInfo == null) {  
1152 - Toast.makeText(this, "没找到议案信息", Toast.LENGTH_LONG).show();  
1153 - return;  
1154 - }  
1155 -  
1156 - if (currBillInfo.billNo == 0 && currBillInfo.billId == 0) {  
1157 - Toast.makeText(this, "没找到议案信息", Toast.LENGTH_LONG).show();  
1158 - return;  
1159 - }  
1160 -  
1161 - ArrayList<MultiTitleItem> list = dbm.getCandidateList(meetingId, currBillInfo.billId);  
1162 - FragmentTransaction transaction = fm.beginTransaction();  
1163 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
1164 - ElectionFragment fr = new ElectionFragment();  
1165 - fr.setInfo(currBillInfo, list, vote);  
1166 - currFragment = fr;  
1167 - transaction.add(R.id.frame_content, currFragment);  
1168 - transaction.addToBackStack("electionvote");  
1169 - transaction.commitAllowingStateLoss();  
1170 - LogUtil.i(TAG, "setElectionVoteFragment");  
1171 - }  
1172 -  
1173 - private void setCustomElectionVoteFragment(VoteInfo vote) {  
1174 - if (currBillInfo == null) {  
1175 - Toast.makeText(this, "没找到议案信息", Toast.LENGTH_LONG).show();  
1176 - return;  
1177 - }  
1178 -  
1179 - if(currBillInfo.billNo==0 && currBillInfo.billId==0){  
1180 - Toast.makeText(this, "没找到议案信息", Toast.LENGTH_LONG).show();  
1181 - return;  
1182 - }  
1183 -  
1184 - if(currBillInfo.billOptions.split("/") == null){  
1185 - Toast.makeText(this, "显示批次结果失败,选项为空", Toast.LENGTH_LONG).show();  
1186 - return;  
1187 - }  
1188 - LogUtil.i(TAG,"setMultiTitleVoteFragment");  
1189 - ArrayList<MultiTitleItem> list = dbm.getMultiTitleItems(meetingId, currBillInfo.billId);  
1190 - FragmentTransaction transaction = fm.beginTransaction();  
1191 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
1192 - ElectionCustomFragment fr = new ElectionCustomFragment();  
1193 - fr.setInfo(currBillInfo,list,vote);  
1194 - currFragment = fr;  
1195 - transaction.add(R.id.frame_content, currFragment);  
1196 - transaction.addToBackStack("multititleVote");  
1197 - transaction.commitAllowingStateLoss();  
1198 - LogUtil.i(TAG, "setCustomElectionVoteFragment");  
1199 - }  
1200 -  
1201 - public void getBillInfo(int billId) {  
1202 - currBillInfo = dbm.getBillInfo(meetingId, billId);  
1203 - }  
1204 -  
1205 - @Override  
1206 - public void onComData(byte[] data, int len) {  
1207 - // TODO Auto-generated method stub  
1208 -  
1209 - }  
1210 -  
1211 - @Override  
1212 - public void onSendData(byte[] data, int len) {  
1213 - // TODO Auto-generated method stub  
1214 -  
1215 - }  
1216 -  
1217 - @Override  
1218 - public void onModelEvent(ModelInfo info) {  
1219 - LogUtil.i(TAG, "onModelEvent");  
1220 - mModelInfo = info;  
1221 - if (firmFragment != null) {  
1222 - Intent intent = new Intent();  
1223 - intent.setAction("com.xpad.firm");  
1224 - intent.putExtra("ver", info.sVer);  
1225 - MainActivity.this.sendBroadcast(intent);  
1226 - LogUtil.i(TAG, "send broadcast");  
1227 - // firmFragment.setFirmVer(mModelInfo.sVer);  
1228 - }  
1229 -  
1230 - }  
1231 -  
1232 -  
1233 -  
1234 - @Override  
1235 - public void onBaseEvent(BaseInfo info) {  
1236 - mBaseInfo = info;  
1237 - LogUtil.i(TAG, "baseEvent:" + info);  
1238 - meetingId = info.confId;  
1239 - if (info.confId != 0) {  
1240 - if (dbm != null && dbm.confId != info.confId) {  
1241 - dbm.closeDB();  
1242 - docFragment = null;  
1243 - }  
1244 - if (dbm == null || !dbm.checkDB() || dbm.confId != info.confId) {  
1245 - dbm = new DBManager(this, info.confId);// 如果没打开,则打开数据库  
1246 - roleType = dbm.getKeypadRole(XPadApi.getInstance().getClient().getUdpModuleNO());  
1247 - }  
1248 - if (!dbm.checkDB()) {  
1249 - Message message = new Message();  
1250 - message.what = Msg_DBfileNotExist;  
1251 - myHandler.sendMessage(message);  
1252 - presenter.getVoteStatus();  
1253 - return;  
1254 - }  
1255 - if (meetingInfo == null || info.billId <= 1) {  
1256 - meetingInfo = dbm.getMettingInfo(info.confId);  
1257 - roleType = dbm.getKeypadRole(XPadApi.getInstance().getClient().getUdpModuleNO());  
1258 - }  
1259 -  
1260 - if (info.billId == 0) { // 没有议案的情况,显示欢迎界面  
1261 - if (mOnlineInfo.onLine == 1) {  
1262 - removePDFContextShowFragment();  
1263 - Message message = new Message();  
1264 - message.what = Msg_Welcome;  
1265 - myHandler.sendMessage(message);  
1266 - }  
1267 - } else if (info.billId == 255) { // 自由浏览  
1268 - freeBrowsing();  
1269 - } else {// 进入议案  
1270 - currBillInfo = dbm.getBillInfo(info.confId, info.billId);  
1271 - Message message = new Message();  
1272 - message.what = Msg_ShowBill;  
1273 - message.obj = info;  
1274 - myHandler.sendMessage(message);  
1275 - // processBaseEvent();  
1276 - }  
1277 -  
1278 - presenter.getVoteStatus();  
1279 -  
1280 - // 显示会议标题  
1281 - } else {// confId为0 ,表示停止会议  
1282 - if (mOnlineInfo.onLine == 1) {  
1283 - Message message = new Message();  
1284 - message.what = Msg_Online;  
1285 - myHandler.sendMessage(message);  
1286 - }  
1287 - if (dbm != null) {  
1288 - dbm.closeDB();  
1289 - }  
1290 - }  
1291 -  
1292 -  
1293 - }  
1294 -  
1295 - private void freeBrowsing() {  
1296 - if (dbm != null && dbm.checkDB()) {  
1297 - removePDFContextShowFragment();  
1298 - Message message = new Message();  
1299 - message.what = Msg_DocumentBroswer;  
1300 - myHandler.sendMessage(message);  
1301 - }  
1302 - }  
1303 -  
1304 - @Override  
1305 - public void onVoteEvent(VoteInfo info) {  
1306 - startVoteTime = System.currentTimeMillis();  
1307 - LogUtil.i(TAG, "onVoteEvent " + info);  
1308 - if (downloading) {  
1309 - Message message = new Message();  
1310 - message.what = Msg_StopDownload;  
1311 - myHandler.sendMessage(message);  
1312 - }  
1313 - Message message = new Message();  
1314 - message.what = Msg_onVoteEvent;  
1315 - message.obj = info;  
1316 - myHandler.sendMessage(message);  
1317 - }  
1318 -  
1319 - private void hideCurrFragment() {  
1320 -  
1321 - if (currFragment != null) {  
1322 - LogUtil.i(TAG, "hideCurrFragment success, " + currFragment.getClass().getName());  
1323 - FragmentManager fm = getFragmentManager();  
1324 - FragmentTransaction tx = fm.beginTransaction();  
1325 - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
1326 - if(currFragment instanceof SingleTitleFragment) {  
1327 - if (multiContentFragment != null) {  
1328 - tx.remove(multiContentFragment);  
1329 - multiContentFragment = null;  
1330 - }  
1331 - }  
1332 - fm.popBackStack();  
1333 - tx.remove(currFragment);  
1334 - tx.commitAllowingStateLoss();  
1335 - currFragment = null;  
1336 - }  
1337 - }  
1338 -  
1339 - private void doVote(VoteInfo voteInfo) {  
1340 - LogUtil.i(TAG,"doVote:" + voteInfo);  
1341 - mVoteInfo=voteInfo;  
1342 - if (voteInfo.mode == XPadApi.VoteType_KeypadTest) {  
1343 - setKeypadTestFragment();  
1344 - return;  
1345 - } else if (voteInfo.mode == XPadApi.VoteType_Choice && voteInfo.mode5 == 10) {  
1346 - setChoice10Fragment();  
1347 - return;  
1348 - } else if (voteInfo.mode == XPadApi.VoteType_Stop) {  
1349 - if (inKeyTesting) {  
1350 - hideKeypadTestFragment();  
1351 - return;  
1352 - }  
1353 - }  
1354 -  
1355 - if(mBaseInfo!=null){  
1356 - if(mBaseInfo.billId==0 || mBaseInfo.billId==255){  
1357 - removePDFContextShowFragment();  
1358 - }  
1359 - }  
1360 -  
1361 - hideResultFragment();  
1362 - /*  
1363 - * 暂时去掉角色 if (mKeypadInfo != null && dbm != null) { roleType =  
1364 - * dbm.getKeypadRole(mKeypadInfo.keyId); Log.d(TAG, "roleType:" +  
1365 - * roleType); } if (roleType == 0) {// 列席代表不处理 return; }  
1366 - */  
1367 - tmpMulResultBuffer = null;  
1368 - if (!(voteInfo.mode == XPadApi.VoteType_Stop && voteInfo.mode1_msgType == 2  
1369 - && voteInfo.resultInfo.resultType == XPadApi.VoteType_BatchVote)) {  
1370 - hideCurrFragment();  
1371 - }  
1372 - if (dbm == null || !dbm.checkDB() ) {  
1373 - dbm = new DBManager(this, this.meetingId);// 如果没打开,则打开数据库  
1374 - }  
1375 - roleType = dbm.getKeypadRole(XPadApi.getInstance().getClient().getUdpModuleNO());  
1376 - // voteInfo.voteid = 1;//debug  
1377 - if (voteInfo.voteid > 0 && voteInfo.voteid < 255) {  
1378 - try {  
1379 - currBillInfo = dbm.getBillInfo(meetingId, voteInfo.voteid);  
1380 - } catch (Exception e) {  
1381 - e.printStackTrace();  
1382 - }  
1383 - if (currBillInfo == null) {  
1384 - LogUtil.i(TAG, "BillInfo not found!!!");  
1385 - }  
1386 - }  
1387 -  
1388 - if (voteInfo.mode == XPadApi.VoteType_Stop) {  
1389 - int count = fm.getBackStackEntryCount();  
1390 - LogUtil.i(TAG, "getBackStackEntryCount:" + count );  
1391 - if(count > 1){  
1392 - for(int i = 0; i < count ; i++){  
1393 - LogUtil.i(TAG, "name:" + fm.getBackStackEntryAt(i).getName());  
1394 - }  
1395 - }  
1396 - if (voteInfo.mode1_msgType == 2) { // 结果显示  
1397 - if(voteInfo.resultInfo.resultType == XPadApi.VoteType_Stop){  
1398 - showSigninResultFragment(voteInfo);  
1399 - }else if (voteInfo.resultInfo.resultType == XPadApi.VoteType_BatchVote) { // 多项  
1400 - if (currFragment != null) {  
1401 - currFragment.onVoteEvent(voteInfo);  
1402 - }  
1403 - } else if (voteInfo.resultInfo.resultType !=101 && voteInfo.resultInfo.resultType != XPadApi.VoteType_BatchElect){  
1404 - showVoteResultFragment(voteInfo);  
1405 - }  
1406 - }  
1407 - } else if (voteInfo.mode == XPadApi.VoteType_Signin) {  
1408 - if(isChair){  
1409 - return;  
1410 - }  
1411 - if(roleType != 2){  
1412 - setSigninFragment(voteInfo);  
1413 - }  
1414 - }else if (voteInfo.mode == XPadApi.VoteType_Evaluate){  
1415 -  
1416 - }else if(voteInfo.mode == XPadApi.VoteType_BatchElect){  
1417 - if(isChair){  
1418 - return;  
1419 - }  
1420 - if(roleType != 2) {  
1421 - setElectionVoteFragment(voteInfo);  
1422 - }  
1423 - }else {  
1424 - if (voteInfo.mode == XPadApi.VoteType_BatchVote) {  
1425 - /**  
1426 - * 是否带票数限定,,对批次表决、批次评议、批次自定义评议有效  
1427 - 0 不限定  
1428 - 1 带票数限定  
1429 - */  
1430 - if(voteInfo.fixballot==1){  
1431 - if (dbm != null && dbm.checkDB()) {  
1432 - if(isChair){  
1433 - return;  
1434 - }  
1435 - if(roleType != 2){  
1436 - setCustomElectionVoteFragment(voteInfo);  
1437 - }  
1438 - }else{  
1439 - if(meetingId>0) {  
1440 - Toast.makeText(this, "启动差额选举失败,会议" + meetingId + "不存在,请下载会议资料", Toast.LENGTH_LONG).show();  
1441 - }  
1442 - }  
1443 - }else {  
1444 - if (dbm != null && dbm.checkDB()) {  
1445 - if(isChair){  
1446 - return;  
1447 - }  
1448 - if(roleType != 2){  
1449 - setMultiTitleVoteFragment(voteInfo);  
1450 - }  
1451 - }else{  
1452 - LogUtil.i(TAG, "doVote: "+"启动批次表决失败,会议" + meetingId + "不存在,请下载会议资料");  
1453 - if(meetingId>0) {  
1454 - Toast.makeText(this, "启动批次表决失败,会议" + meetingId + "不存在,请下载会议资料", Toast.LENGTH_LONG).show();  
1455 - }  
1456 - }  
1457 - }  
1458 - } else {  
1459 - if (voteInfo.init == 0 || checkHasBillFile(currBillInfo) == false) {  
1460 - if(isChair){  
1461 - return;  
1462 - }  
1463 - if(roleType != 2){  
1464 - setTitleVoteFragment(voteInfo);  
1465 - }  
1466 - } else {  
1467 - if(isChair){  
1468 - return;  
1469 - }  
1470 - billFragment=null;  
1471 - if(roleType != 2) {  
1472 - showBill(voteInfo,1);  
1473 - }  
1474 - }  
1475 - }  
1476 - }  
1477 - }  
1478 -  
1479 - private boolean isInVoteState(){  
1480 - if(mVoteInfo != null){  
1481 - return mVoteInfo.mode > 0 ;  
1482 - }  
1483 - return false;  
1484 - }  
1485 -  
1486 - private boolean checkHasBillFile(BillInfo bill) {  
1487 - return (bill != null && bill.billFile != null && bill.billFile.length() > 0);  
1488 - }  
1489 -  
1490 - @Override  
1491 - public void onVoteSubmitSuccess(XPadApi.VoteResultItem item) {  
1492 - Message message = new Message();  
1493 - message.obj = item;  
1494 - message.what = Msg_onCommitSuccessEvent;  
1495 - myHandler.sendMessage(message);  
1496 -  
1497 - }  
1498 -  
1499 - @Override  
1500 - public void onVoteSubmitAllOkSuccess() {  
1501 - Message message = new Message();  
1502 - message.what = Msg_onCommitAllOkSuccessEvent;  
1503 - myHandler.sendMessage(message);  
1504 - }  
1505 -  
1506 - @Override  
1507 - public void onKeyPadEvent(KeypadInfo info) {  
1508 - LogUtil.i(TAG, "onKeyPadEvent");  
1509 - mKeypadInfo = info;  
1510 - XPadSystem.setStatusBarPadID(this, info.keyId);  
1511 - XPadSystem.setStatusBarChannel(this, info.chan);  
1512 - if (info.cmd1 == 8 || info.cmd1 == 9) {  
1513 - Message message = new Message();  
1514 - message.what = Msg_MatchInfo;  
1515 - message.obj = info;  
1516 - myHandler.sendMessage(message);  
1517 - }  
1518 -  
1519 - }  
1520 -  
1521 - @Override  
1522 - public void onOnLineEvent(OnLineInfo info) {  
1523 -  
1524 - if (info.comError == 1) {  
1525 - if (info.comError != mOnlineInfo.comError) {  
1526 - Message message = new Message();  
1527 - message.what = Msg_ComError;  
1528 - myHandler.sendMessage(message);  
1529 - }  
1530 - LogUtil.i(TAG, "onOnLineEvent: comError");  
1531 - } else {  
1532 - if (info.onLine != mOnlineInfo.onLine) {  
1533 - if (info.onLine == 1) {  
1534 - Message message = new Message();  
1535 - message.what = Msg_Online;  
1536 - myHandler.sendMessage(message);  
1537 - presenter.getBaseStatus();  
1538 - LogUtil.i(TAG, "onOnLineEvent: onLine");  
1539 -  
1540 - } else {  
1541 - Message message = new Message();  
1542 - message.what = Msg_Offline;  
1543 - myHandler.sendMessage(message);  
1544 - LogUtil.i(TAG, "onOnLineEvent: offLine");  
1545 - }  
1546 - } else if (info.onLine == 1) {  
1547 - if (offlineFragment != null && offlineFragment.isVisible) {  
1548 - Message message = new Message();  
1549 - message.what = Msg_Online;  
1550 - myHandler.sendMessage(message);  
1551 - presenter.getBaseStatus();  
1552 - LogUtil.i(TAG, "onOnLineEvent: onLine");  
1553 - }  
1554 - }  
1555 -  
1556 -  
1557 - }  
1558 -  
1559 - mOnlineInfo = info;  
1560 - XPadSystem.setStatusBarDataIcon(this, info.tx, info.rx);  
1561 - XPadSystem.setStatusBarChannel(this, info.chan);  
1562 - XPadSystem.setStatusBarBaseId(this, getString(R.string.base_id) + ":" + info.baseId);  
1563 - XPadSystem.setStatusBarSingal(this, info.rssi);  
1564 -  
1565 -  
1566 - }  
1567 -  
1568 -  
1569 - private CmdDataInfo cmdInfo;  
1570 - private long lastRecvCmdDataTime;  
1571 - private long lastCleanCmd;  
1572 - private long lastAdminCmd;  
1573 -  
1574 - @Override  
1575 - public void onCmdData(CmdDataInfo info) {  
1576 -  
1577 - if (cmdInfo != null && info.cmd == cmdInfo.cmd && Arrays.equals(info.data, cmdInfo.data)  
1578 - && (System.currentTimeMillis() - lastRecvCmdDataTime < 1000)) {  
1579 - LogUtil.i(TAG, "onCmdData,recv same data, ignore!");  
1580 - return;  
1581 - }  
1582 - lastRecvCmdDataTime = System.currentTimeMillis();  
1583 - cmdInfo = info;  
1584 - XPadApi.printDataBuf(info.data, info.data.length, "cmd:" + info.cmd + " data:");  
1585 - if (info.cmd == 7) { // 键盘测试  
1586 - Message message = new Message();  
1587 - message.what = Msg_CommunicationTest;  
1588 - message.obj = info.data;  
1589 - myHandler.sendMessage(message);  
1590 - } else if (info.cmd == 10) {// 显示编号  
1591 - if (info.data[0] == 0) {  
1592 - LogUtil.i(TAG, "Msg_HideShowID");  
1593 - Message message = new Message();  
1594 - message.what = Msg_HideShowID;  
1595 - myHandler.sendMessage(message);  
1596 - } else {  
1597 - LogUtil.i(TAG, "Msg_ShowID");  
1598 - Message message = new Message();  
1599 - message.what = Msg_ShowID;  
1600 - myHandler.sendMessage(message);  
1601 - }  
1602 - } else if (info.cmd == 5) {// 关机  
1603 - XPadSystem.powerOffXPad(this);  
1604 - finish();  
1605 - Intent intent = new Intent(this,MoniService.class);  
1606 - stopService(intent);  
1607 - } else if (info.cmd == 50) {// 主控透传  
1608 - byte cmd = info.data[0];  
1609 - LogUtil.i(TAG, "cmd:" + cmd);  
1610 - byte[] data = Arrays.copyOfRange(info.data, 1, 19);  
1611 - Message message = null;  
1612 - switch (cmd) {  
1613 - case 0x31:// wifi ssid  
1614 - wifiSsid = new String(data).trim();  
1615 - LogUtil.i(TAG, "receve 0x31 wifi ssid:" + wifiSsid);  
1616 - break;  
1617 - case 0x32:// wifi pwd  
1618 - wifiPwd = new String(data).trim();  
1619 - LogUtil.i(TAG, "receve 0x32 wifi pwd:" + wifiPwd);  
1620 - break;  
1621 - case 0x33: // ip  
1622 - serverIp = new String(data).trim();  
1623 - LogUtil.i(TAG, "receve 0x33 server ip:" + serverIp);  
1624 - break;  
1625 - case 0x34: // start download  
1626 - LogUtil.i(TAG, "receve start download");  
1627 - message = new Message();  
1628 - message.what = Msg_Download;  
1629 - myHandler.sendMessage(message);  
1630 - break;  
1631 - case 0x35: // stop download  
1632 - LogUtil.i(TAG, "receve stop download");  
1633 - message = new Message();  
1634 - message.what = Msg_StopDownload;  
1635 - myHandler.sendMessage(message);  
1636 - break;  
1637 - case 0x36: // 暂去掉角色控制  
1638 - LogUtil.i(TAG, "not support");  
1639 - break;  
1640 - case 0x37:  
1641 - XPadSystem.rebootXPad(this);  
1642 - break;  
1643 - case 0x38:  
1644 - message = new Message();  
1645 - message.what = Msg_HideVoteResult;  
1646 - myHandler.sendMessage(message);  
1647 - break;  
1648 - case 0x39:  
1649 - message = new Message();  
1650 - message.what = Msg_ChangeBright;  
1651 - message.arg1 = info.data[1];  
1652 - myHandler.sendMessage(message);  
1653 - SharedPreferencesUtil.saveData(MainActivity.this, "bright", Integer.valueOf(info.data[1]));  
1654 - break;  
1655 - case 0x40:  
1656 - if (info.data[1] == 0) {  
1657 - message = new Message();  
1658 - message.what = Msg_ScreenDark;  
1659 - myHandler.sendMessage(message);  
1660 - } else {  
1661 - message = new Message();  
1662 - message.what = Msg_ChangeBright;  
1663 - message.arg1 = brigntLevel;  
1664 - myHandler.sendMessage(message);  
1665 - }  
1666 - break;  
1667 - case 0x41:  
1668 - darkTime = Integer.valueOf(info.data[1]);  
1669 - scrTimerCnt = 0;  
1670 - LogUtil.i(TAG, "set darkTime:" + darkTime);  
1671 - SharedPreferencesUtil.saveData(MainActivity.this, "darkTime", darkTime);  
1672 - break;  
1673 -  
1674 - case 0x42:  
1675 - if (System.currentTimeMillis() - lastCleanCmd > 8000) {  
1676 - lastCleanCmd = System.currentTimeMillis();  
1677 - FileUtil.deleteFile(new File(Environment.getExternalStorageDirectory().getPath() + "/sunvote"), "sunvote.dat");  
1678 - message = new Message();  
1679 - message.what = MSG_CLEAN_FILE;  
1680 - myHandler.sendMessage(message);  
1681 - }  
1682 - break;  
1683 - case 0x43:  
1684 - if (System.currentTimeMillis() - lastAdminCmd > 8000) {  
1685 - lastAdminCmd = System.currentTimeMillis();  
1686 - message = new Message();  
1687 - message.what = MSG_SHOW_ADMIN;  
1688 - myHandler.sendMessage(message);  
1689 - }  
1690 - break;  
1691 -  
1692 - default:  
1693 - break;  
1694 - }  
1695 - } else if (info.cmd == 66) {//66.加上一键统一清除会议文件功能。  
1696 - FileUtil.deleteFile(new File(Environment.getExternalStorageDirectory().getPath() + "/sunvote"));  
1697 - } else if (info.cmd == 67) {//67.遥控统一进入管理员界面  
1698 - Message message = new Message();  
1699 - message.what = MSG_SHOW_ADMIN;  
1700 - myHandler.sendMessage(message);  
1701 - }  
1702 -  
1703 - }  
1704 -  
1705 - private byte[] tmpMulResultBuffer;  
1706 -  
1707 - @Override  
1708 - public void onMultiPackageData(byte[] data, int len) {  
1709 - LogUtil.i(TAG,"onMultiPackageData");  
1710 - XPadApi.printDataBuf(data, len, "onMultiPackageData:");  
1711 - byte[] buf = new byte[len];  
1712 - Arrays.fill(buf, (byte) 0x0);  
1713 - System.arraycopy(data, 0, buf, 0, len);  
1714 -  
1715 - if(isInVoteState()){  
1716 - return;  
1717 - }  
1718 - if ((data[0] & 0xff) == 0xF2 && data[1] == 20) {  
1719 -  
1720 - if (tmpMulResultBuffer != null && Arrays.equals(buf, tmpMulResultBuffer)) {  
1721 - Log.e(TAG, "onMultiPackageData same data,abort");  
1722 - return;  
1723 - }  
1724 - tmpMulResultBuffer = buf;  
1725 -  
1726 - Message message = new Message();  
1727 - message.what = Msg_ShowMultiVoteResult;  
1728 - message.obj = buf;  
1729 - myHandler.sendMessage(message);  
1730 - return;  
1731 - }  
1732 -  
1733 - //选举结果  
1734 - if ((data[0] & 0xff) == 0xF2 && data[1] == 22) {  
1735 - if (tmpMulResultBuffer != null && Arrays.equals(buf, tmpMulResultBuffer)) {  
1736 - Log.e(TAG, "onMultiPackageData same data,abort");  
1737 - return;  
1738 - }  
1739 - tmpMulResultBuffer = buf;  
1740 -  
1741 - Message message = new Message();  
1742 - message.what = Msg_ShowElectionVoteResult;  
1743 - message.obj = buf;  
1744 - myHandler.sendMessage(message);  
1745 - return;  
1746 - }  
1747 -  
1748 - //自定义表决结果  
1749 - if ((data[0] & 0xff) == 0xF2 && data[1] == 101) {  
1750 - if (tmpMulResultBuffer != null && Arrays.equals(buf, tmpMulResultBuffer)) {  
1751 - LogUtil.i(TAG, "onMultiPackageData same data,abort");  
1752 - return;  
1753 - }  
1754 - tmpMulResultBuffer = buf;  
1755 - Message message = new Message();  
1756 - message.what = Msg_ShowCustomTitleResult;  
1757 - message.obj = buf;  
1758 - myHandler.sendMessage(message);  
1759 - return;  
1760 - }  
1761 -  
1762 - String str;  
1763 - try {  
1764 - str = new String(buf, "GB2312").trim();  
1765 - LogUtil.i(TAG, "onMultiPackageInfo:" + str);  
1766 - Message message = new Message();  
1767 - message.what = Msg_onMultiPackageData;  
1768 - message.arg1 = len;  
1769 - message.obj = str;  
1770 - myHandler.sendMessage(message);  
1771 - } catch (UnsupportedEncodingException e) {  
1772 - LogUtil.e(TAG, e);  
1773 - }  
1774 -  
1775 - }  
1776 -  
1777 - @Override  
1778 - public void onVoteSubmitError(XPadApi.VoteResultItem item) {  
1779 - Message message = new Message();  
1780 - message.obj = item;  
1781 - message.what = Msg_onCommitErrorEvent;  
1782 - myHandler.sendMessage(message);  
1783 -  
1784 - }  
1785 -  
1786 - TimerTask screenTask = new TimerTask() {  
1787 - public void run() {  
1788 - scrTimerCnt++;  
1789 - if (scrTimerCnt == darkTime * 60) {  
1790 - scrTimerCnt = 0;  
1791 - Message message = new Message();  
1792 - message.what = Msg_ScreenDark;  
1793 - myHandler.sendMessage(message);  
1794 - }  
1795 } 52 }
1796 }; 53 };
1797 54
1798 - @Override  
1799 - public boolean dispatchTouchEvent(MotionEvent event) {  
1800 - switch (event.getAction()) {  
1801 - case MotionEvent.ACTION_DOWN:  
1802 - scrTimerCnt = 0;  
1803 - ScreenUtil.setNormalMode(MainActivity.this, brigntLevel);  
1804 - LogUtil.i("CustomBtnonTouchEvent", "MotionEvent.ACTION_DOWN");  
1805 - break;  
1806 - case MotionEvent.ACTION_MOVE:  
1807 - // LogUtil.i("CustomButton--onTouchEvent", "MotionEvent.ACTION_MOVE");  
1808 - break;  
1809 - case MotionEvent.ACTION_UP:  
1810 - // LogUtil.i("CustomButton--onTouchEvent", "MotionEvent.ACTION_UP");  
1811 - break;  
1812 -  
1813 - default:  
1814 - break;  
1815 - }  
1816 - return super.dispatchTouchEvent(event);  
1817 - } 55 + private OnlineInfoChanageListener onlineInfoChanageListener = new OnlineInfoChanageListener() {
1818 56
1819 - @Override  
1820 - public void onFirmUpdate(int percent) {  
1821 - if (firmFragment != null) {  
1822 - firmFragment.onFirmUpdate(percent);  
1823 - }  
1824 -  
1825 - }  
1826 -  
1827 - @Override  
1828 - public void onFirmUpdateResult(boolean success, String msg) {  
1829 -  
1830 - if (firmFragment != null) {  
1831 - firmFragment.onFirmUpdateResult(success, msg);  
1832 - }  
1833 - }  
1834 -  
1835 - @Override  
1836 - public void onFirmUpdateInfo(String info) {  
1837 - if (firmFragment != null) {  
1838 - firmFragment.onFirmUpdateInfo(info);  
1839 - }  
1840 - }  
1841 -  
1842 - @Override  
1843 - public void onComCommunicationTest(int sendn, boolean checkOk) {  
1844 -// if (adminFragment != null) {  
1845 -// adminFragment.onComCommunicationTest(sendn, checkOk);  
1846 -// }  
1847 - }  
1848 -  
1849 - private File checkUpdateApkFile() {  
1850 - String filePath = Environment.getExternalStorageDirectory().getPath() + "/sunvote/apk/";  
1851 - File file = new File(filePath);  
1852 - if (file == null) {  
1853 - LogUtil.i(TAG, "checkUpdateApkFile: no apk dir");  
1854 - return null;  
1855 - }  
1856 - if (!file.exists()) {  
1857 - LogUtil.i(TAG, "checkUpdateApkFile: no apk dir2");  
1858 - return null;  
1859 - }  
1860 - File[] files = file.listFiles();  
1861 -  
1862 - if (files == null || files.length == 0) {  
1863 - LogUtil.i(TAG, "checkUpdateApkFile: no apk file");  
1864 - return null;  
1865 - }  
1866 - return files[0];  
1867 - }  
1868 -  
1869 - private void clearApkFile() {  
1870 - try {  
1871 - String filePath = Environment.getExternalStorageDirectory().getPath() + "/sunvote/apk/";  
1872 - File file = new File(filePath);  
1873 - FileUtil.deleteFile(file);  
1874 -  
1875 - filePath = Environment.getExternalStorageDirectory().getPath() + "/sunvote/apk.zip";  
1876 - file = new File(filePath);  
1877 - FileUtil.deleteFile(file);  
1878 - } catch (Exception e) {  
1879 - // TODO: handle exception  
1880 - }  
1881 - }  
1882 -  
1883 - private Runnable installTask = new Runnable() {  
1884 @Override 57 @Override
1885 - public void run() {  
1886 - File apkFile = checkUpdateApkFile();  
1887 - if(apkFile != null){  
1888 - installApk(apkFile);  
1889 - } 58 + public void onOnlineInfoChanage(OnLineInfo newOnlineInfo) {
  59 + showEvent();
1890 } 60 }
1891 }; 61 };
1892 62
1893 - protected void installApk(File apkFile) {  
1894 - Intent intent = new Intent();  
1895 - // 执行动作  
1896 - intent.setAction(Intent.ACTION_VIEW);  
1897 - // 执行的数据类型  
1898 -// intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");  
1899 - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {  
1900 - intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);  
1901 - Uri contentUri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".fileProvider", apkFile);  
1902 - intent.setDataAndType(contentUri, "application/vnd.android.package-archive"); 63 + private void showEvent(){
  64 + if (XpadApiServiceInfoProxyManager.getInstance().getOnLineInfo().getOnLine() == 2) {
  65 + // 离线界面
  66 + } else if (XpadApiServiceInfoProxyManager.getInstance().getBaseVoteInfo().getMode() > 0) {
  67 + // 显示对应的投票界面
  68 + } else if (XpadApiServiceInfoProxyManager.getInstance().getBaseInfo() != null) {// 修改
  69 + // 自由浏览
  70 + } else if (XpadApiServiceInfoProxyManager.getInstance().getBaseInfo() != null) {//修改
  71 + // 欢迎界面
1903 } else { 72 } else {
1904 - intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");  
1905 - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 73 + // 在线界面
1906 } 74 }
1907 - startActivity(intent);  
1908 } 75 }
1909 76
1910 - public void showPDFFragment() {  
1911 - PDFContextShowFragment pdfContextShowFragment = new PDFContextShowFragment();  
1912 - pdfContextShowFragment.setInfo("/sdcard/ETest/androittext.pdf", "android", "1", "0", false);  
1913 - FragmentManager fm = getFragmentManager();  
1914 - FragmentTransaction transaction = fm.beginTransaction();  
1915 - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
1916 - transaction.add(R.id.frame_content, pdfContextShowFragment);  
1917 - transaction.addToBackStack("PDF");  
1918 - transaction.commitAllowingStateLoss();  
1919 - LogUtil.i(TAG, "showPDFFragment");  
1920 - }  
1921 -  
1922 - public void showServiceDialog() {  
1923 - View servicePanel = findViewById(R.id.service_panel);  
1924 - final ServicePresent servicePresent = new ServicePresent(this, servicePanel);  
1925 - DialogInterface.OnDismissListener dismissListener = new DialogInterface.OnDismissListener() {  
1926 - @Override  
1927 - public void onDismiss(DialogInterface dialog) {  
1928 - service.setVisibility(View.VISIBLE);  
1929 - servicePresent.dismiss();  
1930 - }  
1931 - };  
1932 - servicePresent.setDismissListener(dismissListener);  
1933 - servicePresent.show();  
1934 - }  
1935 -  
1936 -  
1937 - public String getImei() {  
1938 - TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);  
1939 - String uid = UUID.randomUUID().toString().replace("-","").substring(0,15);  
1940 - String saveIime = SPUtils.getString(this,"IMEI");  
1941 - String szImei = "" ;  
1942 - if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {  
1943 - szImei = TelephonyMgr.getDeviceId();  
1944 - if("0000000000000".equals(szImei) || StringUtils.isEmpty(szImei)){  
1945 - if(saveIime != null){  
1946 - szImei = saveIime ;  
1947 - }else{  
1948 - szImei = uid;  
1949 - }  
1950 - }  
1951 - }else{  
1952 - if(saveIime != null){  
1953 - szImei = saveIime ;  
1954 - }else{  
1955 - szImei = uid;  
1956 - }  
1957 - }  
1958 - SPUtils.putString(this,"IMEI",szImei);  
1959 - return szImei.toUpperCase();  
1960 - }  
1961 -  
1962 - public String password(){  
1963 - String password = EncryptUtils.encryptMD5ToString( "SUNVOTE" + getImei() + "SUNVOTE");  
1964 - password = EncryptUtils.encryptMD5ToString("SUNVOTE" + password + "SUNVOTE");  
1965 - if(password.length() > 6){  
1966 - password = password.substring(0,6);  
1967 - }  
1968 - return password;  
1969 - }  
1970 -  
1971 - public boolean isUnlock(){  
1972 - String key = EncryptUtils.encryptMD5ToString(getImei() + password());  
1973 - return SPUtils.getBoolean(this,key,false);  
1974 - }  
1975 -  
1976 - public void unlock(){  
1977 - String key = EncryptUtils.encryptMD5ToString(getImei() + password());  
1978 - SPUtils.putBoolean(this,key,true);  
1979 - }  
1980 - private AuthorizationFragment authorizationFragment ;  
1981 - public void setUnlockScreen(){  
1982 - if(authorizationFragment == null) {  
1983 - FragmentTransaction transaction = fm.beginTransaction();  
1984 - authorizationFragment = new AuthorizationFragment();  
1985 - transaction.replace(R.id.lockscreen, authorizationFragment);  
1986 - transaction.commit();  
1987 - lockscreen.setVisibility(View.VISIBLE);  
1988 - LogUtil.i(TAG, "setUnlockScreen");  
1989 - }  
1990 - }  
1991 -  
1992 - public void removeUnlockScreen(){  
1993 - if(authorizationFragment != null) { 77 + private void showFragment(Fragment frag){
  78 + if(!(frag != null && fragment != null && frag.getClass().getSimpleName().equals(fragment.getClass().getSimpleName()))){
  79 + fragment = frag;
1994 FragmentManager fm = getFragmentManager(); 80 FragmentManager fm = getFragmentManager();
1995 - FragmentTransaction tx = fm.beginTransaction();  
1996 - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);  
1997 - tx.remove(authorizationFragment);  
1998 - tx.commitAllowingStateLoss();  
1999 - lockscreen.setVisibility(View.GONE);  
2000 - authorizationFragment = null;  
2001 - }  
2002 - }  
2003 -  
2004 - @Override  
2005 - public boolean dispatchKeyEvent(KeyEvent event) {  
2006 - if(authorizationFragment != null) {  
2007 - authorizationFragment.dispatchKeyEvent(event); 81 + FragmentTransaction transaction = fm.beginTransaction();
  82 + transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
  83 + transaction.replace(R.id.frame_content, fragment);
  84 + transaction.commitAllowingStateLoss();
2008 } 85 }
2009 - return super.dispatchKeyEvent(event);  
2010 } 86 }
2011 } 87 }
C5/app/src/main/java/com/sunvote/xpadapp/base/BaseActivity.java
@@ -151,50 +151,6 @@ public class BaseActivity extends FragmentActivity { @@ -151,50 +151,6 @@ public class BaseActivity extends FragmentActivity {
151 return true; 151 return true;
152 } 152 }
153 153
154 - /*@Override  
155 - public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {  
156 - super.onRequestPermissionsResult(requestCode, permissions, grantResults);  
157 - switch (requestCode){  
158 - case WRITE_EXTERNAL_STORAGE:  
159 - if (grantResults.length > 0  
160 - && grantResults[0] == PackageManager.PERMISSION_GRANTED) {  
161 - boolean p = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE)  
162 - && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE)  
163 - && checkSelfPermission(Manifest.permission.CAMERA,CAMERA)  
164 - && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION,ACCESS_COARSE_LOCATION);  
165 - }  
166 - break;  
167 - case READ_EXTERNAL_STORAGE:  
168 - if (grantResults.length > 0  
169 - && grantResults[0] == PackageManager.PERMISSION_GRANTED) {  
170 - boolean p = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE)  
171 - && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE)  
172 - && checkSelfPermission(Manifest.permission.CAMERA,CAMERA)  
173 - && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION,ACCESS_COARSE_LOCATION);  
174 - }  
175 - break;  
176 - case CAMERA:  
177 - if (grantResults.length > 0  
178 - && grantResults[0] == PackageManager.PERMISSION_GRANTED) {  
179 - boolean p = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE)  
180 - && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE)  
181 - && checkSelfPermission(Manifest.permission.CAMERA,CAMERA)  
182 - && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION,ACCESS_COARSE_LOCATION);  
183 - }  
184 - break;  
185 -  
186 - case ACCESS_COARSE_LOCATION:  
187 - if (grantResults.length > 0  
188 - && grantResults[0] == PackageManager.PERMISSION_GRANTED) {  
189 - boolean p = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE)  
190 - && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE)  
191 - && checkSelfPermission(Manifest.permission.CAMERA,CAMERA)  
192 - && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION,ACCESS_COARSE_LOCATION);  
193 - }  
194 - break;  
195 - }  
196 - }*/  
197 -  
198 public void getScreenDensity_ByWindowManager(){ 154 public void getScreenDensity_ByWindowManager(){
199 DisplayMetrics mDisplayMetrics = new DisplayMetrics();//屏幕分辨率容器 155 DisplayMetrics mDisplayMetrics = new DisplayMetrics();//屏幕分辨率容器
200 getWindowManager().getDefaultDisplay().getMetrics(mDisplayMetrics); 156 getWindowManager().getDefaultDisplay().getMetrics(mDisplayMetrics);
@@ -202,8 +158,6 @@ public class BaseActivity extends FragmentActivity { @@ -202,8 +158,6 @@ public class BaseActivity extends FragmentActivity {
202 int height = mDisplayMetrics.heightPixels; 158 int height = mDisplayMetrics.heightPixels;
203 float density = mDisplayMetrics.density; 159 float density = mDisplayMetrics.density;
204 int densityDpi = mDisplayMetrics.densityDpi; 160 int densityDpi = mDisplayMetrics.densityDpi;
205 -// showToast("Screen Ratio: ["+width+"x"+height+"],density="+density+",densityDpi="+densityDpi);  
206 -// showToast("Screen mDisplayMetrics: "+mDisplayMetrics);  
207 LogUtil.i(TAG,"Screen Ratio: ["+width+"x"+height+"],density="+density+",densityDpi="+densityDpi); 161 LogUtil.i(TAG,"Screen Ratio: ["+width+"x"+height+"],density="+density+",densityDpi="+densityDpi);
208 LogUtil.i(TAG,"Screen mDisplayMetrics: "+mDisplayMetrics); 162 LogUtil.i(TAG,"Screen mDisplayMetrics: "+mDisplayMetrics);
209 } 163 }
C5/app/src/main/java/com/sunvote/xpadapp/fragments/AdminFragment.java
@@ -34,7 +34,6 @@ public class AdminFragment extends BaseFragment { @@ -34,7 +34,6 @@ public class AdminFragment extends BaseFragment {
34 34
35 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 35 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
36 View view = inflater.inflate(R.layout.fragment_admin, container, false); 36 View view = inflater.inflate(R.layout.fragment_admin, container, false);
37 - mMainActivity.adminFragment = this;  
38 37
39 tvModalInfo = view.findViewById(R.id.admin_modal_info); 38 tvModalInfo = view.findViewById(R.id.admin_modal_info);
40 btnBack = view.findViewById(R.id.admin_btnback); 39 btnBack = view.findViewById(R.id.admin_btnback);
@@ -53,7 +52,6 @@ public class AdminFragment extends BaseFragment { @@ -53,7 +52,6 @@ public class AdminFragment extends BaseFragment {
53 @Override 52 @Override
54 public void onClick(View v) { 53 public void onClick(View v) {
55 LogUtil.d("AdminFragment", "btnConfig"); 54 LogUtil.d("AdminFragment", "btnConfig");
56 - mMainActivity.presenter.configMode();  
57 Toast.makeText(getActivity(),R.string.modify_id_msg,Toast.LENGTH_SHORT).show(); 55 Toast.makeText(getActivity(),R.string.modify_id_msg,Toast.LENGTH_SHORT).show();
58 56
59 } 57 }
@@ -102,21 +100,17 @@ public class AdminFragment extends BaseFragment { @@ -102,21 +100,17 @@ public class AdminFragment extends BaseFragment {
102 100
103 @Override 101 @Override
104 public void onResume() { 102 public void onResume() {
105 - mMainActivity.showBottomUIMenu();  
106 super.onResume(); 103 super.onResume();
107 } 104 }
108 105
109 @Override 106 @Override
110 public void onStop() { 107 public void onStop() {
111 - mMainActivity.hideBottomUIMenu();  
112 - mMainActivity.adminFragment = null;  
113 super.onStop(); 108 super.onStop();
114 } 109 }
115 110
116 @Override 111 @Override
117 public void onDetach() { 112 public void onDetach() {
118 super.onDetach(); 113 super.onDetach();
119 - mMainActivity.adminFragment = null;  
120 } 114 }
121 115
122 private String getVersionName() { 116 private String getVersionName() {