22 lines
508 B
Kotlin
22 lines
508 B
Kotlin
package code.name.monkey.retromusic.extensions
|
|
|
|
import android.view.LayoutInflater
|
|
import android.view.View
|
|
import android.view.ViewGroup
|
|
import androidx.annotation.LayoutRes
|
|
|
|
|
|
@Suppress("UNCHECKED_CAST")
|
|
fun <T : View> ViewGroup.inflate(@LayoutRes layout: Int): T {
|
|
return LayoutInflater.from(context).inflate(layout, this, false) as T
|
|
}
|
|
|
|
fun View.show() {
|
|
visibility = View.VISIBLE
|
|
}
|
|
|
|
fun View.hide() {
|
|
visibility = View.GONE
|
|
}
|
|
|
|
fun View.showOrHide(show: Boolean) = if (show) show() else hide() |