diff --git a/C5/app/build.gradle b/C5/app/build.gradle index 6acc3ab..22429ac 100644 --- a/C5/app/build.gradle +++ b/C5/app/build.gradle @@ -94,6 +94,7 @@ dependencies { compile 'com.github.barteksc:android-pdf-viewer:2.7.0' compile 'cn.yipianfengye.android:zxing-library:2.2' compile 'com.jaredrummler:android-processes:1.1.1' + implementation project(':xpadapi') } //#解决某些输入文件使用或覆盖了已过时的 API diff --git a/C5/app/src/main/java/com/sunvote/xpadapp/MainActivity.java b/C5/app/src/main/java/com/sunvote/xpadapp/MainActivity.java index 7930b71..11686b5 100644 --- a/C5/app/src/main/java/com/sunvote/xpadapp/MainActivity.java +++ b/C5/app/src/main/java/com/sunvote/xpadapp/MainActivity.java @@ -1,2011 +1,87 @@ package com.sunvote.xpadapp; -import android.Manifest; -import android.annotation.SuppressLint; import android.app.Fragment; import android.app.FragmentManager; import android.app.FragmentTransaction; -import android.app.ProgressDialog; -import android.content.BroadcastReceiver; -import android.content.DialogInterface; import android.content.Intent; -import android.content.pm.PackageManager; -import android.graphics.Color; -import android.net.Uri; -import android.os.Build; import android.os.Bundle; -import android.os.Environment; import android.os.Handler; -import android.os.Message; -import android.support.v4.app.ActivityCompat; -import android.support.v4.content.FileProvider; -import android.telephony.TelephonyManager; -import android.util.Log; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.view.View; -import android.widget.FrameLayout; -import android.widget.ImageView; import android.widget.TextView; -import android.widget.Toast; -import com.sunvote.udptransfer.Config; -import com.sunvote.util.EncryptUtils; -import com.sunvote.util.LogUtil; -import com.sunvote.util.SPUtils; -import com.sunvote.util.StringUtils; +import com.sunvote.xpadapi.service.XpadApiService; +import com.sunvote.xpadapi.service.logic.XpadApiServiceInfoProxyManager; +import com.sunvote.xpadapi.service.bean.BaseInfo; +import com.sunvote.xpadapi.service.bean.BaseVoteInfo; +import com.sunvote.xpadapi.service.bean.OnLineInfo; +import com.sunvote.xpadapi.service.listener.BaseInfoChanageListener; +import com.sunvote.xpadapi.service.listener.BaseVoteInfoChanageListener; +import com.sunvote.xpadapi.service.listener.OnlineInfoChanageListener; import com.sunvote.xpadapp.base.BaseActivity; -import com.sunvote.xpadapp.base.BaseFragment; -import com.sunvote.xpadapp.db.DBManager; -import com.sunvote.xpadapp.db.modal.BillInfo; -import com.sunvote.xpadapp.db.modal.MeetingInfo; -import com.sunvote.xpadapp.db.modal.MultiTitleItem; -import com.sunvote.xpadapp.fragments.AdminFragment; -import com.sunvote.xpadapp.fragments.AuthorizationFragment; -import com.sunvote.xpadapp.fragments.ComErrorFragment; -import com.sunvote.xpadapp.fragments.CommunicationTestFragment; -import com.sunvote.xpadapp.fragments.ContentVoteFragment; -import com.sunvote.xpadapp.fragments.DocumentBrowserFragment; -import com.sunvote.xpadapp.fragments.DownloadFragment; -import com.sunvote.xpadapp.fragments.ElectionCustomFragment; -import com.sunvote.xpadapp.fragments.ElectionFragment; -import com.sunvote.xpadapp.fragments.FirmUpdateFragment; -import com.sunvote.xpadapp.fragments.KeypadTestChoice10Fragment; -import com.sunvote.xpadapp.fragments.KeypadTestFragment; -import com.sunvote.xpadapp.fragments.MeetingWelcomeFragment; -import com.sunvote.xpadapp.fragments.MultiContentDetailFragment; -import com.sunvote.xpadapp.fragments.MultiContentFragment; -import com.sunvote.xpadapp.fragments.MultiPingshengFragment; -import com.sunvote.xpadapp.fragments.MultiTitleFragment; -import com.sunvote.xpadapp.fragments.UserResultVoteFragment; -import com.sunvote.xpadapp.fragments.NoFileFragment; -import com.sunvote.xpadapp.fragments.OfflineFragment; -import com.sunvote.xpadapp.fragments.OnLineFragment; -import com.sunvote.xpadapp.fragments.PDFContextShowFragment; -import com.sunvote.xpadapp.fragments.ResultElectionFragment; -import com.sunvote.xpadapp.fragments.ResultMultiVoteFragment; -import com.sunvote.xpadapp.fragments.ResultVoteFragment; -import com.sunvote.xpadapp.fragments.ShowIdFragment; -import com.sunvote.xpadapp.fragments.SigninFragment; -import com.sunvote.xpadapp.fragments.SinginResultFragment; -import com.sunvote.xpadapp.fragments.SingleTitleFragment; -import com.sunvote.xpadapp.presenter.ServicePresent; -import com.sunvote.xpadapp.presenter.XPadPresenter; -import com.sunvote.xpadapp.server.MoniService; -import com.sunvote.xpadapp.utils.FileUtil; -import com.sunvote.xpadapp.utils.SharedPreferencesUtil; -import com.sunvote.xpadcomm.ComListener; -import com.sunvote.xpadcomm.FileRecver; -import com.sunvote.xpadcomm.ScreenUtil; -import com.sunvote.xpadcomm.XPadApi; -import com.sunvote.xpadcomm.XPadApiInterface.BaseInfo; -import com.sunvote.xpadcomm.XPadApiInterface.CmdDataInfo; -import com.sunvote.xpadcomm.XPadApiInterface.KeypadInfo; -import com.sunvote.xpadcomm.XPadApiInterface.ModelInfo; -import com.sunvote.xpadcomm.XPadApiInterface.OnLineInfo; -import com.sunvote.xpadcomm.XPadApiInterface.VoteInfo; -import com.sunvote.xpadcomm.XPadSystem; -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Timer; -import java.util.TimerTask; -import java.util.UUID; - -@SuppressLint("NewApi") -public class MainActivity extends BaseActivity implements ComListener { - - private final int Msg_ComError = 0; - private final int Msg_Offline = 1; - private final int Msg_Online = 2; - private final int Msg_Download = 3; - private final int Msg_Welcome = 4; - -// private final int Msg_Signin = 5; -// private final int Msg_QuickVote = 6; -// private final int Msg_SingleTitleVote = 7; -// private final int Msg_MultiTitleVote = 8; -// private final int Msg_SingleContentVote = 9; -// private final int Msg_MultiContentVote = 10; -// private final int Msg_ElectionVote = 11; - public static final int Msg_StopDownload = 12; - - // private final int Msg_KeypadTest = 13; - private final int Msg_CommunicationTest = 14;//100次成功率 - private final int Msg_ShowID = 15; - private final int Msg_HideShowID = 17; - -// private final int Msg_MultiPingShengVote = 16; - - private final int Msg_onVoteEvent = 20; - private final int Msg_onCommitSuccessEvent = 21; - private final int Msg_onCommitAllOkSuccessEvent = 22; - private final int Msg_onMultiPackageData = 23;//显示结果 - private final int Msg_HideVoteResult = 24; - private final int Msg_ShowMultiVoteResult = 25; - private final int Msg_DBfileNotExist = 30; - - private final int Msg_MatchInfo = 31; - private final int Msg_CommunicationTestHideResult = 32; - - private final int Msg_onCommitErrorEvent = 33; - - public static final int Msg_DocumentBroswer = 40; - private final int Msg_ShowBill = 41; - - private final int Msg_ScreenDark = 50; - private final int Msg_ChangeBright = 51; -// private final int Msg_ChangeOffTime = 52; - - private final int Msg_FirmUpdate = 53; - private final int Msg_HideFirmUpdate = 54; - - public static final int MSG_DELAY_TO_VIEW = 56; - - private final int Msg_ShowElectionVoteResult = 60; - private final int Msg_ShowCustomTitleResult = 61; - private final int MSG_SHOW_ADMIN = 100; - private final int MSG_CLEAN_FILE = 101; - - public BroadcastReceiver batteryLevelRcvr; - - // WifiManager wifiManager; - // WiFiConnecter wac; - private String TAG = "MainActivity"; - FragmentManager fm = getFragmentManager(); - private FileRecver cs = null; - private String ip = "192.168.0.105"; - private int port = 15154; - - private BaseFragment billFragment; - private BaseFragment currFragment; - public BaseFragment multiContentFragment; - private DownloadFragment downloadFragment; - private DocumentBrowserFragment docFragment; - public BaseFragment pdfFragment; - private Fragment showIdFragment; - public Fragment resultFragment; - private FirmUpdateFragment firmFragment; - - private String wifiSsid; - private String wifiPwd; - private String serverIp; - private int serverPort; - - public XPadPresenter presenter; - public OnLineInfo mOnlineInfo; - public BaseInfo mBaseInfo; - public KeypadInfo mKeypadInfo; - public VoteInfo mVoteInfo; - public ModelInfo mModelInfo; - - public String meetingDir; - - public MeetingInfo meetingInfo; - public BillInfo currBillInfo; - public BillInfo subBillInfo; - public DBManager dbm; - public int meetingId; - public int roleType;//1 正式代表 , 2 列席代表 0 未配置 - - private boolean inKeyTesting = false; - private boolean isChair=false; - - private long lastTouchTime; - private Timer screenTimer; - private long scrTimerCnt; - private Integer brigntLevel; - private Integer darkTime;// minit - - public long startVoteTime;// 启动投票时间 用于测试10选1 功能 - public boolean isLoadPDF; - - private boolean downloading = false; - - public AdminFragment adminFragment; - private FrameLayout lockscreen; +public class MainActivity extends BaseActivity { + private Handler handler; private TextView terminalId; - private ImageView service; + private Fragment fragment; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + Intent intent = new Intent(this, XpadApiService.class); + startService(intent); setContentView(R.layout.activity_main); terminalId = findViewById(R.id.terminal_id); - service = findViewById(R.id.service); - lockscreen = findViewById(R.id.lockscreen); - if (service != null) { - service.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (mOnlineInfo.onLine == 1) { - showServiceDialog(); - service.setVisibility(View.GONE); - } else { - Intent intent = new Intent(MainActivity.this, ConnectWifiActivity.class); - startActivity(intent); - } - } - }); - } - - mOnlineInfo = new OnLineInfo(); - mOnlineInfo.onLine = 0; - - presenter = new XPadPresenter(this); - setOnlineFragment(); - darkTime = (Integer) SharedPreferencesUtil.getData(MainActivity.this, "darkTime", 3); - brigntLevel = (Integer) SharedPreferencesUtil.getData(MainActivity.this, "bright", 30); - ScreenUtil.setNormalMode(MainActivity.this, brigntLevel); - screenTimer = new Timer(true); - screenTimer.schedule(screenTask, 1000, 1000); // 延时1000ms后执行,1000ms执行一次 - - clearApkFile(); - FirmUpdateFragment.clearUpdateFile(); - - if(!isUnlock()){ - setUnlockScreen(); - } - } - - public void setTerminalId(int id) { - terminalId.setText(getString(R.string.terminal_id) + id); - } - - @Override - public void onAttachedToWindow() { - hideBottomUIMenu(); - super.onAttachedToWindow(); - } - - public void hideBottomUIMenu() { - - // 隐藏虚拟按键,并且全屏 - if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower - // api - View v = this.getWindow().getDecorView(); - v.setSystemUiVisibility(View.GONE); - } else if (Build.VERSION.SDK_INT >= 19) { - // for new api versions. - View decorView = getWindow().getDecorView(); - - int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | 0x00002000; - decorView.setSystemUiVisibility(uiOptions); - } - } - - public void showBottomUIMenu() { - // 隐藏虚拟按键,并且全屏 - if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower - // api - View v = this.getWindow().getDecorView(); - v.setSystemUiVisibility(View.GONE); - } else if (Build.VERSION.SDK_INT >= 19) { - // for new api versions. - View decorView = getWindow().getDecorView(); - int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY //| View.SYSTEM_UI_FLAG_FULLSCREEN - & ~0x00002000; - decorView.setSystemUiVisibility(uiOptions); - } - XPadSystem.setNavgationVisible(this); - } - - @Override - protected void onResume() { - hideBottomUIMenu(); - setTerminalId(XPadApi.getInstance().getClient().getUdpModuleNO()); - super.onResume(); - } - - public void setBackgroundColor(int color){ - findViewById(R.id.root).setBackgroundColor(color); + handler = new Handler(); + XpadApiServiceInfoProxyManager.getInstance().setOnlineInfoChanageListener(onlineInfoChanageListener); + XpadApiServiceInfoProxyManager.getInstance().setBaseInfoListener(onBaseInfoListener); + XpadApiServiceInfoProxyManager.getInstance().setBaseVoteInfoListener(baseVoteInfoChanageListener); } - @Override - protected void onPause() { - LogUtil.i(TAG, "onPause"); - super.onPause(); - } - - @Override - protected void onStop() { - LogUtil.i(TAG, "onstop"); - XPadSystem.setNavgationVisible(this); - super.onStop(); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - showBottomUIMenu(); - XPadApi.getInstance().closeCom(); - if (batteryLevelRcvr != null) { - unregisterReceiver(batteryLevelRcvr); - } - - System.exit(0); - } - - public Handler myHandler = new Handler() { + private BaseVoteInfoChanageListener baseVoteInfoChanageListener = new BaseVoteInfoChanageListener() { @Override - public void handleMessage(Message msg) { - switch (msg.what) { - case Msg_ComError: - setComErrorFragment(); - break; - case Msg_Offline: - setOfflineFragment(); - break; - case Msg_Online: - setOnlineFragment(); - break; - case Msg_Download: - if (!downloading) { - clearApkFile(); - FirmUpdateFragment.clearUpdateFile(); - downloading = true; - setDownloadFragment(); - } - break; - case Msg_StopDownload: - downloading = false; - if (downloadFragment != null) { - downloadFragment.stopDownload(); - hideDownloadFragment(); - } - - if (dbm != null) { - try { - dbm.closeDB(); - dbm = null; - } catch (Exception e) { - LogUtil.e(TAG, e); - } - } - docFragment = null; - File apkFile = checkUpdateApkFile(); - File firmFile = FirmUpdateFragment.checkFirmFile(); - String str = String.format("Msg_StopDownload apkFile:%s ,firmFile:%s", apkFile != null ? "Y" : "N", firmFile != null ? "Y" : "N"); - //Toast.makeText(MainActivity.this,str,Toast.LENGTH_SHORT).show(); - LogUtil.d(TAG, "handleMessage: " + str); - - if (firmFile != null) { - LogUtil.i(TAG, "handleMessage: firm update"); - setFirmUpdateFragment(); - } else if (apkFile != null) { - LogUtil.i(TAG, "handleMessage: install apk"); - Intent intent1 = new Intent(MainActivity.this,MoniService.class); - stopService(intent1); - myHandler.removeCallbacks(installTask); - myHandler.postDelayed(installTask,2000); -// installApk(apkFile); - } else { - LogUtil.i(TAG, "handleMessage: stop download and getBaseStatus"); - presenter.getBaseStatus(); - } - // dbm.closeDB(); - // if (meetingInfo != null) { - // setWelcomeFragment(); - // } else { - // setOnlineFragment(); - // } - break; - case Msg_Welcome: - setWelcomeFragment(); - break; - case Msg_ShowBill: - BaseInfo baseInfo = (BaseInfo) msg.obj; - if (baseInfo.pageNo > 0) { - setPDFContextShowFragment(baseInfo); - } else { - showBill(null, baseInfo.pageNo); - } - break; - case Msg_DocumentBroswer: - setDocumentBrowserFragment(); - break; + public void onBaseVoteInfoListener(BaseVoteInfo newBaseVoteInfo) { - case MSG_DELAY_TO_VIEW: - if (mBaseInfo != null && mBaseInfo.billId == 255 &&(mVoteInfo.mode == 0 || mVoteInfo.mode == 1)) { // 自由浏览 - freeBrowsing(); - } - break; - case Msg_onVoteEvent: - VoteInfo vote = (VoteInfo) msg.obj; - doVote(vote); - break; - case Msg_onCommitSuccessEvent: - if (multiContentFragment != null) { - multiContentFragment.onVoteSubmitSuccess(); - } - if (currFragment != null) { - XPadApi.VoteResultItem item = (XPadApi.VoteResultItem) msg.obj; - currFragment.onVoteSubmitSuccess(item); - } - break; - case Msg_onCommitErrorEvent: - if (multiContentFragment != null) { - multiContentFragment.onVoteSubmitError(); - } else { - XPadApi.VoteResultItem item = (XPadApi.VoteResultItem) msg.obj; - if (currFragment != null) { - currFragment.onVoteSubmitError(item); - } - } - break; - case Msg_onCommitAllOkSuccessEvent: - if (multiContentFragment != null) { - multiContentFragment.onVoteSubmitAllOkSuccess(); - } - if (currFragment != null) { - currFragment.onVoteSubmitAllOkSuccess(); - } - break; - case Msg_onMultiPackageData:// 显示结果 - - break; - case Msg_ShowMultiVoteResult: - - showMultiVoteResultFragment((byte[]) msg.obj); - break; - case Msg_ShowElectionVoteResult: - showResultElectionFragment((byte[]) msg.obj); - break; - case Msg_ShowCustomTitleResult: - showVoteResultFragment((byte[]) msg.obj); - break; - case Msg_HideVoteResult:// 隐藏结果 - hideResultFragment(); - break; - case Msg_DBfileNotExist: - setNoFileFragment(); - break; - - case Msg_CommunicationTest: - showCommucationFragment((byte[]) msg.obj); - break; - case Msg_ShowID: - setShowIdFragment(); - break; - case Msg_HideShowID: - hideShowIdFragment(); - break; - case Msg_MatchInfo: - KeypadInfo info = (KeypadInfo) msg.obj; - mKeypadInfo = info; - ShowMatchInfo(info); - break; - case Msg_CommunicationTestHideResult: - dlg.dismiss(); - break; - case Msg_ScreenDark: - if (!App.isBackground(MainActivity.this)) { - ScreenUtil.setDarkMode(MainActivity.this); - } - break; - case Msg_ChangeBright: - brigntLevel = msg.arg1; - LogUtil.d(TAG, "-----change bright percent :" + brigntLevel); - ScreenUtil.setNormalMode(MainActivity.this, brigntLevel); - break; - case Msg_FirmUpdate: - setFirmUpdateFragment(); - break; - case Msg_HideFirmUpdate: - hideFirmUpdateFragment(); - break; - case MSG_SHOW_ADMIN: - showAdmin(); - break; - case MSG_CLEAN_FILE: - Toast.makeText(MainActivity.this, "文件清除完成!", Toast.LENGTH_SHORT).show(); - break; - default: - - } - - super.handleMessage(msg); } }; - public void showAdmin() { - FragmentManager fm = getFragmentManager(); - FragmentTransaction tx = fm.beginTransaction(); - if (adminFragment == null) { - adminFragment = new AdminFragment(); - tx.add(R.id.frame_content, adminFragment, "admin"); - tx.addToBackStack("admin"); - tx.commitAllowingStateLoss(); - LogUtil.i(TAG, "showAdmin"); - } - } - - - private void ShowMatchInfo(KeypadInfo info) { - if (info.cmd1 == 8) { // 配对 - String strMsg = null; - if (info.ok == 1) { - strMsg = "键盘编号:" + info.keyId; - } else { - strMsg = "配对失败"; - } - Toast.makeText(this, strMsg, Toast.LENGTH_SHORT).show(); - } else if (info.cmd1 == 9) { - String strMsg = null; - if (info.ok == 1) { - strMsg = "键盘编号:" + info.keyId; - } else { - strMsg = "配置失败"; - } - Toast.makeText(this, strMsg, Toast.LENGTH_SHORT).show(); - } - setTerminalId(info.keyId); - } - - private void hideResultFragment() { - setBackgroundColor(Color.parseColor("#720600")); - if (resultFragment == null) { - return; - } - FragmentManager fm = getFragmentManager(); - FragmentTransaction tx = fm.beginTransaction(); - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - fm.popBackStack(); - tx.remove(resultFragment); - tx.commitAllowingStateLoss(); - resultFragment = null; - } + private BaseInfoChanageListener onBaseInfoListener = new BaseInfoChanageListener() { - private ProgressDialog dlg = null; - private CommunicationTestFragment commFragment; - - private void showCommucationFragment(byte[] info) { - if (dlg == null) { - dlg = new ProgressDialog(MainActivity.this); - dlg.setCancelable(true);// 设置是否可以通过点击Back键取消 - dlg.setCanceledOnTouchOutside(true);// 设置在点击Dialog外是否取消Dialog进度条 - } - if (!dlg.isShowing()) { - dlg.show(); - } - dlg.setTitle("通讯测试"); - dlg.setMessage("通讯测试 次数:" + info[0] + " 成功次数:" + info[1] + " 基站信号:" + info[2] + " 键盘信号:" + info[3]); - myHandler.removeCallbacks(closeDlg); - myHandler.postDelayed(closeDlg, 20 * 1000); - - } - - private Runnable closeDlg = new Runnable() { @Override - public void run() { - Message message = new Message(); - message.what = Msg_CommunicationTestHideResult; - myHandler.sendMessage(message); - } - }; - - public void removePDFContextShowFragment() { - if (pdfFragment != null) { - PDFContextShowFragment fr = (PDFContextShowFragment) pdfFragment; - fr.setCloseFile(); - pdfFragment = null; - } - } - - private void setPDFContextShowFragment(BaseInfo baseInfo) { - if (currBillInfo == null) { - Toast.makeText(this, "没找到议案信息", Toast.LENGTH_LONG).show(); - return; - } - String dataPath = android.os.Environment.getExternalStorageDirectory().getAbsolutePath(); - String filePath = dataPath + "/sunvote/" + meetingId + "/" + currBillInfo.billFile; - File file = new File(filePath); - if (!file.exists()) { - Toast.makeText(this, "议案文件未找到", Toast.LENGTH_LONG).show(); - return; - } - FragmentManager fm = getFragmentManager(); - FragmentTransaction tx = fm.beginTransaction(); - PDFContextShowFragment fr = new PDFContextShowFragment(); - fr.setInfo(filePath, currBillInfo.billFile, baseInfo.pageNo + "", "1", true); - if (isLoadPDF) { - if (!fr.PDFLastOpenFilename.equals(currBillInfo.billFile)) { - removePDFContextShowFragment(); - isLoadPDF = false; - } else { - fr.setTopBarstate(); - fr.setPageIndex(baseInfo.pageNo); - fr.lockPageState(1); - } - } - pdfFragment = fr; - tx.add(R.id.frame_content, fr, "PDF"); - tx.addToBackStack("PDF"); - tx.commitAllowingStateLoss(); - } - - private void showVoteResultFragment(VoteInfo vote) { - hideResultFragment(); - FragmentManager fm = getFragmentManager(); - FragmentTransaction transaction = fm.beginTransaction(); - ResultVoteFragment fr = new ResultVoteFragment(); -// fr.voteInfo = vote; -// fr.bill = currBillInfo; - fr.setVoteInfo(vote); - resultFragment = fr; - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - transaction.add(R.id.frame_content, fr); - transaction.addToBackStack("voteresult"); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "showVoteResultFragment 信标"); - } - - private void showSigninResultFragment(VoteInfo vote) { - hideResultFragment(); - FragmentManager fm = getFragmentManager(); - FragmentTransaction transaction = fm.beginTransaction(); - SinginResultFragment fr = new SinginResultFragment(); - fr.setResultInfo(vote.resultInfo); - resultFragment = fr; - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - transaction.add(R.id.frame_content, fr); - transaction.addToBackStack("signinresult"); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "showSigninResultFragment 信标"); - } - - private void showResultElectionFragment(byte[] buffer) { - - int voteId = buffer[3] & 0xff; - if (dbm == null) { - Toast.makeText(this, "请先开始会议", Toast.LENGTH_LONG).show(); - return; - } + public void onBaseInfoChange(BaseInfo newBaseInfo) { - currBillInfo = dbm.getBillInfo(meetingId, voteId); - if (currBillInfo == null) { - Toast.makeText(this, "显示选举结果失败,没有找到会议资料", Toast.LENGTH_LONG).show(); - return; - } - - if (currBillInfo.billNo == 0 && currBillInfo.billId == 0) { - Toast.makeText(this, "没找到议案信息", Toast.LENGTH_LONG).show(); - return; - } - hideCurrFragment(); - hideResultFragment(); - - FragmentTransaction transaction = fm.beginTransaction(); - ResultElectionFragment fr = new ResultElectionFragment(); - fr.data = buffer; - fr.bill = currBillInfo; - resultFragment = fr; - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - transaction.add(R.id.frame_content, fr); - transaction.addToBackStack("PDF"); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "showResultElectionFragment buffer"); - } - - private void showVoteResultFragment(byte[] buffer) { - int voteId = buffer[3] & 0xff; - if (dbm == null) { - Toast.makeText(this, "请先开始会议", Toast.LENGTH_LONG).show(); - return; - } - currBillInfo = dbm.getBillInfo(meetingId, voteId); - roleType = dbm.getKeypadRole(XPadApi.getInstance().getClient().getUdpModuleNO()); - if (currBillInfo == null) { - Toast.makeText(this, "显示批次结果失败,没有找到会议资料", Toast.LENGTH_LONG).show(); - return; - } - if (currBillInfo.billOptions == null) { - Toast.makeText(this, "显示结果失败,选项为空", Toast.LENGTH_LONG).show(); - return; - } - - hideCurrFragment(); - hideResultFragment(); - - FragmentTransaction transaction = fm.beginTransaction(); - UserResultVoteFragment fr = new UserResultVoteFragment(); - fr.setData(buffer); - fr.setOptions(currBillInfo.billOptions.split("/")); - resultFragment = fr; - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - transaction.add(R.id.frame_content, fr); - transaction.addToBackStack("voteresult"); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "showVoteResultFragment buffer"); - } - - - private void showMultiVoteResultFragment(byte[] buffer) { - int voteId = buffer[3] & 0xff; - if (dbm == null) { - Toast.makeText(this, "请先开始会议", Toast.LENGTH_SHORT).show(); - return; - } - - currBillInfo = dbm.getBillInfo(meetingId, voteId); - if (currBillInfo == null) { - Toast.makeText(this, "显示批次结果失败,没有找到会议资料", Toast.LENGTH_SHORT).show(); - return; - } - if (currBillInfo.billOptions == null) { - Toast.makeText(this, "显示批次结果失败,选项为空", Toast.LENGTH_SHORT).show(); - return; - } - - hideCurrFragment(); - hideResultFragment(); - FragmentManager fm = getFragmentManager(); - FragmentTransaction transaction = fm.beginTransaction(); - ResultMultiVoteFragment fr = new ResultMultiVoteFragment(); - fr.bill = currBillInfo; - fr.data = buffer; - resultFragment = fr; - // transaction.setCustomAnimations(android.R.animator.fade_in,android.R.animator.fade_out); - transaction.add(R.id.frame_content, fr); - transaction.addToBackStack("multivote"); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "showMultiVoteResultFragment buffer"); - } - - private void setFirmUpdateFragment() { - LogUtil.i(TAG, "setFirmUpdateFragment: "); - FragmentManager fm = getFragmentManager(); - FragmentTransaction transaction = fm.beginTransaction(); - if (firmFragment == null) { - firmFragment = new FirmUpdateFragment(); - } - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - transaction.replace(R.id.frame_content, firmFragment); - // transaction.addToBackStack(null); - transaction.commitAllowingStateLoss(); - } - - private void hideFirmUpdateFragment() { - if (firmFragment != null) { - FragmentManager fm = getFragmentManager(); - FragmentTransaction tx = fm.beginTransaction(); - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - tx.remove(firmFragment); - tx.commitAllowingStateLoss(); - firmFragment = null; - } - } - - private OfflineFragment offlineFragment; - - private void setOfflineFragment() { - service.setImageResource(R.drawable.scan_qrcode); - FragmentManager fm = getFragmentManager(); - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - if (offlineFragment == null) { - offlineFragment = new OfflineFragment(); - transaction.add(R.id.frame_content, offlineFragment); - transaction.addToBackStack("offlineFragment"); - LogUtil.i(TAG, "setOfflineFragment"); - } else { - transaction.replace(R.id.frame_content, offlineFragment); - } - transaction.commitAllowingStateLoss(); - Intent intent = new Intent(this,MoniService.class); - stopService(intent); - } - - private ComErrorFragment comErrorFragment; - - private void setComErrorFragment() { - FragmentManager fm = getFragmentManager(); - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - if (comErrorFragment == null) { - comErrorFragment = new ComErrorFragment(); - transaction.add(R.id.frame_content, comErrorFragment); - transaction.addToBackStack("comErrorFragment"); - } else { - transaction.replace(R.id.frame_content, comErrorFragment); - } - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "setComErrorFragment"); - } - - private OnLineFragment onLineFragment; - - private void setOnlineFragment() { - FragmentManager fm = getFragmentManager(); - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - if (onLineFragment == null) { - onLineFragment = new OnLineFragment(); - transaction.add(R.id.frame_content, onLineFragment); - transaction.addToBackStack("onLineFragment"); - } else { - transaction.replace(R.id.frame_content, onLineFragment); - } - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "setOnlineFragment"); - presenter.getBaseStatus(); - service.setImageResource(R.drawable.service_server); - Intent intent = new Intent(this,MoniService.class); - startService(intent); - } - - private void setShowIdFragment() { - FragmentManager fm = getFragmentManager(); - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - if (showIdFragment == null) { - showIdFragment = new ShowIdFragment(); - transaction.add(R.id.frame_content, showIdFragment); - transaction.addToBackStack("showIdFragment"); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "showIdFragment"); - } - } - - private void hideShowIdFragment() { - if (showIdFragment != null) { - FragmentManager fm = getFragmentManager(); - FragmentTransaction tx = fm.beginTransaction(); - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - tx.remove(showIdFragment); - tx.commitAllowingStateLoss(); - showIdFragment = null; - } - } - - private KeypadTestFragment keypadTestFragment; - - private void setKeypadTestFragment() { - if (keypadTestFragment == null) { - inKeyTesting = true; - FragmentManager fm = getFragmentManager(); - FragmentTransaction tx = fm.beginTransaction(); - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - keypadTestFragment = new KeypadTestFragment(); - tx.add(R.id.frame_content, keypadTestFragment); - tx.addToBackStack("keypadTestFragment"); - tx.commitAllowingStateLoss(); - LogUtil.i(TAG, "keypadTestFragment"); - } - } - - private KeypadTestChoice10Fragment keypadTestChoice10Fragment; - - private void setChoice10Fragment() { - inKeyTesting = true; - FragmentManager fm = getFragmentManager(); - FragmentTransaction tx = fm.beginTransaction(); - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - if (keypadTestChoice10Fragment == null) { - keypadTestChoice10Fragment = new KeypadTestChoice10Fragment(); - tx.add(R.id.frame_content, keypadTestChoice10Fragment); - tx.addToBackStack("setChoice10Fragment"); - } else { - tx.replace(R.id.frame_content, keypadTestChoice10Fragment); - } - tx.commitAllowingStateLoss(); - LogUtil.i(TAG, "setChoice10Fragment"); - } - - private void hideKeypadTestFragment() { - inKeyTesting = false; - if (keypadTestFragment != null) { - FragmentManager fm = getFragmentManager(); - FragmentTransaction tx = fm.beginTransaction(); - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - tx.remove(keypadTestFragment); - tx.commitAllowingStateLoss(); - keypadTestFragment = null; - } - LogUtil.i(TAG, "hideKeypadTestFragment"); - } - - private long lastSetDownloadTime = 0; - - private void setDownloadFragment() { - if (System.currentTimeMillis() - lastSetDownloadTime < 5000) { - LogUtil.i(TAG, "ignore redownload"); - return; - } - if (mKeypadInfo == null) { - presenter.getKeypadParam(); - } - if (wifiSsid == null || wifiSsid.length() == 0) { -// Toast.makeText(this, "wifiSsid is null ", Toast.LENGTH_SHORT).show(); -// return; - } - if (wifiPwd == null || wifiPwd.length() == 0) { -// Toast.makeText(this, "wifiPwd is null ", Toast.LENGTH_SHORT).show(); -// return; - } - if (serverIp == null || serverIp.length() == 0) { -// Toast.makeText(this, "serverIp is null ", Toast.LENGTH_SHORT).show(); -// return; - serverIp = Config.getInstance().serverIP; - } - // if(serverPort == 0){ - // Toast.makeText(this, "serverPort is 0 ", Toast.LENGTH_SHORT); - // return; - // } - lastSetDownloadTime = System.currentTimeMillis(); - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - if (downloadFragment == null) { - downloadFragment = new DownloadFragment(); - serverPort = 4002; - downloadFragment.setInfo(wifiSsid, wifiPwd, serverIp, serverPort, XPadApi.getInstance().getClient().getUdpModuleNO()); - transaction.add(R.id.frame_content, downloadFragment); - transaction.addToBackStack("downloadFragment"); - } else { - serverPort = 4002; - downloadFragment.setInfo(wifiSsid, wifiPwd, serverIp, serverPort, XPadApi.getInstance().getClient().getUdpModuleNO()); - transaction.replace(R.id.frame_content, downloadFragment); - } - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "downloadFragment"); - } - - private void hideDownloadFragment() { - if (downloadFragment != null) { - FragmentTransaction tx = fm.beginTransaction(); - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - tx.remove(downloadFragment); - tx.commitAllowingStateLoss(); - downloadFragment = null; - LogUtil.i(TAG, "hideDownloadFragment"); - } - } - - private MeetingWelcomeFragment meetingWelcomeFragment; - - private void setWelcomeFragment() { - // if (mBaseInfo == null) { - // mBaseInfo = new BaseInfo(); - // mBaseInfo.confId = 1; - // } - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - if (meetingWelcomeFragment == null) { - meetingWelcomeFragment = new MeetingWelcomeFragment(); - } - meetingWelcomeFragment.setMeeting(); - transaction.replace(R.id.frame_content, meetingWelcomeFragment); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "setWelcomeFragment"); - } - - private NoFileFragment noFileFragment; - - private void setNoFileFragment() { - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - if (noFileFragment == null) { - noFileFragment = new NoFileFragment(); - noFileFragment.setMeetingId(meetingId); - transaction.add(R.id.frame_content, noFileFragment); - transaction.addToBackStack("setNoFileFragment"); - } else { - transaction.replace(R.id.frame_content, noFileFragment); - } - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG,"setNoFileFragment"); - } - - private SigninFragment signinFragment; - - private void setSigninFragment(VoteInfo info) { - hideDownloadFragment(); - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - signinFragment = new SigninFragment(); - signinFragment.setInfo(info); - currFragment = signinFragment; - transaction.add(R.id.frame_content, currFragment); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG,"setSigninFragment"); - } - - private void setQuickVoteFragment() { - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - SingleTitleFragment fr = new SingleTitleFragment(); - fr.setInfo(currBillInfo); - currFragment = fr; - transaction.add(R.id.frame_content, currFragment); - transaction.addToBackStack("setQuickVoteFragment"); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG,"setQuickVoteFragment"); - } - - private void setTitleVoteFragment(VoteInfo vote) { - hideDownloadFragment(); - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - SingleTitleFragment fr = new SingleTitleFragment(); - fr.setInfo(currBillInfo, vote); - currFragment = fr; - transaction.add(R.id.frame_content, currFragment); - transaction.addToBackStack("titleVote"); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG,"setTitleVoteFragment"); - } - - private void setMultiTitleVoteFragment(VoteInfo vote) { - - if (currBillInfo == null) { - Toast.makeText(this, "没找到议案信息", Toast.LENGTH_SHORT).show(); - return; - } - ArrayList list = dbm.getMultiTitleItems(meetingId, currBillInfo.billId); - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - MultiTitleFragment fr = new MultiTitleFragment(); - fr.setInfo(currBillInfo, vote, list); - currFragment = fr; - transaction.add(R.id.frame_content, currFragment); - transaction.addToBackStack("multititleVote"); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "setMultiTitleVoteFragment"); - } - - - private void setSingleContentVoteFragment() { - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - ContentVoteFragment fr = new ContentVoteFragment(); - fr.setInfo(currBillInfo); - currFragment = fr; - transaction.replace(R.id.frame_content, currFragment); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "setSingleContentVoteFragment"); - } - - private void setMultiContentVoteFragment() { - ArrayList list = dbm.getMultiTitleItems(meetingId, currBillInfo.billId); - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - MultiContentFragment fr = new MultiContentFragment(); - fr.setInfo(currBillInfo, list); - currFragment = fr; - transaction.replace(R.id.frame_content, currFragment); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "setMultiContentVoteFragment"); - } - - - private void setDocumentBrowserFragment() { - ArrayList list = dbm.getBillItemsMain(meetingId); - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - if (docFragment == null) { - docFragment = new DocumentBrowserFragment(); - docFragment.setInfo(list, false); - } - transaction.replace(R.id.frame_content, docFragment); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "setDocumentBrowserFragment"); - } - - private void showBill(VoteInfo vInfo, final int pageNo) { - - if (currBillInfo.billFile == null) { - return; - } - hideDownloadFragment(); - FragmentManager fm = getFragmentManager(); - FragmentTransaction tx = fm.beginTransaction(); - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - if (vInfo != null) { - MultiContentDetailFragment fr = new MultiContentDetailFragment(); - fr.setInfo(currBillInfo, vInfo, false, pageNo, 1); - currFragment = fr; - tx.add(R.id.frame_content, currFragment, "fDetail"); - tx.addToBackStack("fDetail"); - tx.commitAllowingStateLoss(); - LogUtil.i(TAG, "fDetail"); - } else { - if (currFragment instanceof MultiContentDetailFragment) { - ((MultiContentDetailFragment) currFragment).setPdfPage(pageNo); - LogUtil.i(TAG, "fDetail setPdfPage"); - } else { - MultiContentDetailFragment fDetail = new MultiContentDetailFragment(); - fDetail.setInfo(currBillInfo, vInfo, false, pageNo, 1); - currFragment = fDetail; - tx.add(R.id.frame_content, fDetail, "fDetail"); - tx.addToBackStack("fDetail"); - tx.commitAllowingStateLoss(); - LogUtil.i(TAG, "MultiContentDetailFragment setPdfPage"); - } - } - - } - - private void setMultiPinsShengFragment() { - ArrayList list = dbm.getMultiTitleItems(meetingId, currBillInfo.billId); - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - MultiPingshengFragment fr = new MultiPingshengFragment(); - fr.setInfo(currBillInfo, list); - currFragment = fr; - transaction.replace(R.id.frame_content, currFragment); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "setMultiPinsShengFragment"); - } - - private void setElectionVoteFragment(VoteInfo vote) { - if (dbm == null) { - Toast.makeText(this, "请先开始会议", Toast.LENGTH_LONG).show(); - return; - } - currBillInfo = dbm.getBillInfo(meetingId, vote.electInfo.voteid); - roleType = dbm.getKeypadRole(XPadApi.getInstance().getClient().getUdpModuleNO()); - if (currBillInfo == null) { - Toast.makeText(this, "没找到议案信息", Toast.LENGTH_LONG).show(); - return; - } - - if (currBillInfo.billNo == 0 && currBillInfo.billId == 0) { - Toast.makeText(this, "没找到议案信息", Toast.LENGTH_LONG).show(); - return; - } - - ArrayList list = dbm.getCandidateList(meetingId, currBillInfo.billId); - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - ElectionFragment fr = new ElectionFragment(); - fr.setInfo(currBillInfo, list, vote); - currFragment = fr; - transaction.add(R.id.frame_content, currFragment); - transaction.addToBackStack("electionvote"); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "setElectionVoteFragment"); - } - - private void setCustomElectionVoteFragment(VoteInfo vote) { - if (currBillInfo == null) { - Toast.makeText(this, "没找到议案信息", Toast.LENGTH_LONG).show(); - return; - } - - if(currBillInfo.billNo==0 && currBillInfo.billId==0){ - Toast.makeText(this, "没找到议案信息", Toast.LENGTH_LONG).show(); - return; - } - - if(currBillInfo.billOptions.split("/") == null){ - Toast.makeText(this, "显示批次结果失败,选项为空", Toast.LENGTH_LONG).show(); - return; - } - LogUtil.i(TAG,"setMultiTitleVoteFragment"); - ArrayList list = dbm.getMultiTitleItems(meetingId, currBillInfo.billId); - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - ElectionCustomFragment fr = new ElectionCustomFragment(); - fr.setInfo(currBillInfo,list,vote); - currFragment = fr; - transaction.add(R.id.frame_content, currFragment); - transaction.addToBackStack("multititleVote"); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "setCustomElectionVoteFragment"); - } - - public void getBillInfo(int billId) { - currBillInfo = dbm.getBillInfo(meetingId, billId); - } - - @Override - public void onComData(byte[] data, int len) { - // TODO Auto-generated method stub - - } - - @Override - public void onSendData(byte[] data, int len) { - // TODO Auto-generated method stub - - } - - @Override - public void onModelEvent(ModelInfo info) { - LogUtil.i(TAG, "onModelEvent"); - mModelInfo = info; - if (firmFragment != null) { - Intent intent = new Intent(); - intent.setAction("com.xpad.firm"); - intent.putExtra("ver", info.sVer); - MainActivity.this.sendBroadcast(intent); - LogUtil.i(TAG, "send broadcast"); - // firmFragment.setFirmVer(mModelInfo.sVer); - } - - } - - - - @Override - public void onBaseEvent(BaseInfo info) { - mBaseInfo = info; - LogUtil.i(TAG, "baseEvent:" + info); - meetingId = info.confId; - if (info.confId != 0) { - if (dbm != null && dbm.confId != info.confId) { - dbm.closeDB(); - docFragment = null; - } - if (dbm == null || !dbm.checkDB() || dbm.confId != info.confId) { - dbm = new DBManager(this, info.confId);// 如果没打开,则打开数据库 - roleType = dbm.getKeypadRole(XPadApi.getInstance().getClient().getUdpModuleNO()); - } - if (!dbm.checkDB()) { - Message message = new Message(); - message.what = Msg_DBfileNotExist; - myHandler.sendMessage(message); - presenter.getVoteStatus(); - return; - } - if (meetingInfo == null || info.billId <= 1) { - meetingInfo = dbm.getMettingInfo(info.confId); - roleType = dbm.getKeypadRole(XPadApi.getInstance().getClient().getUdpModuleNO()); - } - - if (info.billId == 0) { // 没有议案的情况,显示欢迎界面 - if (mOnlineInfo.onLine == 1) { - removePDFContextShowFragment(); - Message message = new Message(); - message.what = Msg_Welcome; - myHandler.sendMessage(message); - } - } else if (info.billId == 255) { // 自由浏览 - freeBrowsing(); - } else {// 进入议案 - currBillInfo = dbm.getBillInfo(info.confId, info.billId); - Message message = new Message(); - message.what = Msg_ShowBill; - message.obj = info; - myHandler.sendMessage(message); - // processBaseEvent(); - } - - presenter.getVoteStatus(); - - // 显示会议标题 - } else {// confId为0 ,表示停止会议 - if (mOnlineInfo.onLine == 1) { - Message message = new Message(); - message.what = Msg_Online; - myHandler.sendMessage(message); - } - if (dbm != null) { - dbm.closeDB(); - } - } - - - } - - private void freeBrowsing() { - if (dbm != null && dbm.checkDB()) { - removePDFContextShowFragment(); - Message message = new Message(); - message.what = Msg_DocumentBroswer; - myHandler.sendMessage(message); - } - } - - @Override - public void onVoteEvent(VoteInfo info) { - startVoteTime = System.currentTimeMillis(); - LogUtil.i(TAG, "onVoteEvent " + info); - if (downloading) { - Message message = new Message(); - message.what = Msg_StopDownload; - myHandler.sendMessage(message); - } - Message message = new Message(); - message.what = Msg_onVoteEvent; - message.obj = info; - myHandler.sendMessage(message); - } - - private void hideCurrFragment() { - - if (currFragment != null) { - LogUtil.i(TAG, "hideCurrFragment success, " + currFragment.getClass().getName()); - FragmentManager fm = getFragmentManager(); - FragmentTransaction tx = fm.beginTransaction(); - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - if(currFragment instanceof SingleTitleFragment) { - if (multiContentFragment != null) { - tx.remove(multiContentFragment); - multiContentFragment = null; - } - } - fm.popBackStack(); - tx.remove(currFragment); - tx.commitAllowingStateLoss(); - currFragment = null; - } - } - - private void doVote(VoteInfo voteInfo) { - LogUtil.i(TAG,"doVote:" + voteInfo); - mVoteInfo=voteInfo; - if (voteInfo.mode == XPadApi.VoteType_KeypadTest) { - setKeypadTestFragment(); - return; - } else if (voteInfo.mode == XPadApi.VoteType_Choice && voteInfo.mode5 == 10) { - setChoice10Fragment(); - return; - } else if (voteInfo.mode == XPadApi.VoteType_Stop) { - if (inKeyTesting) { - hideKeypadTestFragment(); - return; - } - } - - if(mBaseInfo!=null){ - if(mBaseInfo.billId==0 || mBaseInfo.billId==255){ - removePDFContextShowFragment(); - } - } - - hideResultFragment(); - /* - * 暂时去掉角色 if (mKeypadInfo != null && dbm != null) { roleType = - * dbm.getKeypadRole(mKeypadInfo.keyId); Log.d(TAG, "roleType:" + - * roleType); } if (roleType == 0) {// 列席代表不处理 return; } - */ - tmpMulResultBuffer = null; - if (!(voteInfo.mode == XPadApi.VoteType_Stop && voteInfo.mode1_msgType == 2 - && voteInfo.resultInfo.resultType == XPadApi.VoteType_BatchVote)) { - hideCurrFragment(); - } - if (dbm == null || !dbm.checkDB() ) { - dbm = new DBManager(this, this.meetingId);// 如果没打开,则打开数据库 - } - roleType = dbm.getKeypadRole(XPadApi.getInstance().getClient().getUdpModuleNO()); - // voteInfo.voteid = 1;//debug - if (voteInfo.voteid > 0 && voteInfo.voteid < 255) { - try { - currBillInfo = dbm.getBillInfo(meetingId, voteInfo.voteid); - } catch (Exception e) { - e.printStackTrace(); - } - if (currBillInfo == null) { - LogUtil.i(TAG, "BillInfo not found!!!"); - } - } - - if (voteInfo.mode == XPadApi.VoteType_Stop) { - int count = fm.getBackStackEntryCount(); - LogUtil.i(TAG, "getBackStackEntryCount:" + count ); - if(count > 1){ - for(int i = 0; i < count ; i++){ - LogUtil.i(TAG, "name:" + fm.getBackStackEntryAt(i).getName()); - } - } - if (voteInfo.mode1_msgType == 2) { // 结果显示 - if(voteInfo.resultInfo.resultType == XPadApi.VoteType_Stop){ - showSigninResultFragment(voteInfo); - }else if (voteInfo.resultInfo.resultType == XPadApi.VoteType_BatchVote) { // 多项 - if (currFragment != null) { - currFragment.onVoteEvent(voteInfo); - } - } else if (voteInfo.resultInfo.resultType !=101 && voteInfo.resultInfo.resultType != XPadApi.VoteType_BatchElect){ - showVoteResultFragment(voteInfo); - } - } - } else if (voteInfo.mode == XPadApi.VoteType_Signin) { - if(isChair){ - return; - } - if(roleType != 2){ - setSigninFragment(voteInfo); - } - }else if (voteInfo.mode == XPadApi.VoteType_Evaluate){ - - }else if(voteInfo.mode == XPadApi.VoteType_BatchElect){ - if(isChair){ - return; - } - if(roleType != 2) { - setElectionVoteFragment(voteInfo); - } - }else { - if (voteInfo.mode == XPadApi.VoteType_BatchVote) { - /** - * 是否带票数限定,,对批次表决、批次评议、批次自定义评议有效 - 0 不限定 - 1 带票数限定 - */ - if(voteInfo.fixballot==1){ - if (dbm != null && dbm.checkDB()) { - if(isChair){ - return; - } - if(roleType != 2){ - setCustomElectionVoteFragment(voteInfo); - } - }else{ - if(meetingId>0) { - Toast.makeText(this, "启动差额选举失败,会议" + meetingId + "不存在,请下载会议资料", Toast.LENGTH_LONG).show(); - } - } - }else { - if (dbm != null && dbm.checkDB()) { - if(isChair){ - return; - } - if(roleType != 2){ - setMultiTitleVoteFragment(voteInfo); - } - }else{ - LogUtil.i(TAG, "doVote: "+"启动批次表决失败,会议" + meetingId + "不存在,请下载会议资料"); - if(meetingId>0) { - Toast.makeText(this, "启动批次表决失败,会议" + meetingId + "不存在,请下载会议资料", Toast.LENGTH_LONG).show(); - } - } - } - } else { - if (voteInfo.init == 0 || checkHasBillFile(currBillInfo) == false) { - if(isChair){ - return; - } - if(roleType != 2){ - setTitleVoteFragment(voteInfo); - } - } else { - if(isChair){ - return; - } - billFragment=null; - if(roleType != 2) { - showBill(voteInfo,1); - } - } - } - } - } - - private boolean isInVoteState(){ - if(mVoteInfo != null){ - return mVoteInfo.mode > 0 ; - } - return false; - } - - private boolean checkHasBillFile(BillInfo bill) { - return (bill != null && bill.billFile != null && bill.billFile.length() > 0); - } - - @Override - public void onVoteSubmitSuccess(XPadApi.VoteResultItem item) { - Message message = new Message(); - message.obj = item; - message.what = Msg_onCommitSuccessEvent; - myHandler.sendMessage(message); - - } - - @Override - public void onVoteSubmitAllOkSuccess() { - Message message = new Message(); - message.what = Msg_onCommitAllOkSuccessEvent; - myHandler.sendMessage(message); - } - - @Override - public void onKeyPadEvent(KeypadInfo info) { - LogUtil.i(TAG, "onKeyPadEvent"); - mKeypadInfo = info; - XPadSystem.setStatusBarPadID(this, info.keyId); - XPadSystem.setStatusBarChannel(this, info.chan); - if (info.cmd1 == 8 || info.cmd1 == 9) { - Message message = new Message(); - message.what = Msg_MatchInfo; - message.obj = info; - myHandler.sendMessage(message); - } - - } - - @Override - public void onOnLineEvent(OnLineInfo info) { - - if (info.comError == 1) { - if (info.comError != mOnlineInfo.comError) { - Message message = new Message(); - message.what = Msg_ComError; - myHandler.sendMessage(message); - } - LogUtil.i(TAG, "onOnLineEvent: comError"); - } else { - if (info.onLine != mOnlineInfo.onLine) { - if (info.onLine == 1) { - Message message = new Message(); - message.what = Msg_Online; - myHandler.sendMessage(message); - presenter.getBaseStatus(); - LogUtil.i(TAG, "onOnLineEvent: onLine"); - - } else { - Message message = new Message(); - message.what = Msg_Offline; - myHandler.sendMessage(message); - LogUtil.i(TAG, "onOnLineEvent: offLine"); - } - } else if (info.onLine == 1) { - if (offlineFragment != null && offlineFragment.isVisible) { - Message message = new Message(); - message.what = Msg_Online; - myHandler.sendMessage(message); - presenter.getBaseStatus(); - LogUtil.i(TAG, "onOnLineEvent: onLine"); - } - } - - - } - - mOnlineInfo = info; - XPadSystem.setStatusBarDataIcon(this, info.tx, info.rx); - XPadSystem.setStatusBarChannel(this, info.chan); - XPadSystem.setStatusBarBaseId(this, getString(R.string.base_id) + ":" + info.baseId); - XPadSystem.setStatusBarSingal(this, info.rssi); - - - } - - - private CmdDataInfo cmdInfo; - private long lastRecvCmdDataTime; - private long lastCleanCmd; - private long lastAdminCmd; - - @Override - public void onCmdData(CmdDataInfo info) { - - if (cmdInfo != null && info.cmd == cmdInfo.cmd && Arrays.equals(info.data, cmdInfo.data) - && (System.currentTimeMillis() - lastRecvCmdDataTime < 1000)) { - LogUtil.i(TAG, "onCmdData,recv same data, ignore!"); - return; - } - lastRecvCmdDataTime = System.currentTimeMillis(); - cmdInfo = info; - XPadApi.printDataBuf(info.data, info.data.length, "cmd:" + info.cmd + " data:"); - if (info.cmd == 7) { // 键盘测试 - Message message = new Message(); - message.what = Msg_CommunicationTest; - message.obj = info.data; - myHandler.sendMessage(message); - } else if (info.cmd == 10) {// 显示编号 - if (info.data[0] == 0) { - LogUtil.i(TAG, "Msg_HideShowID"); - Message message = new Message(); - message.what = Msg_HideShowID; - myHandler.sendMessage(message); - } else { - LogUtil.i(TAG, "Msg_ShowID"); - Message message = new Message(); - message.what = Msg_ShowID; - myHandler.sendMessage(message); - } - } else if (info.cmd == 5) {// 关机 - XPadSystem.powerOffXPad(this); - finish(); - Intent intent = new Intent(this,MoniService.class); - stopService(intent); - } else if (info.cmd == 50) {// 主控透传 - byte cmd = info.data[0]; - LogUtil.i(TAG, "cmd:" + cmd); - byte[] data = Arrays.copyOfRange(info.data, 1, 19); - Message message = null; - switch (cmd) { - case 0x31:// wifi ssid - wifiSsid = new String(data).trim(); - LogUtil.i(TAG, "receve 0x31 wifi ssid:" + wifiSsid); - break; - case 0x32:// wifi pwd - wifiPwd = new String(data).trim(); - LogUtil.i(TAG, "receve 0x32 wifi pwd:" + wifiPwd); - break; - case 0x33: // ip - serverIp = new String(data).trim(); - LogUtil.i(TAG, "receve 0x33 server ip:" + serverIp); - break; - case 0x34: // start download - LogUtil.i(TAG, "receve start download"); - message = new Message(); - message.what = Msg_Download; - myHandler.sendMessage(message); - break; - case 0x35: // stop download - LogUtil.i(TAG, "receve stop download"); - message = new Message(); - message.what = Msg_StopDownload; - myHandler.sendMessage(message); - break; - case 0x36: // 暂去掉角色控制 - LogUtil.i(TAG, "not support"); - break; - case 0x37: - XPadSystem.rebootXPad(this); - break; - case 0x38: - message = new Message(); - message.what = Msg_HideVoteResult; - myHandler.sendMessage(message); - break; - case 0x39: - message = new Message(); - message.what = Msg_ChangeBright; - message.arg1 = info.data[1]; - myHandler.sendMessage(message); - SharedPreferencesUtil.saveData(MainActivity.this, "bright", Integer.valueOf(info.data[1])); - break; - case 0x40: - if (info.data[1] == 0) { - message = new Message(); - message.what = Msg_ScreenDark; - myHandler.sendMessage(message); - } else { - message = new Message(); - message.what = Msg_ChangeBright; - message.arg1 = brigntLevel; - myHandler.sendMessage(message); - } - break; - case 0x41: - darkTime = Integer.valueOf(info.data[1]); - scrTimerCnt = 0; - LogUtil.i(TAG, "set darkTime:" + darkTime); - SharedPreferencesUtil.saveData(MainActivity.this, "darkTime", darkTime); - break; - - case 0x42: - if (System.currentTimeMillis() - lastCleanCmd > 8000) { - lastCleanCmd = System.currentTimeMillis(); - FileUtil.deleteFile(new File(Environment.getExternalStorageDirectory().getPath() + "/sunvote"), "sunvote.dat"); - message = new Message(); - message.what = MSG_CLEAN_FILE; - myHandler.sendMessage(message); - } - break; - case 0x43: - if (System.currentTimeMillis() - lastAdminCmd > 8000) { - lastAdminCmd = System.currentTimeMillis(); - message = new Message(); - message.what = MSG_SHOW_ADMIN; - myHandler.sendMessage(message); - } - break; - - default: - break; - } - } else if (info.cmd == 66) {//66.加上一键统一清除会议文件功能。 - FileUtil.deleteFile(new File(Environment.getExternalStorageDirectory().getPath() + "/sunvote")); - } else if (info.cmd == 67) {//67.遥控统一进入管理员界面 - Message message = new Message(); - message.what = MSG_SHOW_ADMIN; - myHandler.sendMessage(message); - } - - } - - private byte[] tmpMulResultBuffer; - - @Override - public void onMultiPackageData(byte[] data, int len) { - LogUtil.i(TAG,"onMultiPackageData"); - XPadApi.printDataBuf(data, len, "onMultiPackageData:"); - byte[] buf = new byte[len]; - Arrays.fill(buf, (byte) 0x0); - System.arraycopy(data, 0, buf, 0, len); - - if(isInVoteState()){ - return; - } - if ((data[0] & 0xff) == 0xF2 && data[1] == 20) { - - if (tmpMulResultBuffer != null && Arrays.equals(buf, tmpMulResultBuffer)) { - Log.e(TAG, "onMultiPackageData same data,abort"); - return; - } - tmpMulResultBuffer = buf; - - Message message = new Message(); - message.what = Msg_ShowMultiVoteResult; - message.obj = buf; - myHandler.sendMessage(message); - return; - } - - //选举结果 - if ((data[0] & 0xff) == 0xF2 && data[1] == 22) { - if (tmpMulResultBuffer != null && Arrays.equals(buf, tmpMulResultBuffer)) { - Log.e(TAG, "onMultiPackageData same data,abort"); - return; - } - tmpMulResultBuffer = buf; - - Message message = new Message(); - message.what = Msg_ShowElectionVoteResult; - message.obj = buf; - myHandler.sendMessage(message); - return; - } - - //自定义表决结果 - if ((data[0] & 0xff) == 0xF2 && data[1] == 101) { - if (tmpMulResultBuffer != null && Arrays.equals(buf, tmpMulResultBuffer)) { - LogUtil.i(TAG, "onMultiPackageData same data,abort"); - return; - } - tmpMulResultBuffer = buf; - Message message = new Message(); - message.what = Msg_ShowCustomTitleResult; - message.obj = buf; - myHandler.sendMessage(message); - return; - } - - String str; - try { - str = new String(buf, "GB2312").trim(); - LogUtil.i(TAG, "onMultiPackageInfo:" + str); - Message message = new Message(); - message.what = Msg_onMultiPackageData; - message.arg1 = len; - message.obj = str; - myHandler.sendMessage(message); - } catch (UnsupportedEncodingException e) { - LogUtil.e(TAG, e); - } - - } - - @Override - public void onVoteSubmitError(XPadApi.VoteResultItem item) { - Message message = new Message(); - message.obj = item; - message.what = Msg_onCommitErrorEvent; - myHandler.sendMessage(message); - - } - - TimerTask screenTask = new TimerTask() { - public void run() { - scrTimerCnt++; - if (scrTimerCnt == darkTime * 60) { - scrTimerCnt = 0; - Message message = new Message(); - message.what = Msg_ScreenDark; - myHandler.sendMessage(message); - } } }; - @Override - public boolean dispatchTouchEvent(MotionEvent event) { - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - scrTimerCnt = 0; - ScreenUtil.setNormalMode(MainActivity.this, brigntLevel); - LogUtil.i("CustomBtnonTouchEvent", "MotionEvent.ACTION_DOWN"); - break; - case MotionEvent.ACTION_MOVE: - // LogUtil.i("CustomButton--onTouchEvent", "MotionEvent.ACTION_MOVE"); - break; - case MotionEvent.ACTION_UP: - // LogUtil.i("CustomButton--onTouchEvent", "MotionEvent.ACTION_UP"); - break; - - default: - break; - } - return super.dispatchTouchEvent(event); - } + private OnlineInfoChanageListener onlineInfoChanageListener = new OnlineInfoChanageListener() { - @Override - public void onFirmUpdate(int percent) { - if (firmFragment != null) { - firmFragment.onFirmUpdate(percent); - } - - } - - @Override - public void onFirmUpdateResult(boolean success, String msg) { - - if (firmFragment != null) { - firmFragment.onFirmUpdateResult(success, msg); - } - } - - @Override - public void onFirmUpdateInfo(String info) { - if (firmFragment != null) { - firmFragment.onFirmUpdateInfo(info); - } - } - - @Override - public void onComCommunicationTest(int sendn, boolean checkOk) { -// if (adminFragment != null) { -// adminFragment.onComCommunicationTest(sendn, checkOk); -// } - } - - private File checkUpdateApkFile() { - String filePath = Environment.getExternalStorageDirectory().getPath() + "/sunvote/apk/"; - File file = new File(filePath); - if (file == null) { - LogUtil.i(TAG, "checkUpdateApkFile: no apk dir"); - return null; - } - if (!file.exists()) { - LogUtil.i(TAG, "checkUpdateApkFile: no apk dir2"); - return null; - } - File[] files = file.listFiles(); - - if (files == null || files.length == 0) { - LogUtil.i(TAG, "checkUpdateApkFile: no apk file"); - return null; - } - return files[0]; - } - - private void clearApkFile() { - try { - String filePath = Environment.getExternalStorageDirectory().getPath() + "/sunvote/apk/"; - File file = new File(filePath); - FileUtil.deleteFile(file); - - filePath = Environment.getExternalStorageDirectory().getPath() + "/sunvote/apk.zip"; - file = new File(filePath); - FileUtil.deleteFile(file); - } catch (Exception e) { - // TODO: handle exception - } - } - - private Runnable installTask = new Runnable() { @Override - public void run() { - File apkFile = checkUpdateApkFile(); - if(apkFile != null){ - installApk(apkFile); - } + public void onOnlineInfoChanage(OnLineInfo newOnlineInfo) { + showEvent(); } }; - protected void installApk(File apkFile) { - Intent intent = new Intent(); - // 执行动作 - intent.setAction(Intent.ACTION_VIEW); - // 执行的数据类型 -// intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive"); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); - Uri contentUri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".fileProvider", apkFile); - intent.setDataAndType(contentUri, "application/vnd.android.package-archive"); + private void showEvent(){ + if (XpadApiServiceInfoProxyManager.getInstance().getOnLineInfo().getOnLine() == 2) { + // 离线界面 + } else if (XpadApiServiceInfoProxyManager.getInstance().getBaseVoteInfo().getMode() > 0) { + // 显示对应的投票界面 + } else if (XpadApiServiceInfoProxyManager.getInstance().getBaseInfo() != null) {// 修改 + // 自由浏览 + } else if (XpadApiServiceInfoProxyManager.getInstance().getBaseInfo() != null) {//修改 + // 欢迎界面 } else { - intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive"); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + // 在线界面 } - startActivity(intent); } - public void showPDFFragment() { - PDFContextShowFragment pdfContextShowFragment = new PDFContextShowFragment(); - pdfContextShowFragment.setInfo("/sdcard/ETest/androittext.pdf", "android", "1", "0", false); - FragmentManager fm = getFragmentManager(); - FragmentTransaction transaction = fm.beginTransaction(); - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - transaction.add(R.id.frame_content, pdfContextShowFragment); - transaction.addToBackStack("PDF"); - transaction.commitAllowingStateLoss(); - LogUtil.i(TAG, "showPDFFragment"); - } - - public void showServiceDialog() { - View servicePanel = findViewById(R.id.service_panel); - final ServicePresent servicePresent = new ServicePresent(this, servicePanel); - DialogInterface.OnDismissListener dismissListener = new DialogInterface.OnDismissListener() { - @Override - public void onDismiss(DialogInterface dialog) { - service.setVisibility(View.VISIBLE); - servicePresent.dismiss(); - } - }; - servicePresent.setDismissListener(dismissListener); - servicePresent.show(); - } - - - public String getImei() { - TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); - String uid = UUID.randomUUID().toString().replace("-","").substring(0,15); - String saveIime = SPUtils.getString(this,"IMEI"); - String szImei = "" ; - if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) { - szImei = TelephonyMgr.getDeviceId(); - if("0000000000000".equals(szImei) || StringUtils.isEmpty(szImei)){ - if(saveIime != null){ - szImei = saveIime ; - }else{ - szImei = uid; - } - } - }else{ - if(saveIime != null){ - szImei = saveIime ; - }else{ - szImei = uid; - } - } - SPUtils.putString(this,"IMEI",szImei); - return szImei.toUpperCase(); - } - - public String password(){ - String password = EncryptUtils.encryptMD5ToString( "SUNVOTE" + getImei() + "SUNVOTE"); - password = EncryptUtils.encryptMD5ToString("SUNVOTE" + password + "SUNVOTE"); - if(password.length() > 6){ - password = password.substring(0,6); - } - return password; - } - - public boolean isUnlock(){ - String key = EncryptUtils.encryptMD5ToString(getImei() + password()); - return SPUtils.getBoolean(this,key,false); - } - - public void unlock(){ - String key = EncryptUtils.encryptMD5ToString(getImei() + password()); - SPUtils.putBoolean(this,key,true); - } - private AuthorizationFragment authorizationFragment ; - public void setUnlockScreen(){ - if(authorizationFragment == null) { - FragmentTransaction transaction = fm.beginTransaction(); - authorizationFragment = new AuthorizationFragment(); - transaction.replace(R.id.lockscreen, authorizationFragment); - transaction.commit(); - lockscreen.setVisibility(View.VISIBLE); - LogUtil.i(TAG, "setUnlockScreen"); - } - } - - public void removeUnlockScreen(){ - if(authorizationFragment != null) { + private void showFragment(Fragment frag){ + if(!(frag != null && fragment != null && frag.getClass().getSimpleName().equals(fragment.getClass().getSimpleName()))){ + fragment = frag; FragmentManager fm = getFragmentManager(); - FragmentTransaction tx = fm.beginTransaction(); - tx.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - tx.remove(authorizationFragment); - tx.commitAllowingStateLoss(); - lockscreen.setVisibility(View.GONE); - authorizationFragment = null; - } - } - - @Override - public boolean dispatchKeyEvent(KeyEvent event) { - if(authorizationFragment != null) { - authorizationFragment.dispatchKeyEvent(event); + FragmentTransaction transaction = fm.beginTransaction(); + transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); + transaction.replace(R.id.frame_content, fragment); + transaction.commitAllowingStateLoss(); } - return super.dispatchKeyEvent(event); } } diff --git a/C5/app/src/main/java/com/sunvote/xpadapp/base/BaseActivity.java b/C5/app/src/main/java/com/sunvote/xpadapp/base/BaseActivity.java index 350253b..6a3392d 100644 --- a/C5/app/src/main/java/com/sunvote/xpadapp/base/BaseActivity.java +++ b/C5/app/src/main/java/com/sunvote/xpadapp/base/BaseActivity.java @@ -151,50 +151,6 @@ public class BaseActivity extends FragmentActivity { return true; } - /*@Override - public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults); - switch (requestCode){ - case WRITE_EXTERNAL_STORAGE: - if (grantResults.length > 0 - && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - boolean p = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE) - && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE) - && checkSelfPermission(Manifest.permission.CAMERA,CAMERA) - && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION,ACCESS_COARSE_LOCATION); - } - break; - case READ_EXTERNAL_STORAGE: - if (grantResults.length > 0 - && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - boolean p = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE) - && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE) - && checkSelfPermission(Manifest.permission.CAMERA,CAMERA) - && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION,ACCESS_COARSE_LOCATION); - } - break; - case CAMERA: - if (grantResults.length > 0 - && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - boolean p = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE) - && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE) - && checkSelfPermission(Manifest.permission.CAMERA,CAMERA) - && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION,ACCESS_COARSE_LOCATION); - } - break; - - case ACCESS_COARSE_LOCATION: - if (grantResults.length > 0 - && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - boolean p = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE) - && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE) - && checkSelfPermission(Manifest.permission.CAMERA,CAMERA) - && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION,ACCESS_COARSE_LOCATION); - } - break; - } - }*/ - public void getScreenDensity_ByWindowManager(){ DisplayMetrics mDisplayMetrics = new DisplayMetrics();//屏幕分辨率容器 getWindowManager().getDefaultDisplay().getMetrics(mDisplayMetrics); @@ -202,8 +158,6 @@ public class BaseActivity extends FragmentActivity { int height = mDisplayMetrics.heightPixels; float density = mDisplayMetrics.density; int densityDpi = mDisplayMetrics.densityDpi; -// showToast("Screen Ratio: ["+width+"x"+height+"],density="+density+",densityDpi="+densityDpi); -// showToast("Screen mDisplayMetrics: "+mDisplayMetrics); LogUtil.i(TAG,"Screen Ratio: ["+width+"x"+height+"],density="+density+",densityDpi="+densityDpi); LogUtil.i(TAG,"Screen mDisplayMetrics: "+mDisplayMetrics); } diff --git a/C5/app/src/main/java/com/sunvote/xpadapp/fragments/AdminFragment.java b/C5/app/src/main/java/com/sunvote/xpadapp/fragments/AdminFragment.java index 75f14e7..462b79f 100644 --- a/C5/app/src/main/java/com/sunvote/xpadapp/fragments/AdminFragment.java +++ b/C5/app/src/main/java/com/sunvote/xpadapp/fragments/AdminFragment.java @@ -34,7 +34,6 @@ public class AdminFragment extends BaseFragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_admin, container, false); - mMainActivity.adminFragment = this; tvModalInfo = view.findViewById(R.id.admin_modal_info); btnBack = view.findViewById(R.id.admin_btnback); @@ -53,7 +52,6 @@ public class AdminFragment extends BaseFragment { @Override public void onClick(View v) { LogUtil.d("AdminFragment", "btnConfig"); - mMainActivity.presenter.configMode(); Toast.makeText(getActivity(),R.string.modify_id_msg,Toast.LENGTH_SHORT).show(); } @@ -102,21 +100,17 @@ public class AdminFragment extends BaseFragment { @Override public void onResume() { - mMainActivity.showBottomUIMenu(); super.onResume(); } @Override public void onStop() { - mMainActivity.hideBottomUIMenu(); - mMainActivity.adminFragment = null; super.onStop(); } @Override public void onDetach() { super.onDetach(); - mMainActivity.adminFragment = null; } private String getVersionName() {