作者 qin

bug修改

不能预览此文件类型
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
<codeStyleSettings language="XML">
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>
\ No newline at end of file
... ...
... ... @@ -12,6 +12,7 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="testRunner" value="PLATFORM" />
</GradleProjectSettings>
</option>
</component>
... ...
... ... @@ -42,11 +42,11 @@
<activity
android:name=".MainActivity"
android:launchMode="singleTask">
<!-- <intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>-->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>-->
</activity>
<activity
android:name=".activity.personal.InfromationActivity"
... ... @@ -123,7 +123,16 @@
<activity
android:name=".activity.pratice.AnswerWrongActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.pratice.a"
android:screenOrientation="portrait" />
<activity
android:name=".activity.pratice.b"
android:screenOrientation="portrait" />
<activity
android:name=".activity.pratice.c"
android:screenOrientation="portrait" />
</application>
</manifest>
\ No newline at end of file
... ...
... ... @@ -5,6 +5,7 @@ import android.view.View;
import android.widget.TextView;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.WaveView;
import com.hh.xuetubao.model.MainModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
... ... @@ -25,14 +26,16 @@ public class AnswerResultActivity extends BaseMvpActivity<CommonPresenter, MainM
TextView tvWrong;
@BindView(R.id.tv_next)
TextView tvNext;
@BindView(R.id.waveview)
WaveView waveview;
@Override
public void initView() {
int rightCount = getIntent().getIntExtra("rightCount",0);
int wrongCount = getIntent().getIntExtra("wrongCount",0);
int rightCount = getIntent().getIntExtra("rightCount", 0);
int wrongCount = getIntent().getIntExtra("wrongCount", 0);
tvRight.setText(String.valueOf(rightCount));
tvWrong.setText(String.valueOf(wrongCount));
tvRight.setText(String.valueOf(rightCount));
tvWrong.setText(String.valueOf(wrongCount));
tvNext.setOnClickListener(this);
}
... ...
... ... @@ -374,6 +374,9 @@ public class AnswerWrongActivity extends BaseMvpActivity<CommonPresenter, Exerci
case R.id.tv_look:
rlAnswer.setVisibility(View.VISIBLE);
break;
case R.id.tv_show_card:
break;
}
}
... ...
... ... @@ -117,7 +117,8 @@ public class MockExamActivity extends BaseMvpActivity<CommonPresenter, ExerciseM
this.finish();
break;
case R.id.mock_exam_btn: // this - > 答题界面
Intent intent = new Intent(this, AnswerActivity.class);
// Intent intent = new Intent(this, AnswerActivity.class);
Intent intent = new Intent(this, b.class);
intent.putExtra("catalogOid", catalogOid);
SharedPrefrenceUtils.saveString(this, "thisCatalogOid", catalogOid);
startActivity(intent);
... ...
... ... @@ -92,7 +92,6 @@ public class TestScoreActivity extends BaseMvpActivity<CommonPresenter, Exercise
tv11.setText(String.valueOf(duoxuanWrongt));
tv17.setText(String.valueOf(panduanWrong));
tv7.setText(getFormat(danxuanCount, danxuanWrong) + "%");
tv13.setText(getFormat(duoxuanCount, duoxuanWrongt) + "%");
tv19.setText(getFormat(panduanCount, panduanWrong) + "%");
... ... @@ -179,12 +178,12 @@ public class TestScoreActivity extends BaseMvpActivity<CommonPresenter, Exercise
finish();
break;
case R.id.rl_allWrong:
intent = new Intent(this, AnswerWrongActivity.class);
intent = new Intent(this,c.class);
intent.putExtra("catalogOid", catalogOid);
startActivity(intent);
break;
case R.id.rl_reStart:
intent = new Intent(this, AnswerActivity.class);
intent = new Intent(this, b.class);
intent.putExtra("catalogOid", catalogOid);
startActivity(intent);
break;
... ...
package com.hh.xuetubao.activity.pratice;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
import com.hh.xuetubao.adapter.AnswerSheetGridAdapter;
import com.hh.xuetubao.adapter.ListAnswerAdapter;
import com.hh.xuetubao.bean.AnswerBean;
import com.hh.xuetubao.model.ExerciseModel;
... ... @@ -74,8 +85,20 @@ public class a extends BaseMvpActivity<CommonPresenter, ExerciseModel> implement
private String accountOid;
private int listIndex = 0; //数据下标
private String type;//题目类型
private boolean isClickAble = true;//是否能选择多条目
private String rightAnswer;//当前题目正确答案
private int rightCount;//答对题的数量
private int wrongCount;//答错题的数量
private List<AnswerBean.QuestionLstBean> questionLst = new ArrayList<>();//创建集合存储这一套题
private ListAnswerAdapter optionsAdapter;
private String selectAnswer = "";
private AnswerSheetGridAdapter sheetGridAdapter;
private PopupWindow popupWindow;
private List<Integer> statusList = new ArrayList<>();//保存答题结果 0:未答题 1:答对 2:答错
private List<Integer> integerList = new ArrayList<>();// 存放 1或者2 用来判断多选题 是否答对
private List<String> stringList = new ArrayList<>();//用来存放多选题选择的答案
private List<String> historyAnswer = new ArrayList<>();//存放历史选择的答案
private boolean isRight;
@Override
... ... @@ -94,8 +117,155 @@ public class a extends BaseMvpActivity<CommonPresenter, ExerciseModel> implement
listAnswer.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ImageView wrong = (ImageView) view.findViewById(R.id.img_wrong);
ImageView right = (ImageView) view.findViewById(R.id.img_right);
TextView option = (TextView) view.findViewById(R.id.option);
Log.e("zhangtao:trueType", type);
if (type.contains("单选") || type.contains("判断")) {
//单选· 多选 选择答案 设置为单选
if (isClickAble) {
isClickAble = false;
try {
if (position == 0) {
selectAnswer = "A";
} else if (position == 1) {
selectAnswer = "B";
} else if (position == 2) {
selectAnswer = "C";
} else if (position == 3) {
selectAnswer = "D";
} else if (position == 4) {
selectAnswer = "E";
}
} catch (Exception e) {
Log.e("xuetubao:", e.toString());
}
//判断 单选题 是否答对
if (rightAnswer.contains(selectAnswer)) {
right.setVisibility(View.VISIBLE);
wrong.setVisibility(View.GONE);
option.setVisibility(View.GONE);
rightCount++;
tvRightNum.setText(String.valueOf(rightCount));
statusList.set(listIndex, 1);
sheetGridAdapter.notifyDataSetChanged();
if (listIndex < questionLst.size() - 1) {
listIndex++;//答对 自动下一题
doRefresh(true);
} else {
Toast.makeText(a.this, "当前已是最后一题", Toast.LENGTH_SHORT).show();
tvShowCard.setVisibility(View.GONE);
commit.setVisibility(View.VISIBLE);
}
} else if (!rightAnswer.contains(selectAnswer)) {
wrongCount++;
tvWrongNum.setText(String.valueOf(wrongCount));
rlAnswer.setVisibility(View.VISIBLE);//展示错题解析
statusList.set(listIndex, 2);
sheetGridAdapter.notifyDataSetChanged();
String questionOid = questionLst.get(listIndex).getQuestionOid();
mPresenter.getPresenter(4, 2, accountOid, questionOid, String.valueOf(1), catalogOid);
optionsAdapter.setRight(rightAnswer);
optionsAdapter.notifyDataSetChanged();
}
}
} else if (type.contains("多选")) {
//多选题 选择答案 不用设置为单选
if (isClickAble) {
try {
if (position == 0) {
selectAnswer += "A";
stringList.add("A");
} else if (position == 1) {
selectAnswer += "B";
stringList.add("B");
} else if (position == 2) {
selectAnswer += "C";
stringList.add("C");
} else if (position == 3) {
selectAnswer += "D";
stringList.add("D");
} else if (position == 4) {
selectAnswer += "E";
stringList.add("E");
}
} catch (Exception e) {
Log.e("xuetubao:", e.toString());
}
for (int i = 0; i < stringList.size(); i++) {
if (rightAnswer.contains(stringList.get(i))) {
integerList.add(1);
} else {
integerList.add(2);
}
}
//判断多选题是否答对
for (int i = 0; i < integerList.size(); i++) {
if (integerList.get(i) == 2) {
right.setVisibility(View.GONE);
wrong.setVisibility(View.VISIBLE);
option.setVisibility(View.GONE);
isRight = false;
} else {
right.setVisibility(View.VISIBLE);
wrong.setVisibility(View.GONE);
option.setVisibility(View.GONE);
isRight = true;
}
}
if (!isRight) {
isClickAble = false;
statusList.set(listIndex, 1);
sheetGridAdapter.notifyDataSetChanged();
wrongCount++;
tvWrongNum.setText(String.valueOf(wrongCount));
rlAnswer.setVisibility(View.VISIBLE);//展示错题解析
statusList.set(listIndex, 2);
sheetGridAdapter.notifyDataSetChanged();
String questionOid = questionLst.get(listIndex).getQuestionOid();
mPresenter.getPresenter(4, 2, accountOid, questionOid, String.valueOf(1), catalogOid);
optionsAdapter.setRight(rightAnswer);
optionsAdapter.notifyDataSetChanged();
} else if (isRight && rightAnswer.length() == selectAnswer.length()) {
rightCount++;
tvRightNum.setText(String.valueOf(rightCount));
statusList.set(listIndex, 1);
sheetGridAdapter.notifyDataSetChanged();
if (listIndex < questionLst.size() - 1) {
listIndex++;//答对 自动下一题
doRefresh(true);
} else {
Toast.makeText(a.this, "当前已是最后一题", Toast.LENGTH_SHORT).show();
tvShowCard.setVisibility(View.GONE);
commit.setVisibility(View.VISIBLE);
}
}
}
}
}
});
... ... @@ -133,14 +303,95 @@ public class a extends BaseMvpActivity<CommonPresenter, ExerciseModel> implement
all.setText(String.valueOf(questionLst.size()));
tvTopic.setText(questionLstBeans.get(listIndex).getQuestionTitle());
tvCurrent.setText(String.valueOf(listIndex + 1));
index.setText(String.valueOf(listIndex + 1));
type = questionLstBeans.get(listIndex).getQuestionTypeName();
tvRadio.setText(type);
rightAnswer = questionLstBeans.get(listIndex).getAnswer();
rightSelect.setText(questionLstBeans.get(listIndex).getAnswer());
if(!TextUtils.isEmpty(questionLstBeans.get(listIndex).getAnswer())){
rightAnswerText.setText(questionLstBeans.get(listIndex).getWrongAnaly());
}
optionsAdapter = new ListAnswerAdapter(questionLst.get(listIndex).getOptionsLst(), this);
listAnswer.setAdapter(optionsAdapter);
optionsAdapter.notifyDataSetChanged();
for (AnswerBean.QuestionLstBean a : questionLst) {
statusList.add(0);
}
sheetGridAdapter = new AnswerSheetGridAdapter(statusList, this);
}
}
private void doRefresh(boolean isNext) {
historyAnswer.add(selectAnswer);
integerList.clear();
selectAnswer = "";
stringList.clear();
isClickAble = true;
tvTopic.setText(questionLst.get(listIndex).getQuestionTitle());
tvCurrent.setText(String.valueOf(listIndex + 1));
type = questionLst.get(listIndex).getQuestionTypeName();
tvRadio.setText(type);
index.setText(String.valueOf(listIndex + 1));
rightAnswer = questionLst.get(listIndex).getAnswer();
rightSelect.setText(questionLst.get(listIndex).getAnswer());
if(!TextUtils.isEmpty(questionLst.get(listIndex).getWrongAnaly()))
rightAnswerText.setText(questionLst.get(listIndex).getWrongAnaly());
rlAnswer.setVisibility(View.GONE);
optionsAdapter = new ListAnswerAdapter(questionLst.get(listIndex).getOptionsLst(), this);
listAnswer.setAdapter(optionsAdapter);
optionsAdapter.notifyDataSetChanged();
if (historyAnswer.size() > listIndex) {
optionsAdapter.setSelect(historyAnswer.get(listIndex));
optionsAdapter.notifyDataSetInvalidated();
if (TextUtils.isEmpty(historyAnswer.get(listIndex))) {
rlAnswer.setVisibility(View.GONE);
} else {
rlAnswer.setVisibility(View.VISIBLE);
}
}
}
private void showAnswerCard(List<Integer> sheetCard, int rightCount, int wrongCount, int currentIndex, int maxTopic) {
View contentView = LayoutInflater.from(this).inflate(R.layout.pop_answer_sheet, null);
View view = LayoutInflater.from(this).inflate(R.layout.activity_answer, null);
TextView tv_card = (TextView) contentView.findViewById(R.id.tv_card);
GridView gridView = (GridView) contentView.findViewById(R.id.grid_dati);
TextView index = (TextView) contentView.findViewById(R.id.index);
TextView total = (TextView) contentView.findViewById(R.id.total);
TextView right = (TextView) contentView.findViewById(R.id.tv_right_num);
TextView wrong = (TextView) contentView.findViewById(R.id.tv_wrong_num);
right.setText(String.valueOf(rightCount));
wrong.setText(String.valueOf(wrongCount));
index.setText(String.valueOf(currentIndex + 1));
total.setText(String.valueOf(maxTopic));
gridView.setAdapter(sheetGridAdapter);
popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popupWindow.setOutsideTouchable(false);
popupWindow.setTouchable(true);
popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
tv_card.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (popupWindow != null) {
popupWindow.dismiss();
}
}
});
}
@Override
... ... @@ -164,19 +415,67 @@ public class a extends BaseMvpActivity<CommonPresenter, ExerciseModel> implement
public void onClick(View v) {
switch (v.getId()) {
case R.id.rl_last:
if (listIndex == 0) {
Toast.makeText(this, "当前已是第一题", Toast.LENGTH_SHORT).show();
} else {
listIndex--;
doRefresh(false);
}
break;
case R.id.rl_next:
Log.e("zhangtao:right", rightCount + "");
Log.e("zhangtao:wrong", wrongCount + "");
if (listIndex < questionLst.size() - 1) {
if (type.contains("多选")) {
if (selectAnswer.length() != rightAnswer.length()) {
statusList.set(listIndex, 2);
}
}
if (TextUtils.isEmpty(selectAnswer)) {
if (listIndex > historyAnswer.size() - 1) {
wrongCount++;
statusList.set(listIndex, 0);
}
}
listIndex++;
doRefresh(true);
} else if (listIndex == questionLst.size() - 1) {
Toast.makeText(this, "当前已是最后一题", Toast.LENGTH_SHORT).show();
tvShowCard.setVisibility(View.GONE);
commit.setVisibility(View.VISIBLE);
}
break;
case R.id.lin_tab:
this.finish();
break;
case R.id.rl_card:
break;
case R.id.tv_look:
rlAnswer.setVisibility(View.VISIBLE);
break;
case R.id.commit:
if (listIndex > historyAnswer.size()) {
if (TextUtils.isEmpty(selectAnswer)) {
wrongCount++;
}
}else if(listIndex==questionLst.size()-1){
if(TextUtils.isEmpty(selectAnswer)){
wrongCount++;
}
}
Intent intent = new Intent(this, AnswerResultActivity.class);
intent.putExtra("rightCount", rightCount);
intent.putExtra("wrongCount", wrongCount);
startActivity(intent);
break;
case R.id.tv_show_card:
showAnswerCard(statusList, rightCount, wrongCount, listIndex, questionLst.size());
break;
case R.id.rl_card:
showAnswerCard(statusList, rightCount, wrongCount, listIndex, questionLst.size());
break;
}
}
... ...
package com.hh.xuetubao.activity.pratice;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
import com.hh.xuetubao.adapter.AnswerSheetGridAdapter;
import com.hh.xuetubao.adapter.ListAnswerAdapter;
import com.hh.xuetubao.bean.AnswerBean;
import com.hh.xuetubao.model.ExerciseModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 模拟练习页面
*/
public class b extends BaseMvpActivity<CommonPresenter, ExerciseModel> implements ICommonView, View.OnClickListener {
@BindView(R.id.list_answer)
ListView listAnswer;
@BindView(R.id.tv_radio)
TextView tvRadio;
@BindView(R.id.tv_max)
TextView tvMax;
@BindView(R.id.tv_current)
TextView tvCurrent;
@BindView(R.id.tv_title)
TextView tvTitle;
@BindView(R.id.tv_topic)
TextView tvTopic;
@BindView(R.id.rl_last)
RelativeLayout rlLast;
@BindView(R.id.rl_next)
RelativeLayout rlNext;
@BindView(R.id.index)
TextView index;
@BindView(R.id.all)
TextView all;
@BindView(R.id.tv_right_num)
TextView tvRightNum;
@BindView(R.id.tv_wrong_num)
TextView tvWrongNum;
@BindView(R.id.lin_tab)
LinearLayout linTab;
@BindView(R.id.rl_card)
RelativeLayout rlCard;
@BindView(R.id.right_select)
TextView rightSelect;
@BindView(R.id.right_answer)
TextView rightAnswerText;
@BindView(R.id.rl_answer)
RelativeLayout rlAnswer;
@BindView(R.id.commit)
LinearLayout commit;
@BindView(R.id.tv2)
TextView tv2;
@BindView(R.id.tv_show_card)
TextView tvShowCard;
private String catalogOid;
private String accountOid;
private int listIndex = 0; //数据下标
private String type;//题目类型
private boolean isClickAble = true;//是否能选择多条目
private String rightAnswer;//当前题目正确答案
private int rightCount;//答对题的数量
private int wrongCount;//答错题的数量
private List<AnswerBean.QuestionLstBean> questionLst = new ArrayList<>();//创建集合存储这一套题
private ListAnswerAdapter optionsAdapter;
private String selectAnswer = "";
private AnswerSheetGridAdapter sheetGridAdapter;
private PopupWindow popupWindow;
private List<Integer> statusList = new ArrayList<>();//保存答题结果 0:未答题 1:答对 2:答错
private List<Integer> integerList = new ArrayList<>();// 存放 1或者2 用来判断多选题 是否答对
private List<String> stringList = new ArrayList<>();//用来存放多选题选择的答案
private List<String> historyAnswer = new ArrayList<>();//存放历史选择的答案
private List<String> listRightAnswer = new ArrayList<>();
private boolean isRight;
private int unDone;//未完成的题
private int danxuanCount;
private int duoxuanCount;
private int panduanCount;
private int danxuanWrong;
private int panduanWrong;
private int duoxuanWrong;
private double totalScore;
private double danxuan;
private double duoxuan;
private double panduan;
@Override
public void initView() {
accountOid = SharedPrefrenceUtils.getString(this, "AccountOid");
catalogOid = getIntent().getStringExtra("catalogOid");
rlLast.setOnClickListener(this);
rlNext.setOnClickListener(this);
linTab.setOnClickListener(this);
rlCard.setOnClickListener(this);
commit.setOnClickListener(this);
tvShowCard.setOnClickListener(this);
listAnswer.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ImageView wrong = (ImageView) view.findViewById(R.id.img_wrong);
ImageView right = (ImageView) view.findViewById(R.id.img_right);
TextView option = (TextView) view.findViewById(R.id.option);
TextView text = (TextView) view.findViewById(R.id.text);
Log.e("zhangtao:trueType", type);
if (type.contains("单选") || type.contains("判断")) {
//单选· 多选 选择答案 设置为单选
if (isClickAble) {
isClickAble = false;
try {
if (position == 0) {
selectAnswer = "A";
} else if (position == 1) {
selectAnswer = "B";
} else if (position == 2) {
selectAnswer = "C";
} else if (position == 3) {
selectAnswer = "D";
} else if (position == 4) {
selectAnswer = "E";
}
} catch (Exception e) {
Log.e("xuetubao:", e.toString());
}
//判断 单选题 是否答对
if (rightAnswer.contains(selectAnswer)) {
text.setTextColor(getResources().getColor(R.color.color_ff5400));
option.setTextColor(getResources().getColor(R.color.color_ff5400));
rightCount++;
tvRightNum.setText(String.valueOf(rightCount));
statusList.set(listIndex, 1);
sheetGridAdapter.notifyDataSetChanged();
if (type.contains("单选")) {
totalScore += danxuan;
} else if (type.contains("判断")) {
totalScore += panduan;
}
} else if (!rightAnswer.contains(selectAnswer)) {
wrongCount++;
tvWrongNum.setText(String.valueOf(wrongCount));
statusList.set(listIndex, 2);
sheetGridAdapter.notifyDataSetChanged();
String questionOid = questionLst.get(listIndex).getQuestionOid();
mPresenter.getPresenter(4, 2, accountOid, questionOid, String.valueOf(1), catalogOid);
text.setTextColor(getResources().getColor(R.color.color_ff5400));
option.setTextColor(getResources().getColor(R.color.color_ff5400));
if (type.contains("单选")) {
danxuanWrong++;
} else if (type.contains("判断")) {
panduanWrong++;
}
}
}
} else if (type.contains("多选")) {
//多选题 选择答案 不用设置为单选
if (isClickAble) {
try {
if (position == 0) {
selectAnswer += "A";
stringList.add("A");
} else if (position == 1) {
selectAnswer += "B";
stringList.add("B");
} else if (position == 2) {
selectAnswer += "C";
stringList.add("C");
} else if (position == 3) {
selectAnswer += "D";
stringList.add("D");
} else if (position == 4) {
selectAnswer += "E";
stringList.add("E");
}
} catch (Exception e) {
Log.e("xuetubao:", e.toString());
}
for (int i = 0; i < stringList.size(); i++) {
if (rightAnswer.contains(stringList.get(i))) {
integerList.add(1);
} else {
integerList.add(2);
}
}
//判断多选题是否答对
for (int i = 0; i < integerList.size(); i++) {
if (integerList.get(i) == 2) {
text.setTextColor(getResources().getColor(R.color.color_ff5400));
option.setTextColor(getResources().getColor(R.color.color_ff5400));
isRight = false;
} else {
text.setTextColor(getResources().getColor(R.color.color_ff5400));
option.setTextColor(getResources().getColor(R.color.color_ff5400));
isRight = true;
}
}
if (!isRight) {
isClickAble = false;
statusList.set(listIndex, 1);
sheetGridAdapter.notifyDataSetChanged();
wrongCount++;
tvWrongNum.setText(String.valueOf(wrongCount));
statusList.set(listIndex, 2);
sheetGridAdapter.notifyDataSetChanged();
String questionOid = questionLst.get(listIndex).getQuestionOid();
mPresenter.getPresenter(4, 2, accountOid, questionOid, String.valueOf(1), catalogOid);
/* optionsAdapter.setRight(rightAnswer);
optionsAdapter.notifyDataSetChanged();*/
text.setTextColor(getResources().getColor(R.color.color_ff5400));
option.setTextColor(getResources().getColor(R.color.color_ff5400));
duoxuanWrong++;
} else if (isRight && rightAnswer.length() == selectAnswer.length()) {
isClickAble = false;
rightCount++;
tvRightNum.setText(String.valueOf(rightCount));
statusList.set(listIndex, 1);
sheetGridAdapter.notifyDataSetChanged();
totalScore += duoxuan;
text.setTextColor(getResources().getColor(R.color.color_ff5400));
option.setTextColor(getResources().getColor(R.color.color_ff5400));
}
}
}
}
});
}
@Override
public int initLayout() {
// return R.layout.activity_answer;
return R.layout.activity_answer_sheet;
}
@Override
public void initData() {
// mPresenter.getPresenter(8, 1, catalogOid, String.valueOf(10), accountOid);
mPresenter.getPresenter(4, 1, catalogOid, accountOid);
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public ExerciseModel getModel() {
return new ExerciseModel();
}
@Override
public void getData(Object o, int api, int intent) {
if (api == 4 && intent == 1) {
AnswerBean bean = (AnswerBean) o;
List<AnswerBean.QuestionLstBean> questionLstBeans = bean.getQuestionLst();
questionLst.addAll(questionLstBeans);
danxuanCount = bean.getRadioCount();
duoxuanCount = bean.getMultipleCount();
panduanCount = bean.getJudgeCount();
danxuan = bean.getRadioScore();
duoxuan = bean.getMultipleScore();
panduan = bean.getJudgeScore();
tvMax.setText(String.valueOf(questionLst.size()));
all.setText(String.valueOf(questionLst.size()));
tvTopic.setText(questionLstBeans.get(listIndex).getQuestionTitle());
tvCurrent.setText(String.valueOf(listIndex + 1));
index.setText(String.valueOf(listIndex + 1));
type = questionLstBeans.get(listIndex).getQuestionTypeName();
tvRadio.setText(type);
rightAnswer = questionLstBeans.get(listIndex).getAnswer();
rightSelect.setText(questionLstBeans.get(listIndex).getAnswer());
if (!TextUtils.isEmpty(questionLstBeans.get(listIndex).getAnswer())) {
rightAnswerText.setText(questionLstBeans.get(listIndex).getWrongAnaly());
}
optionsAdapter = new ListAnswerAdapter(questionLst.get(listIndex).getOptionsLst(), this);
listAnswer.setAdapter(optionsAdapter);
optionsAdapter.notifyDataSetChanged();
for (AnswerBean.QuestionLstBean a : questionLst) {
statusList.add(0);
}
sheetGridAdapter = new AnswerSheetGridAdapter(statusList, this);
}
}
private void doRefresh(boolean isNext) {
historyAnswer.add(selectAnswer);
listRightAnswer.add(rightAnswer);
integerList.clear();
selectAnswer = "";
stringList.clear();
isClickAble = true;
tvTopic.setText(questionLst.get(listIndex).getQuestionTitle());
tvCurrent.setText(String.valueOf(listIndex + 1));
type = questionLst.get(listIndex).getQuestionTypeName();
tvRadio.setText(type);
index.setText(String.valueOf(listIndex + 1));
rightAnswer = questionLst.get(listIndex).getAnswer();
rightSelect.setText(questionLst.get(listIndex).getAnswer());
if (!TextUtils.isEmpty(questionLst.get(listIndex).getWrongAnaly()))
rightAnswerText.setText(questionLst.get(listIndex).getWrongAnaly());
rlAnswer.setVisibility(View.GONE);
optionsAdapter = new ListAnswerAdapter(questionLst.get(listIndex).getOptionsLst(), this);
listAnswer.setAdapter(optionsAdapter);
optionsAdapter.notifyDataSetChanged();
if (historyAnswer.size() > listIndex) {
optionsAdapter.setSelect(historyAnswer.get(listIndex));
optionsAdapter.notifyDataSetInvalidated();
}
}
private void showAnswerCard(List<Integer> sheetCard, int rightCount, int wrongCount, int currentIndex, int maxTopic) {
View contentView = LayoutInflater.from(this).inflate(R.layout.pop_answer_sheet, null);
View view = LayoutInflater.from(this).inflate(R.layout.activity_answer, null);
TextView tv_card = (TextView) contentView.findViewById(R.id.tv_card);
GridView gridView = (GridView) contentView.findViewById(R.id.grid_dati);
TextView index = (TextView) contentView.findViewById(R.id.index);
TextView total = (TextView) contentView.findViewById(R.id.total);
TextView right = (TextView) contentView.findViewById(R.id.tv_right_num);
TextView wrong = (TextView) contentView.findViewById(R.id.tv_wrong_num);
right.setText(String.valueOf(rightCount));
wrong.setText(String.valueOf(wrongCount));
index.setText(String.valueOf(currentIndex + 1));
total.setText(String.valueOf(maxTopic));
// sheetGridAdapter = new AnswerSheetGridAdapter(sheetCard, this);
gridView.setAdapter(sheetGridAdapter);
popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popupWindow.setOutsideTouchable(false);
popupWindow.setTouchable(true);
popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
tv_card.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (popupWindow != null) {
popupWindow.dismiss();
}
}
});
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void showCommitCard(final Context context, int laveCount) {
View contentView = LayoutInflater.from(this).inflate(R.layout.pop_answer_commit, null);
View view = LayoutInflater.from(this).inflate(R.layout.activity_answer, null);
TextView count = (TextView) contentView.findViewById(R.id.tv_count);
TextView goOn = (TextView) contentView.findViewById(R.id.tv_continue);
TextView commit = (TextView) contentView.findViewById(R.id.tv_commit);
count.setText(String.valueOf(laveCount));
popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popupWindow.setOutsideTouchable(false);
popupWindow.setTouchable(true);
popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0);
goOn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.dismiss();
}
});
commit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.dismiss();
Intent intent = new Intent(context, TestScoreActivity.class);
intent.putExtra("catalogOid", catalogOid);
intent.putExtra("danxuanCount", danxuanCount);
intent.putExtra("duoxuanCount", duoxuanCount);
intent.putExtra("panduanCount", panduanCount);
intent.putExtra("danxuanWrong", danxuanWrong);
intent.putExtra("panduanWrong", panduanWrong);
intent.putExtra("duoxuanWrong", duoxuanWrong);
intent.putExtra("totalScore", totalScore);
Log.e("zhangtao", totalScore + "分");
startActivity(intent);
b.this.finish();
}
});
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
chageAlpha(1f);
}
});
}
private void chageAlpha(float color) {
WindowManager.LayoutParams lp = this.getWindow().getAttributes();
lp.alpha = color;
this.getWindow().setAttributes(lp);
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.rl_last:
if (listIndex == 0) {
Toast.makeText(this, "当前已是第一题", Toast.LENGTH_SHORT).show();
} else {
listIndex--;
doRefresh(false);
}
break;
case R.id.rl_next:
if (listIndex < questionLst.size() - 1) {
if (type.contains("多选")) {
if (selectAnswer.length() != rightAnswer.length()) {
statusList.set(listIndex, 2);
}
}
if (TextUtils.isEmpty(selectAnswer)) {
if (listIndex > historyAnswer.size() - 1) {
unDone++;
wrongCount++;
statusList.set(listIndex, 0);
}
}
listIndex++;
doRefresh(true);
} else if (listIndex == questionLst.size() - 1) {
Toast.makeText(this, "当前已是最后一题", Toast.LENGTH_SHORT).show();
tvShowCard.setVisibility(View.GONE);
commit.setVisibility(View.VISIBLE);
}
break;
case R.id.lin_tab:
this.finish();
break;
case R.id.tv_look:
rlAnswer.setVisibility(View.VISIBLE);
break;
case R.id.commit:
if (listIndex > historyAnswer.size()) {
if (TextUtils.isEmpty(selectAnswer)) {
wrongCount++;
if (type.contains("单选")) {
danxuanWrong++;
} else if (type.contains("判断")) {
panduanWrong++;
} else if (type.contains("多选")) {
duoxuanWrong++;
}
}
} else if (listIndex == questionLst.size() - 1) {
if (TextUtils.isEmpty(selectAnswer)) {
unDone++;
if (type.contains("单选")) {
danxuanWrong++;
} else if (type.contains("判断")) {
panduanWrong++;
} else if (type.contains("多选")) {
duoxuanWrong++;
}
}
}
showCommitCard(this, unDone);
chageAlpha(0.5f);
break;
case R.id.tv_show_card:
showAnswerCard(statusList, rightCount, wrongCount, listIndex, questionLst.size());
break;
case R.id.rl_card:
showAnswerCard(statusList, rightCount, wrongCount, listIndex, questionLst.size());
break;
}
}
}
... ...
package com.hh.xuetubao.activity.pratice;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
import com.hh.xuetubao.adapter.AnswerSheetGridAdapter;
import com.hh.xuetubao.adapter.ListAnswerAdapter;
import com.hh.xuetubao.bean.AnswerBean;
import com.hh.xuetubao.model.ExerciseModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 模拟练习页面
*/
public class c extends BaseMvpActivity<CommonPresenter, ExerciseModel> implements ICommonView, View.OnClickListener {
@BindView(R.id.list_answer)
ListView listAnswer;
@BindView(R.id.tv_radio)
TextView tvRadio;
@BindView(R.id.tv_max)
TextView tvMax;
@BindView(R.id.tv_current)
TextView tvCurrent;
@BindView(R.id.tv_title)
TextView tvTitle;
@BindView(R.id.tv_topic)
TextView tvTopic;
@BindView(R.id.rl_last)
RelativeLayout rlLast;
@BindView(R.id.rl_next)
RelativeLayout rlNext;
@BindView(R.id.index)
TextView index;
@BindView(R.id.all)
TextView all;
@BindView(R.id.tv_right_num)
TextView tvRightNum;
@BindView(R.id.tv_wrong_num)
TextView tvWrongNum;
@BindView(R.id.lin_tab)
LinearLayout linTab;
@BindView(R.id.rl_card)
RelativeLayout rlCard;
@BindView(R.id.right_select)
TextView rightSelect;
@BindView(R.id.right_answer)
TextView rightAnswerText;
@BindView(R.id.rl_answer)
RelativeLayout rlAnswer;
@BindView(R.id.commit)
LinearLayout commit;
@BindView(R.id.tv2)
TextView tv2;
@BindView(R.id.tv_show_card)
TextView tvShowCard;
private String catalogOid;
private String accountOid;
private int listIndex = 0; //数据下标
private String type;//题目类型
private boolean isClickAble = true;//是否能选择多条目
private String rightAnswer;//当前题目正确答案
private int rightCount;//答对题的数量
private int wrongCount;//答错题的数量
private List<AnswerBean.QuestionLstBean> questionLst = new ArrayList<>();//创建集合存储这一套题
private ListAnswerAdapter optionsAdapter;
private String selectAnswer = "";
private AnswerSheetGridAdapter sheetGridAdapter;
private PopupWindow popupWindow;
private List<Integer> statusList = new ArrayList<>();//保存答题结果 0:未答题 1:答对 2:答错
private List<Integer> integerList = new ArrayList<>();// 存放 1或者2 用来判断多选题 是否答对
private List<String> stringList = new ArrayList<>();//用来存放多选题选择的答案
private List<String> historyAnswer = new ArrayList<>();//存放历史选择的答案
private boolean isRight;
private int unDone;//未完成的题
private int danxuanCount;
private int duoxuanCount;
private int panduanCount;
private int danxuanWrong;
private int panduanWrong;
private int duoxuanWrong;
private double totalScore;
private double danxuan;
private double duoxuan;
private double panduan;
@Override
public void initView() {
accountOid = SharedPrefrenceUtils.getString(this, "AccountOid");
catalogOid = getIntent().getStringExtra("catalogOid");
rlLast.setOnClickListener(this);
rlNext.setOnClickListener(this);
linTab.setOnClickListener(this);
rlCard.setOnClickListener(this);
commit.setOnClickListener(this);
tvShowCard.setOnClickListener(this);
tvShowCard.setText("查看答案");
listAnswer.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ImageView wrong = (ImageView) view.findViewById(R.id.img_wrong);
ImageView right = (ImageView) view.findViewById(R.id.img_right);
TextView option = (TextView) view.findViewById(R.id.option);
TextView text = (TextView) view.findViewById(R.id.text);
Log.e("zhangtao:trueType", type);
if (type.contains("单选") || type.contains("判断")) {
//单选· 多选 选择答案 设置为单选
if (isClickAble) {
isClickAble = false;
try {
if (position == 0) {
selectAnswer = "A";
} else if (position == 1) {
selectAnswer = "B";
} else if (position == 2) {
selectAnswer = "C";
} else if (position == 3) {
selectAnswer = "D";
} else if (position == 4) {
selectAnswer = "E";
}
} catch (Exception e) {
Log.e("xuetubao:", e.toString());
}
//判断 单选题 是否答对
if (rightAnswer.contains(selectAnswer)) {
text.setTextColor(getResources().getColor(R.color.color_ff5400));
option.setTextColor(getResources().getColor(R.color.color_ff5400));
rightCount++;
tvRightNum.setText(String.valueOf(rightCount));
statusList.set(listIndex, 1);
sheetGridAdapter.notifyDataSetChanged();
if (type.contains("单选")) {
totalScore += danxuan;
} else if (type.contains("判断")) {
totalScore += panduan;
}
String questionOid = questionLst.get(position).getQuestionOid();
mPresenter.getPresenter(7, 2, accountOid, questionOid, String.valueOf(1), catalogOid);
} else if (!rightAnswer.contains(selectAnswer)) {
wrongCount++;
tvWrongNum.setText(String.valueOf(wrongCount));
statusList.set(listIndex, 2);
sheetGridAdapter.notifyDataSetChanged();
String questionOid = questionLst.get(position).getQuestionOid();
mPresenter.getPresenter(4, 2, accountOid, questionOid, String.valueOf(1), catalogOid);
text.setTextColor(getResources().getColor(R.color.color_ff5400));
option.setTextColor(getResources().getColor(R.color.color_ff5400));
if (type.contains("单选")) {
danxuanWrong++;
} else if (type.contains("判断")) {
panduanWrong++;
}
}
}
} else if (type.contains("多选")) {
//多选题 选择答案 不用设置为单选
if (isClickAble) {
try {
if (position == 0) {
selectAnswer += "A";
stringList.add("A");
} else if (position == 1) {
selectAnswer += "B";
stringList.add("B");
} else if (position == 2) {
selectAnswer += "C";
stringList.add("C");
} else if (position == 3) {
selectAnswer += "D";
stringList.add("D");
} else if (position == 4) {
selectAnswer += "E";
stringList.add("E");
}
} catch (Exception e) {
Log.e("xuetubao:", e.toString());
}
for (int i = 0; i < stringList.size(); i++) {
if (rightAnswer.contains(stringList.get(i))) {
integerList.add(1);
} else {
integerList.add(2);
}
}
//判断多选题是否答对
for (int i = 0; i < integerList.size(); i++) {
if (integerList.get(i) == 2) {
text.setTextColor(getResources().getColor(R.color.color_ff5400));
option.setTextColor(getResources().getColor(R.color.color_ff5400));
isRight = false;
} else {
text.setTextColor(getResources().getColor(R.color.color_ff5400));
option.setTextColor(getResources().getColor(R.color.color_ff5400));
isRight = true;
}
}
if (!isRight) {
isClickAble = false;
statusList.set(listIndex, 1);
sheetGridAdapter.notifyDataSetChanged();
wrongCount++;
tvWrongNum.setText(String.valueOf(wrongCount));
statusList.set(listIndex, 2);
sheetGridAdapter.notifyDataSetChanged();
String questionOid = questionLst.get(position).getQuestionOid();
mPresenter.getPresenter(4, 2, accountOid, questionOid, String.valueOf(1), catalogOid);
/* optionsAdapter.setRight(rightAnswer);
optionsAdapter.notifyDataSetChanged();*/
text.setTextColor(getResources().getColor(R.color.color_ff5400));
option.setTextColor(getResources().getColor(R.color.color_ff5400));
duoxuanWrong++;
} else if (isRight && rightAnswer.length() == selectAnswer.length()) {
isClickAble = false;
rightCount++;
tvRightNum.setText(String.valueOf(rightCount));
statusList.set(listIndex, 1);
sheetGridAdapter.notifyDataSetChanged();
totalScore += duoxuan;
text.setTextColor(getResources().getColor(R.color.color_ff5400));
option.setTextColor(getResources().getColor(R.color.color_ff5400));
}
}
}
}
});
}
@Override
public int initLayout() {
// return R.layout.activity_answer;
return R.layout.activity_answer_sheet;
}
@Override
public void initData() {
// mPresenter.getPresenter(8, 1, catalogOid, String.valueOf(10), accountOid);
mPresenter.getPresenter(7, 1, accountOid, catalogOid, String.valueOf(1));
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public ExerciseModel getModel() {
return new ExerciseModel();
}
@Override
public void getData(Object o, int api, int intent) {
if (api == 7 && intent == 1) {
AnswerBean bean = (AnswerBean) o;
List<AnswerBean.QuestionLstBean> questionLstBeans = bean.getQuestionLst();
questionLst.addAll(questionLstBeans);
danxuanCount = bean.getRadioCount();
duoxuanCount = bean.getMultipleCount();
panduanCount = bean.getJudgeCount();
danxuan = bean.getRadioScore();
duoxuan = bean.getMultipleScore();
panduan = bean.getJudgeScore();
tvMax.setText(String.valueOf(questionLst.size()));
all.setText(String.valueOf(questionLst.size()));
tvTopic.setText(questionLstBeans.get(listIndex).getQuestionTitle());
tvCurrent.setText(String.valueOf(listIndex + 1));
index.setText(String.valueOf(listIndex + 1));
type = questionLstBeans.get(listIndex).getQuestionTypeName();
tvRadio.setText(type);
rightAnswer = questionLstBeans.get(listIndex).getAnswer();
rightSelect.setText(questionLstBeans.get(listIndex).getAnswer());
if (!TextUtils.isEmpty(questionLstBeans.get(listIndex).getAnswer())) {
rightAnswerText.setText(questionLstBeans.get(listIndex).getWrongAnaly());
}
optionsAdapter = new ListAnswerAdapter(questionLst.get(listIndex).getOptionsLst(), this);
listAnswer.setAdapter(optionsAdapter);
optionsAdapter.notifyDataSetChanged();
for (AnswerBean.QuestionLstBean a : questionLst) {
statusList.add(0);
}
sheetGridAdapter = new AnswerSheetGridAdapter(statusList, this);
}
}
private void doRefresh(boolean isNext) {
historyAnswer.add(selectAnswer);
integerList.clear();
selectAnswer = "";
stringList.clear();
isClickAble = true;
tvTopic.setText(questionLst.get(listIndex).getQuestionTitle());
tvCurrent.setText(String.valueOf(listIndex + 1));
type = questionLst.get(listIndex).getQuestionTypeName();
tvRadio.setText(type);
index.setText(String.valueOf(listIndex + 1));
rightAnswer = questionLst.get(listIndex).getAnswer();
rightSelect.setText(questionLst.get(listIndex).getAnswer());
if (!TextUtils.isEmpty(questionLst.get(listIndex).getWrongAnaly()))
rightAnswerText.setText(questionLst.get(listIndex).getWrongAnaly());
rlAnswer.setVisibility(View.GONE);
optionsAdapter = new ListAnswerAdapter(questionLst.get(listIndex).getOptionsLst(), this);
listAnswer.setAdapter(optionsAdapter);
optionsAdapter.notifyDataSetChanged();
if (historyAnswer.size() > listIndex) {
optionsAdapter.setSelect(historyAnswer.get(listIndex));
optionsAdapter.notifyDataSetInvalidated();
}
}
private void showAnswerCard(List<Integer> sheetCard, int rightCount, int wrongCount, int currentIndex, int maxTopic) {
View contentView = LayoutInflater.from(this).inflate(R.layout.pop_answer_sheet, null);
View view = LayoutInflater.from(this).inflate(R.layout.activity_answer, null);
TextView tv_card = (TextView) contentView.findViewById(R.id.tv_card);
GridView gridView = (GridView) contentView.findViewById(R.id.grid_dati);
TextView index = (TextView) contentView.findViewById(R.id.index);
TextView total = (TextView) contentView.findViewById(R.id.total);
TextView right = (TextView) contentView.findViewById(R.id.tv_right_num);
TextView wrong = (TextView) contentView.findViewById(R.id.tv_wrong_num);
right.setText(String.valueOf(rightCount));
wrong.setText(String.valueOf(wrongCount));
index.setText(String.valueOf(currentIndex + 1));
total.setText(String.valueOf(maxTopic));
// sheetGridAdapter = new AnswerSheetGridAdapter(sheetCard, this);
gridView.setAdapter(sheetGridAdapter);
popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popupWindow.setOutsideTouchable(false);
popupWindow.setTouchable(true);
popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
tv_card.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (popupWindow != null) {
popupWindow.dismiss();
}
}
});
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void showCommitCard(final Context context, int laveCount) {
View contentView = LayoutInflater.from(this).inflate(R.layout.pop_answer_commit, null);
View view = LayoutInflater.from(this).inflate(R.layout.activity_answer, null);
TextView count = (TextView) contentView.findViewById(R.id.tv_count);
TextView goOn = (TextView) contentView.findViewById(R.id.tv_continue);
TextView commit = (TextView) contentView.findViewById(R.id.tv_commit);
count.setText(String.valueOf(laveCount));
popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popupWindow.setOutsideTouchable(false);
popupWindow.setTouchable(true);
popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0);
goOn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.dismiss();
}
});
commit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.dismiss();
Intent intent = new Intent(context, TestScoreActivity.class);
intent.putExtra("catalogOid", catalogOid);
intent.putExtra("danxuanCount", danxuanCount);
intent.putExtra("duoxuanCount", duoxuanCount);
intent.putExtra("panduanCount", panduanCount);
intent.putExtra("danxuanWrong", danxuanWrong);
intent.putExtra("panduanWrong", panduanWrong);
intent.putExtra("duoxuanWrong", duoxuanWrong);
intent.putExtra("totalScore", totalScore);
Log.e("zhangtao", totalScore + "分");
startActivity(intent);
c.this.finish();
}
});
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
chageAlpha(1f);
}
});
}
private void chageAlpha(float color) {
WindowManager.LayoutParams lp = this.getWindow().getAttributes();
lp.alpha = color;
this.getWindow().setAttributes(lp);
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.rl_last:
if (listIndex == 0) {
Toast.makeText(this, "当前已是第一题", Toast.LENGTH_SHORT).show();
} else {
listIndex--;
doRefresh(false);
}
break;
case R.id.rl_next:
if (listIndex < questionLst.size() - 1) {
if (type.contains("多选")) {
if (selectAnswer.length() != rightAnswer.length()) {
statusList.set(listIndex, 2);
}
}
if (TextUtils.isEmpty(selectAnswer)) {
if (listIndex > historyAnswer.size() - 1) {
unDone++;
wrongCount++;
statusList.set(listIndex, 0);
}
}
listIndex++;
doRefresh(true);
} else if (listIndex == questionLst.size() - 1) {
Toast.makeText(this, "当前已是最后一题", Toast.LENGTH_SHORT).show();
}
break;
case R.id.lin_tab:
this.finish();
break;
case R.id.tv_look:
rlAnswer.setVisibility(View.VISIBLE);
break;
case R.id.commit:
if (listIndex > historyAnswer.size()) {
if (TextUtils.isEmpty(selectAnswer)) {
wrongCount++;
if (type.contains("单选")) {
danxuanWrong++;
} else if (type.contains("判断")) {
panduanWrong++;
} else if (type.contains("多选")) {
duoxuanWrong++;
}
}
} else if (listIndex == questionLst.size() - 1) {
if (TextUtils.isEmpty(selectAnswer)) {
unDone++;
if (type.contains("单选")) {
danxuanWrong++;
} else if (type.contains("判断")) {
panduanWrong++;
} else if (type.contains("多选")) {
duoxuanWrong++;
}
}
} else {
Toast.makeText(this, "当前已是最后一题", Toast.LENGTH_SHORT).show();
}
break;
case R.id.tv_show_card:
rlAnswer.setVisibility(View.VISIBLE);
break;
case R.id.rl_card:
showAnswerCard(statusList, rightCount, wrongCount, listIndex, questionLst.size());
break;
}
}
}
... ...
... ... @@ -49,6 +49,18 @@ public class ListAnswerAdapter extends BaseAdapter {
option.setText(list.get(position).getOptionName());
text.setText(list.get(position).getOptionDesc());
if (!TextUtils.isEmpty(rightAnswer)) {
if (rightAnswer.contains(list.get(position).getOptionName())) {
right.setVisibility(View.VISIBLE);
wrong.setVisibility(View.GONE);
option.setVisibility(View.GONE);
} else {
right.setVisibility(View.GONE);
wrong.setVisibility(View.VISIBLE);
option.setVisibility(View.GONE);
}
}
if (!TextUtils.isEmpty(selectString)) {
if (selectString.contains(list.get(position).getOptionName())) {
option.setTextColor(context.getResources().getColor(R.color.color_ff5400));
... ... @@ -64,6 +76,18 @@ public class ListAnswerAdapter extends BaseAdapter {
this.selectString = answer;
}
private String rightAnswer;
public void setRight(String answer) {
this.rightAnswer = answer;
}
private String listRight;
public void setListRight(String answer) {
this.listRight = answer;
}
@Override
public boolean isEnabled(int position) {
if (!TextUtils.isEmpty(selectString)) {
... ...
... ... @@ -14,7 +14,7 @@ import android.widget.TextView;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
import com.hh.xuetubao.activity.pratice.AnswerWrongActivity;
import com.hh.xuetubao.activity.pratice.c;
import com.hh.xuetubao.adapter.PractiveWrongAdapter;
import com.hh.xuetubao.bean.AnswerBean;
import com.hh.xuetubao.model.ExerciseModel;
... ... @@ -30,7 +30,7 @@ import butterknife.ButterKnife;
import butterknife.Unbinder;
/**
* 错题Fragment
* 我的错题
*/
public class PraticeWrongFragment extends BaseMvpFragment<CommonPresenter, ExerciseModel> implements ICommonView {
... ... @@ -43,6 +43,7 @@ public class PraticeWrongFragment extends BaseMvpFragment<CommonPresenter, Exerc
private List<AnswerBean.CatalogLstBean> catalogLst = new ArrayList<>();
private PraticeWrongFragment fragment;
private String accountOid;
private int count;
@Override
public int getLayoutId() {
... ... @@ -58,7 +59,8 @@ public class PraticeWrongFragment extends BaseMvpFragment<CommonPresenter, Exerc
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getActivity(), AnswerWrongActivity.class);
// Intent intent = new Intent(getActivity(), AnswerWrongActivity.class);
Intent intent = new Intent(getActivity(), c.class);
intent.putExtra("catalogOid", catalogLst.get(position).getCatalogOid());
startActivity(intent);
}
... ... @@ -90,15 +92,21 @@ public class PraticeWrongFragment extends BaseMvpFragment<CommonPresenter, Exerc
@Override
public void getData(Object o, int api, int intent) {
catalogLst.clear();
AnswerBean bean = (AnswerBean) o;
List<AnswerBean.CatalogLstBean> catalogLstBeans = bean.getCatalogLst();
tvNum.setText(String.valueOf(catalogLstBeans.size()));
catalogLst.addAll(catalogLstBeans);
practiveWrongAdapter.notifyDataSetChanged();
if (api == 6 && intent == 1) {
count=0;
catalogLst.clear();
AnswerBean bean = (AnswerBean) o;
List<AnswerBean.CatalogLstBean> catalogLstBeans = bean.getCatalogLst();
for (int i = 0; i < catalogLstBeans.size(); i++) {
count += catalogLstBeans.get(i).getWrongNum();
Log.e("xuetubao", String.valueOf(count));
}
tvNum.setText(String.valueOf(count));
catalogLst.addAll(catalogLstBeans);
practiveWrongAdapter.notifyDataSetChanged();
}
}
... ...
... ... @@ -12,6 +12,7 @@ import android.widget.RelativeLayout;
import com.hh.xuetubao.R;
import com.hh.xuetubao.activity.pratice.AnswerSheetActivity;
import com.hh.xuetubao.activity.pratice.MockExamActivity;
import com.hh.xuetubao.activity.pratice.a;
import com.hh.xuetubao.model.MainModel;
import com.hh.xuetubao.mvp.BaseMvpFragment;
import com.hh.xuetubao.mvp.CommonPresenter;
... ... @@ -102,7 +103,8 @@ public class PriacticeDistFragment extends BaseMvpFragment<CommonPresenter, Main
getActivity().finish();
break;
case R.id.frag_pricatice_dist_sjlx: // - > 随机练习
intent = new Intent(getActivity(), AnswerSheetActivity.class);
// intent = new Intent(getActivity(), AnswerSheetActivity.class);
intent = new Intent(getActivity(), a.class);
intent.putExtra("catalogOid", catalogOid);
startActivity(intent);
break;
... ...
... ... @@ -110,6 +110,12 @@
</RelativeLayout>
<com.hh.xuetubao.Utils.WaveView
android:id="@+id/waveview"
android:layout_width="@dimen/dp_90"
android:layout_height="@dimen/dp_90"
android:layout_below="@id/lin_tab"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_50" />
</RelativeLayout>
\ No newline at end of file
... ...