Skip to content

Instantly share code, notes, and snippets.

@TroyStopera
Last active September 20, 2019 17:38
Show Gist options
  • Save TroyStopera/ba16ae99609573dcf4ab5e55a2984390 to your computer and use it in GitHub Desktop.
Save TroyStopera/ba16ae99609573dcf4ab5e55a2984390 to your computer and use it in GitHub Desktop.
View visibility
import android.view.View
fun View?.setVisibleIf(boolean: Boolean, otherwise: Int = View.GONE) {
this?.visibility = if (boolean) View.VISIBLE else otherwise
}
fun View?.setVisibleIfNot(boolean: Boolean, otherwise: Int = View.GONE) = setVisibleIf(!boolean, otherwise)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment