Compare commits
2 Commits
7d92099a95
...
8e84fe2ff5
Author | SHA1 | Date |
---|---|---|
luca0N! | 8e84fe2ff5 | |
luca0N! | c3c820715b |
|
@ -43,6 +43,7 @@ import java.net.Proxy;
|
|||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.luca0n.joguitos.pluck.R;
|
||||
import com.luca0n.joguitos.pluck.PluckApplication;
|
||||
|
@ -127,7 +128,11 @@ public class ApiUtil {
|
|||
|
||||
ArrayList<TriviaQuestion> questions = new ArrayList<>();
|
||||
|
||||
int elements = 0;
|
||||
|
||||
for (JsonElement element : jsonArray) {
|
||||
if (elements++ == filters.getAmount())
|
||||
break;
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
TriviaType type = TriviaType.get(object.get("type").getAsString());
|
||||
|
||||
|
@ -152,6 +157,9 @@ public class ApiUtil {
|
|||
if (questions.size() == 0)
|
||||
throw new NoTriviaResultsException();
|
||||
|
||||
// Shuffle the question array.
|
||||
Collections.shuffle(questions);
|
||||
|
||||
return questions;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue