Skip to content

Commit

Permalink
Use isVisible for setting visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
zsmb13 committed Jan 7, 2020
1 parent 053a1c4 commit 12b51db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
Expand Up @@ -6,6 +6,7 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders import androidx.lifecycle.ViewModelProviders
Expand Down Expand Up @@ -50,23 +51,17 @@ class DashboardFragment : Fragment() {


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


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


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


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


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


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


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


Glide.with(itemView.context) Glide.with(itemView.context)
Expand Down

0 comments on commit 12b51db

Please sign in to comment.