-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement questions load screen; implement questions state saving; implement session token saving;
- Loading branch information
1 parent
2d50367
commit 1f409c6
Showing
10 changed files
with
92 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.dfl.trivia; | ||
|
||
import android.util.Base64; | ||
import com.dfl.trivia.data.questions.Result; | ||
import java.io.UnsupportedEncodingException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by Loureiro on 18/11/2017. | ||
*/ | ||
|
||
public class Base64Decoder { | ||
|
||
public static List<Result> decodeResults(List<Result> results) | ||
throws UnsupportedEncodingException { | ||
ArrayList<Result> resultList = new ArrayList<>(); | ||
for (Result result : results) { | ||
result.setCategory(decodeString(result.getCategory())); | ||
result.setCorrectAnswer(decodeString(result.getCorrectAnswer())); | ||
result.setDifficulty(decodeString(result.getDifficulty())); | ||
result.setQuestion(decodeString(result.getQuestion())); | ||
result.setType(decodeString(result.getType())); | ||
ArrayList<String> incorrectAnswers = new ArrayList<>(); | ||
for (String answer : result.getIncorrectAnswers()) { | ||
incorrectAnswers.add(decodeString(answer)); | ||
} | ||
result.setIncorrectAnswers(incorrectAnswers); | ||
resultList.add(result); | ||
} | ||
return resultList; | ||
} | ||
|
||
private static String decodeString(String base64) throws UnsupportedEncodingException { | ||
byte[] data = Base64.decode(base64, Base64.DEFAULT); | ||
return new String(data, "UTF-8"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters