Skip to content

Commit

Permalink
Update ProfileFragment.kt for bug Vishwajith-Shettigar#37
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramharsh-aidev authored Oct 24, 2024
1 parent bad8f94 commit 4c2a9b0
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions app/src/main/java/com/example/nextgen/profile/ProfileFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,24 @@ class ProfileFragment : BaseFragment() {
binding.viewModel = profileViewModel
binding.lifecycleOwner = this

profileViewModel.profile.observe(viewLifecycleOwner) {
binding.apply {
profileViewModel.profile.observe(viewLifecycleOwner) {
binding.apply {
try {
this.username.text = it.userName
this.bio.text = it.bio
if (!it.imageUrl.isBlank())
Picasso.get().load(it.imageUrl)
.error(R.drawable.profile_placeholder).into(this.profilePic)
} catch (e: java.lang.Exception) {
this.username.text = it.userName
this.bio.text = it.bio
if (it.privacy.disableProfilePicture) {
Picasso.get().load(R.drawable.profile_placeholder).into(this.profilePic) // Default avatar
} else if (!it.imageUrl.isBlank()) {
Picasso.get().load(it.imageUrl)
.error(R.drawable.profile_placeholder).into(this.profilePic)
} else {
Picasso.get().load(R.drawable.profile_placeholder).into(this.profilePic) // Default avatar
}
} catch (e: Exception) {
e.printStackTrace() // Optional: log the error
}
}
}
}

binding.parentProfileInfo.setOnClickListener {
(activity as RouteToEditProfileActivity).routeToEditProfileActivity(
Expand Down

0 comments on commit 4c2a9b0

Please sign in to comment.