Skip to content

Latest commit

 

History

History
22 lines (19 loc) · 609 Bytes

ViewExtensions.md

File metadata and controls

22 lines (19 loc) · 609 Bytes

ViewExtensions.kt

/**
* Visibility modifiers and check functions
*/

fun View.isVisibile(): Boolean = this.visibility == View.VISIBLE 

, , , , , , /**
* Returns typedArray from Styleable given defStyleAttr and defStyleRes can be defaulted to 0.
* Also will call recycle() on typeArray once operations are complete.
*/
inline fun View.readAttributes(
   attrs: AttributeSet?,
   styleableArray: IntArray,
   block: (TypedArray) -> Unit
) {
   val typedArray = context.theme.obtainStyledAttributes(attrs, styleableArray, 0, 0)
   typedArray.use(block)  // From androidx.core
}