1 |
efrain |
1 |
package com.cesams.twogetskills.activity;
|
|
|
2 |
|
|
|
3 |
import android.content.Intent;
|
|
|
4 |
import android.os.Bundle;
|
|
|
5 |
|
|
|
6 |
import com.cesams.twogetskills.Constants;
|
|
|
7 |
import com.cesams.twogetskills.dao.AnswerDao;
|
|
|
8 |
import com.cesams.twogetskills.dao.QuestionDao;
|
|
|
9 |
import com.cesams.twogetskills.dao.QuizDao;
|
|
|
10 |
import com.cesams.twogetskills.fragment.QuizFailFragment;
|
|
|
11 |
import com.cesams.twogetskills.fragment.QuizIntroFragment;
|
|
|
12 |
import com.cesams.twogetskills.fragment.QuizMultipleAnswerFragment;
|
|
|
13 |
import com.cesams.twogetskills.fragment.QuizPassFragment;
|
|
|
14 |
import com.cesams.twogetskills.fragment.QuizRangeSimpleFragment;
|
|
|
15 |
import com.cesams.twogetskills.fragment.QuizSingleAnswerFragment;
|
|
|
16 |
import com.cesams.twogetskills.entity.Answer;
|
|
|
17 |
import com.cesams.twogetskills.entity.Question;
|
|
|
18 |
import com.cesams.twogetskills.entity.Quiz;
|
|
|
19 |
import com.cesams.twogetskills.pojo.QuizResponse;
|
|
|
20 |
import com.cesams.twogetskills.skeleton.IQuizActivity;
|
|
|
21 |
|
|
|
22 |
import androidx.appcompat.app.AppCompatActivity;
|
|
|
23 |
import androidx.fragment.app.Fragment;
|
|
|
24 |
import androidx.fragment.app.FragmentTransaction;
|
|
|
25 |
|
|
|
26 |
import android.os.CountDownTimer;
|
|
|
27 |
import android.view.View;
|
|
|
28 |
import android.widget.Button;
|
|
|
29 |
import android.widget.TextView;
|
|
|
30 |
|
|
|
31 |
import com.cesams.twogetskills.R;
|
|
|
32 |
|
|
|
33 |
import java.text.SimpleDateFormat;
|
|
|
34 |
import java.util.ArrayList;
|
|
|
35 |
import java.util.Calendar;
|
|
|
36 |
import java.util.Date;
|
|
|
37 |
import java.util.HashMap;
|
|
|
38 |
|
|
|
39 |
public class QuizActivity extends AppCompatActivity implements IQuizActivity {
|
8 |
gabriel |
40 |
|
1 |
efrain |
41 |
private final static String TAG = "C2GS - QuizActivity";
|
|
|
42 |
private final static String PREFIX_FRAG = "FRAG";
|
|
|
43 |
private Quiz quiz;
|
|
|
44 |
private String quizUuid;
|
|
|
45 |
private ArrayList<Question> questions;
|
|
|
46 |
private HashMap<String, ArrayList<Answer>> answers;
|
|
|
47 |
private ArrayList<QuizResponse> quizResponses;
|
|
|
48 |
private TextView textViewScore;
|
|
|
49 |
private TextView textViewQuestion;
|
|
|
50 |
private TextView textChronometer;
|
|
|
51 |
private HashMap<String, Fragment> fragmentHashMap;
|
|
|
52 |
private Button btnPrevious;
|
|
|
53 |
private Button btnNext;
|
|
|
54 |
private Button btnStart;
|
|
|
55 |
private Button btnFinish;
|
|
|
56 |
private Button btnExit;
|
|
|
57 |
private int questionIdxActive;
|
|
|
58 |
private int fragmentIdxActive;
|
|
|
59 |
private int totalPoints;
|
|
|
60 |
private CountDownTimer countDownTimer;
|
|
|
61 |
|
|
|
62 |
@Override
|
|
|
63 |
protected void onCreate(Bundle savedInstanceState) {
|
|
|
64 |
super.onCreate(savedInstanceState);
|
|
|
65 |
setContentView(R.layout.activity_quiz);
|
|
|
66 |
|
|
|
67 |
questionIdxActive = 0;
|
|
|
68 |
fragmentIdxActive = 0;
|
|
|
69 |
questions = new ArrayList<>();
|
|
|
70 |
answers = new HashMap<>();
|
|
|
71 |
quizResponses = new ArrayList<>();
|
|
|
72 |
fragmentHashMap = new HashMap<>();
|
|
|
73 |
|
|
|
74 |
//companyUuid = getIntent().getStringExtra("companyUuid");
|
|
|
75 |
//topicUuid = getIntent().getStringExtra("topicUuid");
|
|
|
76 |
//capsuleUuid = getIntent().getStringExtra("capsuleUuid");
|
|
|
77 |
// slideUuid = getIntent().getStringExtra("slideUuid");
|
|
|
78 |
quizUuid = getIntent().getStringExtra("quizUuid");
|
|
|
79 |
//userUuid = getIntent().getStringExtra("userUuid");
|
|
|
80 |
|
|
|
81 |
quiz = new Quiz();
|
|
|
82 |
quiz.setCompanyUuid(getIntent().getStringExtra("quiz_company_uuid"));
|
|
|
83 |
quiz.setUuid(getIntent().getStringExtra("quiz_uuid"));
|
|
|
84 |
quiz.setName(getIntent().getStringExtra("quiz_name"));
|
|
|
85 |
quiz.setText(getIntent().getStringExtra("quiz_text"));
|
|
|
86 |
quiz.setFailed(getIntent().getStringExtra("quiz_failed"));
|
|
|
87 |
quiz.setPoints(getIntent().getIntExtra("quiz_points", 0));
|
|
|
88 |
quiz.setMinimumPointsRequired(getIntent().getIntExtra("quiz_minimum_points_required", 0));
|
|
|
89 |
quiz.setMaxTime(getIntent().getIntExtra("quiz_max_time", 0));
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
int maxAnswer = 0;
|
|
|
94 |
int maxQuestion = getIntent().getIntExtra("questions", 0);
|
|
|
95 |
Question question;
|
|
|
96 |
Answer answer;
|
|
|
97 |
ArrayList<Answer> questionAnswers;
|
|
|
98 |
for(int i = 1; i <= maxQuestion; i++){
|
|
|
99 |
question = new Question();
|
|
|
100 |
question.setQuizUuid(quizUuid);
|
|
|
101 |
question.setUuid(getIntent().getStringExtra("question" + i + "_uuid"));
|
|
|
102 |
question.setText(getIntent().getStringExtra("question" + i + "_text"));
|
|
|
103 |
question.setPoints(getIntent().getIntExtra("question" + i + "_points", 0));
|
|
|
104 |
question.setMaxlength(getIntent().getIntExtra("question" + i + "_max_length", 0));
|
|
|
105 |
question.setType(getIntent().getStringExtra("question" + i + "_type"));
|
|
|
106 |
|
|
|
107 |
questions.add(question);
|
|
|
108 |
|
|
|
109 |
maxAnswer = getIntent().getIntExtra("question" + i + "_answers", 0);
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
questionAnswers = new ArrayList<>();
|
|
|
113 |
for(int j = 1; j <= maxAnswer; j++ ) {
|
|
|
114 |
answer = new Answer();
|
|
|
115 |
answer.setQuestionUuid(question.getUuid());
|
|
|
116 |
answer.setUuid(getIntent().getStringExtra("question" + i + "_answer_uuid" + j));
|
|
|
117 |
answer.setText(getIntent().getStringExtra("question" + i + "_answer_text" + j));
|
|
|
118 |
answer.setPoints(getIntent().getIntExtra("question" + i + "_answer_points" + j, 0));
|
|
|
119 |
answer.setCorrect(getIntent().getStringExtra("question" + i + "_answer_correct" + j));
|
|
|
120 |
|
|
|
121 |
questionAnswers.add(answer);
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
|
|
|
125 |
answers.put(question.getUuid(), questionAnswers);
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
textViewScore = (TextView) findViewById(R.id.activity_quiz_textview_score);
|
|
|
130 |
textViewScore.setText("0");
|
|
|
131 |
|
|
|
132 |
textViewQuestion = (TextView) findViewById(R.id.activity_quiz_textview_question_count);
|
|
|
133 |
textViewQuestion.setText(String.valueOf(questions.size()));
|
|
|
134 |
|
|
|
135 |
textChronometer = (TextView) findViewById(R.id.activity_quiz_textview_chronometer);
|
|
|
136 |
textChronometer.setText("00:00");
|
|
|
137 |
|
|
|
138 |
btnPrevious = (Button) findViewById(R.id.activity_quiz_button_previous);
|
|
|
139 |
btnPrevious.setVisibility(View.INVISIBLE);
|
8 |
gabriel |
140 |
|
1 |
efrain |
141 |
btnPrevious.setOnClickListener(new View.OnClickListener() {
|
|
|
142 |
@Override
|
|
|
143 |
public void onClick(View view) {
|
|
|
144 |
if (questionIdxActive > 0) {
|
|
|
145 |
questionIdxActive--;
|
|
|
146 |
}
|
|
|
147 |
showQuestions();
|
|
|
148 |
}
|
|
|
149 |
});
|
|
|
150 |
|
|
|
151 |
btnNext = (Button) findViewById(R.id.activity_quiz_button_next);
|
|
|
152 |
btnNext.setVisibility(View.INVISIBLE);
|
|
|
153 |
btnNext.setOnClickListener(new View.OnClickListener() {
|
|
|
154 |
@Override
|
|
|
155 |
public void onClick(View view) {
|
|
|
156 |
if (questionIdxActive < (questions.size() - 1)) {
|
|
|
157 |
questionIdxActive++;
|
|
|
158 |
showQuestions();
|
|
|
159 |
}
|
|
|
160 |
}
|
|
|
161 |
});
|
|
|
162 |
|
|
|
163 |
btnExit = (Button) findViewById(R.id.activity_quiz_button_exit);
|
|
|
164 |
btnExit.setVisibility(View.INVISIBLE);
|
|
|
165 |
btnExit.setOnClickListener(new View.OnClickListener() {
|
|
|
166 |
@Override
|
|
|
167 |
public void onClick(View view) {
|
|
|
168 |
if(totalPoints >= quiz.getMinimumPointsRequired()) {
|
|
|
169 |
exitQuizPass();
|
|
|
170 |
} else {
|
|
|
171 |
exitQuizFail();
|
|
|
172 |
}
|
|
|
173 |
}
|
|
|
174 |
});
|
|
|
175 |
|
|
|
176 |
btnStart = (Button) findViewById(R.id.activity_quiz_button_start);
|
|
|
177 |
btnStart.setVisibility(View.VISIBLE);
|
|
|
178 |
btnStart.setOnClickListener(new View.OnClickListener() {
|
|
|
179 |
@Override
|
|
|
180 |
public void onClick(View view) {
|
|
|
181 |
Calendar calendar = Calendar.getInstance();
|
|
|
182 |
Date date = calendar.getTime();
|
|
|
183 |
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.FORMAT_DATETIME_SERVICE);
|
|
|
184 |
String dateOn = simpleDateFormat.format(date);
|
|
|
185 |
|
|
|
186 |
long millisInFuture = quiz.getMaxTime() * 60000;
|
|
|
187 |
|
|
|
188 |
countDownTimer = new CountDownTimer(millisInFuture, 1000) {
|
|
|
189 |
|
|
|
190 |
public void onTick(long millisUntilFinished) {
|
|
|
191 |
long minutes = millisUntilFinished / 60000;
|
|
|
192 |
long seconds = (millisUntilFinished - (minutes * 60000)) / 1000;
|
|
|
193 |
|
|
|
194 |
String sMinutes = minutes < 10 ? "0" + minutes : String.valueOf(minutes);
|
|
|
195 |
String sSeconds = seconds < 10 ? "0" + seconds : String.valueOf(seconds);
|
|
|
196 |
|
|
|
197 |
textChronometer.setText(sMinutes + ":" + sSeconds);
|
|
|
198 |
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
public void onFinish() {
|
|
|
202 |
textChronometer.setText("--:--");
|
|
|
203 |
finishQuiz();
|
|
|
204 |
}
|
|
|
205 |
}.start();
|
|
|
206 |
|
|
|
207 |
btnStart.setVisibility(View.INVISIBLE);
|
|
|
208 |
|
|
|
209 |
if (questions.size() == 1) {
|
|
|
210 |
btnFinish.setVisibility(View.VISIBLE);
|
|
|
211 |
} else {
|
|
|
212 |
btnNext.setVisibility(View.VISIBLE);
|
|
|
213 |
}
|
|
|
214 |
|
|
|
215 |
showQuestions();
|
|
|
216 |
}
|
|
|
217 |
|
|
|
218 |
});
|
|
|
219 |
|
|
|
220 |
btnFinish = (Button) findViewById(R.id.activity_quiz_button_finish);
|
|
|
221 |
btnFinish.setVisibility(View.INVISIBLE);
|
|
|
222 |
btnFinish.setOnClickListener(new View.OnClickListener() {
|
|
|
223 |
@Override
|
|
|
224 |
public void onClick(View view) {
|
|
|
225 |
finishQuiz();
|
|
|
226 |
|
|
|
227 |
}
|
|
|
228 |
});
|
|
|
229 |
|
|
|
230 |
invokeFragment(Constants.IDX_QUIZ_FRAGMENT_INTRO);
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
@Override
|
|
|
236 |
public int getTotalPoints() {
|
|
|
237 |
return totalPoints;
|
|
|
238 |
}
|
|
|
239 |
|
|
|
240 |
|
|
|
241 |
|
|
|
242 |
@Override
|
|
|
243 |
public void exitQuizFail()
|
|
|
244 |
{
|
|
|
245 |
Intent intent = new Intent();
|
|
|
246 |
intent.putExtra("completed", false);
|
|
|
247 |
intent.putExtra("requestCode", Constants.REQUEST_CODE_QUIZ);
|
|
|
248 |
setResult(RESULT_CANCELED, intent);
|
|
|
249 |
finish();
|
|
|
250 |
}
|
|
|
251 |
|
|
|
252 |
@Override
|
|
|
253 |
public void exitQuizPass()
|
|
|
254 |
{
|
|
|
255 |
Intent intent = new Intent();
|
|
|
256 |
intent.putExtra("completed", true);
|
|
|
257 |
intent.putExtra("requestCode", Constants.REQUEST_CODE_QUIZ);
|
|
|
258 |
setResult(RESULT_OK, intent);
|
|
|
259 |
finish();
|
|
|
260 |
}
|
|
|
261 |
|
|
|
262 |
public void finishQuiz()
|
|
|
263 |
{
|
|
|
264 |
if(countDownTimer != null) {
|
|
|
265 |
countDownTimer.cancel();
|
|
|
266 |
}
|
|
|
267 |
textChronometer.setText("--:--");
|
|
|
268 |
|
|
|
269 |
totalPoints = 0;
|
|
|
270 |
for(int i = 0; i < quizResponses.size(); i++)
|
|
|
271 |
{
|
|
|
272 |
totalPoints += quizResponses.get(i).getPoints();
|
|
|
273 |
}
|
|
|
274 |
|
|
|
275 |
textViewScore.setText(totalPoints + " / " + quiz.getPoints());
|
|
|
276 |
|
|
|
277 |
btnFinish.setVisibility(View.INVISIBLE);
|
|
|
278 |
btnExit.setVisibility(View.VISIBLE);
|
|
|
279 |
if(totalPoints >= quiz.getMinimumPointsRequired()) {
|
|
|
280 |
//Pass
|
|
|
281 |
|
|
|
282 |
invokeFragment(Constants.IDX_QUIZ_FRAGMENT_PASS);
|
|
|
283 |
} else {
|
|
|
284 |
//Fail
|
|
|
285 |
invokeFragment(Constants.IDX_QUIZ_FRAGMENT_FAIL);
|
|
|
286 |
}
|
|
|
287 |
}
|
|
|
288 |
|
|
|
289 |
public void showQuestions()
|
|
|
290 |
{
|
|
|
291 |
btnStart.setVisibility(View.INVISIBLE);
|
|
|
292 |
btnFinish.setVisibility(View.INVISIBLE);
|
|
|
293 |
btnNext.setVisibility(View.INVISIBLE);
|
|
|
294 |
btnPrevious.setVisibility(View.INVISIBLE);
|
|
|
295 |
|
|
|
296 |
if(questionIdxActive == 0) {
|
|
|
297 |
|
|
|
298 |
if(questions.size() > 1) {
|
|
|
299 |
btnNext.setVisibility(View.VISIBLE);
|
|
|
300 |
} else {
|
|
|
301 |
btnFinish.setVisibility(View.VISIBLE);
|
|
|
302 |
}
|
|
|
303 |
} else {
|
|
|
304 |
if(questionIdxActive == (questions.size() - 1)) {
|
|
|
305 |
btnFinish.setVisibility(View.VISIBLE);
|
|
|
306 |
} else {
|
|
|
307 |
btnNext.setVisibility(View.VISIBLE);
|
|
|
308 |
}
|
|
|
309 |
}
|
|
|
310 |
|
|
|
311 |
int score = 0;
|
|
|
312 |
for(int i = 0; i < quizResponses.size(); i++)
|
|
|
313 |
{
|
|
|
314 |
score += quizResponses.get(i).getPoints();
|
|
|
315 |
}
|
|
|
316 |
|
|
|
317 |
textViewQuestion.setText((1 + questionIdxActive) + " / " + questions.size() );
|
|
|
318 |
textViewScore.setText(String.valueOf(score));
|
|
|
319 |
|
|
|
320 |
|
|
|
321 |
Question question = questions.get(questionIdxActive);
|
|
|
322 |
if(question.getType().equals(Constants.QUESTION_TYPE_RANGE_1_10)) {
|
|
|
323 |
invokeFragment(Constants.IDX_QUIZ_FRAGMENT_QUESTION_RANGE_SIMPLE);
|
|
|
324 |
} else if(question.getType().equals(Constants.QUESTION_TYPE_RANGE_1_6)) {
|
|
|
325 |
invokeFragment(Constants.IDX_QUIZ_FRAGMENT_QUESTION_RANGE_SIMPLE);
|
|
|
326 |
} else if(question.getType().equals(Constants.QUESTION_TYPE_RANGE_1_5)) {
|
|
|
327 |
invokeFragment(Constants.IDX_QUIZ_FRAGMENT_QUESTION_RANGE_SIMPLE);
|
|
|
328 |
} else if(question.getType().equals(Constants.QUESTION_TYPE_SINGLE_SELECTION)) {
|
|
|
329 |
invokeFragment(Constants.IDX_QUIZ_FRAGMENT_QUESTION_SIMPLE);
|
|
|
330 |
} else if(question.getType().equals(Constants.QUESTION_TYPE_MULTIPLE_SELECTION)) {
|
|
|
331 |
invokeFragment(Constants.IDX_QUIZ_FRAGMENT_QUESTION_MULTIPLE);
|
|
|
332 |
}
|
|
|
333 |
|
|
|
334 |
}
|
|
|
335 |
|
|
|
336 |
|
|
|
337 |
@Override
|
|
|
338 |
public void onBackPressed() {
|
|
|
339 |
|
|
|
340 |
return;
|
|
|
341 |
/*
|
|
|
342 |
Intent intent = new Intent();
|
|
|
343 |
setResult(RESULT_CANCELED, intent);
|
|
|
344 |
finish();*/
|
|
|
345 |
}
|
|
|
346 |
|
|
|
347 |
@Override
|
|
|
348 |
protected void onDestroy() {
|
|
|
349 |
super.onDestroy();
|
|
|
350 |
|
|
|
351 |
|
|
|
352 |
}
|
|
|
353 |
|
|
|
354 |
|
|
|
355 |
@Override
|
|
|
356 |
public Quiz getQuiz()
|
|
|
357 |
{
|
|
|
358 |
return quiz;
|
|
|
359 |
}
|
|
|
360 |
|
|
|
361 |
@Override
|
|
|
362 |
public ArrayList<Question> getQuestions()
|
|
|
363 |
{
|
|
|
364 |
return questions;
|
|
|
365 |
}
|
|
|
366 |
|
|
|
367 |
@Override
|
|
|
368 |
public ArrayList<Answer> getAnswers(String questionUuid)
|
|
|
369 |
{
|
|
|
370 |
if(answers.containsKey(questionUuid)) {
|
|
|
371 |
return answers.get(questionUuid);
|
|
|
372 |
} else {
|
|
|
373 |
return null;
|
|
|
374 |
}
|
|
|
375 |
|
|
|
376 |
|
|
|
377 |
}
|
|
|
378 |
|
|
|
379 |
@Override
|
|
|
380 |
public ArrayList<QuizResponse> getQuizResponses()
|
|
|
381 |
{
|
|
|
382 |
return quizResponses;
|
|
|
383 |
}
|
|
|
384 |
|
|
|
385 |
@Override
|
|
|
386 |
public Question getQuestionActive()
|
|
|
387 |
{
|
|
|
388 |
return questions.get(questionIdxActive);
|
|
|
389 |
}
|
|
|
390 |
|
|
|
391 |
|
|
|
392 |
public void invokeFragment(int fragmentIdxActiveNuevo)
|
|
|
393 |
{
|
|
|
394 |
String fragmentKeyActual = PREFIX_FRAG + fragmentIdxActive;
|
|
|
395 |
String fragmentKeyNuevo = PREFIX_FRAG + fragmentIdxActiveNuevo;
|
|
|
396 |
fragmentIdxActive = fragmentIdxActiveNuevo;
|
|
|
397 |
|
|
|
398 |
Fragment fragment;
|
|
|
399 |
// if(!fragmentKeyActual.equalsIgnoreCase(fragmentKeyNuevo)) {
|
|
|
400 |
if(fragmentHashMap.containsKey(fragmentKeyActual)) {
|
|
|
401 |
fragment = fragmentHashMap.get(fragmentKeyActual);
|
|
|
402 |
if(fragment != null) {
|
|
|
403 |
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
|
|
404 |
fragmentTransaction.hide(fragment);
|
|
|
405 |
fragmentTransaction.commit();
|
|
|
406 |
}
|
|
|
407 |
}
|
|
|
408 |
//}
|
|
|
409 |
|
|
|
410 |
boolean add = false;
|
|
|
411 |
fragment = null;
|
|
|
412 |
|
|
|
413 |
|
|
|
414 |
switch(fragmentIdxActiveNuevo) {
|
|
|
415 |
|
|
|
416 |
case Constants.IDX_QUIZ_FRAGMENT_QUESTION_RANGE_SIMPLE :
|
|
|
417 |
if(fragmentHashMap.containsKey(fragmentKeyNuevo)) {
|
|
|
418 |
fragment = fragmentHashMap.get(fragmentKeyNuevo);
|
|
|
419 |
} else {
|
|
|
420 |
add = true;
|
|
|
421 |
fragment = new QuizRangeSimpleFragment(this);
|
|
|
422 |
}
|
|
|
423 |
break;
|
|
|
424 |
|
|
|
425 |
case Constants.IDX_QUIZ_FRAGMENT_QUESTION_SIMPLE :
|
|
|
426 |
if(fragmentHashMap.containsKey(fragmentKeyNuevo)) {
|
|
|
427 |
fragment = fragmentHashMap.get(fragmentKeyNuevo);
|
|
|
428 |
} else {
|
|
|
429 |
add = true;
|
|
|
430 |
fragment = new QuizSingleAnswerFragment(this);
|
|
|
431 |
}
|
|
|
432 |
break;
|
|
|
433 |
|
|
|
434 |
case Constants.IDX_QUIZ_FRAGMENT_QUESTION_MULTIPLE :
|
|
|
435 |
if(fragmentHashMap.containsKey(fragmentKeyNuevo)) {
|
|
|
436 |
fragment = fragmentHashMap.get(fragmentKeyNuevo);
|
|
|
437 |
} else {
|
|
|
438 |
add = true;
|
|
|
439 |
fragment = new QuizMultipleAnswerFragment(this);
|
|
|
440 |
}
|
|
|
441 |
break;
|
|
|
442 |
|
|
|
443 |
case Constants.IDX_QUIZ_FRAGMENT_PASS :
|
|
|
444 |
if(fragmentHashMap.containsKey(fragmentKeyNuevo)) {
|
|
|
445 |
fragment = fragmentHashMap.get(fragmentKeyNuevo);
|
|
|
446 |
} else {
|
|
|
447 |
add = true;
|
|
|
448 |
fragment = new QuizPassFragment(this);
|
|
|
449 |
}
|
|
|
450 |
break;
|
|
|
451 |
|
|
|
452 |
case Constants.IDX_QUIZ_FRAGMENT_FAIL :
|
|
|
453 |
if(fragmentHashMap.containsKey(fragmentKeyNuevo)) {
|
|
|
454 |
fragment = fragmentHashMap.get(fragmentKeyNuevo);
|
|
|
455 |
} else {
|
|
|
456 |
add = true;
|
|
|
457 |
fragment = new QuizFailFragment(this);
|
|
|
458 |
}
|
|
|
459 |
break;
|
|
|
460 |
|
|
|
461 |
default :
|
|
|
462 |
if(fragmentHashMap.containsKey(fragmentKeyNuevo)) {
|
|
|
463 |
fragment = fragmentHashMap.get(fragmentKeyNuevo);
|
|
|
464 |
} else {
|
|
|
465 |
add = true;
|
|
|
466 |
fragment = new QuizIntroFragment();
|
|
|
467 |
}
|
|
|
468 |
break;
|
|
|
469 |
|
|
|
470 |
|
|
|
471 |
}
|
|
|
472 |
|
|
|
473 |
if(add) {
|
|
|
474 |
fragmentHashMap.put(fragmentKeyNuevo, fragment);
|
|
|
475 |
|
|
|
476 |
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
|
|
477 |
fragmentTransaction.add(R.id.activity_quiz_fragment_container, fragment, fragmentKeyNuevo);
|
|
|
478 |
fragmentTransaction.commit();
|
|
|
479 |
}
|
|
|
480 |
|
|
|
481 |
|
|
|
482 |
if(fragment != null) {
|
|
|
483 |
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
|
|
484 |
fragmentTransaction.show(fragment);
|
|
|
485 |
fragmentTransaction.commit();
|
|
|
486 |
}
|
|
|
487 |
|
|
|
488 |
}
|
|
|
489 |
|
|
|
490 |
|
|
|
491 |
}
|