Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6c16d16 authored by tibbi's avatar tibbi
Browse files

catch exceptions thrown at showing toasts

parent 498e68a5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ buildscript {
        propMinSdkVersion = 16
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '4.5.19'
        propVersionName = '4.5.20'
        kotlin_version = '1.2.60'
        support_libs = '27.1.1'
    }
+1 −4
Original line number Diff line number Diff line
@@ -62,10 +62,7 @@ private fun showToast(activity: Activity, messageId: Int, length: Int) {

private fun showToast(activity: Activity, message: String, length: Int) {
    if (!activity.isActivityDestroyed()) {
        try {
            Toast.makeText(activity.applicationContext, message, length).show()
        } catch (e: Exception) {
        }
        activity.applicationContext.toast(message, length)
    }
}

+5 −2
Original line number Diff line number Diff line
@@ -90,11 +90,14 @@ fun Context.isBlackAndWhiteTheme() = baseConfig.textColor == Color.WHITE && base
fun Context.getAdjustedPrimaryColor() = if (isBlackAndWhiteTheme()) Color.WHITE else baseConfig.primaryColor

fun Context.toast(id: Int, length: Int = Toast.LENGTH_SHORT) {
    Toast.makeText(this, id, length).show()
    toast(getString(id), length)
}

fun Context.toast(msg: String, length: Int = Toast.LENGTH_SHORT) {
    Toast.makeText(this, msg, length).show()
    try {
        Toast.makeText(applicationContext, msg, length).show()
    } catch (e: Exception) {
    }
}

val Context.baseConfig: BaseConfig get() = BaseConfig.newInstance(this)