diff --git a/app/src/main/java/com/common/commonlibtest/MyApplication.kt b/app/src/main/java/com/common/commonlibtest/MyApplication.kt index a0a8f4e..8a96353 100644 --- a/app/src/main/java/com/common/commonlibtest/MyApplication.kt +++ b/app/src/main/java/com/common/commonlibtest/MyApplication.kt @@ -1,15 +1,13 @@ package com.common.commonlibtest -import android.app.Application import com.common.commonlib.CommonApplication import com.common.commonlib.image.config.GlideBaseConfig import com.common.commonlib.image.loader.ImageLoader -class MyApplication : Application() { +class MyApplication : CommonApplication() { override fun onCreate() { super.onCreate() - CommonApplication.intLibs(this) ImageLoader.init(this, GlideBaseConfig.MemoryType.NORMAL) } } \ No newline at end of file diff --git a/commonLib/src/main/java/com/common/commonlib/CommonApplication.kt b/commonLib/src/main/java/com/common/commonlib/CommonApplication.kt index 4165b13..dce1cd9 100644 --- a/commonLib/src/main/java/com/common/commonlib/CommonApplication.kt +++ b/commonLib/src/main/java/com/common/commonlib/CommonApplication.kt @@ -11,19 +11,21 @@ import android.content.Context * @since 2021/7/28 */ @SuppressLint("StaticFieldLeak") -object CommonApplication : Application() { - private var commonContext: Context? = null - +open class CommonApplication : Application() { override fun onCreate() { super.onCreate() intLibs(this) } - fun intLibs(context: Context) { + private fun intLibs(context: Context) { commonContext = context } - fun getContext(): Context? { - return commonContext + companion object { + private var commonContext: Context? = null + + fun getContext(): Context? { + return commonContext + } } } \ No newline at end of file