From 49b6752a0f05e10c7d1b15fc32a2f27a59c88e5d Mon Sep 17 00:00:00 2001 From: Elvis Date: Fri, 15 Mar 2019 14:14:04 +0800 Subject: [PATCH] 批次表决 --- C5/app/src/main/java/com/sunvote/xpadapp/fragments/MultiTitleFragment.java | 46 +++++++++++++++++++--------------------------- C5/app/src/main/java/com/sunvote/xpadapp/fragments/ResultVoteFragment.java | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------- C5/app/src/main/java/com/sunvote/xpadapp/fragments/UserResultVoteFragment.java | 34 +++++++++++++++++----------------- C5/app/src/main/res/drawable/bh_cicle.xml | 2 +- C5/app/src/main/res/layout/fragment_multi_title.xml | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------- C5/app/src/main/res/layout/fragment_result_vote.xml | 256 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------- C5/app/src/main/res/layout/list_multi_title_item.xml | 44 ++++++++++++++++++++++---------------------- C5/app/src/main/res/values/strings.xml | 6 +++--- 8 files changed, 328 insertions(+), 330 deletions(-) diff --git a/C5/app/src/main/java/com/sunvote/xpadapp/fragments/MultiTitleFragment.java b/C5/app/src/main/java/com/sunvote/xpadapp/fragments/MultiTitleFragment.java index 4a83714..3209df8 100644 --- a/C5/app/src/main/java/com/sunvote/xpadapp/fragments/MultiTitleFragment.java +++ b/C5/app/src/main/java/com/sunvote/xpadapp/fragments/MultiTitleFragment.java @@ -43,6 +43,7 @@ public class MultiTitleFragment extends BaseFragment implements TitleVoteOnBack BillInfo bill; private TextView tvTitle; private ListView listview; + private View tvInfoLayout; private TextView tvInfo; private TextView tvPage; private Button btnConfirm; @@ -109,39 +110,23 @@ public class MultiTitleFragment extends BaseFragment implements TitleVoteOnBack tvTitle = (TextView) view.findViewById(R.id.multivote_title); tvTitle.setText(replaceBlank(bill.title)); + tvInfoLayout = view.findViewById(R.id.multivote_info_layout); tvInfo = (TextView) view.findViewById(R.id.multivote_info); tvInfo.setText(""); - bottomLayout = (RelativeLayout) view.findViewById(R.id.multivote_pannal_bottom); - confirmLayout = (RelativeLayout) view.findViewById(R.id.multivote_confirm_panel); - tvConfirmText = (TextView) view.findViewById(R.id.multivote_confirm_text); - - // tvPage = (TextView) view.findViewById(R.id.multivote_page); - View btnPageUp = view.findViewById(R.id.multivote_pageup); - View btnPageDown = view.findViewById(R.id.multivote_pagedown); - View btnPageEnd = view.findViewById(R.id.multivote_pageend); - - btnPageUp.setOnClickListener(new OnClickListener() { - + tvInfo.setBackgroundResource(0); + tvInfoLayout.setVisibility(View.GONE); + tvInfoLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - listview.smoothScrollByOffset(-2); - } - }); - btnPageDown.setOnClickListener(new OnClickListener() { - - @Override - public void onClick(View v) { - listview.smoothScrollByOffset(2); } }); + bottomLayout = (RelativeLayout) view.findViewById(R.id.multivote_pannal_bottom); + confirmLayout = (RelativeLayout) view.findViewById(R.id.multivote_confirm_panel); + tvConfirmText = (TextView) view.findViewById(R.id.multivote_confirm_text); + + // tvPage = (TextView) view.findViewById(R.id.multivote_page); - btnPageEnd.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - listview.setSelection(mAdapter.getCount() - 1); - } - }); btnConfirm = (Button) view.findViewById(R.id.multivote_btn_submit); btnConfirm.setOnClickListener(new OnClickListener() { @@ -246,6 +231,7 @@ public class MultiTitleFragment extends BaseFragment implements TitleVoteOnBack // tvPage.setText(page + "/" + totalPage); tvInfo.setText(""); + tvInfoLayout.setVisibility(View.GONE); showVote(false); checkIsVoted(); return view; @@ -271,6 +257,7 @@ public class MultiTitleFragment extends BaseFragment implements TitleVoteOnBack private void doSubmitAllOk() { tvInfo.setText(getString(R.string.submiting)); + tvInfo.setBackgroundResource(0); btnConfirm.setEnabled(false); disableVote(); mMainActivity.presenter.submitVoteAllOK(); @@ -413,10 +400,15 @@ public class MultiTitleFragment extends BaseFragment implements TitleVoteOnBack private void showModifyOrDisable() { if (voteInfo.mode2_modify == 1) { btnModify.setVisibility(View.VISIBLE); - tvInfo.setText(getString(R.string.submited)); +// tvInfo.setText(getString(R.string.submited)); + tvInfo.setBackgroundResource(R.drawable.voted); + tvInfoLayout.setVisibility(View.VISIBLE); } else { disableVote(); - tvInfo.setText(getString(R.string.submited_no_modify)); +// tvInfo.setText(getString(R.string.submited)); + tvInfo.setBackgroundResource(R.drawable.voted); + tvInfoLayout.setVisibility(View.VISIBLE); +// tvInfo.setText(getString(R.string.submited_no_modify)); } } diff --git a/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ResultVoteFragment.java b/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ResultVoteFragment.java index 0ee459a..2dce17c 100644 --- a/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ResultVoteFragment.java +++ b/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ResultVoteFragment.java @@ -8,6 +8,7 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.LinearLayout; +import android.widget.RelativeLayout; import android.widget.TextView; import com.sunvote.util.LogUtil; @@ -16,6 +17,8 @@ import com.sunvote.xpadapp.R; import com.sunvote.xpadapp.base.BaseFragment; import com.sunvote.xpadcomm.XPadApiInterface; +import org.apache.tools.ant.Main; + import java.text.DecimalFormat; public class ResultVoteFragment extends BaseFragment { @@ -28,9 +31,12 @@ public class ResultVoteFragment extends BaseFragment { private TextView fragmentResultMemo; private TextView fragmentMemo; // - private LinearLayout tResult; - private LinearLayout dResult; - private LinearLayout pResult; + private RelativeLayout dataTitleLayout1; + private RelativeLayout dataTitleLayout2; + private RelativeLayout dataTitleLayout3; + private RelativeLayout dataTitleLayout4; +// private LinearLayout dResult; +// private LinearLayout pResult; public static String formatDoubleToString(double value, Integer digits, boolean remove) { if (value == 0 || value == 100) { @@ -75,6 +81,12 @@ public class ResultVoteFragment extends BaseFragment { return tv1; } + @Override + public void onResume() { + super.onResume(); + ((MainActivity)getActivity()).setBackgroundColor(Color.parseColor("#042148")); + } + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_result_vote, container, false); root.setOnClickListener(new OnClickListener() { @@ -86,10 +98,12 @@ public class ResultVoteFragment extends BaseFragment { shidaoresult = root.findViewById(R.id.shidaoresult); fragmentResultMemo = root.findViewById(R.id.fragment_result_memo); fragmentMemo = root.findViewById(R.id.fragment_memo); - ((MainActivity)getActivity()).setBackgroundColor(Color.parseColor("#042160")); - tResult = root.findViewById(R.id.t_result); - dResult = root.findViewById(R.id.d_result); - pResult = root.findViewById(R.id.p_result); + + dataTitleLayout1 = root.findViewById(R.id.data_title_layout1); + dataTitleLayout2 = root.findViewById(R.id.data_title_layout2); + dataTitleLayout3 = root.findViewById(R.id.data_title_layout3); + dataTitleLayout4 = root.findViewById(R.id.data_title_layout4); + showResult(); return root; } @@ -99,10 +113,6 @@ public class ResultVoteFragment extends BaseFragment { int xiaoShuWei = (voteInfo.resultInfo.bits >> 4) & 0xF; int fenmu = voteInfo.resultInfo.num0; LogUtil.d(TAG, "xiaoshu:" + xiaoShuWei + " fenmu:" + fenmu); - tResult.removeAllViews(); - dResult.removeAllViews(); - pResult.removeAllViews(); - if (voteInfo.resultInfo.num1 != 0xffff) { yingdaoresult.setText("" + voteInfo.resultInfo.num1); } @@ -132,20 +142,31 @@ public class ResultVoteFragment extends BaseFragment { swa = formatDoubleToString(pwa, xiaoShuWei, false); } if (voteInfo.resultInfo.num4 != 0xffff) { - tResult.addView(createView(getString(R.string.agree),Color.YELLOW),lp); - dResult.addView(createView("" + voteInfo.resultInfo.num4,Color.WHITE),lp); - pResult.addView(createView( szc + "%",Color.WHITE),lp); - + dataTitleLayout1.setVisibility(View.VISIBLE); + String text = "" + voteInfo.resultInfo.num4 ; + if(szc != null && !"".equals(szc)){ + text += "(" + szc + "%)" ; + } + ((TextView)(dataTitleLayout1.findViewById(R.id.data_title_layout1_text1))).setText(getString(R.string.agree)); + ((TextView)(dataTitleLayout1.findViewById(R.id.data_title_layout1_text2))).setText(text); } if (voteInfo.resultInfo.num5 != 0xffff) { - tResult.addView(createView(getString(R.string.oppose),Color.YELLOW),lp); - dResult.addView(createView("" + voteInfo.resultInfo.num5,Color.WHITE),lp); - pResult.addView(createView( sfd + "%",Color.WHITE),lp); + dataTitleLayout2.setVisibility(View.VISIBLE); + String text = "" + voteInfo.resultInfo.num5 ; + if(sfd != null && !"".equals(sfd)){ + text += "(" + sfd + "%)" ; + } + ((TextView)(dataTitleLayout2.findViewById(R.id.data_title_layout2_text1))).setText(getString(R.string.oppose)); + ((TextView)(dataTitleLayout2.findViewById(R.id.data_title_layout2_text2))).setText(text); } if (voteInfo.resultInfo.num3 != 0xffff) { - tResult.addView(createView(getString(R.string.weian),Color.YELLOW),lp); - dResult.addView(createView("" + voteInfo.resultInfo.num3,Color.WHITE),lp); - pResult.addView(createView( swa + "%",Color.WHITE),lp); + dataTitleLayout3.setVisibility(View.VISIBLE); + String text = "" + voteInfo.resultInfo.num3 ; + if(swa != null && !"".equals(swa)){ + text += "(" + swa + "%)" ; + } + ((TextView)(dataTitleLayout3.findViewById(R.id.data_title_layout3_text1))).setText(getString(R.string.weian)); + ((TextView)(dataTitleLayout3.findViewById(R.id.data_title_layout3_text2))).setText(text); } } else { String szc = ""; @@ -160,57 +181,83 @@ public class ResultVoteFragment extends BaseFragment { swa = formatDoubleToString(pwa, xiaoShuWei, false); } if (voteInfo.resultInfo.num4 != 0xffff) { - dResult.addView(createView("" + voteInfo.resultInfo.num4,Color.WHITE), lp); - pResult.addView(createView(szc + "%",Color.WHITE), lp); + + dataTitleLayout1.setVisibility(View.VISIBLE); + String text = "" + voteInfo.resultInfo.num4 ; + if(szc != null && !"".equals(szc)){ + text += "(" + szc + "%)" ; + } + ((TextView)(dataTitleLayout1.findViewById(R.id.data_title_layout1_text2))).setText(text); } if (voteInfo.resultInfo.num5 != 0xffff) { - dResult.addView(createView("" + voteInfo.resultInfo.num5,Color.WHITE), lp); - pResult.addView(createView(sfd + "%",Color.WHITE), lp); + dataTitleLayout2.setVisibility(View.VISIBLE); + String text = "" + voteInfo.resultInfo.num5 ; + if(szc != null && !"".equals(szc)){ + text += "(" + szc + "%)" ; + } + ((TextView)(dataTitleLayout2.findViewById(R.id.data_title_layout2_text2))).setText(text); } if (voteInfo.resultInfo.num6 != 0xffff) { - dResult.addView(createView("" + voteInfo.resultInfo.num6,Color.WHITE), lp); - pResult.addView(createView(swa + "%",Color.WHITE), lp); + dataTitleLayout1.setVisibility(View.VISIBLE); + String text = "" + voteInfo.resultInfo.num6 ; + if(szc != null && !"".equals(szc)){ + text += "(" + szc + "%)" ; + } + ((TextView)(dataTitleLayout3.findViewById(R.id.data_title_layout3_text2))).setText(text); } if (voteInfo.resultInfo.resultType == 2) { fragmentMemo.setText(getString(R.string.biaojue_result)); if (voteInfo.resultInfo.num4 != 0xffff) { - tResult.addView(createView(getString(R.string.agree),Color.YELLOW), lp); + dataTitleLayout1.setVisibility(View.VISIBLE); + ((TextView)(dataTitleLayout1.findViewById(R.id.data_title_layout1_text1))).setText(getString(R.string.agree)); } if (voteInfo.resultInfo.num5 != 0xffff) { - tResult.addView(createView(getString(R.string.oppose),Color.YELLOW), lp); + dataTitleLayout2.setVisibility(View.VISIBLE); + ((TextView)(dataTitleLayout2.findViewById(R.id.data_title_layout2_text1))).setText(getString(R.string.oppose)); } if (voteInfo.resultInfo.num6 != 0xffff) { - tResult.addView(createView(getString(R.string.abstant),Color.YELLOW), lp); + dataTitleLayout3.setVisibility(View.VISIBLE); + ((TextView)(dataTitleLayout3.findViewById(R.id.data_title_layout3_text1))).setText(getString(R.string.abstant)); } } else if (voteInfo.resultInfo.resultType == 4) { fragmentMemo.setText(getString(R.string.ceping_result)); if (voteInfo.resultInfo.num4 != 0xffff) { - tResult.addView(createView(getString(R.string.manyi),Color.YELLOW), lp); + dataTitleLayout1.setVisibility(View.VISIBLE); + ((TextView)(dataTitleLayout1.findViewById(R.id.data_title_layout1_text1))).setText(getString(R.string.manyi)); } if (voteInfo.resultInfo.num5 != 0xffff) { - tResult.addView(createView(getString(R.string.jbmanyi),Color.YELLOW), lp); + dataTitleLayout2.setVisibility(View.VISIBLE); + ((TextView)(dataTitleLayout2.findViewById(R.id.data_title_layout2_text1))).setText(getString(R.string.jbmanyi)); } if (voteInfo.resultInfo.num6 != 0xffff) { - tResult.addView(createView(getString(R.string.bumanyi),Color.YELLOW), lp); + dataTitleLayout3.setVisibility(View.VISIBLE); + ((TextView)(dataTitleLayout3.findViewById(R.id.data_title_layout3_text1))).setText(getString(R.string.bumanyi)); } } else if (voteInfo.resultInfo.resultType == 12) { fragmentMemo.setText(getString(R.string.ceping_result)); if (voteInfo.resultInfo.num4 != 0xffff) { - tResult.addView(createView(getString(R.string.manyi),Color.YELLOW), lp); + dataTitleLayout1.setVisibility(View.VISIBLE); + ((TextView)(dataTitleLayout1.findViewById(R.id.data_title_layout1_text1))).setText(getString(R.string.manyi)); } if (voteInfo.resultInfo.num5 != 0xffff) { - tResult.addView(createView(getString(R.string.bumanyi),Color.YELLOW), lp); + dataTitleLayout2.setVisibility(View.VISIBLE); + ((TextView)(dataTitleLayout2.findViewById(R.id.data_title_layout2_text1))).setText(getString(R.string.bumanyi)); } if (voteInfo.resultInfo.num6 != 0xffff) { - tResult.addView(createView(getString(R.string.fcbumanyi),Color.YELLOW), lp); + dataTitleLayout3.setVisibility(View.VISIBLE); + ((TextView)(dataTitleLayout3.findViewById(R.id.data_title_layout3_text1))).setText(getString(R.string.fcbumanyi)); } } if(voteInfo.resultInfo.num3 != 0xffff){ double opt4 = voteInfo.resultInfo.num3 * 1.0 / fenmu * 100; String strOpt4 = formatDoubleToString(opt4, xiaoShuWei, false); - tResult.addView(createView(getString(R.string.weian),Color.YELLOW),lp); - dResult.addView(createView("" +voteInfo.resultInfo.num3 ,Color.WHITE),lp); - pResult.addView(createView(strOpt4 + "%",Color.WHITE),lp); + dataTitleLayout4.setVisibility(View.VISIBLE); + ((TextView)(dataTitleLayout4.findViewById(R.id.data_title_layout4_text1))).setText(getString(R.string.weian)); + String text = "" + voteInfo.resultInfo.num3 ; + if(strOpt4 != null && !"".equals(strOpt4)){ + text += "(" + strOpt4 + "%)" ; + } + ((TextView)(dataTitleLayout4.findViewById(R.id.data_title_layout4_text2))).setText(text); } } } diff --git a/C5/app/src/main/java/com/sunvote/xpadapp/fragments/UserResultVoteFragment.java b/C5/app/src/main/java/com/sunvote/xpadapp/fragments/UserResultVoteFragment.java index 8bc4f87..48d4cb1 100644 --- a/C5/app/src/main/java/com/sunvote/xpadapp/fragments/UserResultVoteFragment.java +++ b/C5/app/src/main/java/com/sunvote/xpadapp/fragments/UserResultVoteFragment.java @@ -37,9 +37,9 @@ public class UserResultVoteFragment extends BaseFragment { private TextView fragmentResultMemo; private TextView fragmentMemo; // - private LinearLayout tResult; - private LinearLayout dResult; - private LinearLayout pResult; +// private LinearLayout tResult; +// private LinearLayout dResult; +// private LinearLayout pResult; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_result_vote, container, false); @@ -48,9 +48,9 @@ public class UserResultVoteFragment extends BaseFragment { fragmentResultMemo = root.findViewById(R.id.fragment_result_memo); fragmentMemo = root.findViewById(R.id.fragment_memo); - tResult = root.findViewById(R.id.t_result); - dResult = root.findViewById(R.id.d_result); - pResult = root.findViewById(R.id.p_result); +// tResult = root.findViewById(R.id.t_result); +// dResult = root.findViewById(R.id.d_result); +// pResult = root.findViewById(R.id.p_result); showResult(); return root; } @@ -130,9 +130,9 @@ public class UserResultVoteFragment extends BaseFragment { } private void setView(int pos, int digiters, int bitNum, int type) { - tResult.removeAllViews(); - dResult.removeAllViews(); - pResult.removeAllViews(); +// tResult.removeAllViews(); +// dResult.removeAllViews(); +// pResult.removeAllViews(); LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.WRAP_CONTENT,1.0f); for(int i = 1; i <= options.length ; i++) { if (options.length >= i) { @@ -142,32 +142,32 @@ public class UserResultVoteFragment extends BaseFragment { } else { value1 = (data[pos++] << 8 | data[pos++]) & 0xffff; } - tResult.addView(createView(options[i - 1], Color.YELLOW), lp); - dResult.addView(createView("" + value1, Color.WHITE), lp); +// tResult.addView(createView(options[i - 1], Color.YELLOW), lp); +// dResult.addView(createView("" + value1, Color.WHITE), lp); if (type == 1) { //分母 if ((fenmu > 0 && fenmu != 0xff)) { double pzc = value1 * 1.0 / fenmu * 100; String szc = formatDoubleToString(pzc, digiters, false); - pResult.addView(createView(szc + "%", Color.WHITE), lp); +// pResult.addView(createView(szc + "%", Color.WHITE), lp); } } else { //分母 if ((fenmu > 0 && fenmu != 0xffff)) { double pzc = value1 * 1.0 / fenmu * 100; String szc = formatDoubleToString(pzc, digiters, false); - pResult.addView(createView(szc + "%", Color.WHITE), lp); +// pResult.addView(createView(szc + "%", Color.WHITE), lp); } } } } if (notVote != 0xff) { - tResult.addView(createView(getString(R.string.weian), Color.YELLOW), lp); - dResult.addView(createView("" + notVote, Color.WHITE), lp); +// tResult.addView(createView(getString(R.string.weian), Color.YELLOW), lp); +// dResult.addView(createView("" + notVote, Color.WHITE), lp); if ((fenmu > 0 && fenmu != 0xff)) { - pResult.addView(createView("0%", Color.WHITE), lp); +// pResult.addView(createView("0%", Color.WHITE), lp); }else{ - pResult.setVisibility(View.GONE); +// pResult.setVisibility(View.GONE); } } } diff --git a/C5/app/src/main/res/drawable/bh_cicle.xml b/C5/app/src/main/res/drawable/bh_cicle.xml index d8b43bd..c3c73ed 100644 --- a/C5/app/src/main/res/drawable/bh_cicle.xml +++ b/C5/app/src/main/res/drawable/bh_cicle.xml @@ -2,7 +2,7 @@ - + diff --git a/C5/app/src/main/res/layout/fragment_multi_title.xml b/C5/app/src/main/res/layout/fragment_multi_title.xml index ba921af..588b99d 100644 --- a/C5/app/src/main/res/layout/fragment_multi_title.xml +++ b/C5/app/src/main/res/layout/fragment_multi_title.xml @@ -7,98 +7,90 @@ + android:paddingRight="@dimen/px120dp"> + android:textSize="@dimen/px60dp" /> + + - - -