From 8590dca05e62c0946fe071c2fd3b5a53ff9b2e65 Mon Sep 17 00:00:00 2001 From: Alloula Elias <72727849+flicker71@users.noreply.github.com> Date: Thu, 22 Feb 2024 22:18:45 +0100 Subject: [PATCH] Overwrite character in names #91 I do the issue #91 I hope it will be accepted --- .../skydoves/pokedex/ui/details/DetailActivity.kt | 10 +++++++--- .../com/skydoves/pokedex/ui/main/PokemonAdapter.kt | 12 +++++++++++- .../com/skydoves/pokedex/core/model/Pokemon.kt | 4 +++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/skydoves/pokedex/ui/details/DetailActivity.kt b/app/src/main/kotlin/com/skydoves/pokedex/ui/details/DetailActivity.kt index 749eff02d..fe4a77ce4 100644 --- a/app/src/main/kotlin/com/skydoves/pokedex/ui/details/DetailActivity.kt +++ b/app/src/main/kotlin/com/skydoves/pokedex/ui/details/DetailActivity.kt @@ -41,13 +41,17 @@ class DetailActivity : BindingActivity(R.layout.activity_ internal val viewModel: DetailViewModel by viewModels { DetailViewModel.provideFactory(detailViewModelFactory, pokemon.name) } - private val pokemon: Pokemon by bundleNonNull(EXTRA_POKEMON) - override fun onCreate(savedInstanceState: Bundle?) { onTransformationEndContainerApplyParams(this) super.onCreate(savedInstanceState) - binding.pokemon = pokemon + // I create a temporary Pokemon variable 'pokemonBis' for modifying the name before binding. + // I needed for that to change the data class Pokemon here Pokemon.kt + var pokemonBis = pokemon + // I do a replace for the name only + pokemonBis.name = pokemon.name.replace("-", " ") + // And i change set the value of binding.pokemon + binding.pokemon = pokemonBis binding.vm = viewModel } diff --git a/app/src/main/kotlin/com/skydoves/pokedex/ui/main/PokemonAdapter.kt b/app/src/main/kotlin/com/skydoves/pokedex/ui/main/PokemonAdapter.kt index 23b5ff924..f347650f6 100644 --- a/app/src/main/kotlin/com/skydoves/pokedex/ui/main/PokemonAdapter.kt +++ b/app/src/main/kotlin/com/skydoves/pokedex/ui/main/PokemonAdapter.kt @@ -55,7 +55,17 @@ class PokemonAdapter : BindingListAdapter