Skip to content

Commit 520ab98

Browse files
committed
fix number format exception
1 parent 7236f76 commit 520ab98

File tree

5 files changed

+20
-25
lines changed

5 files changed

+20
-25
lines changed

app/build.gradle

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ jacocoAndroidUnitTestReport {
2626

2727
android {
2828

29-
signingConfigs {
30-
release {
31-
keyAlias "theforcekey"
32-
keyPassword "theforce2020"
33-
storeFile file("../theforce.jks")
34-
storePassword "theforce2020"
35-
}
36-
}
37-
3829
compileSdkVersion rootProject.ext.compileSdkVersion
3930
buildToolsVersion rootProject.ext.buildToolsVersion
4031

app/src/main/kotlin/com/k0d4black/theforce/features/character_details/CharacterDetailActivity.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,22 @@ class CharacterDetailActivity : AppCompatActivity() {
118118
onNetworkChange { isConnected ->
119119
characterDetailViewModel.detailViewState.value?.let { viewState ->
120120
if (isConnected && viewState.error != null) {
121-
binding.filmsLayout.filmsErrorTextView.remove()
122-
binding.planetLayout.planetErrorTextView.remove()
123-
binding.specieLayout.specieErrorTextView.remove()
124-
binding.filmsLayout.filmsProgressBar.show()
125-
binding.planetLayout.planetProgressBar.show()
126-
binding.specieLayout.speciesProgressBar.show()
121+
resolveErrorViewState()
127122
characterDetailViewModel.getCharacterDetails(characterUrl, isRetry = true)
128123
}
129124
}
130125
}
131126
}
132127

128+
private fun resolveErrorViewState() {
129+
binding.filmsLayout.filmsErrorTextView.remove()
130+
binding.planetLayout.planetErrorTextView.remove()
131+
binding.specieLayout.specieErrorTextView.remove()
132+
binding.filmsLayout.filmsProgressBar.show()
133+
binding.planetLayout.planetProgressBar.show()
134+
binding.specieLayout.speciesProgressBar.show()
135+
}
136+
133137
private fun onNetworkChange(block: (Boolean) -> Unit) {
134138
NetworkUtils.getNetworkStatus(this)
135139
.observe(this, Observer { isConnected ->

app/src/main/kotlin/com/k0d4black/theforce/features/character_details/CharacterDetailViewModel.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package com.k0d4black.theforce.features.character_details
22

3+
import android.util.Log
34
import androidx.annotation.StringRes
4-
import androidx.lifecycle.*
5+
import androidx.lifecycle.LiveData
6+
import androidx.lifecycle.MutableLiveData
7+
import androidx.lifecycle.ViewModel
8+
import androidx.lifecycle.viewModelScope
59
import com.k0d4black.theforce.commons.ExceptionHandler
610
import com.k0d4black.theforce.domain.usecases.FilmsUseCase
711
import com.k0d4black.theforce.domain.usecases.PlanetUseCase
@@ -27,6 +31,7 @@ internal class CharacterDetailViewModel(
2731
private var _detailViewState = MutableLiveData<CharacterDetailsViewState>()
2832

2933
private val characterDetailExceptionHandler = CoroutineExceptionHandler { _, exception ->
34+
Log.d("Character Detail VM", "$exception")
3035
val message = ExceptionHandler.parse(exception)
3136
_detailViewState.value = _detailViewState.value?.copy(error = Error(message))
3237
}
@@ -47,14 +52,10 @@ internal class CharacterDetailViewModel(
4752
_detailViewState.value = _detailViewState.value?.copy(error = null)
4853
}
4954
viewModelScope.launch(characterDetailExceptionHandler) {
50-
val planetRequest = async { loadPlanet(characterUrl) }
51-
val filmsRequest = async { loadFilms(characterUrl) }
52-
val speciesRequest = async { loadSpecies(characterUrl) }
53-
planetRequest.await()
54-
filmsRequest.await()
55-
speciesRequest.await()
55+
async { loadPlanet(characterUrl) }.await()
56+
async { loadFilms(characterUrl) }.await()
57+
async { loadSpecies(characterUrl) }.await()
5658
_detailViewState.value = _detailViewState.value?.copy(isComplete = true)
57-
5859
}
5960
}
6061

app/src/main/kotlin/com/k0d4black/theforce/features/character_search/CharacterSearchViewModel.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ internal class CharacterSearchViewModel(
2121
private var _searchViewState = MutableLiveData<SearchViewState>()
2222

2323
private val searchExceptionHandler = CoroutineExceptionHandler { _, exception ->
24-
Log.d("Vm","$exception")
2524
val message = ExceptionHandler.parse(exception)
2625
_searchViewState.value = Error(message)
2726
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fun Character.toPresentation(): CharacterPresentation {
2222
}
2323

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

0 commit comments

Comments
 (0)