Hi guys. I have a question here. I have a BaseAct...
# android
a
Hi guys. I have a question here. I have a BaseActivity which has the
showProgressBar(visibility: Boolean)
function, this will toggle the ProgressBar visibility based on the value. Then, I have a RecipeListActivity which extends BaseActivity that will send the boolean data type in the
showProgressBar
when the button is clicked.
Copy code
BaseActivity .kt

fun showProgressBar(visibility: Boolean) {
    progressBar.visibility = if (visibility) View.INVISIBLE else View.VISIBLE
}
Copy code
RecipeListActivity.kt

activity_content.test.setOnClickListener(View.OnClickListener { view ->
    val visibility = view.visibility != View.VISIBLE
    showProgressBar(visibility)
})
But right now the value of the visibility in the
showProgressBar
is showing
8
or
0
instead of true or false. Did I miss out anything?
s
val visibility = !(view.visibility == View.VISIBLE)
a
That does not help. Lol.
🤣 1
s
sorry 🙂
a
No problem.
m
View.VISIBLE and View.INVISIBLE are constants under the hood, so it makes sense that you’re seeing “0” and “8” as values in the debugger! Here’s a stack overflow post about similar: https://stackoverflow.com/questions/8636133/whats-the-difference-of-setvisibilityview-invisible-setvisibility0
👆🏻 1
âž• 2