|
1 | 1 | package io.gloop.drawed.utils; |
2 | 2 |
|
| 3 | +import android.content.Context; |
| 4 | + |
| 5 | +import java.util.Random; |
| 6 | + |
| 7 | +import io.gloop.drawed.R; |
| 8 | + |
3 | 9 | /** |
4 | 10 | * Created by Alex Untertrifaller on 20.02.17. |
5 | 11 | */ |
6 | 12 |
|
7 | 13 | public class NameUtil { |
8 | 14 |
|
9 | | - public static String randomUserName() { |
10 | | - return randomAdjective() + randomColor() + randomAnimal(); |
11 | | - } |
| 15 | + private static final Random random = new Random(); |
12 | 16 |
|
13 | | - public static String randomBoardName() { |
14 | | - return randomAdjective() + randomColor() + randomObject(); |
| 17 | + public static String randomUserName(Context context) { |
| 18 | + return randomAdjective(context) + randomColor(context) + randomAnimal(context); |
15 | 19 | } |
16 | 20 |
|
17 | | - private static String randomAdjective() { |
18 | | - return ""; // TODO impl |
| 21 | +// public static String randomBoardName(Context context) { |
| 22 | +// return randomAdjective(context) + randomColor(context) + randomObject(context); |
| 23 | +// } |
| 24 | + |
| 25 | + public static String randomAdjective(Context context) { |
| 26 | + String[] myString = context.getResources().getStringArray(R.array.adjectives); |
| 27 | + return myString[random.nextInt(myString.length)]; |
19 | 28 | } |
20 | 29 |
|
21 | | - private static String randomColor() { |
22 | | - return ""; // TODO impl |
| 30 | + public static String randomColor(Context context) { |
| 31 | + String[] myString = context.getResources().getStringArray(R.array.colors); |
| 32 | + return myString[random.nextInt(myString.length)]; |
23 | 33 | } |
24 | 34 |
|
25 | | - private static String randomAnimal() { |
26 | | - return ""; // TODO impl |
| 35 | + public static String randomAnimal(Context context) { |
| 36 | + String[] myString = context.getResources().getStringArray(R.array.animals); |
| 37 | + return myString[random.nextInt(myString.length)]; |
27 | 38 | } |
28 | 39 |
|
29 | | - private static String randomObject() { |
30 | | - return ""; // TODO impl |
| 40 | + public static String randomObject(Context context) { |
| 41 | + String[] myString = context.getResources().getStringArray(R.array.objects); |
| 42 | + return myString[random.nextInt(myString.length)]; |
31 | 43 | } |
32 | 44 | } |
0 commit comments