Finished filter support

The game now limits trivia file questions based on the question amount picked by the player on `MainActivity`.
This commit is contained in:
luca0N! 2021-03-16 01:00:19 -03:00
parent c3c820715b
commit 8e84fe2ff5
Signed by: luca0N
GPG Key ID: 2E7B4655CF16D7D6
1 changed files with 4 additions and 0 deletions

View File

@ -128,7 +128,11 @@ public class ApiUtil {
ArrayList<TriviaQuestion> questions = new ArrayList<>(); ArrayList<TriviaQuestion> questions = new ArrayList<>();
int elements = 0;
for (JsonElement element : jsonArray) { for (JsonElement element : jsonArray) {
if (elements++ == filters.getAmount())
break;
JsonObject object = element.getAsJsonObject(); JsonObject object = element.getAsJsonObject();
TriviaType type = TriviaType.get(object.get("type").getAsString()); TriviaType type = TriviaType.get(object.get("type").getAsString());