Fix null safety
This commit is contained in:
parent
fdee056ade
commit
20e71f355a
16 changed files with 40 additions and 67 deletions
|
@ -13,25 +13,12 @@ object ATHUtil {
|
|||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun resolveColor(context: Context?, @AttrRes attr: Int, fallback: Int = 0): Int {
|
||||
val a = context!!.theme.obtainStyledAttributes(intArrayOf(attr))
|
||||
fun resolveColor(context: Context, @AttrRes attr: Int, fallback: Int = 0): Int {
|
||||
val a = context.theme.obtainStyledAttributes(intArrayOf(attr))
|
||||
try {
|
||||
return a.getColor(0, fallback)
|
||||
} finally {
|
||||
a.recycle()
|
||||
}
|
||||
}
|
||||
|
||||
fun inClassPath(clsName: String): Class<*> {
|
||||
try {
|
||||
return Class.forName(clsName)
|
||||
} catch (t: Throwable) {
|
||||
throw IllegalStateException(
|
||||
String.format(
|
||||
"%s is not in your class path! You must include the associated library.",
|
||||
clsName
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package code.name.monkey.appthemehelper.util
|
||||
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.TransitionDrawable
|
||||
import androidx.annotation.ColorInt
|
||||
|
||||
object DrawableUtil {
|
||||
|
||||
fun createTransitionDrawable(@ColorInt startColor: Int, @ColorInt endColor: Int): TransitionDrawable {
|
||||
return createTransitionDrawable(ColorDrawable(startColor), ColorDrawable(endColor))
|
||||
}
|
||||
|
||||
fun createTransitionDrawable(start: Drawable, end: Drawable): TransitionDrawable {
|
||||
val drawables = arrayOfNulls<Drawable>(2)
|
||||
|
||||
drawables[0] = start
|
||||
drawables[1] = end
|
||||
|
||||
return TransitionDrawable(drawables)
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import com.google.android.material.textfield.TextInputLayout
|
|||
object MaterialUtil {
|
||||
|
||||
@JvmOverloads
|
||||
@JvmStatic
|
||||
fun setTint(
|
||||
button: MaterialButton, background: Boolean = true,
|
||||
color: Int = ThemeStore.accentColor(button.context)
|
||||
|
@ -37,6 +38,8 @@ object MaterialUtil {
|
|||
}
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
@JvmStatic
|
||||
fun setTint(textInputLayout: TextInputLayout, background: Boolean = true) {
|
||||
val context = textInputLayout.context
|
||||
val accentColor = ThemeStore.accentColor(context)
|
||||
|
@ -52,6 +55,8 @@ object MaterialUtil {
|
|||
}
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
@JvmStatic
|
||||
fun setTint(
|
||||
button: DialogActionButton,
|
||||
color: Int = ThemeStore.accentColor(button.context),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue