From 31cd9deb6ca489cb4402d731f7bc47082baa2908 Mon Sep 17 00:00:00 2001 From: wutaian Date: Fri, 15 Mar 2019 18:18:01 +0800 Subject: [PATCH] 修改民事投票结果显示 --- C5/app/src/main/java/com/sunvote/xpadapp/MainActivity.java | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- C5/app/src/main/java/com/sunvote/xpadapp/db/DBManager.java | 3 +++ C5/app/src/main/java/com/sunvote/xpadapp/db/modal/BillInfo.java | 1 + C5/app/src/main/java/com/sunvote/xpadapp/fragments/ElectionCustomFragment.java | 9 +++++---- C5/app/src/main/java/com/sunvote/xpadapp/fragments/ResultElectionCustomFragment.java | 98 ++++++++++---------------------------------------------------------------------------------------- 5 files changed, 74 insertions(+), 93 deletions(-) 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 a469b42..b723513 100644 --- a/C5/app/src/main/java/com/sunvote/xpadapp/MainActivity.java +++ b/C5/app/src/main/java/com/sunvote/xpadapp/MainActivity.java @@ -57,6 +57,7 @@ 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.ResultElectionCustomFragment; import com.sunvote.xpadapp.fragments.UserResultVoteFragment; import com.sunvote.xpadapp.fragments.NoFileFragment; import com.sunvote.xpadapp.fragments.OfflineFragment; @@ -150,6 +151,7 @@ public class MainActivity extends BaseActivity implements ComListener { private final int MSG_CLEAN_FILE = 101; public BroadcastReceiver batteryLevelRcvr; + private final int Msg_ShowElectionCustom = 70; // WifiManager wifiManager; // WiFiConnecter wac; @@ -449,9 +451,11 @@ public class MainActivity extends BaseActivity implements ComListener { break; case Msg_ShowMultiVoteResult: - showMultiVoteResultFragment((byte[]) msg.obj); break; + case Msg_ShowElectionCustom: + showElectionCustomFragment((byte[]) msg.obj); + break; case Msg_ShowElectionVoteResult: showResultElectionFragment((byte[]) msg.obj); break; @@ -723,6 +727,37 @@ public class MainActivity extends BaseActivity implements ComListener { LogUtil.i(TAG, "showVoteResultFragment buffer"); } + private void showElectionCustomFragment(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(); + ResultElectionCustomFragment fr = new ResultElectionCustomFragment(); + 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 showMultiVoteResultFragment(byte[] buffer) { int voteId = buffer[3] & 0xff; @@ -1732,6 +1767,25 @@ public class MainActivity extends BaseActivity implements ComListener { if(isInVoteState()){ return; } + + if(currBillInfo!=null) { + if (currBillInfo.billmodel == 1) { //民事选举 + 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_ShowElectionCustom; + message.obj = buf; + myHandler.sendMessage(message); + return; + } + } + } + if ((data[0] & 0xff) == 0xF2 && data[1] == 20) { if (tmpMulResultBuffer != null && Arrays.equals(buf, tmpMulResultBuffer)) { Log.e(TAG, "onMultiPackageData same data,abort"); diff --git a/C5/app/src/main/java/com/sunvote/xpadapp/db/DBManager.java b/C5/app/src/main/java/com/sunvote/xpadapp/db/DBManager.java index bfcf950..4c2459a 100644 --- a/C5/app/src/main/java/com/sunvote/xpadapp/db/DBManager.java +++ b/C5/app/src/main/java/com/sunvote/xpadapp/db/DBManager.java @@ -116,6 +116,9 @@ public class DBManager { info.memo = c.getString(c.getColumnIndex("BillMemo")); info.billFile = c.getString(c.getColumnIndex("BillFile")); info.billOptions = c.getString(c.getColumnIndex("BillPar")); + if(c.getColumnIndex("BillMode")>0){ + info.billmodel = c.getInt(c.getColumnIndex("BillMode")); + } break; } } catch (Exception e) { diff --git a/C5/app/src/main/java/com/sunvote/xpadapp/db/modal/BillInfo.java b/C5/app/src/main/java/com/sunvote/xpadapp/db/modal/BillInfo.java index c2060ad..6d2c4df 100644 --- a/C5/app/src/main/java/com/sunvote/xpadapp/db/modal/BillInfo.java +++ b/C5/app/src/main/java/com/sunvote/xpadapp/db/modal/BillInfo.java @@ -16,6 +16,7 @@ public class BillInfo { public String memo; //投票内容 public String billFile;//议案文件名 public String billOptions;//评议选项 + public int billmodel;//模式1:民事 public int voteResult; public int voteStatus; diff --git a/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ElectionCustomFragment.java b/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ElectionCustomFragment.java index 6c15bf2..82f7378 100644 --- a/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ElectionCustomFragment.java +++ b/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ElectionCustomFragment.java @@ -23,6 +23,7 @@ import com.sunvote.xpadapp.R; import com.sunvote.xpadapp.base.BaseFragment; import com.sunvote.xpadapp.db.modal.BillInfo; import com.sunvote.xpadapp.db.modal.MultiTitleItem; +import com.sunvote.xpadapp.dialog.ToastAlertDialog; import com.sunvote.xpadapp.utils.SharedPreferencesUtil; import com.sunvote.xpadcomm.XPadApi; import com.sunvote.xpadcomm.XPadApiInterface; @@ -218,17 +219,17 @@ public class ElectionCustomFragment extends BaseFragment { private void confirmInfo(){ btnConfirm.setEnabled(false); if (agreeVotedCount < voteInfo.limitFavor) { - Toast.makeText(mMainActivity, "需投赞成票"+voteInfo.limitFavor+"张", Toast.LENGTH_SHORT).show(); + ToastAlertDialog.makeText(mMainActivity, "需投票"+voteInfo.limitFavor+"张").show(); btnConfirm.setEnabled(true); return; } - int count = agreeVotedCount+opposeVotedCount+abstantVotedCount; + /* int count = agreeVotedCount+opposeVotedCount+abstantVotedCount; if(count= voteInfo.limitFavor){ - Toast.makeText(mMainActivity, "只允许投赞成票"+ voteInfo.limitFavor + getString(R.string.fix), Toast.LENGTH_SHORT).show(); + ToastAlertDialog.makeText(mMainActivity, "已投"+agreeVotedCount+getString(R.string.fix)+",不可多选").show(); checkVoted(); return; } diff --git a/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ResultElectionCustomFragment.java b/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ResultElectionCustomFragment.java index dd19318..4457075 100644 --- a/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ResultElectionCustomFragment.java +++ b/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ResultElectionCustomFragment.java @@ -62,7 +62,7 @@ public class ResultElectionCustomFragment extends BaseFragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LogUtil.d(TAG, "onCreateView"); - View view = inflater.inflate(R.layout.fragment_result_multi_vote, container, false); + View view = inflater.inflate(R.layout.fragment_result_election_custom, container, false); final MainActivity mact = (MainActivity) getActivity(); view.setOnClickListener(new OnClickListener() { @@ -72,7 +72,7 @@ public class ResultElectionCustomFragment extends BaseFragment { } }); - listview = (ListView) view.findViewById(R.id.multi_vote_result_listview); + listview = (ListView) view.findViewById(R.id.fragment_result_election_list); options = bill.billOptions.split("/"); try { @@ -82,27 +82,13 @@ public class ResultElectionCustomFragment extends BaseFragment { mAdapter = new MyAdapter(getActivity()); listview.setAdapter(mAdapter); - tvTitle = (TextView) view.findViewById(R.id.multi_vote_result_tv_title); + tvTitle = (TextView) view.findViewById(R.id.tv_title); if (bill != null) { - tvTitle.setText( replaceBlank(bill.title)); + tvTitle.setText(replaceBlank(bill.title)); } - titleAbstain = (TextView) view.findViewById(R.id.multi_vote_result_title_abstan); - titleUnvote = (TextView) view.findViewById(R.id.multi_vote_result_title_unvote); - titleResult = (TextView) view.findViewById(R.id.multi_vote_result_title_result); - - if (resultBits == 0xffff) { - titleResult.setVisibility(View.GONE); - } else { - titleResult.setVisibility(View.VISIBLE); - } - if (options.length == 2) { - titleAbstain.setVisibility(View.GONE); - } else { - titleAbstain.setVisibility(View.VISIBLE); - } - TextView tvYindao = (TextView) view.findViewById(R.id.multi_vote_result_yindao); - TextView tvShidao = (TextView) view.findViewById(R.id.multi_vote_result_shidao); + TextView tvYindao = (TextView) view.findViewById(R.id.yingdaoresult); + TextView tvShidao = (TextView) view.findViewById(R.id.shidaoresult); if (yindao == 0xff || yindao == 0xffff) { tvYindao.setVisibility(View.GONE); } else { @@ -116,7 +102,6 @@ public class ResultElectionCustomFragment extends BaseFragment { tvShidao.setText("" + shidao); tvShidao.setVisibility(View.VISIBLE); } - return view; } @@ -321,31 +306,21 @@ public class ResultElectionCustomFragment extends BaseFragment { LogUtil.v("BaseAdapterTest", "getView " + position + " " + convertView); if (convertView == null) { - convertView = mInflater.inflate(R.layout.list_multi_vote_result_item, null); + convertView = mInflater.inflate(R.layout.list_result_election_custom_item, null); holder = new ViewHolder(); - - holder.tvNum = (TextView) convertView.findViewById(R.id.list_multi_result_item_num); - holder.tvTitle = (TextView) convertView.findViewById(R.id.list_multi_result_item_name); - holder.tvAgree = (TextView) convertView.findViewById(R.id.list_multi_result_item_agree); - holder.tvOppose = (TextView) convertView.findViewById(R.id.list_multi_result_item_oppose); - holder.tvAbstain = (TextView) convertView.findViewById(R.id.list_multi_result_item_abstan); - holder.tvUnvote = (TextView) convertView.findViewById(R.id.list_multi_result_item_unvote); - holder.tvResult = (TextView) convertView.findViewById(R.id.list_multi_result_item_result); + holder.tvNum = (TextView) convertView.findViewById(R.id.item_result_election_num); + holder.tvTitle = (TextView) convertView.findViewById(R.id.item_result_election_name); + holder.tvAgree = (TextView) convertView.findViewById(R.id.item_result_election_agree); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } - - ListItem it = aryContent.get(position); holder.tvNum.setText(String.valueOf(it.No)); holder.tvTitle.setText(it.title); - - holder.tvOppose.setText(String.valueOf(it.oppose)); - holder.tvAbstain.setText(String.valueOf(it.abstain)); if(it.agree != 0xff && it.agree != 0xffff){ holder.tvAgree.setVisibility(View.VISIBLE); holder.tvAgree.setText(String.valueOf(it.agree)); @@ -353,66 +328,13 @@ public class ResultElectionCustomFragment extends BaseFragment { holder.tvAgree.setVisibility(View.INVISIBLE); holder.tvAgree.setText(""); } - if(it.oppose != 0xff && it.oppose != 0xffff){ - holder.tvOppose.setVisibility(View.VISIBLE); - holder.tvOppose.setText(String.valueOf(it.oppose)); - }else{ - holder.tvOppose.setVisibility(View.INVISIBLE); - holder.tvOppose.setText(""); - } - if(it.abstain != 0xff && it.abstain != 0xffff){ - holder.tvAbstain.setVisibility(View.VISIBLE); - holder.tvAbstain.setText(String.valueOf(it.abstain)); - }else{ - holder.tvAbstain.setVisibility(View.INVISIBLE); - holder.tvAbstain.setText(""); - } - - if (it.unvote != 0xff && it.unvote != 0xffff) { - titleUnvote.setVisibility(View.VISIBLE); - holder.tvUnvote.setVisibility(View.VISIBLE); - holder.tvUnvote.setText(String.valueOf(it.unvote)); - } else { - titleUnvote.setVisibility(View.INVISIBLE); - holder.tvUnvote.setVisibility(View.INVISIBLE); - holder.tvUnvote.setText(""); - - } - - String strPass = ""; - - if (it.pass == 0) { - strPass = getString(R.string.no_pass); - } else if (it.pass == 1) { - strPass = getString(R.string.pass); - } - - holder.tvResult.setText(strPass); - if (it.pass == 0xffff) { - holder.tvResult.setVisibility(View.GONE); - } else { - holder.tvResult.setVisibility(View.VISIBLE); - } - - if (options.length == 2) { - holder.tvAbstain.setVisibility(View.GONE); - - } else { - holder.tvAbstain.setVisibility(View.VISIBLE); - } - return convertView; } - public final class ViewHolder { public TextView tvNum; public TextView tvTitle; public TextView tvAgree; - public TextView tvOppose; - public TextView tvAbstain; - public TextView tvUnvote; - public TextView tvResult; } } } -- libgit2 0.21.4