-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ajustando o conteúdo das Activitys e a navegação #89
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gi, baixei o código e quando clico no ver mais o aplicativo está crashando com o erro abaixo
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.devpass.spaceapp/com.devpass.spaceapp.presentation.LaunchDetailsActivity}: java.lang.ClassCastException: java.lang.String cannot be cast to com.devpass.spaceapp.data.model.NextLaunchesModel
binding.viewPager.adapter = launchDetailsPagerAdapter | ||
|
||
// Adiciona as abas ao TabLayout | ||
val titles = arrayOf("Overview", "Mission", "Rocket") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Os títulos são "Details", "Rocket", "Launchpad", e poderiamos deixar esses textos no string.xml
val launch = intent.getSerializableExtra("nextLaunch") as NextLaunchesModel | ||
|
||
// Preencher os campos com as informações do objeto launch | ||
binding.launchTitleTextView.text = launch.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Não está errado, mas a gente tratar as variáveis com a extension do kotlin .apply
.
Ficaria mais ou menos assim
binding.apply { lunchTitleTextView.text = launch.name launchStatusTextView.text = launch.date_utc //outros elementos da view }
binding.launchTitleTextView.text = launch.name | ||
binding.launchDateTextView.text = launch.date_utc | ||
binding.launchStatusTextView.text = launch.status.toString() | ||
if(launch.links.image.small.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Não está errado, mas nesse caso a gente pode colocar a função no Glide .error("drawable desejado")
assim a gente evita de fazer um if sem "tanta necessidade"
@@ -31,8 +32,24 @@ class LaunchDetailsFragment : Fragment() { | |||
// Recupera o objeto NextLaunchesModel dos argumentos | |||
val launch = arguments?.getSerializable(ARG_LAUNCH) as NextLaunchesModel? | |||
|
|||
// Exibe o nome da missão em um TextView | |||
binding.launchDescription.text = launch?.name ?: "Nome da missão desconhecido" | |||
val fullDescription = launch?.details ?: "Erro ao carregar detalhes" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Podemos colocar o texto no string.xml
val shortDescription = fullDescription.lineSequence().take(1).joinToString("\n") | ||
binding.launchDescriptionFragment.text = shortDescription | ||
|
||
val viewMore:String = "View more..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
podemos colocar o ´string.xml´
Descrição e Solução
Checklist:
Evidências:
| print | print |