Skip to content
Permalink
Browse files

Use isVisible for setting visibility

  • Loading branch information
zsmb13 committed Jan 7, 2020
1 parent 053a1c4 commit 12b51dbfa84fe552852b45a826311d5f35c0a3d0
@@ -6,6 +6,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
@@ -50,23 +51,17 @@ class DashboardFragment : Fragment() {

pokemon?.typeofpokemon?.getOrNull(0).let { firstType ->
textViewType3.text = firstType
if (firstType == null) {
textViewType3.visibility = View.GONE
}
textViewType3.isVisible = firstType != null
}

pokemon?.typeofpokemon?.getOrNull(1).let { secondType ->
textViewType2.text = secondType
if (secondType == null) {
textViewType2.visibility = View.GONE
}
textViewType2.isVisible = secondType != null
}

pokemon?.typeofpokemon?.getOrNull(2).let { thirdType ->
textViewType1.text = thirdType
if (thirdType == null) {
textViewType1.visibility = View.GONE
}
textViewType1.isVisible = thirdType != null
}

Glide.with(view.context)
@@ -7,6 +7,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.os.bundleOf
import androidx.core.view.isVisible
import androidx.navigation.findNavController
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
@@ -31,23 +32,17 @@ class PokemonAdapter(

item.typeofpokemon?.getOrNull(0).let { firstType ->
itemView.textViewType3.text = firstType
if (firstType == null) {
itemView.textViewType3.visibility = View.GONE
}
itemView.textViewType3.isVisible = firstType != null
}

item.typeofpokemon?.getOrNull(1).let { secondType ->
itemView.textViewType2.text = secondType
if (secondType == null) {
itemView.textViewType2.visibility = View.GONE
}
itemView.textViewType2.isVisible = secondType != null
}

item.typeofpokemon?.getOrNull(2).let { thirdType ->
itemView.textViewType1.text = thirdType
if (thirdType == null) {
itemView.textViewType1.visibility = View.GONE
}
itemView.textViewType1.isVisible = thirdType != null
}

Glide.with(itemView.context)

0 comments on commit 12b51db

Please sign in to comment.
You can’t perform that action at this time.