Skip to content

Commit 7122ad8

Browse files
authored
Merge pull request #91 from odaridavid/add-commas-to-population
Add commas to population
2 parents 59bbdc2 + d895f6e commit 7122ad8

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

app/src/main/kotlin/com/k0d4black/theforce/mappers/DomainToPresentation.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.k0d4black.theforce.mappers
22

3+
import com.k0d4black.theforce.commons.convertToInches
34
import com.k0d4black.theforce.domain.models.Character
45
import com.k0d4black.theforce.domain.models.Film
56
import com.k0d4black.theforce.domain.models.Planet
67
import com.k0d4black.theforce.domain.models.Specie
8+
import com.k0d4black.theforce.models.CharacterPresentation
79
import com.k0d4black.theforce.models.FilmPresentation
810
import com.k0d4black.theforce.models.PlanetPresentation
911
import com.k0d4black.theforce.models.SpeciePresentation
10-
import com.k0d4black.theforce.models.CharacterPresentation
11-
import com.k0d4black.theforce.commons.convertToInches
1212

1313

1414
fun Character.toPresentation(): CharacterPresentation {
@@ -22,7 +22,8 @@ fun Character.toPresentation(): CharacterPresentation {
2222
}
2323

2424
fun Planet.toPresentation(): PlanetPresentation {
25-
return PlanetPresentation(this.name, this.population)
25+
val populationAsLong = if (this.population.contains("Unknown")) 0L else this.population.toLong()
26+
return PlanetPresentation(this.name, populationAsLong)
2627
}
2728

2829
fun Film.toPresentation(): FilmPresentation {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package com.k0d4black.theforce.models
22

3-
data class PlanetPresentation(val name: String, val population: String)
3+
data class PlanetPresentation(val name: String, val population: Long)

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<!-- Data Binding String Templates -->
3030
<string name="template_planet_name">Name : %s</string>
31-
<string name="template_planet_population">Population : %s</string>
31+
<string name="template_planet_population">Population : %,d</string>
3232
<string name="template_species_name">Name : %s</string>
3333
<string name="template_height_cm">%s cm</string>
3434
<string name="template_height_inches">%s inches</string>

0 commit comments

Comments
 (0)