diff --git a/app/build.gradle b/app/build.gradle index d6384df2..633f3d15 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -42,18 +42,18 @@ android { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' manifestPlaceholders = [ - crashlyticsEnabled: true, - appIcon : "@mipmap/ic_launcher", - appIconRound : "@mipmap/ic_launcher_round" + crashlyticsEnabled : true, + appIcon : "@mipmap/ic_launcher", + appIconRound : "@mipmap/ic_launcher_round" ] } debug { applicationIdSuffix ".debug" versionNameSuffix "-debug" manifestPlaceholders = [ - crashlyticsEnabled: false, - appIcon : "@mipmap/ic_debug_launcher", - appIconRound : "@mipmap/ic_debug_launcher_round" + crashlyticsEnabled : false, + appIcon : "@mipmap/ic_debug_launcher", + appIconRound : "@mipmap/ic_debug_launcher_round" ] testCoverageEnabled true } diff --git a/app/src/debug/AndroidManifest.xml b/app/src/debug/AndroidManifest.xml deleted file mode 100644 index d5980b7b..00000000 --- a/app/src/debug/AndroidManifest.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a95d6191..3536fecb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,6 +9,7 @@ android:label="@string/app_name" android:roundIcon="${appIconRound}" android:supportsRtl="true" + android:networkSecurityConfig="@xml/network_security_config" android:theme="@style/AppTheme"> characterDetailViewModel.detailViewState.value?.let { viewState -> if (isConnected && viewState.error != null) { - binding.filmsLayout.filmsErrorTextView.remove() - binding.planetLayout.planetErrorTextView.remove() - binding.specieLayout.specieErrorTextView.remove() - binding.filmsLayout.filmsProgressBar.show() - binding.planetLayout.planetProgressBar.show() - binding.specieLayout.speciesProgressBar.show() + resolveErrorViewState() characterDetailViewModel.getCharacterDetails(characterUrl, isRetry = true) } } } } + private fun resolveErrorViewState() { + binding.filmsLayout.filmsErrorTextView.remove() + binding.planetLayout.planetErrorTextView.remove() + binding.specieLayout.specieErrorTextView.remove() + binding.filmsLayout.filmsProgressBar.show() + binding.planetLayout.planetProgressBar.show() + binding.specieLayout.speciesProgressBar.show() + } + private fun onNetworkChange(block: (Boolean) -> Unit) { NetworkUtils.getNetworkStatus(this) .observe(this, Observer { isConnected -> diff --git a/app/src/main/kotlin/com/k0d4black/theforce/features/character_details/CharacterDetailViewModel.kt b/app/src/main/kotlin/com/k0d4black/theforce/features/character_details/CharacterDetailViewModel.kt index 958ef634..d98ec7e9 100644 --- a/app/src/main/kotlin/com/k0d4black/theforce/features/character_details/CharacterDetailViewModel.kt +++ b/app/src/main/kotlin/com/k0d4black/theforce/features/character_details/CharacterDetailViewModel.kt @@ -1,7 +1,11 @@ package com.k0d4black.theforce.features.character_details +import android.util.Log import androidx.annotation.StringRes -import androidx.lifecycle.* +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope import com.k0d4black.theforce.commons.ExceptionHandler import com.k0d4black.theforce.domain.usecases.FilmsUseCase import com.k0d4black.theforce.domain.usecases.PlanetUseCase @@ -27,6 +31,7 @@ internal class CharacterDetailViewModel( private var _detailViewState = MutableLiveData() private val characterDetailExceptionHandler = CoroutineExceptionHandler { _, exception -> + Log.d("Character Detail VM", "$exception") val message = ExceptionHandler.parse(exception) _detailViewState.value = _detailViewState.value?.copy(error = Error(message)) } @@ -47,14 +52,10 @@ internal class CharacterDetailViewModel( _detailViewState.value = _detailViewState.value?.copy(error = null) } viewModelScope.launch(characterDetailExceptionHandler) { - val planetRequest = async { loadPlanet(characterUrl) } - val filmsRequest = async { loadFilms(characterUrl) } - val speciesRequest = async { loadSpecies(characterUrl) } - planetRequest.await() - filmsRequest.await() - speciesRequest.await() + async { loadPlanet(characterUrl) }.await() + async { loadFilms(characterUrl) }.await() + async { loadSpecies(characterUrl) }.await() _detailViewState.value = _detailViewState.value?.copy(isComplete = true) - } } diff --git a/app/src/main/kotlin/com/k0d4black/theforce/features/character_search/CharacterSearchViewModel.kt b/app/src/main/kotlin/com/k0d4black/theforce/features/character_search/CharacterSearchViewModel.kt index d8c434f4..efe56544 100644 --- a/app/src/main/kotlin/com/k0d4black/theforce/features/character_search/CharacterSearchViewModel.kt +++ b/app/src/main/kotlin/com/k0d4black/theforce/features/character_search/CharacterSearchViewModel.kt @@ -1,5 +1,6 @@ package com.k0d4black.theforce.features.character_search +import android.util.Log import androidx.annotation.StringRes import androidx.lifecycle.* import com.k0d4black.theforce.commons.ExceptionHandler diff --git a/app/src/main/kotlin/com/k0d4black/theforce/mappers/DomainToPresentation.kt b/app/src/main/kotlin/com/k0d4black/theforce/mappers/DomainToPresentation.kt index 7b6e87e7..e501046f 100644 --- a/app/src/main/kotlin/com/k0d4black/theforce/mappers/DomainToPresentation.kt +++ b/app/src/main/kotlin/com/k0d4black/theforce/mappers/DomainToPresentation.kt @@ -22,7 +22,7 @@ fun Character.toPresentation(): CharacterPresentation { } fun Planet.toPresentation(): PlanetPresentation { - val populationAsLong = if (this.population.contains("Unknown")) 0L else this.population.toLong() + val populationAsLong = if (this.population.contains("unknown")) 0L else this.population.toLong() return PlanetPresentation(this.name, populationAsLong) } diff --git a/app/src/main/res/xml/network_security_config.xml b/app/src/main/res/xml/network_security_config.xml new file mode 100644 index 00000000..30d83e35 --- /dev/null +++ b/app/src/main/res/xml/network_security_config.xml @@ -0,0 +1,21 @@ + + + + swapi.dev + + + localhost + + \ No newline at end of file diff --git a/dependencies.gradle b/dependencies.gradle index efecba19..05c83dbc 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -6,8 +6,8 @@ ext { buildToolsVersion = "29.0.2" //App Versioning - versionCodeMajor = 1 - versionCodeMinor = 3 + versionCodeMajor = 2 + versionCodeMinor = 0 versionCodePatch = 0 versionName = "$versionCodeMajor.$versionCodeMinor.$versionCodePatch"