Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added correct number format and date format
- Loading branch information
Anni Hillig
committed
Nov 2, 2023
1 parent
42dbeb1
commit 545eb25
Showing
36 changed files
with
876 additions
and
285 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
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
71 changes: 71 additions & 0 deletions
71
app/src/main/java/eu/inscico/aurora_app/model/user/RegionEnum.kt
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,71 @@ | ||
package eu.inscico.aurora_app.model.user | ||
|
||
import android.content.Context | ||
import eu.inscico.aurora_app.R | ||
import eu.inscico.aurora_app.model.consumptions.ElectricitySource | ||
|
||
enum class RegionEnum { | ||
SYSTEM, | ||
GERMANY, | ||
PORTUGAL, | ||
SLOVENIA, | ||
DENMARK, | ||
UNITED_KINGDOM, | ||
USA; | ||
|
||
companion object { | ||
fun parseStringToRegion(regionString: String?): RegionEnum { | ||
return when (regionString) { | ||
"system" -> SYSTEM | ||
"germany" -> GERMANY | ||
"portugal" -> PORTUGAL | ||
"slovenia" -> SLOVENIA | ||
"denmark" -> DENMARK | ||
"united_kingdom" -> UNITED_KINGDOM | ||
"usa" -> USA | ||
else -> SYSTEM | ||
} | ||
} | ||
|
||
fun parseRegionToString(region: RegionEnum): String { | ||
return when (region) { | ||
SYSTEM -> "system" | ||
GERMANY -> "germany" | ||
PORTUGAL -> "portugal" | ||
SLOVENIA -> "slovenia" | ||
DENMARK -> "denmark" | ||
UNITED_KINGDOM -> "united_kingdom" | ||
USA -> "usa" | ||
} | ||
} | ||
|
||
fun RegionEnum.getDisplayNameRes(): Int { | ||
return when (this) { | ||
SYSTEM -> R.string.settings_profile_select_region_system_title | ||
GERMANY -> R.string.settings_profile_select_region_germany_title | ||
PORTUGAL -> R.string.settings_profile_select_region_portugal_title | ||
SLOVENIA -> R.string.settings_profile_select_region_slovenia_title | ||
DENMARK -> R.string.settings_profile_select_region_denmark_title | ||
UNITED_KINGDOM -> R.string.settings_profile_select_region_united_kingdom_title | ||
USA -> R.string.settings_profile_select_region_usa_title | ||
} | ||
} | ||
|
||
fun RegionEnum.getDisplayName(context: Context): String { | ||
return context.getString(this.getDisplayNameRes()) | ||
} | ||
|
||
fun getRegionsList(): List<RegionEnum> { | ||
return listOf( | ||
SYSTEM, | ||
GERMANY, | ||
PORTUGAL, | ||
SLOVENIA, | ||
DENMARK, | ||
UNITED_KINGDOM, | ||
USA | ||
) | ||
} | ||
|
||
} | ||
} |
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
Oops, something went wrong.