Ayden
10/27/2019, 5:01 AMfindViewById<Button>(R.id.test).setOnClickListener(View.OnClickListener {
if (progressBar.visibility == View.VISIBLE) {
showProgressBar(false)
} else {
showProgressBar(true)
}
})
fun showProgressBar(visibility: Boolean) {
progressBar.visibility = if (visibility) {
View.INVISIBLE
} else {
View.VISIBLE
}
}
Khan
10/27/2019, 8:53 AMval shouldShow = progressBar.visibility != View.VISIBLE
showProgressBar(shouldShow)
fun showProgressBar(shouldShow: Boolean) {
progressBar.visibility = if (shouldShow) View.VISIBLE else View.INVISIBLE
}
I would do it like this & without braces for if else, also in single line. it will look more cleanerAyden
10/27/2019, 9:11 AMrkeazor
10/27/2019, 3:54 PMAslam Hossin
10/29/2019, 2:21 AMyousefa2
12/04/2019, 8:51 AMisVisible
Extension and it can simply be
progressBar.isVisible = !progressBar.isVisible