public void loadQuestion() { // get question cId = SPUtil.getIntegerFromSP(SPUtil.CURRENT_CATALOG_ID, sharedPreferences); if (cId == 0) cId = 1; qId = SPUtil.getIntegerFromSP(SPUtil.CURRENT_QUESTON_ID, sharedPreferences); if (qId == 0) qId = 1; question = ExamParse.getQuestion(exam, cId, qId); }
public void changeQuestion(int newCId, int newQId) { // question = ExamParse.getQuestion(exam,newCId, newQId); // this.cId = newCId; // this.qId = newQId; SPUtil.save2SP(SPUtil.CURRENT_CATALOG_ID, newCId, sharedPreferences); SPUtil.save2SP(SPUtil.CURRENT_QUESTON_ID, newQId, sharedPreferences); loadQuestion(); loadAnswer(); resetQuestion(); changeComponents(); }
public void loadExam() { // get exam String home = SPUtil.getFromSP(SPUtil.CURRENT_APP_HOME, sharedPreferences); // String userId = SPUtil.getFromSP(SPUtil.CURRENT_USER_ID, sharedPreferences); String examId = SPUtil.getFromSP(SPUtil.CURRENT_EXAM_ID, sharedPreferences); FileInputStream inputStream; try { inputStream = new FileInputStream(new File(home + File.separator + "exam" + File.separator + examId)); exam = ExamXMLParse.parseExam(inputStream); } catch (FileNotFoundException e) { Log.e(LOG_TAG, e.getMessage()); } }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { Log.i(LOG_TAG, "onCreate..."); super.onCreate(savedInstanceState); setContentView(R.layout.result); mContext = getApplicationContext(); imgHome = (ImageView) findViewById(R.id.imgHome); imgHome.setOnClickListener(onClickListener); String score = SPUtil.getFromSP(SPUtil.CURRENT_EXAM_SCORE, sharedPreferences); scoreTV = (TextView) this.findViewById(R.id.yourScoreTV); scoreTV.setText(score); String remainExamCount = SPUtil.getFromSP(SPUtil.CURRENT_USER_EXAM_REMAINING_COUNT, sharedPreferences); examLeftTV = (TextView) this.findViewById(R.id.examLeftTV); examLeftTV.setText("You have " + remainExamCount + " exam paper remaining,please continue!"); continueBtn = (Button) this.findViewById(R.id.continueBtn); if ("0".equals(remainExamCount)) { continueBtn.setEnabled(false); continueBtn.setBackgroundResource(R.drawable.button_disable); examLeftTV.setTextColor(getResources().getColor(R.color.success_message_color)); // Save Exam Status SPUtil.save2SP(SPUtil.CURRENT_EXAM_STATUS, SPUtil.EXAM_STATUS_END, sharedPreferences); } else { continueBtn.setOnClickListener(onClickListener); } quitBtn = (Button) this.findViewById(R.id.quitBtn); quitBtn.setOnClickListener(onClickListener); }