Archived
Implemented ability to change the fragment opened on app start; made some optimisations to DietaryPreferences.kt. BUG: tab layout mediator is annoying af
This commit is contained in:
@@ -21,46 +21,28 @@ enum class DietaryPreferences(val value: String) {
|
||||
VEGAN("isVegan"),
|
||||
VEGETARIAN("isVegetarian"),
|
||||
GAME("isGame"),
|
||||
NONE("hasNone"),
|
||||
ERROR("onError")
|
||||
;
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Provides a converting function between the index of a dietary preference and its according
|
||||
* icon.
|
||||
* TODO this seems inefficient
|
||||
*/
|
||||
val indexToDrawable: Map<Int, Int> = mapOf(
|
||||
0 to R.drawable.handshake,
|
||||
1 to R.drawable.fish,
|
||||
2 to R.drawable.chicken,
|
||||
3 to R.drawable.sheep,
|
||||
4 to R.drawable.yoga,
|
||||
5 to R.drawable.cow,
|
||||
6 to R.drawable.pig,
|
||||
7 to R.drawable.leaf,
|
||||
8 to R.drawable.carrot,
|
||||
9 to R.drawable.deer,
|
||||
10 to R.drawable.circle,
|
||||
11 to R.drawable.cross,
|
||||
)
|
||||
|
||||
/**
|
||||
* Provides a converting function between the index of a dietary preference and its
|
||||
* according localised text string.
|
||||
* TODO this seems inefficient
|
||||
* Provides a converting function between
|
||||
*/
|
||||
val indexToString: Map<Int, Int> = mapOf(
|
||||
0 to R.string.pref_fair,
|
||||
1 to R.string.pref_fish,
|
||||
2 to R.string.pref_poultry,
|
||||
3 to R.string.pref_lamb,
|
||||
4 to R.string.pref_vital,
|
||||
5 to R.string.pref_beef,
|
||||
6 to R.string.pref_pork,
|
||||
7 to R.string.pref_vegan,
|
||||
8 to R.string.pref_vegetarian,
|
||||
9 to R.string.pref_game,
|
||||
10 to 0, // shouldn't occur
|
||||
)
|
||||
fun getData(index: Int): Pair<Int, Int> = when (index) {
|
||||
FAIR.ordinal -> Pair(R.string.pref_fair, R.drawable.handshake)
|
||||
FISH.ordinal -> Pair(R.string.pref_fish, R.drawable.fish)
|
||||
POULTRY.ordinal -> Pair(R.string.pref_poultry, R.drawable.chicken)
|
||||
LAMB.ordinal -> Pair(R.string.pref_lamb, R.drawable.sheep)
|
||||
VITAL.ordinal -> Pair(R.string.pref_vital, R.drawable.yoga)
|
||||
BEEF.ordinal -> Pair(R.string.pref_beef, R.drawable.cow)
|
||||
PORK.ordinal -> Pair(R.string.pref_pork, R.drawable.pig)
|
||||
VEGAN.ordinal -> Pair(R.string.pref_vegan, R.drawable.leaf)
|
||||
VEGETARIAN.ordinal -> Pair(R.string.pref_vegetarian, R.drawable.carrot)
|
||||
GAME.ordinal -> Pair(R.string.pref_game, R.drawable.deer)
|
||||
NONE.ordinal -> Pair(R.string.question_mark, R.drawable.circle)
|
||||
else -> Pair(R.string.question_mark, R.drawable.cross) // ERROR.ordinal
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user