desc:替换CommonApplication的实现方式

author:wangyimiao
master
yimiao 3 years ago
parent 3982660340
commit eb98dc0826

@ -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)
}
}

@ -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
}
}
}
Loading…
Cancel
Save