作者 qin

bug修改

不能预览此文件类型
1 <component name="ProjectCodeStyleConfiguration"> 1 <component name="ProjectCodeStyleConfiguration">
2 <code_scheme name="Project" version="173"> 2 <code_scheme name="Project" version="173">
3 - <Objective-C-extensions>  
4 - <file>  
5 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />  
6 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />  
7 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />  
8 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />  
9 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />  
10 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />  
11 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />  
12 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />  
13 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />  
14 - </file>  
15 - <class>  
16 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />  
17 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />  
18 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />  
19 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />  
20 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />  
21 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />  
22 - </class>  
23 - <extensions>  
24 - <pair source="cpp" header="h" fileNamingConvention="NONE" />  
25 - <pair source="c" header="h" fileNamingConvention="NONE" />  
26 - </extensions>  
27 - </Objective-C-extensions> 3 + <codeStyleSettings language="XML">
  4 + <arrangement>
  5 + <rules>
  6 + <section>
  7 + <rule>
  8 + <match>
  9 + <AND>
  10 + <NAME>xmlns:android</NAME>
  11 + <XML_ATTRIBUTE />
  12 + <XML_NAMESPACE>^$</XML_NAMESPACE>
  13 + </AND>
  14 + </match>
  15 + </rule>
  16 + </section>
  17 + <section>
  18 + <rule>
  19 + <match>
  20 + <AND>
  21 + <NAME>xmlns:.*</NAME>
  22 + <XML_ATTRIBUTE />
  23 + <XML_NAMESPACE>^$</XML_NAMESPACE>
  24 + </AND>
  25 + </match>
  26 + <order>BY_NAME</order>
  27 + </rule>
  28 + </section>
  29 + <section>
  30 + <rule>
  31 + <match>
  32 + <AND>
  33 + <NAME>.*:id</NAME>
  34 + <XML_ATTRIBUTE />
  35 + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
  36 + </AND>
  37 + </match>
  38 + </rule>
  39 + </section>
  40 + <section>
  41 + <rule>
  42 + <match>
  43 + <AND>
  44 + <NAME>.*:name</NAME>
  45 + <XML_ATTRIBUTE />
  46 + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
  47 + </AND>
  48 + </match>
  49 + </rule>
  50 + </section>
  51 + <section>
  52 + <rule>
  53 + <match>
  54 + <AND>
  55 + <NAME>name</NAME>
  56 + <XML_ATTRIBUTE />
  57 + <XML_NAMESPACE>^$</XML_NAMESPACE>
  58 + </AND>
  59 + </match>
  60 + </rule>
  61 + </section>
  62 + <section>
  63 + <rule>
  64 + <match>
  65 + <AND>
  66 + <NAME>style</NAME>
  67 + <XML_ATTRIBUTE />
  68 + <XML_NAMESPACE>^$</XML_NAMESPACE>
  69 + </AND>
  70 + </match>
  71 + </rule>
  72 + </section>
  73 + <section>
  74 + <rule>
  75 + <match>
  76 + <AND>
  77 + <NAME>.*</NAME>
  78 + <XML_ATTRIBUTE />
  79 + <XML_NAMESPACE>^$</XML_NAMESPACE>
  80 + </AND>
  81 + </match>
  82 + <order>BY_NAME</order>
  83 + </rule>
  84 + </section>
  85 + <section>
  86 + <rule>
  87 + <match>
  88 + <AND>
  89 + <NAME>.*</NAME>
  90 + <XML_ATTRIBUTE />
  91 + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
  92 + </AND>
  93 + </match>
  94 + <order>ANDROID_ATTRIBUTE_ORDER</order>
  95 + </rule>
  96 + </section>
  97 + <section>
  98 + <rule>
  99 + <match>
  100 + <AND>
  101 + <NAME>.*</NAME>
  102 + <XML_ATTRIBUTE />
  103 + <XML_NAMESPACE>.*</XML_NAMESPACE>
  104 + </AND>
  105 + </match>
  106 + <order>BY_NAME</order>
  107 + </rule>
  108 + </section>
  109 + </rules>
  110 + </arrangement>
  111 + </codeStyleSettings>
28 </code_scheme> 112 </code_scheme>
29 </component> 113 </component>
@@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
12 </set> 12 </set>
13 </option> 13 </option>
14 <option name="resolveModulePerSourceSet" value="false" /> 14 <option name="resolveModulePerSourceSet" value="false" />
  15 + <option name="testRunner" value="PLATFORM" />
15 </GradleProjectSettings> 16 </GradleProjectSettings>
16 </option> 17 </option>
17 </component> 18 </component>
@@ -42,11 +42,11 @@ @@ -42,11 +42,11 @@
42 <activity 42 <activity
43 android:name=".MainActivity" 43 android:name=".MainActivity"
44 android:launchMode="singleTask"> 44 android:launchMode="singleTask">
45 - <!-- <intent-filter>  
46 - <action android:name="android.intent.action.MAIN" /> 45 + <!-- <intent-filter>
  46 + <action android:name="android.intent.action.MAIN" />
47 47
48 - <category android:name="android.intent.category.LAUNCHER" />  
49 - </intent-filter>--> 48 + <category android:name="android.intent.category.LAUNCHER" />
  49 + </intent-filter>-->
50 </activity> 50 </activity>
51 <activity 51 <activity
52 android:name=".activity.personal.InfromationActivity" 52 android:name=".activity.personal.InfromationActivity"
@@ -123,7 +123,16 @@ @@ -123,7 +123,16 @@
123 <activity 123 <activity
124 android:name=".activity.pratice.AnswerWrongActivity" 124 android:name=".activity.pratice.AnswerWrongActivity"
125 android:screenOrientation="portrait" /> 125 android:screenOrientation="portrait" />
126 - 126 + <activity
  127 + android:name=".activity.pratice.a"
  128 + android:screenOrientation="portrait" />
  129 + <activity
  130 + android:name=".activity.pratice.b"
  131 + android:screenOrientation="portrait" />
  132 + <activity
  133 + android:name=".activity.pratice.c"
  134 + android:screenOrientation="portrait" />
127 </application> 135 </application>
128 136
  137 +
129 </manifest> 138 </manifest>
@@ -5,6 +5,7 @@ import android.view.View; @@ -5,6 +5,7 @@ import android.view.View;
5 import android.widget.TextView; 5 import android.widget.TextView;
6 6
7 import com.hh.xuetubao.R; 7 import com.hh.xuetubao.R;
  8 +import com.hh.xuetubao.Utils.WaveView;
8 import com.hh.xuetubao.model.MainModel; 9 import com.hh.xuetubao.model.MainModel;
9 import com.hh.xuetubao.mvp.BaseMvpActivity; 10 import com.hh.xuetubao.mvp.BaseMvpActivity;
10 import com.hh.xuetubao.mvp.CommonPresenter; 11 import com.hh.xuetubao.mvp.CommonPresenter;
@@ -25,14 +26,16 @@ public class AnswerResultActivity extends BaseMvpActivity<CommonPresenter, MainM @@ -25,14 +26,16 @@ public class AnswerResultActivity extends BaseMvpActivity<CommonPresenter, MainM
25 TextView tvWrong; 26 TextView tvWrong;
26 @BindView(R.id.tv_next) 27 @BindView(R.id.tv_next)
27 TextView tvNext; 28 TextView tvNext;
  29 + @BindView(R.id.waveview)
  30 + WaveView waveview;
28 31
29 @Override 32 @Override
30 public void initView() { 33 public void initView() {
31 - int rightCount = getIntent().getIntExtra("rightCount",0);  
32 - int wrongCount = getIntent().getIntExtra("wrongCount",0); 34 + int rightCount = getIntent().getIntExtra("rightCount", 0);
  35 + int wrongCount = getIntent().getIntExtra("wrongCount", 0);
33 36
34 - tvRight.setText(String.valueOf(rightCount));  
35 - tvWrong.setText(String.valueOf(wrongCount)); 37 + tvRight.setText(String.valueOf(rightCount));
  38 + tvWrong.setText(String.valueOf(wrongCount));
36 39
37 tvNext.setOnClickListener(this); 40 tvNext.setOnClickListener(this);
38 } 41 }
@@ -374,6 +374,9 @@ public class AnswerWrongActivity extends BaseMvpActivity<CommonPresenter, Exerci @@ -374,6 +374,9 @@ public class AnswerWrongActivity extends BaseMvpActivity<CommonPresenter, Exerci
374 case R.id.tv_look: 374 case R.id.tv_look:
375 rlAnswer.setVisibility(View.VISIBLE); 375 rlAnswer.setVisibility(View.VISIBLE);
376 break; 376 break;
  377 + case R.id.tv_show_card:
  378 + break;
  379 +
377 } 380 }
378 } 381 }
379 382
@@ -117,7 +117,8 @@ public class MockExamActivity extends BaseMvpActivity<CommonPresenter, ExerciseM @@ -117,7 +117,8 @@ public class MockExamActivity extends BaseMvpActivity<CommonPresenter, ExerciseM
117 this.finish(); 117 this.finish();
118 break; 118 break;
119 case R.id.mock_exam_btn: // this - > 答题界面 119 case R.id.mock_exam_btn: // this - > 答题界面
120 - Intent intent = new Intent(this, AnswerActivity.class); 120 +// Intent intent = new Intent(this, AnswerActivity.class);
  121 + Intent intent = new Intent(this, b.class);
121 intent.putExtra("catalogOid", catalogOid); 122 intent.putExtra("catalogOid", catalogOid);
122 SharedPrefrenceUtils.saveString(this, "thisCatalogOid", catalogOid); 123 SharedPrefrenceUtils.saveString(this, "thisCatalogOid", catalogOid);
123 startActivity(intent); 124 startActivity(intent);
@@ -92,7 +92,6 @@ public class TestScoreActivity extends BaseMvpActivity<CommonPresenter, Exercise @@ -92,7 +92,6 @@ public class TestScoreActivity extends BaseMvpActivity<CommonPresenter, Exercise
92 tv11.setText(String.valueOf(duoxuanWrongt)); 92 tv11.setText(String.valueOf(duoxuanWrongt));
93 tv17.setText(String.valueOf(panduanWrong)); 93 tv17.setText(String.valueOf(panduanWrong));
94 94
95 -  
96 tv7.setText(getFormat(danxuanCount, danxuanWrong) + "%"); 95 tv7.setText(getFormat(danxuanCount, danxuanWrong) + "%");
97 tv13.setText(getFormat(duoxuanCount, duoxuanWrongt) + "%"); 96 tv13.setText(getFormat(duoxuanCount, duoxuanWrongt) + "%");
98 tv19.setText(getFormat(panduanCount, panduanWrong) + "%"); 97 tv19.setText(getFormat(panduanCount, panduanWrong) + "%");
@@ -179,12 +178,12 @@ public class TestScoreActivity extends BaseMvpActivity<CommonPresenter, Exercise @@ -179,12 +178,12 @@ public class TestScoreActivity extends BaseMvpActivity<CommonPresenter, Exercise
179 finish(); 178 finish();
180 break; 179 break;
181 case R.id.rl_allWrong: 180 case R.id.rl_allWrong:
182 - intent = new Intent(this, AnswerWrongActivity.class); 181 + intent = new Intent(this,c.class);
183 intent.putExtra("catalogOid", catalogOid); 182 intent.putExtra("catalogOid", catalogOid);
184 startActivity(intent); 183 startActivity(intent);
185 break; 184 break;
186 case R.id.rl_reStart: 185 case R.id.rl_reStart:
187 - intent = new Intent(this, AnswerActivity.class); 186 + intent = new Intent(this, b.class);
188 intent.putExtra("catalogOid", catalogOid); 187 intent.putExtra("catalogOid", catalogOid);
189 startActivity(intent); 188 startActivity(intent);
190 break; 189 break;
1 package com.hh.xuetubao.activity.pratice; 1 package com.hh.xuetubao.activity.pratice;
2 2
  3 +import android.content.Intent;
3 import android.os.Bundle; 4 import android.os.Bundle;
  5 +import android.text.TextUtils;
  6 +import android.util.Log;
  7 +import android.view.Gravity;
  8 +import android.view.LayoutInflater;
4 import android.view.View; 9 import android.view.View;
  10 +import android.view.ViewGroup;
5 import android.widget.AdapterView; 11 import android.widget.AdapterView;
  12 +import android.widget.GridView;
  13 +import android.widget.ImageView;
6 import android.widget.LinearLayout; 14 import android.widget.LinearLayout;
7 import android.widget.ListView; 15 import android.widget.ListView;
  16 +import android.widget.PopupWindow;
8 import android.widget.RelativeLayout; 17 import android.widget.RelativeLayout;
9 import android.widget.TextView; 18 import android.widget.TextView;
  19 +import android.widget.Toast;
10 20
11 import com.hh.xuetubao.R; 21 import com.hh.xuetubao.R;
12 import com.hh.xuetubao.Utils.SharedPrefrenceUtils; 22 import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
  23 +import com.hh.xuetubao.adapter.AnswerSheetGridAdapter;
13 import com.hh.xuetubao.adapter.ListAnswerAdapter; 24 import com.hh.xuetubao.adapter.ListAnswerAdapter;
14 import com.hh.xuetubao.bean.AnswerBean; 25 import com.hh.xuetubao.bean.AnswerBean;
15 import com.hh.xuetubao.model.ExerciseModel; 26 import com.hh.xuetubao.model.ExerciseModel;
@@ -74,8 +85,20 @@ public class a extends BaseMvpActivity<CommonPresenter, ExerciseModel> implement @@ -74,8 +85,20 @@ public class a extends BaseMvpActivity<CommonPresenter, ExerciseModel> implement
74 private String accountOid; 85 private String accountOid;
75 private int listIndex = 0; //数据下标 86 private int listIndex = 0; //数据下标
76 private String type;//题目类型 87 private String type;//题目类型
  88 + private boolean isClickAble = true;//是否能选择多条目
  89 + private String rightAnswer;//当前题目正确答案
  90 + private int rightCount;//答对题的数量
  91 + private int wrongCount;//答错题的数量
77 private List<AnswerBean.QuestionLstBean> questionLst = new ArrayList<>();//创建集合存储这一套题 92 private List<AnswerBean.QuestionLstBean> questionLst = new ArrayList<>();//创建集合存储这一套题
78 private ListAnswerAdapter optionsAdapter; 93 private ListAnswerAdapter optionsAdapter;
  94 + private String selectAnswer = "";
  95 + private AnswerSheetGridAdapter sheetGridAdapter;
  96 + private PopupWindow popupWindow;
  97 + private List<Integer> statusList = new ArrayList<>();//保存答题结果 0:未答题 1:答对 2:答错
  98 + private List<Integer> integerList = new ArrayList<>();// 存放 1或者2 用来判断多选题 是否答对
  99 + private List<String> stringList = new ArrayList<>();//用来存放多选题选择的答案
  100 + private List<String> historyAnswer = new ArrayList<>();//存放历史选择的答案
  101 + private boolean isRight;
79 102
80 103
81 @Override 104 @Override
@@ -94,8 +117,155 @@ public class a extends BaseMvpActivity<CommonPresenter, ExerciseModel> implement @@ -94,8 +117,155 @@ public class a extends BaseMvpActivity<CommonPresenter, ExerciseModel> implement
94 listAnswer.setOnItemClickListener(new AdapterView.OnItemClickListener() { 117 listAnswer.setOnItemClickListener(new AdapterView.OnItemClickListener() {
95 @Override 118 @Override
96 public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 119 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
97 - 120 + ImageView wrong = (ImageView) view.findViewById(R.id.img_wrong);
  121 + ImageView right = (ImageView) view.findViewById(R.id.img_right);
  122 + TextView option = (TextView) view.findViewById(R.id.option);
  123 +
  124 + Log.e("zhangtao:trueType", type);
  125 + if (type.contains("单选") || type.contains("判断")) {
  126 + //单选· 多选 选择答案 设置为单选
  127 + if (isClickAble) {
  128 + isClickAble = false;
  129 +
  130 + try {
  131 + if (position == 0) {
  132 + selectAnswer = "A";
  133 + } else if (position == 1) {
  134 + selectAnswer = "B";
  135 + } else if (position == 2) {
  136 + selectAnswer = "C";
  137 + } else if (position == 3) {
  138 + selectAnswer = "D";
  139 + } else if (position == 4) {
  140 + selectAnswer = "E";
  141 + }
  142 + } catch (Exception e) {
  143 + Log.e("xuetubao:", e.toString());
  144 + }
  145 +
  146 + //判断 单选题 是否答对
  147 + if (rightAnswer.contains(selectAnswer)) {
  148 + right.setVisibility(View.VISIBLE);
  149 + wrong.setVisibility(View.GONE);
  150 + option.setVisibility(View.GONE);
  151 +
  152 + rightCount++;
  153 + tvRightNum.setText(String.valueOf(rightCount));
  154 + statusList.set(listIndex, 1);
  155 + sheetGridAdapter.notifyDataSetChanged();
  156 +
  157 + if (listIndex < questionLst.size() - 1) {
  158 + listIndex++;//答对 自动下一题
  159 + doRefresh(true);
  160 + } else {
  161 + Toast.makeText(a.this, "当前已是最后一题", Toast.LENGTH_SHORT).show();
  162 + tvShowCard.setVisibility(View.GONE);
  163 + commit.setVisibility(View.VISIBLE);
  164 + }
  165 +
  166 + } else if (!rightAnswer.contains(selectAnswer)) {
  167 + wrongCount++;
  168 + tvWrongNum.setText(String.valueOf(wrongCount));
  169 +
  170 + rlAnswer.setVisibility(View.VISIBLE);//展示错题解析
  171 + statusList.set(listIndex, 2);
  172 + sheetGridAdapter.notifyDataSetChanged();
  173 +
  174 + String questionOid = questionLst.get(listIndex).getQuestionOid();
  175 + mPresenter.getPresenter(4, 2, accountOid, questionOid, String.valueOf(1), catalogOid);
  176 +
  177 + optionsAdapter.setRight(rightAnswer);
  178 + optionsAdapter.notifyDataSetChanged();
  179 + }
  180 +
  181 + }
  182 + } else if (type.contains("多选")) {
  183 + //多选题 选择答案 不用设置为单选
  184 + if (isClickAble) {
  185 + try {
  186 + if (position == 0) {
  187 + selectAnswer += "A";
  188 + stringList.add("A");
  189 + } else if (position == 1) {
  190 + selectAnswer += "B";
  191 + stringList.add("B");
  192 + } else if (position == 2) {
  193 + selectAnswer += "C";
  194 + stringList.add("C");
  195 + } else if (position == 3) {
  196 + selectAnswer += "D";
  197 + stringList.add("D");
  198 + } else if (position == 4) {
  199 + selectAnswer += "E";
  200 + stringList.add("E");
  201 + }
  202 + } catch (Exception e) {
  203 + Log.e("xuetubao:", e.toString());
  204 + }
  205 +
  206 + for (int i = 0; i < stringList.size(); i++) {
  207 + if (rightAnswer.contains(stringList.get(i))) {
  208 + integerList.add(1);
  209 + } else {
  210 + integerList.add(2);
  211 + }
  212 + }
  213 + //判断多选题是否答对
  214 + for (int i = 0; i < integerList.size(); i++) {
  215 + if (integerList.get(i) == 2) {
  216 + right.setVisibility(View.GONE);
  217 + wrong.setVisibility(View.VISIBLE);
  218 + option.setVisibility(View.GONE);
  219 +
  220 + isRight = false;
  221 + } else {
  222 + right.setVisibility(View.VISIBLE);
  223 + wrong.setVisibility(View.GONE);
  224 + option.setVisibility(View.GONE);
  225 +
  226 + isRight = true;
  227 + }
  228 + }
  229 +
  230 + if (!isRight) {
  231 + isClickAble = false;
  232 + statusList.set(listIndex, 1);
  233 + sheetGridAdapter.notifyDataSetChanged();
  234 + wrongCount++;
  235 + tvWrongNum.setText(String.valueOf(wrongCount));
  236 +
  237 + rlAnswer.setVisibility(View.VISIBLE);//展示错题解析
  238 + statusList.set(listIndex, 2);
  239 + sheetGridAdapter.notifyDataSetChanged();
  240 +
  241 + String questionOid = questionLst.get(listIndex).getQuestionOid();
  242 + mPresenter.getPresenter(4, 2, accountOid, questionOid, String.valueOf(1), catalogOid);
  243 +
  244 + optionsAdapter.setRight(rightAnswer);
  245 + optionsAdapter.notifyDataSetChanged();
  246 +
  247 + } else if (isRight && rightAnswer.length() == selectAnswer.length()) {
  248 +
  249 + rightCount++;
  250 + tvRightNum.setText(String.valueOf(rightCount));
  251 + statusList.set(listIndex, 1);
  252 + sheetGridAdapter.notifyDataSetChanged();
  253 +
  254 + if (listIndex < questionLst.size() - 1) {
  255 + listIndex++;//答对 自动下一题
  256 + doRefresh(true);
  257 + } else {
  258 + Toast.makeText(a.this, "当前已是最后一题", Toast.LENGTH_SHORT).show();
  259 + tvShowCard.setVisibility(View.GONE);
  260 + commit.setVisibility(View.VISIBLE);
  261 + }
  262 + }
  263 +
  264 +
  265 + }
  266 + }
98 } 267 }
  268 +
99 }); 269 });
100 270
101 271
@@ -133,14 +303,95 @@ public class a extends BaseMvpActivity<CommonPresenter, ExerciseModel> implement @@ -133,14 +303,95 @@ public class a extends BaseMvpActivity<CommonPresenter, ExerciseModel> implement
133 all.setText(String.valueOf(questionLst.size())); 303 all.setText(String.valueOf(questionLst.size()));
134 tvTopic.setText(questionLstBeans.get(listIndex).getQuestionTitle()); 304 tvTopic.setText(questionLstBeans.get(listIndex).getQuestionTitle());
135 tvCurrent.setText(String.valueOf(listIndex + 1)); 305 tvCurrent.setText(String.valueOf(listIndex + 1));
  306 + index.setText(String.valueOf(listIndex + 1));
136 type = questionLstBeans.get(listIndex).getQuestionTypeName(); 307 type = questionLstBeans.get(listIndex).getQuestionTypeName();
137 tvRadio.setText(type); 308 tvRadio.setText(type);
  309 + rightAnswer = questionLstBeans.get(listIndex).getAnswer();
  310 + rightSelect.setText(questionLstBeans.get(listIndex).getAnswer());
  311 + if(!TextUtils.isEmpty(questionLstBeans.get(listIndex).getAnswer())){
  312 + rightAnswerText.setText(questionLstBeans.get(listIndex).getWrongAnaly());
  313 + }
138 optionsAdapter = new ListAnswerAdapter(questionLst.get(listIndex).getOptionsLst(), this); 314 optionsAdapter = new ListAnswerAdapter(questionLst.get(listIndex).getOptionsLst(), this);
139 listAnswer.setAdapter(optionsAdapter); 315 listAnswer.setAdapter(optionsAdapter);
  316 + optionsAdapter.notifyDataSetChanged();
  317 +
  318 + for (AnswerBean.QuestionLstBean a : questionLst) {
  319 + statusList.add(0);
  320 + }
  321 + sheetGridAdapter = new AnswerSheetGridAdapter(statusList, this);
  322 +
  323 + }
  324 + }
  325 +
  326 + private void doRefresh(boolean isNext) {
  327 +
  328 + historyAnswer.add(selectAnswer);
  329 +
  330 + integerList.clear();
  331 + selectAnswer = "";
  332 + stringList.clear();
  333 + isClickAble = true;
  334 +
  335 + tvTopic.setText(questionLst.get(listIndex).getQuestionTitle());
  336 + tvCurrent.setText(String.valueOf(listIndex + 1));
  337 + type = questionLst.get(listIndex).getQuestionTypeName();
  338 + tvRadio.setText(type);
  339 + index.setText(String.valueOf(listIndex + 1));
  340 + rightAnswer = questionLst.get(listIndex).getAnswer();
  341 + rightSelect.setText(questionLst.get(listIndex).getAnswer());
  342 + if(!TextUtils.isEmpty(questionLst.get(listIndex).getWrongAnaly()))
  343 + rightAnswerText.setText(questionLst.get(listIndex).getWrongAnaly());
  344 + rlAnswer.setVisibility(View.GONE);
  345 +
  346 + optionsAdapter = new ListAnswerAdapter(questionLst.get(listIndex).getOptionsLst(), this);
  347 + listAnswer.setAdapter(optionsAdapter);
  348 + optionsAdapter.notifyDataSetChanged();
140 349
141 350
  351 + if (historyAnswer.size() > listIndex) {
  352 + optionsAdapter.setSelect(historyAnswer.get(listIndex));
  353 + optionsAdapter.notifyDataSetInvalidated();
142 354
  355 +
  356 + if (TextUtils.isEmpty(historyAnswer.get(listIndex))) {
  357 + rlAnswer.setVisibility(View.GONE);
  358 + } else {
  359 + rlAnswer.setVisibility(View.VISIBLE);
  360 + }
143 } 361 }
  362 +
  363 + }
  364 +
  365 + private void showAnswerCard(List<Integer> sheetCard, int rightCount, int wrongCount, int currentIndex, int maxTopic) {
  366 + View contentView = LayoutInflater.from(this).inflate(R.layout.pop_answer_sheet, null);
  367 + View view = LayoutInflater.from(this).inflate(R.layout.activity_answer, null);
  368 +
  369 + TextView tv_card = (TextView) contentView.findViewById(R.id.tv_card);
  370 + GridView gridView = (GridView) contentView.findViewById(R.id.grid_dati);
  371 + TextView index = (TextView) contentView.findViewById(R.id.index);
  372 + TextView total = (TextView) contentView.findViewById(R.id.total);
  373 + TextView right = (TextView) contentView.findViewById(R.id.tv_right_num);
  374 + TextView wrong = (TextView) contentView.findViewById(R.id.tv_wrong_num);
  375 +
  376 + right.setText(String.valueOf(rightCount));
  377 + wrong.setText(String.valueOf(wrongCount));
  378 + index.setText(String.valueOf(currentIndex + 1));
  379 + total.setText(String.valueOf(maxTopic));
  380 +
  381 + gridView.setAdapter(sheetGridAdapter);
  382 +
  383 + popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
  384 + popupWindow.setOutsideTouchable(false);
  385 + popupWindow.setTouchable(true);
  386 + popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
  387 + tv_card.setOnClickListener(new View.OnClickListener() {
  388 + @Override
  389 + public void onClick(View v) {
  390 + if (popupWindow != null) {
  391 + popupWindow.dismiss();
  392 + }
  393 + }
  394 + });
144 } 395 }
145 396
146 @Override 397 @Override
@@ -164,19 +415,67 @@ public class a extends BaseMvpActivity<CommonPresenter, ExerciseModel> implement @@ -164,19 +415,67 @@ public class a extends BaseMvpActivity<CommonPresenter, ExerciseModel> implement
164 public void onClick(View v) { 415 public void onClick(View v) {
165 switch (v.getId()) { 416 switch (v.getId()) {
166 case R.id.rl_last: 417 case R.id.rl_last:
  418 + if (listIndex == 0) {
  419 + Toast.makeText(this, "当前已是第一题", Toast.LENGTH_SHORT).show();
  420 + } else {
  421 + listIndex--;
  422 + doRefresh(false);
  423 + }
167 break; 424 break;
168 case R.id.rl_next: 425 case R.id.rl_next:
  426 + Log.e("zhangtao:right", rightCount + "");
  427 + Log.e("zhangtao:wrong", wrongCount + "");
  428 +
  429 + if (listIndex < questionLst.size() - 1) {
  430 +
  431 + if (type.contains("多选")) {
  432 + if (selectAnswer.length() != rightAnswer.length()) {
  433 + statusList.set(listIndex, 2);
  434 + }
  435 + }
  436 +
  437 + if (TextUtils.isEmpty(selectAnswer)) {
  438 + if (listIndex > historyAnswer.size() - 1) {
  439 + wrongCount++;
  440 + statusList.set(listIndex, 0);
  441 + }
  442 + }
  443 +
  444 + listIndex++;
  445 + doRefresh(true);
  446 +
  447 + } else if (listIndex == questionLst.size() - 1) {
  448 + Toast.makeText(this, "当前已是最后一题", Toast.LENGTH_SHORT).show();
  449 + tvShowCard.setVisibility(View.GONE);
  450 + commit.setVisibility(View.VISIBLE);
  451 + }
169 break; 452 break;
170 case R.id.lin_tab: 453 case R.id.lin_tab:
171 this.finish(); 454 this.finish();
172 break; 455 break;
173 - case R.id.rl_card:  
174 - break;  
175 case R.id.tv_look: 456 case R.id.tv_look:
  457 + rlAnswer.setVisibility(View.VISIBLE);
176 break; 458 break;
177 case R.id.commit: 459 case R.id.commit:
  460 + if (listIndex > historyAnswer.size()) {
  461 + if (TextUtils.isEmpty(selectAnswer)) {
  462 + wrongCount++;
  463 + }
  464 + }else if(listIndex==questionLst.size()-1){
  465 + if(TextUtils.isEmpty(selectAnswer)){
  466 + wrongCount++;
  467 + }
  468 + }
  469 + Intent intent = new Intent(this, AnswerResultActivity.class);
  470 + intent.putExtra("rightCount", rightCount);
  471 + intent.putExtra("wrongCount", wrongCount);
  472 + startActivity(intent);
178 break; 473 break;
179 case R.id.tv_show_card: 474 case R.id.tv_show_card:
  475 + showAnswerCard(statusList, rightCount, wrongCount, listIndex, questionLst.size());
  476 + break;
  477 + case R.id.rl_card:
  478 + showAnswerCard(statusList, rightCount, wrongCount, listIndex, questionLst.size());
180 break; 479 break;
181 } 480 }
182 } 481 }
  1 +package com.hh.xuetubao.activity.pratice;
  2 +
  3 +import android.content.Context;
  4 +import android.content.Intent;
  5 +import android.os.Build;
  6 +import android.os.Bundle;
  7 +import android.support.annotation.RequiresApi;
  8 +import android.text.TextUtils;
  9 +import android.util.Log;
  10 +import android.view.Gravity;
  11 +import android.view.LayoutInflater;
  12 +import android.view.View;
  13 +import android.view.ViewGroup;
  14 +import android.view.WindowManager;
  15 +import android.widget.AdapterView;
  16 +import android.widget.GridView;
  17 +import android.widget.ImageView;
  18 +import android.widget.LinearLayout;
  19 +import android.widget.ListView;
  20 +import android.widget.PopupWindow;
  21 +import android.widget.RelativeLayout;
  22 +import android.widget.TextView;
  23 +import android.widget.Toast;
  24 +
  25 +import com.hh.xuetubao.R;
  26 +import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
  27 +import com.hh.xuetubao.adapter.AnswerSheetGridAdapter;
  28 +import com.hh.xuetubao.adapter.ListAnswerAdapter;
  29 +import com.hh.xuetubao.bean.AnswerBean;
  30 +import com.hh.xuetubao.model.ExerciseModel;
  31 +import com.hh.xuetubao.mvp.BaseMvpActivity;
  32 +import com.hh.xuetubao.mvp.CommonPresenter;
  33 +import com.hh.xuetubao.mvp.ICommonView;
  34 +
  35 +import java.util.ArrayList;
  36 +import java.util.List;
  37 +
  38 +import butterknife.BindView;
  39 +import butterknife.ButterKnife;
  40 +
  41 +/**
  42 + * 模拟练习页面
  43 + */
  44 +public class b extends BaseMvpActivity<CommonPresenter, ExerciseModel> implements ICommonView, View.OnClickListener {
  45 +
  46 +
  47 + @BindView(R.id.list_answer)
  48 + ListView listAnswer;
  49 + @BindView(R.id.tv_radio)
  50 + TextView tvRadio;
  51 + @BindView(R.id.tv_max)
  52 + TextView tvMax;
  53 + @BindView(R.id.tv_current)
  54 + TextView tvCurrent;
  55 + @BindView(R.id.tv_title)
  56 + TextView tvTitle;
  57 + @BindView(R.id.tv_topic)
  58 + TextView tvTopic;
  59 + @BindView(R.id.rl_last)
  60 + RelativeLayout rlLast;
  61 + @BindView(R.id.rl_next)
  62 + RelativeLayout rlNext;
  63 + @BindView(R.id.index)
  64 + TextView index;
  65 + @BindView(R.id.all)
  66 + TextView all;
  67 + @BindView(R.id.tv_right_num)
  68 + TextView tvRightNum;
  69 + @BindView(R.id.tv_wrong_num)
  70 + TextView tvWrongNum;
  71 + @BindView(R.id.lin_tab)
  72 + LinearLayout linTab;
  73 + @BindView(R.id.rl_card)
  74 + RelativeLayout rlCard;
  75 + @BindView(R.id.right_select)
  76 + TextView rightSelect;
  77 + @BindView(R.id.right_answer)
  78 + TextView rightAnswerText;
  79 + @BindView(R.id.rl_answer)
  80 + RelativeLayout rlAnswer;
  81 + @BindView(R.id.commit)
  82 + LinearLayout commit;
  83 + @BindView(R.id.tv2)
  84 + TextView tv2;
  85 + @BindView(R.id.tv_show_card)
  86 + TextView tvShowCard;
  87 +
  88 + private String catalogOid;
  89 + private String accountOid;
  90 + private int listIndex = 0; //数据下标
  91 + private String type;//题目类型
  92 + private boolean isClickAble = true;//是否能选择多条目
  93 + private String rightAnswer;//当前题目正确答案
  94 + private int rightCount;//答对题的数量
  95 + private int wrongCount;//答错题的数量
  96 + private List<AnswerBean.QuestionLstBean> questionLst = new ArrayList<>();//创建集合存储这一套题
  97 + private ListAnswerAdapter optionsAdapter;
  98 + private String selectAnswer = "";
  99 + private AnswerSheetGridAdapter sheetGridAdapter;
  100 + private PopupWindow popupWindow;
  101 + private List<Integer> statusList = new ArrayList<>();//保存答题结果 0:未答题 1:答对 2:答错
  102 + private List<Integer> integerList = new ArrayList<>();// 存放 1或者2 用来判断多选题 是否答对
  103 + private List<String> stringList = new ArrayList<>();//用来存放多选题选择的答案
  104 + private List<String> historyAnswer = new ArrayList<>();//存放历史选择的答案
  105 + private List<String> listRightAnswer = new ArrayList<>();
  106 + private boolean isRight;
  107 + private int unDone;//未完成的题
  108 + private int danxuanCount;
  109 + private int duoxuanCount;
  110 + private int panduanCount;
  111 + private int danxuanWrong;
  112 + private int panduanWrong;
  113 + private int duoxuanWrong;
  114 + private double totalScore;
  115 + private double danxuan;
  116 + private double duoxuan;
  117 + private double panduan;
  118 +
  119 +
  120 + @Override
  121 + public void initView() {
  122 +
  123 + accountOid = SharedPrefrenceUtils.getString(this, "AccountOid");
  124 + catalogOid = getIntent().getStringExtra("catalogOid");
  125 +
  126 + rlLast.setOnClickListener(this);
  127 + rlNext.setOnClickListener(this);
  128 + linTab.setOnClickListener(this);
  129 + rlCard.setOnClickListener(this);
  130 + commit.setOnClickListener(this);
  131 + tvShowCard.setOnClickListener(this);
  132 +
  133 + listAnswer.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  134 + @Override
  135 + public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  136 + ImageView wrong = (ImageView) view.findViewById(R.id.img_wrong);
  137 + ImageView right = (ImageView) view.findViewById(R.id.img_right);
  138 + TextView option = (TextView) view.findViewById(R.id.option);
  139 + TextView text = (TextView) view.findViewById(R.id.text);
  140 +
  141 + Log.e("zhangtao:trueType", type);
  142 + if (type.contains("单选") || type.contains("判断")) {
  143 + //单选· 多选 选择答案 设置为单选
  144 + if (isClickAble) {
  145 + isClickAble = false;
  146 +
  147 + try {
  148 + if (position == 0) {
  149 + selectAnswer = "A";
  150 + } else if (position == 1) {
  151 + selectAnswer = "B";
  152 + } else if (position == 2) {
  153 + selectAnswer = "C";
  154 + } else if (position == 3) {
  155 + selectAnswer = "D";
  156 + } else if (position == 4) {
  157 + selectAnswer = "E";
  158 + }
  159 + } catch (Exception e) {
  160 + Log.e("xuetubao:", e.toString());
  161 + }
  162 +
  163 + //判断 单选题 是否答对
  164 + if (rightAnswer.contains(selectAnswer)) {
  165 + text.setTextColor(getResources().getColor(R.color.color_ff5400));
  166 + option.setTextColor(getResources().getColor(R.color.color_ff5400));
  167 +
  168 + rightCount++;
  169 + tvRightNum.setText(String.valueOf(rightCount));
  170 + statusList.set(listIndex, 1);
  171 + sheetGridAdapter.notifyDataSetChanged();
  172 +
  173 + if (type.contains("单选")) {
  174 + totalScore += danxuan;
  175 + } else if (type.contains("判断")) {
  176 + totalScore += panduan;
  177 + }
  178 +
  179 + } else if (!rightAnswer.contains(selectAnswer)) {
  180 +
  181 + wrongCount++;
  182 + tvWrongNum.setText(String.valueOf(wrongCount));
  183 +
  184 + statusList.set(listIndex, 2);
  185 + sheetGridAdapter.notifyDataSetChanged();
  186 +
  187 + String questionOid = questionLst.get(listIndex).getQuestionOid();
  188 + mPresenter.getPresenter(4, 2, accountOid, questionOid, String.valueOf(1), catalogOid);
  189 +
  190 + text.setTextColor(getResources().getColor(R.color.color_ff5400));
  191 + option.setTextColor(getResources().getColor(R.color.color_ff5400));
  192 +
  193 + if (type.contains("单选")) {
  194 + danxuanWrong++;
  195 + } else if (type.contains("判断")) {
  196 + panduanWrong++;
  197 + }
  198 +
  199 + }
  200 +
  201 + }
  202 + } else if (type.contains("多选")) {
  203 + //多选题 选择答案 不用设置为单选
  204 + if (isClickAble) {
  205 + try {
  206 + if (position == 0) {
  207 + selectAnswer += "A";
  208 + stringList.add("A");
  209 + } else if (position == 1) {
  210 + selectAnswer += "B";
  211 + stringList.add("B");
  212 + } else if (position == 2) {
  213 + selectAnswer += "C";
  214 + stringList.add("C");
  215 + } else if (position == 3) {
  216 + selectAnswer += "D";
  217 + stringList.add("D");
  218 + } else if (position == 4) {
  219 + selectAnswer += "E";
  220 + stringList.add("E");
  221 + }
  222 + } catch (Exception e) {
  223 + Log.e("xuetubao:", e.toString());
  224 + }
  225 +
  226 + for (int i = 0; i < stringList.size(); i++) {
  227 + if (rightAnswer.contains(stringList.get(i))) {
  228 + integerList.add(1);
  229 + } else {
  230 + integerList.add(2);
  231 + }
  232 + }
  233 + //判断多选题是否答对
  234 + for (int i = 0; i < integerList.size(); i++) {
  235 + if (integerList.get(i) == 2) {
  236 + text.setTextColor(getResources().getColor(R.color.color_ff5400));
  237 + option.setTextColor(getResources().getColor(R.color.color_ff5400));
  238 +
  239 + isRight = false;
  240 + } else {
  241 + text.setTextColor(getResources().getColor(R.color.color_ff5400));
  242 + option.setTextColor(getResources().getColor(R.color.color_ff5400));
  243 +
  244 + isRight = true;
  245 + }
  246 + }
  247 +
  248 + if (!isRight) {
  249 + isClickAble = false;
  250 + statusList.set(listIndex, 1);
  251 + sheetGridAdapter.notifyDataSetChanged();
  252 + wrongCount++;
  253 + tvWrongNum.setText(String.valueOf(wrongCount));
  254 +
  255 + statusList.set(listIndex, 2);
  256 + sheetGridAdapter.notifyDataSetChanged();
  257 +
  258 + String questionOid = questionLst.get(listIndex).getQuestionOid();
  259 + mPresenter.getPresenter(4, 2, accountOid, questionOid, String.valueOf(1), catalogOid);
  260 +
  261 + /* optionsAdapter.setRight(rightAnswer);
  262 + optionsAdapter.notifyDataSetChanged();*/
  263 +
  264 + text.setTextColor(getResources().getColor(R.color.color_ff5400));
  265 + option.setTextColor(getResources().getColor(R.color.color_ff5400));
  266 +
  267 + duoxuanWrong++;
  268 +
  269 + } else if (isRight && rightAnswer.length() == selectAnswer.length()) {
  270 + isClickAble = false;
  271 + rightCount++;
  272 + tvRightNum.setText(String.valueOf(rightCount));
  273 + statusList.set(listIndex, 1);
  274 + sheetGridAdapter.notifyDataSetChanged();
  275 +
  276 + totalScore += duoxuan;
  277 +
  278 + text.setTextColor(getResources().getColor(R.color.color_ff5400));
  279 + option.setTextColor(getResources().getColor(R.color.color_ff5400));
  280 +
  281 + }
  282 +
  283 + }
  284 + }
  285 + }
  286 +
  287 + });
  288 +
  289 +
  290 + }
  291 +
  292 + @Override
  293 + public int initLayout() {
  294 +// return R.layout.activity_answer;
  295 + return R.layout.activity_answer_sheet;
  296 + }
  297 +
  298 + @Override
  299 + public void initData() {
  300 +// mPresenter.getPresenter(8, 1, catalogOid, String.valueOf(10), accountOid);
  301 + mPresenter.getPresenter(4, 1, catalogOid, accountOid);
  302 + }
  303 +
  304 + @Override
  305 + public CommonPresenter getPresenter() {
  306 + return new CommonPresenter();
  307 + }
  308 +
  309 + @Override
  310 + public ExerciseModel getModel() {
  311 + return new ExerciseModel();
  312 + }
  313 +
  314 + @Override
  315 + public void getData(Object o, int api, int intent) {
  316 + if (api == 4 && intent == 1) {
  317 + AnswerBean bean = (AnswerBean) o;
  318 +
  319 + List<AnswerBean.QuestionLstBean> questionLstBeans = bean.getQuestionLst();
  320 + questionLst.addAll(questionLstBeans);
  321 +
  322 + danxuanCount = bean.getRadioCount();
  323 + duoxuanCount = bean.getMultipleCount();
  324 + panduanCount = bean.getJudgeCount();
  325 +
  326 + danxuan = bean.getRadioScore();
  327 + duoxuan = bean.getMultipleScore();
  328 + panduan = bean.getJudgeScore();
  329 +
  330 + tvMax.setText(String.valueOf(questionLst.size()));
  331 + all.setText(String.valueOf(questionLst.size()));
  332 + tvTopic.setText(questionLstBeans.get(listIndex).getQuestionTitle());
  333 + tvCurrent.setText(String.valueOf(listIndex + 1));
  334 + index.setText(String.valueOf(listIndex + 1));
  335 + type = questionLstBeans.get(listIndex).getQuestionTypeName();
  336 + tvRadio.setText(type);
  337 + rightAnswer = questionLstBeans.get(listIndex).getAnswer();
  338 + rightSelect.setText(questionLstBeans.get(listIndex).getAnswer());
  339 + if (!TextUtils.isEmpty(questionLstBeans.get(listIndex).getAnswer())) {
  340 + rightAnswerText.setText(questionLstBeans.get(listIndex).getWrongAnaly());
  341 + }
  342 + optionsAdapter = new ListAnswerAdapter(questionLst.get(listIndex).getOptionsLst(), this);
  343 + listAnswer.setAdapter(optionsAdapter);
  344 + optionsAdapter.notifyDataSetChanged();
  345 +
  346 + for (AnswerBean.QuestionLstBean a : questionLst) {
  347 + statusList.add(0);
  348 + }
  349 + sheetGridAdapter = new AnswerSheetGridAdapter(statusList, this);
  350 +
  351 + }
  352 + }
  353 +
  354 + private void doRefresh(boolean isNext) {
  355 +
  356 + historyAnswer.add(selectAnswer);
  357 + listRightAnswer.add(rightAnswer);
  358 +
  359 + integerList.clear();
  360 + selectAnswer = "";
  361 + stringList.clear();
  362 + isClickAble = true;
  363 +
  364 + tvTopic.setText(questionLst.get(listIndex).getQuestionTitle());
  365 + tvCurrent.setText(String.valueOf(listIndex + 1));
  366 + type = questionLst.get(listIndex).getQuestionTypeName();
  367 + tvRadio.setText(type);
  368 + index.setText(String.valueOf(listIndex + 1));
  369 + rightAnswer = questionLst.get(listIndex).getAnswer();
  370 + rightSelect.setText(questionLst.get(listIndex).getAnswer());
  371 + if (!TextUtils.isEmpty(questionLst.get(listIndex).getWrongAnaly()))
  372 + rightAnswerText.setText(questionLst.get(listIndex).getWrongAnaly());
  373 + rlAnswer.setVisibility(View.GONE);
  374 +
  375 + optionsAdapter = new ListAnswerAdapter(questionLst.get(listIndex).getOptionsLst(), this);
  376 + listAnswer.setAdapter(optionsAdapter);
  377 + optionsAdapter.notifyDataSetChanged();
  378 +
  379 +
  380 + if (historyAnswer.size() > listIndex) {
  381 + optionsAdapter.setSelect(historyAnswer.get(listIndex));
  382 + optionsAdapter.notifyDataSetInvalidated();
  383 +
  384 + }
  385 +
  386 + }
  387 +
  388 + private void showAnswerCard(List<Integer> sheetCard, int rightCount, int wrongCount, int currentIndex, int maxTopic) {
  389 + View contentView = LayoutInflater.from(this).inflate(R.layout.pop_answer_sheet, null);
  390 + View view = LayoutInflater.from(this).inflate(R.layout.activity_answer, null);
  391 +
  392 + TextView tv_card = (TextView) contentView.findViewById(R.id.tv_card);
  393 + GridView gridView = (GridView) contentView.findViewById(R.id.grid_dati);
  394 + TextView index = (TextView) contentView.findViewById(R.id.index);
  395 + TextView total = (TextView) contentView.findViewById(R.id.total);
  396 + TextView right = (TextView) contentView.findViewById(R.id.tv_right_num);
  397 + TextView wrong = (TextView) contentView.findViewById(R.id.tv_wrong_num);
  398 +
  399 + right.setText(String.valueOf(rightCount));
  400 + wrong.setText(String.valueOf(wrongCount));
  401 + index.setText(String.valueOf(currentIndex + 1));
  402 + total.setText(String.valueOf(maxTopic));
  403 +
  404 +// sheetGridAdapter = new AnswerSheetGridAdapter(sheetCard, this);
  405 + gridView.setAdapter(sheetGridAdapter);
  406 +
  407 + popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
  408 + popupWindow.setOutsideTouchable(false);
  409 + popupWindow.setTouchable(true);
  410 + popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
  411 + tv_card.setOnClickListener(new View.OnClickListener() {
  412 + @Override
  413 + public void onClick(View v) {
  414 + if (popupWindow != null) {
  415 + popupWindow.dismiss();
  416 + }
  417 + }
  418 + });
  419 + }
  420 +
  421 + @RequiresApi(api = Build.VERSION_CODES.KITKAT)
  422 + private void showCommitCard(final Context context, int laveCount) {
  423 + View contentView = LayoutInflater.from(this).inflate(R.layout.pop_answer_commit, null);
  424 + View view = LayoutInflater.from(this).inflate(R.layout.activity_answer, null);
  425 +
  426 + TextView count = (TextView) contentView.findViewById(R.id.tv_count);
  427 + TextView goOn = (TextView) contentView.findViewById(R.id.tv_continue);
  428 + TextView commit = (TextView) contentView.findViewById(R.id.tv_commit);
  429 +
  430 + count.setText(String.valueOf(laveCount));
  431 +
  432 + popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
  433 + popupWindow.setOutsideTouchable(false);
  434 + popupWindow.setTouchable(true);
  435 + popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0);
  436 +
  437 + goOn.setOnClickListener(new View.OnClickListener() {
  438 + @Override
  439 + public void onClick(View v) {
  440 + popupWindow.dismiss();
  441 + }
  442 + });
  443 +
  444 + commit.setOnClickListener(new View.OnClickListener() {
  445 + @Override
  446 + public void onClick(View v) {
  447 + popupWindow.dismiss();
  448 + Intent intent = new Intent(context, TestScoreActivity.class);
  449 + intent.putExtra("catalogOid", catalogOid);
  450 + intent.putExtra("danxuanCount", danxuanCount);
  451 + intent.putExtra("duoxuanCount", duoxuanCount);
  452 + intent.putExtra("panduanCount", panduanCount);
  453 + intent.putExtra("danxuanWrong", danxuanWrong);
  454 + intent.putExtra("panduanWrong", panduanWrong);
  455 + intent.putExtra("duoxuanWrong", duoxuanWrong);
  456 + intent.putExtra("totalScore", totalScore);
  457 + Log.e("zhangtao", totalScore + "分");
  458 + startActivity(intent);
  459 + b.this.finish();
  460 + }
  461 + });
  462 +
  463 + popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
  464 + @Override
  465 + public void onDismiss() {
  466 + chageAlpha(1f);
  467 + }
  468 + });
  469 + }
  470 +
  471 + private void chageAlpha(float color) {
  472 + WindowManager.LayoutParams lp = this.getWindow().getAttributes();
  473 + lp.alpha = color;
  474 + this.getWindow().setAttributes(lp);
  475 + }
  476 +
  477 + @Override
  478 + public void onComplete(int api) {
  479 +
  480 + }
  481 +
  482 + @Override
  483 + public void onError(Throwable e, int api) {
  484 +
  485 + }
  486 +
  487 + @Override
  488 + protected void onCreate(Bundle savedInstanceState) {
  489 + super.onCreate(savedInstanceState);
  490 + // TODO: add setContentView(...) invocation
  491 + ButterKnife.bind(this);
  492 + }
  493 +
  494 + @Override
  495 + public void onClick(View v) {
  496 + switch (v.getId()) {
  497 + case R.id.rl_last:
  498 + if (listIndex == 0) {
  499 + Toast.makeText(this, "当前已是第一题", Toast.LENGTH_SHORT).show();
  500 + } else {
  501 + listIndex--;
  502 + doRefresh(false);
  503 + }
  504 + break;
  505 + case R.id.rl_next:
  506 + if (listIndex < questionLst.size() - 1) {
  507 +
  508 + if (type.contains("多选")) {
  509 + if (selectAnswer.length() != rightAnswer.length()) {
  510 + statusList.set(listIndex, 2);
  511 + }
  512 + }
  513 +
  514 + if (TextUtils.isEmpty(selectAnswer)) {
  515 + if (listIndex > historyAnswer.size() - 1) {
  516 + unDone++;
  517 + wrongCount++;
  518 + statusList.set(listIndex, 0);
  519 + }
  520 + }
  521 +
  522 + listIndex++;
  523 + doRefresh(true);
  524 +
  525 + } else if (listIndex == questionLst.size() - 1) {
  526 + Toast.makeText(this, "当前已是最后一题", Toast.LENGTH_SHORT).show();
  527 + tvShowCard.setVisibility(View.GONE);
  528 + commit.setVisibility(View.VISIBLE);
  529 + }
  530 + break;
  531 + case R.id.lin_tab:
  532 + this.finish();
  533 + break;
  534 + case R.id.tv_look:
  535 + rlAnswer.setVisibility(View.VISIBLE);
  536 + break;
  537 + case R.id.commit:
  538 + if (listIndex > historyAnswer.size()) {
  539 + if (TextUtils.isEmpty(selectAnswer)) {
  540 + wrongCount++;
  541 + if (type.contains("单选")) {
  542 + danxuanWrong++;
  543 + } else if (type.contains("判断")) {
  544 + panduanWrong++;
  545 + } else if (type.contains("多选")) {
  546 + duoxuanWrong++;
  547 + }
  548 + }
  549 + } else if (listIndex == questionLst.size() - 1) {
  550 + if (TextUtils.isEmpty(selectAnswer)) {
  551 + unDone++;
  552 + if (type.contains("单选")) {
  553 + danxuanWrong++;
  554 + } else if (type.contains("判断")) {
  555 + panduanWrong++;
  556 + } else if (type.contains("多选")) {
  557 + duoxuanWrong++;
  558 + }
  559 + }
  560 + }
  561 + showCommitCard(this, unDone);
  562 + chageAlpha(0.5f);
  563 + break;
  564 + case R.id.tv_show_card:
  565 + showAnswerCard(statusList, rightCount, wrongCount, listIndex, questionLst.size());
  566 + break;
  567 + case R.id.rl_card:
  568 + showAnswerCard(statusList, rightCount, wrongCount, listIndex, questionLst.size());
  569 + break;
  570 + }
  571 + }
  572 +
  573 +}
  1 +package com.hh.xuetubao.activity.pratice;
  2 +
  3 +import android.content.Context;
  4 +import android.content.Intent;
  5 +import android.os.Build;
  6 +import android.os.Bundle;
  7 +import android.support.annotation.RequiresApi;
  8 +import android.text.TextUtils;
  9 +import android.util.Log;
  10 +import android.view.Gravity;
  11 +import android.view.LayoutInflater;
  12 +import android.view.View;
  13 +import android.view.ViewGroup;
  14 +import android.view.WindowManager;
  15 +import android.widget.AdapterView;
  16 +import android.widget.GridView;
  17 +import android.widget.ImageView;
  18 +import android.widget.LinearLayout;
  19 +import android.widget.ListView;
  20 +import android.widget.PopupWindow;
  21 +import android.widget.RelativeLayout;
  22 +import android.widget.TextView;
  23 +import android.widget.Toast;
  24 +
  25 +import com.hh.xuetubao.R;
  26 +import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
  27 +import com.hh.xuetubao.adapter.AnswerSheetGridAdapter;
  28 +import com.hh.xuetubao.adapter.ListAnswerAdapter;
  29 +import com.hh.xuetubao.bean.AnswerBean;
  30 +import com.hh.xuetubao.model.ExerciseModel;
  31 +import com.hh.xuetubao.mvp.BaseMvpActivity;
  32 +import com.hh.xuetubao.mvp.CommonPresenter;
  33 +import com.hh.xuetubao.mvp.ICommonView;
  34 +
  35 +import java.util.ArrayList;
  36 +import java.util.List;
  37 +
  38 +import butterknife.BindView;
  39 +import butterknife.ButterKnife;
  40 +
  41 +/**
  42 + * 模拟练习页面
  43 + */
  44 +public class c extends BaseMvpActivity<CommonPresenter, ExerciseModel> implements ICommonView, View.OnClickListener {
  45 +
  46 +
  47 + @BindView(R.id.list_answer)
  48 + ListView listAnswer;
  49 + @BindView(R.id.tv_radio)
  50 + TextView tvRadio;
  51 + @BindView(R.id.tv_max)
  52 + TextView tvMax;
  53 + @BindView(R.id.tv_current)
  54 + TextView tvCurrent;
  55 + @BindView(R.id.tv_title)
  56 + TextView tvTitle;
  57 + @BindView(R.id.tv_topic)
  58 + TextView tvTopic;
  59 + @BindView(R.id.rl_last)
  60 + RelativeLayout rlLast;
  61 + @BindView(R.id.rl_next)
  62 + RelativeLayout rlNext;
  63 + @BindView(R.id.index)
  64 + TextView index;
  65 + @BindView(R.id.all)
  66 + TextView all;
  67 + @BindView(R.id.tv_right_num)
  68 + TextView tvRightNum;
  69 + @BindView(R.id.tv_wrong_num)
  70 + TextView tvWrongNum;
  71 + @BindView(R.id.lin_tab)
  72 + LinearLayout linTab;
  73 + @BindView(R.id.rl_card)
  74 + RelativeLayout rlCard;
  75 + @BindView(R.id.right_select)
  76 + TextView rightSelect;
  77 + @BindView(R.id.right_answer)
  78 + TextView rightAnswerText;
  79 + @BindView(R.id.rl_answer)
  80 + RelativeLayout rlAnswer;
  81 + @BindView(R.id.commit)
  82 + LinearLayout commit;
  83 + @BindView(R.id.tv2)
  84 + TextView tv2;
  85 + @BindView(R.id.tv_show_card)
  86 + TextView tvShowCard;
  87 +
  88 +
  89 + private String catalogOid;
  90 + private String accountOid;
  91 + private int listIndex = 0; //数据下标
  92 + private String type;//题目类型
  93 + private boolean isClickAble = true;//是否能选择多条目
  94 + private String rightAnswer;//当前题目正确答案
  95 + private int rightCount;//答对题的数量
  96 + private int wrongCount;//答错题的数量
  97 + private List<AnswerBean.QuestionLstBean> questionLst = new ArrayList<>();//创建集合存储这一套题
  98 + private ListAnswerAdapter optionsAdapter;
  99 + private String selectAnswer = "";
  100 + private AnswerSheetGridAdapter sheetGridAdapter;
  101 + private PopupWindow popupWindow;
  102 + private List<Integer> statusList = new ArrayList<>();//保存答题结果 0:未答题 1:答对 2:答错
  103 + private List<Integer> integerList = new ArrayList<>();// 存放 1或者2 用来判断多选题 是否答对
  104 + private List<String> stringList = new ArrayList<>();//用来存放多选题选择的答案
  105 + private List<String> historyAnswer = new ArrayList<>();//存放历史选择的答案
  106 + private boolean isRight;
  107 + private int unDone;//未完成的题
  108 + private int danxuanCount;
  109 + private int duoxuanCount;
  110 + private int panduanCount;
  111 + private int danxuanWrong;
  112 + private int panduanWrong;
  113 + private int duoxuanWrong;
  114 + private double totalScore;
  115 + private double danxuan;
  116 + private double duoxuan;
  117 + private double panduan;
  118 +
  119 +
  120 + @Override
  121 + public void initView() {
  122 +
  123 + accountOid = SharedPrefrenceUtils.getString(this, "AccountOid");
  124 + catalogOid = getIntent().getStringExtra("catalogOid");
  125 +
  126 + rlLast.setOnClickListener(this);
  127 + rlNext.setOnClickListener(this);
  128 + linTab.setOnClickListener(this);
  129 + rlCard.setOnClickListener(this);
  130 + commit.setOnClickListener(this);
  131 + tvShowCard.setOnClickListener(this);
  132 +
  133 + tvShowCard.setText("查看答案");
  134 +
  135 + listAnswer.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  136 + @Override
  137 + public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  138 + ImageView wrong = (ImageView) view.findViewById(R.id.img_wrong);
  139 + ImageView right = (ImageView) view.findViewById(R.id.img_right);
  140 + TextView option = (TextView) view.findViewById(R.id.option);
  141 + TextView text = (TextView) view.findViewById(R.id.text);
  142 +
  143 + Log.e("zhangtao:trueType", type);
  144 + if (type.contains("单选") || type.contains("判断")) {
  145 + //单选· 多选 选择答案 设置为单选
  146 + if (isClickAble) {
  147 + isClickAble = false;
  148 +
  149 + try {
  150 + if (position == 0) {
  151 + selectAnswer = "A";
  152 + } else if (position == 1) {
  153 + selectAnswer = "B";
  154 + } else if (position == 2) {
  155 + selectAnswer = "C";
  156 + } else if (position == 3) {
  157 + selectAnswer = "D";
  158 + } else if (position == 4) {
  159 + selectAnswer = "E";
  160 + }
  161 + } catch (Exception e) {
  162 + Log.e("xuetubao:", e.toString());
  163 + }
  164 +
  165 + //判断 单选题 是否答对
  166 + if (rightAnswer.contains(selectAnswer)) {
  167 + text.setTextColor(getResources().getColor(R.color.color_ff5400));
  168 + option.setTextColor(getResources().getColor(R.color.color_ff5400));
  169 +
  170 + rightCount++;
  171 + tvRightNum.setText(String.valueOf(rightCount));
  172 + statusList.set(listIndex, 1);
  173 + sheetGridAdapter.notifyDataSetChanged();
  174 +
  175 + if (type.contains("单选")) {
  176 + totalScore += danxuan;
  177 + } else if (type.contains("判断")) {
  178 + totalScore += panduan;
  179 + }
  180 +
  181 + String questionOid = questionLst.get(position).getQuestionOid();
  182 + mPresenter.getPresenter(7, 2, accountOid, questionOid, String.valueOf(1), catalogOid);
  183 +
  184 + } else if (!rightAnswer.contains(selectAnswer)) {
  185 +
  186 + wrongCount++;
  187 + tvWrongNum.setText(String.valueOf(wrongCount));
  188 +
  189 + statusList.set(listIndex, 2);
  190 + sheetGridAdapter.notifyDataSetChanged();
  191 +
  192 + String questionOid = questionLst.get(position).getQuestionOid();
  193 + mPresenter.getPresenter(4, 2, accountOid, questionOid, String.valueOf(1), catalogOid);
  194 +
  195 + text.setTextColor(getResources().getColor(R.color.color_ff5400));
  196 + option.setTextColor(getResources().getColor(R.color.color_ff5400));
  197 +
  198 + if (type.contains("单选")) {
  199 + danxuanWrong++;
  200 + } else if (type.contains("判断")) {
  201 + panduanWrong++;
  202 + }
  203 +
  204 + }
  205 +
  206 + }
  207 + } else if (type.contains("多选")) {
  208 + //多选题 选择答案 不用设置为单选
  209 + if (isClickAble) {
  210 + try {
  211 + if (position == 0) {
  212 + selectAnswer += "A";
  213 + stringList.add("A");
  214 + } else if (position == 1) {
  215 + selectAnswer += "B";
  216 + stringList.add("B");
  217 + } else if (position == 2) {
  218 + selectAnswer += "C";
  219 + stringList.add("C");
  220 + } else if (position == 3) {
  221 + selectAnswer += "D";
  222 + stringList.add("D");
  223 + } else if (position == 4) {
  224 + selectAnswer += "E";
  225 + stringList.add("E");
  226 + }
  227 + } catch (Exception e) {
  228 + Log.e("xuetubao:", e.toString());
  229 + }
  230 +
  231 + for (int i = 0; i < stringList.size(); i++) {
  232 + if (rightAnswer.contains(stringList.get(i))) {
  233 + integerList.add(1);
  234 + } else {
  235 + integerList.add(2);
  236 + }
  237 + }
  238 + //判断多选题是否答对
  239 + for (int i = 0; i < integerList.size(); i++) {
  240 + if (integerList.get(i) == 2) {
  241 + text.setTextColor(getResources().getColor(R.color.color_ff5400));
  242 + option.setTextColor(getResources().getColor(R.color.color_ff5400));
  243 +
  244 + isRight = false;
  245 + } else {
  246 + text.setTextColor(getResources().getColor(R.color.color_ff5400));
  247 + option.setTextColor(getResources().getColor(R.color.color_ff5400));
  248 +
  249 + isRight = true;
  250 + }
  251 + }
  252 +
  253 + if (!isRight) {
  254 + isClickAble = false;
  255 + statusList.set(listIndex, 1);
  256 + sheetGridAdapter.notifyDataSetChanged();
  257 + wrongCount++;
  258 + tvWrongNum.setText(String.valueOf(wrongCount));
  259 +
  260 + statusList.set(listIndex, 2);
  261 + sheetGridAdapter.notifyDataSetChanged();
  262 +
  263 + String questionOid = questionLst.get(position).getQuestionOid();
  264 + mPresenter.getPresenter(4, 2, accountOid, questionOid, String.valueOf(1), catalogOid);
  265 +
  266 + /* optionsAdapter.setRight(rightAnswer);
  267 + optionsAdapter.notifyDataSetChanged();*/
  268 +
  269 + text.setTextColor(getResources().getColor(R.color.color_ff5400));
  270 + option.setTextColor(getResources().getColor(R.color.color_ff5400));
  271 +
  272 + duoxuanWrong++;
  273 +
  274 + } else if (isRight && rightAnswer.length() == selectAnswer.length()) {
  275 + isClickAble = false;
  276 + rightCount++;
  277 + tvRightNum.setText(String.valueOf(rightCount));
  278 + statusList.set(listIndex, 1);
  279 + sheetGridAdapter.notifyDataSetChanged();
  280 +
  281 + totalScore += duoxuan;
  282 +
  283 + text.setTextColor(getResources().getColor(R.color.color_ff5400));
  284 + option.setTextColor(getResources().getColor(R.color.color_ff5400));
  285 +
  286 + }
  287 +
  288 + }
  289 + }
  290 + }
  291 +
  292 + });
  293 +
  294 +
  295 + }
  296 +
  297 + @Override
  298 + public int initLayout() {
  299 +// return R.layout.activity_answer;
  300 + return R.layout.activity_answer_sheet;
  301 + }
  302 +
  303 + @Override
  304 + public void initData() {
  305 +// mPresenter.getPresenter(8, 1, catalogOid, String.valueOf(10), accountOid);
  306 + mPresenter.getPresenter(7, 1, accountOid, catalogOid, String.valueOf(1));
  307 + }
  308 +
  309 + @Override
  310 + public CommonPresenter getPresenter() {
  311 + return new CommonPresenter();
  312 + }
  313 +
  314 + @Override
  315 + public ExerciseModel getModel() {
  316 + return new ExerciseModel();
  317 + }
  318 +
  319 + @Override
  320 + public void getData(Object o, int api, int intent) {
  321 + if (api == 7 && intent == 1) {
  322 + AnswerBean bean = (AnswerBean) o;
  323 +
  324 + List<AnswerBean.QuestionLstBean> questionLstBeans = bean.getQuestionLst();
  325 + questionLst.addAll(questionLstBeans);
  326 +
  327 + danxuanCount = bean.getRadioCount();
  328 + duoxuanCount = bean.getMultipleCount();
  329 + panduanCount = bean.getJudgeCount();
  330 +
  331 + danxuan = bean.getRadioScore();
  332 + duoxuan = bean.getMultipleScore();
  333 + panduan = bean.getJudgeScore();
  334 +
  335 + tvMax.setText(String.valueOf(questionLst.size()));
  336 + all.setText(String.valueOf(questionLst.size()));
  337 + tvTopic.setText(questionLstBeans.get(listIndex).getQuestionTitle());
  338 + tvCurrent.setText(String.valueOf(listIndex + 1));
  339 + index.setText(String.valueOf(listIndex + 1));
  340 + type = questionLstBeans.get(listIndex).getQuestionTypeName();
  341 + tvRadio.setText(type);
  342 + rightAnswer = questionLstBeans.get(listIndex).getAnswer();
  343 + rightSelect.setText(questionLstBeans.get(listIndex).getAnswer());
  344 + if (!TextUtils.isEmpty(questionLstBeans.get(listIndex).getAnswer())) {
  345 + rightAnswerText.setText(questionLstBeans.get(listIndex).getWrongAnaly());
  346 + }
  347 + optionsAdapter = new ListAnswerAdapter(questionLst.get(listIndex).getOptionsLst(), this);
  348 + listAnswer.setAdapter(optionsAdapter);
  349 + optionsAdapter.notifyDataSetChanged();
  350 +
  351 + for (AnswerBean.QuestionLstBean a : questionLst) {
  352 + statusList.add(0);
  353 + }
  354 + sheetGridAdapter = new AnswerSheetGridAdapter(statusList, this);
  355 +
  356 + }
  357 + }
  358 +
  359 + private void doRefresh(boolean isNext) {
  360 +
  361 + historyAnswer.add(selectAnswer);
  362 +
  363 + integerList.clear();
  364 + selectAnswer = "";
  365 + stringList.clear();
  366 + isClickAble = true;
  367 +
  368 + tvTopic.setText(questionLst.get(listIndex).getQuestionTitle());
  369 + tvCurrent.setText(String.valueOf(listIndex + 1));
  370 + type = questionLst.get(listIndex).getQuestionTypeName();
  371 + tvRadio.setText(type);
  372 + index.setText(String.valueOf(listIndex + 1));
  373 + rightAnswer = questionLst.get(listIndex).getAnswer();
  374 + rightSelect.setText(questionLst.get(listIndex).getAnswer());
  375 + if (!TextUtils.isEmpty(questionLst.get(listIndex).getWrongAnaly()))
  376 + rightAnswerText.setText(questionLst.get(listIndex).getWrongAnaly());
  377 + rlAnswer.setVisibility(View.GONE);
  378 +
  379 + optionsAdapter = new ListAnswerAdapter(questionLst.get(listIndex).getOptionsLst(), this);
  380 + listAnswer.setAdapter(optionsAdapter);
  381 + optionsAdapter.notifyDataSetChanged();
  382 +
  383 +
  384 + if (historyAnswer.size() > listIndex) {
  385 + optionsAdapter.setSelect(historyAnswer.get(listIndex));
  386 + optionsAdapter.notifyDataSetInvalidated();
  387 +
  388 + }
  389 +
  390 + }
  391 +
  392 + private void showAnswerCard(List<Integer> sheetCard, int rightCount, int wrongCount, int currentIndex, int maxTopic) {
  393 + View contentView = LayoutInflater.from(this).inflate(R.layout.pop_answer_sheet, null);
  394 + View view = LayoutInflater.from(this).inflate(R.layout.activity_answer, null);
  395 +
  396 + TextView tv_card = (TextView) contentView.findViewById(R.id.tv_card);
  397 + GridView gridView = (GridView) contentView.findViewById(R.id.grid_dati);
  398 + TextView index = (TextView) contentView.findViewById(R.id.index);
  399 + TextView total = (TextView) contentView.findViewById(R.id.total);
  400 + TextView right = (TextView) contentView.findViewById(R.id.tv_right_num);
  401 + TextView wrong = (TextView) contentView.findViewById(R.id.tv_wrong_num);
  402 +
  403 + right.setText(String.valueOf(rightCount));
  404 + wrong.setText(String.valueOf(wrongCount));
  405 + index.setText(String.valueOf(currentIndex + 1));
  406 + total.setText(String.valueOf(maxTopic));
  407 +
  408 +// sheetGridAdapter = new AnswerSheetGridAdapter(sheetCard, this);
  409 + gridView.setAdapter(sheetGridAdapter);
  410 +
  411 + popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
  412 + popupWindow.setOutsideTouchable(false);
  413 + popupWindow.setTouchable(true);
  414 + popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
  415 + tv_card.setOnClickListener(new View.OnClickListener() {
  416 + @Override
  417 + public void onClick(View v) {
  418 + if (popupWindow != null) {
  419 + popupWindow.dismiss();
  420 + }
  421 + }
  422 + });
  423 + }
  424 +
  425 + @RequiresApi(api = Build.VERSION_CODES.KITKAT)
  426 + private void showCommitCard(final Context context, int laveCount) {
  427 + View contentView = LayoutInflater.from(this).inflate(R.layout.pop_answer_commit, null);
  428 + View view = LayoutInflater.from(this).inflate(R.layout.activity_answer, null);
  429 +
  430 + TextView count = (TextView) contentView.findViewById(R.id.tv_count);
  431 + TextView goOn = (TextView) contentView.findViewById(R.id.tv_continue);
  432 + TextView commit = (TextView) contentView.findViewById(R.id.tv_commit);
  433 +
  434 + count.setText(String.valueOf(laveCount));
  435 +
  436 + popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
  437 + popupWindow.setOutsideTouchable(false);
  438 + popupWindow.setTouchable(true);
  439 + popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0);
  440 +
  441 + goOn.setOnClickListener(new View.OnClickListener() {
  442 + @Override
  443 + public void onClick(View v) {
  444 + popupWindow.dismiss();
  445 + }
  446 + });
  447 +
  448 + commit.setOnClickListener(new View.OnClickListener() {
  449 + @Override
  450 + public void onClick(View v) {
  451 + popupWindow.dismiss();
  452 + Intent intent = new Intent(context, TestScoreActivity.class);
  453 + intent.putExtra("catalogOid", catalogOid);
  454 + intent.putExtra("danxuanCount", danxuanCount);
  455 + intent.putExtra("duoxuanCount", duoxuanCount);
  456 + intent.putExtra("panduanCount", panduanCount);
  457 + intent.putExtra("danxuanWrong", danxuanWrong);
  458 + intent.putExtra("panduanWrong", panduanWrong);
  459 + intent.putExtra("duoxuanWrong", duoxuanWrong);
  460 + intent.putExtra("totalScore", totalScore);
  461 + Log.e("zhangtao", totalScore + "分");
  462 + startActivity(intent);
  463 + c.this.finish();
  464 + }
  465 + });
  466 +
  467 + popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
  468 + @Override
  469 + public void onDismiss() {
  470 + chageAlpha(1f);
  471 + }
  472 + });
  473 + }
  474 +
  475 + private void chageAlpha(float color) {
  476 + WindowManager.LayoutParams lp = this.getWindow().getAttributes();
  477 + lp.alpha = color;
  478 + this.getWindow().setAttributes(lp);
  479 + }
  480 +
  481 + @Override
  482 + public void onComplete(int api) {
  483 +
  484 + }
  485 +
  486 + @Override
  487 + public void onError(Throwable e, int api) {
  488 +
  489 + }
  490 +
  491 + @Override
  492 + protected void onCreate(Bundle savedInstanceState) {
  493 + super.onCreate(savedInstanceState);
  494 + // TODO: add setContentView(...) invocation
  495 + ButterKnife.bind(this);
  496 + }
  497 +
  498 + @Override
  499 + public void onClick(View v) {
  500 + switch (v.getId()) {
  501 + case R.id.rl_last:
  502 + if (listIndex == 0) {
  503 + Toast.makeText(this, "当前已是第一题", Toast.LENGTH_SHORT).show();
  504 + } else {
  505 + listIndex--;
  506 + doRefresh(false);
  507 + }
  508 + break;
  509 + case R.id.rl_next:
  510 + if (listIndex < questionLst.size() - 1) {
  511 +
  512 + if (type.contains("多选")) {
  513 + if (selectAnswer.length() != rightAnswer.length()) {
  514 + statusList.set(listIndex, 2);
  515 + }
  516 + }
  517 +
  518 + if (TextUtils.isEmpty(selectAnswer)) {
  519 + if (listIndex > historyAnswer.size() - 1) {
  520 + unDone++;
  521 + wrongCount++;
  522 + statusList.set(listIndex, 0);
  523 + }
  524 + }
  525 +
  526 + listIndex++;
  527 + doRefresh(true);
  528 +
  529 + } else if (listIndex == questionLst.size() - 1) {
  530 + Toast.makeText(this, "当前已是最后一题", Toast.LENGTH_SHORT).show();
  531 + }
  532 + break;
  533 + case R.id.lin_tab:
  534 + this.finish();
  535 + break;
  536 + case R.id.tv_look:
  537 + rlAnswer.setVisibility(View.VISIBLE);
  538 + break;
  539 + case R.id.commit:
  540 + if (listIndex > historyAnswer.size()) {
  541 + if (TextUtils.isEmpty(selectAnswer)) {
  542 + wrongCount++;
  543 + if (type.contains("单选")) {
  544 + danxuanWrong++;
  545 + } else if (type.contains("判断")) {
  546 + panduanWrong++;
  547 + } else if (type.contains("多选")) {
  548 + duoxuanWrong++;
  549 + }
  550 + }
  551 + } else if (listIndex == questionLst.size() - 1) {
  552 + if (TextUtils.isEmpty(selectAnswer)) {
  553 + unDone++;
  554 + if (type.contains("单选")) {
  555 + danxuanWrong++;
  556 + } else if (type.contains("判断")) {
  557 + panduanWrong++;
  558 + } else if (type.contains("多选")) {
  559 + duoxuanWrong++;
  560 + }
  561 + }
  562 + } else {
  563 + Toast.makeText(this, "当前已是最后一题", Toast.LENGTH_SHORT).show();
  564 + }
  565 + break;
  566 + case R.id.tv_show_card:
  567 + rlAnswer.setVisibility(View.VISIBLE);
  568 + break;
  569 + case R.id.rl_card:
  570 + showAnswerCard(statusList, rightCount, wrongCount, listIndex, questionLst.size());
  571 + break;
  572 + }
  573 + }
  574 +
  575 +}
@@ -49,6 +49,18 @@ public class ListAnswerAdapter extends BaseAdapter { @@ -49,6 +49,18 @@ public class ListAnswerAdapter extends BaseAdapter {
49 option.setText(list.get(position).getOptionName()); 49 option.setText(list.get(position).getOptionName());
50 text.setText(list.get(position).getOptionDesc()); 50 text.setText(list.get(position).getOptionDesc());
51 51
  52 + if (!TextUtils.isEmpty(rightAnswer)) {
  53 + if (rightAnswer.contains(list.get(position).getOptionName())) {
  54 + right.setVisibility(View.VISIBLE);
  55 + wrong.setVisibility(View.GONE);
  56 + option.setVisibility(View.GONE);
  57 + } else {
  58 + right.setVisibility(View.GONE);
  59 + wrong.setVisibility(View.VISIBLE);
  60 + option.setVisibility(View.GONE);
  61 + }
  62 + }
  63 +
52 if (!TextUtils.isEmpty(selectString)) { 64 if (!TextUtils.isEmpty(selectString)) {
53 if (selectString.contains(list.get(position).getOptionName())) { 65 if (selectString.contains(list.get(position).getOptionName())) {
54 option.setTextColor(context.getResources().getColor(R.color.color_ff5400)); 66 option.setTextColor(context.getResources().getColor(R.color.color_ff5400));
@@ -64,6 +76,18 @@ public class ListAnswerAdapter extends BaseAdapter { @@ -64,6 +76,18 @@ public class ListAnswerAdapter extends BaseAdapter {
64 this.selectString = answer; 76 this.selectString = answer;
65 } 77 }
66 78
  79 + private String rightAnswer;
  80 +
  81 + public void setRight(String answer) {
  82 + this.rightAnswer = answer;
  83 + }
  84 +
  85 + private String listRight;
  86 +
  87 + public void setListRight(String answer) {
  88 + this.listRight = answer;
  89 + }
  90 +
67 @Override 91 @Override
68 public boolean isEnabled(int position) { 92 public boolean isEnabled(int position) {
69 if (!TextUtils.isEmpty(selectString)) { 93 if (!TextUtils.isEmpty(selectString)) {
@@ -14,7 +14,7 @@ import android.widget.TextView; @@ -14,7 +14,7 @@ import android.widget.TextView;
14 14
15 import com.hh.xuetubao.R; 15 import com.hh.xuetubao.R;
16 import com.hh.xuetubao.Utils.SharedPrefrenceUtils; 16 import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
17 -import com.hh.xuetubao.activity.pratice.AnswerWrongActivity; 17 +import com.hh.xuetubao.activity.pratice.c;
18 import com.hh.xuetubao.adapter.PractiveWrongAdapter; 18 import com.hh.xuetubao.adapter.PractiveWrongAdapter;
19 import com.hh.xuetubao.bean.AnswerBean; 19 import com.hh.xuetubao.bean.AnswerBean;
20 import com.hh.xuetubao.model.ExerciseModel; 20 import com.hh.xuetubao.model.ExerciseModel;
@@ -30,7 +30,7 @@ import butterknife.ButterKnife; @@ -30,7 +30,7 @@ import butterknife.ButterKnife;
30 import butterknife.Unbinder; 30 import butterknife.Unbinder;
31 31
32 /** 32 /**
33 - * 错题Fragment 33 + * 我的错题
34 */ 34 */
35 public class PraticeWrongFragment extends BaseMvpFragment<CommonPresenter, ExerciseModel> implements ICommonView { 35 public class PraticeWrongFragment extends BaseMvpFragment<CommonPresenter, ExerciseModel> implements ICommonView {
36 36
@@ -43,6 +43,7 @@ public class PraticeWrongFragment extends BaseMvpFragment<CommonPresenter, Exerc @@ -43,6 +43,7 @@ public class PraticeWrongFragment extends BaseMvpFragment<CommonPresenter, Exerc
43 private List<AnswerBean.CatalogLstBean> catalogLst = new ArrayList<>(); 43 private List<AnswerBean.CatalogLstBean> catalogLst = new ArrayList<>();
44 private PraticeWrongFragment fragment; 44 private PraticeWrongFragment fragment;
45 private String accountOid; 45 private String accountOid;
  46 + private int count;
46 47
47 @Override 48 @Override
48 public int getLayoutId() { 49 public int getLayoutId() {
@@ -58,7 +59,8 @@ public class PraticeWrongFragment extends BaseMvpFragment<CommonPresenter, Exerc @@ -58,7 +59,8 @@ public class PraticeWrongFragment extends BaseMvpFragment<CommonPresenter, Exerc
58 listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { 59 listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
59 @Override 60 @Override
60 public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 61 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
61 - Intent intent = new Intent(getActivity(), AnswerWrongActivity.class); 62 +// Intent intent = new Intent(getActivity(), AnswerWrongActivity.class);
  63 + Intent intent = new Intent(getActivity(), c.class);
62 intent.putExtra("catalogOid", catalogLst.get(position).getCatalogOid()); 64 intent.putExtra("catalogOid", catalogLst.get(position).getCatalogOid());
63 startActivity(intent); 65 startActivity(intent);
64 } 66 }
@@ -90,15 +92,21 @@ public class PraticeWrongFragment extends BaseMvpFragment<CommonPresenter, Exerc @@ -90,15 +92,21 @@ public class PraticeWrongFragment extends BaseMvpFragment<CommonPresenter, Exerc
90 92
91 @Override 93 @Override
92 public void getData(Object o, int api, int intent) { 94 public void getData(Object o, int api, int intent) {
93 - catalogLst.clear();  
94 - AnswerBean bean = (AnswerBean) o;  
95 - List<AnswerBean.CatalogLstBean> catalogLstBeans = bean.getCatalogLst();  
96 -  
97 - tvNum.setText(String.valueOf(catalogLstBeans.size()));  
98 -  
99 - catalogLst.addAll(catalogLstBeans);  
100 - practiveWrongAdapter.notifyDataSetChanged(); 95 + if (api == 6 && intent == 1) {
  96 + count=0;
  97 + catalogLst.clear();
  98 + AnswerBean bean = (AnswerBean) o;
  99 + List<AnswerBean.CatalogLstBean> catalogLstBeans = bean.getCatalogLst();
  100 +
  101 + for (int i = 0; i < catalogLstBeans.size(); i++) {
  102 + count += catalogLstBeans.get(i).getWrongNum();
  103 + Log.e("xuetubao", String.valueOf(count));
  104 + }
  105 + tvNum.setText(String.valueOf(count));
101 106
  107 + catalogLst.addAll(catalogLstBeans);
  108 + practiveWrongAdapter.notifyDataSetChanged();
  109 + }
102 110
103 } 111 }
104 112
@@ -12,6 +12,7 @@ import android.widget.RelativeLayout; @@ -12,6 +12,7 @@ import android.widget.RelativeLayout;
12 import com.hh.xuetubao.R; 12 import com.hh.xuetubao.R;
13 import com.hh.xuetubao.activity.pratice.AnswerSheetActivity; 13 import com.hh.xuetubao.activity.pratice.AnswerSheetActivity;
14 import com.hh.xuetubao.activity.pratice.MockExamActivity; 14 import com.hh.xuetubao.activity.pratice.MockExamActivity;
  15 +import com.hh.xuetubao.activity.pratice.a;
15 import com.hh.xuetubao.model.MainModel; 16 import com.hh.xuetubao.model.MainModel;
16 import com.hh.xuetubao.mvp.BaseMvpFragment; 17 import com.hh.xuetubao.mvp.BaseMvpFragment;
17 import com.hh.xuetubao.mvp.CommonPresenter; 18 import com.hh.xuetubao.mvp.CommonPresenter;
@@ -102,7 +103,8 @@ public class PriacticeDistFragment extends BaseMvpFragment<CommonPresenter, Main @@ -102,7 +103,8 @@ public class PriacticeDistFragment extends BaseMvpFragment<CommonPresenter, Main
102 getActivity().finish(); 103 getActivity().finish();
103 break; 104 break;
104 case R.id.frag_pricatice_dist_sjlx: // - > 随机练习 105 case R.id.frag_pricatice_dist_sjlx: // - > 随机练习
105 - intent = new Intent(getActivity(), AnswerSheetActivity.class); 106 +// intent = new Intent(getActivity(), AnswerSheetActivity.class);
  107 + intent = new Intent(getActivity(), a.class);
106 intent.putExtra("catalogOid", catalogOid); 108 intent.putExtra("catalogOid", catalogOid);
107 startActivity(intent); 109 startActivity(intent);
108 break; 110 break;
@@ -110,6 +110,12 @@ @@ -110,6 +110,12 @@
110 110
111 </RelativeLayout> 111 </RelativeLayout>
112 112
113 - 113 + <com.hh.xuetubao.Utils.WaveView
  114 + android:id="@+id/waveview"
  115 + android:layout_width="@dimen/dp_90"
  116 + android:layout_height="@dimen/dp_90"
  117 + android:layout_below="@id/lin_tab"
  118 + android:layout_centerHorizontal="true"
  119 + android:layout_marginTop="@dimen/dp_50" />
114 120
115 </RelativeLayout> 121 </RelativeLayout>