Commit d9c3bc48 authored by yinjiacheng's avatar yinjiacheng

update BaseApplication的context赋值迁移到BGeneralBusiness组件

parent 3e5af6d1
package com.yidian.shenghuoquan.bgeneralbusiness.app
import com.scwang.smart.refresh.footer.ClassicsFooter
import com.scwang.smart.refresh.header.ClassicsHeader
import com.scwang.smart.refresh.layout.SmartRefreshLayout
import com.scwang.smart.refresh.layout.constant.SpinnerStyle
import com.yidian.bcommon.services.ZapServiceNameConstants
import com.yidian.shenghuoquan.bgeneralbusiness.service.EncryptService
import com.yidian.shenghuoquan.bgeneralbusiness.service.GeneralAbilityService
import com.yidian.shenghuoquan.bgeneralbusiness.service.ImageService
import com.yidian.shenghuoquan.bgeneralbusiness.service.net.BNAHttpReqService
import com.yidian.yac.core.zap.Zap
/**
* author: yinjiacheng
* date: 8/4/21 4:58 PM
* description: 非组件化方案 替代Application
*/
object BGeneralBusiness {
/**
* 作用同application onCreate
*/
fun init() {
initService()
initSmartRefreshLayout()
}
private fun initService() {
Zap.addService(ZapServiceNameConstants.BNAHttpReq, BNAHttpReqService())
Zap.addService(ZapServiceNameConstants.GeneralAbilityService, GeneralAbilityService())
Zap.addService(ZapServiceNameConstants.EncryptService, EncryptService())
Zap.addService(ZapServiceNameConstants.ImageService, ImageService())
}
/**
* 设置刷新 默认的header和footer
*/
private fun initSmartRefreshLayout() {
//设置全局的Header构建器
SmartRefreshLayout.setDefaultRefreshHeaderCreator { context, layout ->
layout.setPrimaryColorsId(android.R.color.transparent)//全局设置主题颜色
ClassicsHeader(context) //指定为经典Header,默认是 贝塞尔雷达Header
}
//设置全局的Footer构建器
SmartRefreshLayout.setDefaultRefreshFooterCreator { context, layout ->
layout.setEnableLoadMoreWhenContentNotFull(true) //内容不满一页时候启用加载更多
val footer = ClassicsFooter(context)
footer.setBackgroundResource(android.R.color.transparent)
footer.setDrawableSize(20f)
footer.spinnerStyle = SpinnerStyle.FixedBehind //设置为固定在背后模式
footer //指定为经典Footer,默认是 BallPulseFooter
}
}
}
......@@ -20,6 +20,7 @@ class BGeneralBusinessApplication : YdBaseApplication() {
override fun onCreate() {
super.onCreate()
if (ProcessUtil.isMainProcess(this)) {
context = this
initService()
initSmartRefreshLayout()
}
......
......@@ -24,7 +24,6 @@ class BusinessApplication : YdBaseApplication() {
override fun onCreate() {
super.onCreate()
if (ProcessUtil.isMainProcess(this)) {
context = this
// 先初始化日志防止调用时报初始化异常
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment