Skip to content
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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

giseletoledo
Copy link
Contributor

Descrição e Solução

  • Descreva o que está sendo implementado e como foi feito.

Checklist:

  • Não adiciona código duplicado
  • Não contém código comentado
  • Não contém código WIP
  • Teste Unitário Implementado

Evidências:

| print | print |

Copy link
Contributor

@brunoh-almeida brunoh-almeida left a 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")
Copy link
Contributor

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
Copy link
Contributor

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()) {
Copy link
Contributor

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"
Copy link
Contributor

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..."
Copy link
Contributor

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´

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants