@Override public final void onBindViewHolder(final ViewHolder viewHolder, int i) { final QuestionAnsweringRVInfo currentQuestionAnsweringRVInfo = questionAnsweringRVInfoList.get(i); viewHolder.questionIndexOut.setText( String.valueOf(currentQuestionAnsweringRVInfo.getIndex() + 1)); String[] answerArray; String text = ""; try { answerArray = currentQuestionAnsweringRVInfo.getAnswer().getAnswerArray(); } catch (NullPointerException e) { answerArray = new String[0]; } if (answerArray.length == 0) { // *Not answered yet: text = context.getResources().getString(R.string.output_examAnswering_questionNotAnsweredYet); } else { // *It has an answer: for (int j = 0; j < answerArray.length; j++) { text += answerArray[j]; text += (answerArray.length > (j + 1)) ? ", " : ""; } } viewHolder.textOut.setText(text); viewHolder.questionAnsweringRVInfo = currentQuestionAnsweringRVInfo; }
/* * * ========== * ========== * ========== * ========== * ========== * ========== * ========== * ========== * * * Validatable methods: * * ========== * ========== * ========== * ========== * ========== * ========== * ========== * ========== * */ @Override public boolean isValid() { for (QuestionAnsweringRVInfo questionAnsweringRVInfo : questionAnsweringRVInfoList) { try { if (questionAnsweringRVInfo.getAnswer().getAnswerArray().length == 0) { try { invalidText = context .getResources() .getString( R.string.output_invalidField_questionAnsweringRV_unansweredQuestions); } catch (NullPointerException e) { e.printStackTrace(); } return false; } } catch (NullPointerException e) { try { invalidText = context .getResources() .getString(R.string.output_invalidField_questionAnsweringRV_unansweredQuestions); } catch (NullPointerException e2) { e2.printStackTrace(); } return false; } } return true; }