File tree Expand file tree Collapse file tree
extensionslib/src/main/java/com/omega_r/libs/extensions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,4 +4,8 @@ import android.content.res.Resources
44
55fun Int.toDp (): Int = (this / Resources .getSystem().displayMetrics.density).toInt()
66
7- fun Int.toPx (): Int = (this * Resources .getSystem().displayMetrics.density).toInt()
7+ fun Int.toPx (): Int = (this * Resources .getSystem().displayMetrics.density).toInt()
8+
9+ fun Float.toDp (): Float = (this / Resources .getSystem().displayMetrics.density)
10+
11+ fun Float.toPx (): Float = (this * Resources .getSystem().displayMetrics.density)
Original file line number Diff line number Diff line change 11package com.omega_r.libs.extensions.view
22
3+ import android.graphics.drawable.AnimatedVectorDrawable
4+ import android.graphics.drawable.ColorDrawable
5+ import android.graphics.drawable.Drawable
6+ import android.os.Build
37import android.view.View
48import android.view.ViewGroup
5- import androidx.annotation.LayoutRes
9+ import androidx.annotation.*
10+ import com.omega_r.libs.extensions.context.*
611
712fun View.inflate (@LayoutRes resource : Int , root : ViewGroup ): View {
813 return View .inflate(context, resource, root)
914}
15+
16+ fun View.getCompatDrawable (@DrawableRes id : Int ): Drawable ? {
17+ return context.getCompatDrawable(id)
18+ }
19+
20+ @RequiresApi(Build .VERSION_CODES .LOLLIPOP )
21+ fun View.getAnimatedVectorDrawable (@DrawableRes res : Int ): AnimatedVectorDrawable ? {
22+ return context.getAnimatedVectorDrawable(res)
23+ }
24+
25+ fun View.getCompatColor (@ColorRes id : Int ): Int {
26+ return context.getCompatColor(id)
27+ }
28+
29+ fun View.getColorByAttribute (@AttrRes attrInt : Int ): Int {
30+ return context.getColorByAttribute(attrInt)
31+ }
32+
33+ fun View.getColorDrawableByAttribute (@AttrRes attrInt : Int ): ColorDrawable {
34+ return context.getColorDrawableByAttribute(attrInt)
35+ }
You can’t perform that action at this time.
0 commit comments