From e7760431934d50b7d7dc598574048c6d2c1cfb46 Mon Sep 17 00:00:00 2001 From: Milos Vasic Date: Sat, 23 Dec 2023 13:34:28 +0300 Subject: [PATCH] Small improvements. --- .../commons/application/BaseApplication.kt | 7 ++++--- .../commons/exception/UnknownException.kt | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Main/src/main/java/com/redelf/commons/application/BaseApplication.kt b/Main/src/main/java/com/redelf/commons/application/BaseApplication.kt index 2ca7241c..2e7cf0c5 100644 --- a/Main/src/main/java/com/redelf/commons/application/BaseApplication.kt +++ b/Main/src/main/java/com/redelf/commons/application/BaseApplication.kt @@ -12,6 +12,7 @@ import com.google.gson.GsonBuilder import com.redelf.commons.BuildConfig import com.redelf.commons.R import com.redelf.commons.execution.Executor +import com.redelf.commons.management.DataManagement import com.redelf.commons.management.Management import com.redelf.commons.persistance.Data import com.redelf.commons.persistance.GsonParser @@ -28,12 +29,12 @@ abstract class BaseApplication : Application() { lateinit var CONTEXT: Context } + val managers = mutableListOf>() + protected abstract fun onDoCreate() protected abstract fun takeSalt(): String - protected open fun populateManagers() = listOf() - - private val managers = mutableListOf() + protected open fun populateManagers() = listOf>() private val screenReceiver: BroadcastReceiver = object : BroadcastReceiver() { diff --git a/Main/src/main/java/com/redelf/commons/exception/UnknownException.kt b/Main/src/main/java/com/redelf/commons/exception/UnknownException.kt index adb96435..c0127d5c 100644 --- a/Main/src/main/java/com/redelf/commons/exception/UnknownException.kt +++ b/Main/src/main/java/com/redelf/commons/exception/UnknownException.kt @@ -1,13 +1,26 @@ package com.redelf.commons.exception +import android.text.TextUtils import com.redelf.commons.recordException -class UnknownException private constructor() : IllegalStateException("Something went wrong") { +class UnknownException + private constructor(reason: String = "") : IllegalStateException(getMessage(reason)) { companion object { - fun throwIt() : UnknownException { + private fun getMessage(reason: String = "") : String { - val exception = UnknownException() + val msg = "Something went wrong" + + if (!TextUtils.isEmpty(reason)) { + + return "$msg, reason: $reason" + } + return msg + } + + fun throwIt(reason: String = "") : UnknownException { + + val exception = UnknownException(reason) recordException(exception) throw exception }