Skip to content

Commit

Permalink
Simplify view hierarchy on profile fragment
Browse files Browse the repository at this point in the history
Related #25
  • Loading branch information
alexandr7035 committed Dec 13, 2021
1 parent 67e519a commit 7008bbc
Show file tree
Hide file tree
Showing 3 changed files with 289 additions and 280 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import android.text.format.DateFormat
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isGone
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import by.alexandr7035.gitstat.R
import by.alexandr7035.gitstat.databinding.FragmentProfileBinding
import by.alexandr7035.gitstat.core.extensions.navigateSafe
import by.alexandr7035.gitstat.core.extensions.observeNullSafe
import by.alexandr7035.gitstat.databinding.FragmentProfileBinding
import by.alexandr7035.gitstat.view.MainActivity
import com.squareup.picasso.Picasso
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber


@AndroidEntryPoint
Expand All @@ -37,8 +37,6 @@ class ProfileFragment : Fragment() {
// Update profile data
viewModel.getUserLiveData().observeNullSafe(viewLifecycleOwner, {

Timber.tag("DEBUG_TAG").d("livedata updated $it")

Picasso.get().load(it.avatar_url).into(binding!!.profileImageView)

// This field can be empty
Expand All @@ -61,9 +59,9 @@ class ProfileFragment : Fragment() {

// This field can be empty
if (it.location.isEmpty()) {
binding!!.locationContainer.visibility = View.GONE
setLocationVisibility(false)
} else {
binding!!.locationContainer.visibility = View.VISIBLE
setLocationVisibility(true)
binding!!.locationView.text = it.location
}

Expand All @@ -82,6 +80,11 @@ class ProfileFragment : Fragment() {

}

private fun setLocationVisibility(isVisible: Boolean) {
binding?.locationIcon?.isGone = ! isVisible
binding?.locationLabel?.isGone = ! isVisible
binding?.locationView?.isGone = ! isVisible
}

override fun onDestroyView() {
super.onDestroyView()
Expand Down
Loading

0 comments on commit 7008bbc

Please sign in to comment.