Commit 332c9fb7 authored by maxiaoliang's avatar maxiaoliang

修改coing

parent d3bcc71d
...@@ -30,8 +30,8 @@ class BaseApplication : MultiDexApplication() { ...@@ -30,8 +30,8 @@ class BaseApplication : MultiDexApplication() {
super.onCreate() super.onCreate()
//第一步初始化 application //第一步初始化 application
AppliContext.init(this) AppliContext.init(this)
Config.init(this) // Config.init(this)
NetConfig.setBase_Url(NetConfig.Environment.PRODUCT)// TODO 上线之后提成成 NetConfig.Environment.PRODUCT NetConfig.setBase_Url(NetConfig.Environment.DEV)// TODO 上线之后提成成 NetConfig.Environment.PRODUCT
Constant.appLs = "a03d5320d905cf3b"//appls Constant.appLs = "a03d5320d905cf3b"//appls
AdManager.init(//TODO 替换id AdManager.init(//TODO 替换id
......
...@@ -6,6 +6,7 @@ import android.text.TextUtils ...@@ -6,6 +6,7 @@ import android.text.TextUtils
import android.util.Log import android.util.Log
import com.ayl.ces.jni.CesCore import com.ayl.ces.jni.CesCore
import com.ym.library.AppliContext import com.ym.library.AppliContext
import com.ym.library.Config
import com.ym.library.Constant import com.ym.library.Constant
import com.ym.library.utils.* import com.ym.library.utils.*
import io.reactivex.Observable import io.reactivex.Observable
...@@ -30,10 +31,10 @@ class SplashPresenter : SplashContract.Presenter { ...@@ -30,10 +31,10 @@ class SplashPresenter : SplashContract.Presenter {
companion object { companion object {
val PERMISSIONS = arrayOf( val PERMISSIONS = arrayOf(
Constant.Permission.PERMISSION_STORAGE, Constant.Permission.PERMISSION_STORAGE,
Constant.Permission.PERMISSION_PHONE, Constant.Permission.PERMISSION_PHONE,
Constant.Permission.PERMISSION_COARSE_LOCATION, Constant.Permission.PERMISSION_COARSE_LOCATION,
Constant.Permission.PERMISSION_FINE_LOCATION Constant.Permission.PERMISSION_FINE_LOCATION
// Constant.Permission.CAMERA // Constant.Permission.CAMERA
) )
} }
...@@ -48,34 +49,35 @@ class SplashPresenter : SplashContract.Presenter { ...@@ -48,34 +49,35 @@ class SplashPresenter : SplashContract.Presenter {
val flag = Utils.needPermissions(*PERMISSIONS) val flag = Utils.needPermissions(*PERMISSIONS)
e?.onNext(flag) e?.onNext(flag)
e?.onComplete() e?.onComplete()
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(object : Observer<Boolean> { }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
override fun onSubscribe(d: Disposable) { .subscribe(object : Observer<Boolean> {
mDisposablePermissions = d override fun onSubscribe(d: Disposable) {
} mDisposablePermissions = d
override fun onNext(aBoolean: Boolean) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && mView.getDestroyed()) {
return
} }
// 缺少权限时, 进入权限配置页面
if (aBoolean) { override fun onNext(aBoolean: Boolean) {
EventUtils.onEvent("SplashPresenter_jumpPermissionsPage") if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && mView.getDestroyed()) {
mView.jumpPermissionsPage() return
} else { }
getAppConfig() // 缺少权限时, 进入权限配置页面
if (aBoolean) {
EventUtils.onEvent("SplashPresenter_jumpPermissionsPage")
mView.jumpPermissionsPage()
} else {
getAppConfig()
}
} }
}
override fun onError(e: Throwable) { override fun onError(e: Throwable) {
} }
override fun onComplete() { override fun onComplete() {
if (mDisposablePermissions != null && mDisposablePermissions?.isDisposed == false) { if (mDisposablePermissions != null && mDisposablePermissions?.isDisposed == false) {
mDisposablePermissions?.dispose() mDisposablePermissions?.dispose()
}
} }
} })
})
} }
override fun getAppConfig() { override fun getAppConfig() {
...@@ -89,19 +91,19 @@ class SplashPresenter : SplashContract.Presenter { ...@@ -89,19 +91,19 @@ class SplashPresenter : SplashContract.Presenter {
} }
ApiClient.homeDataApi.initNovel(url, md5, cv).compose(RxSchedulers.observableIO2Main()) ApiClient.homeDataApi.initNovel(url, md5, cv).compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<NovelInitEntity>() { .subscribe(object : BaseObserver<NovelInitEntity>() {
override fun onSuccess(mNovelInitEntity: NovelInitEntity) { override fun onSuccess(mNovelInitEntity: NovelInitEntity) {
if (mNovelInitEntity != null) { if (mNovelInitEntity != null) {
initConfig(mNovelInitEntity) initConfig(mNovelInitEntity)
} else { } else {
loadCacheConfig()
}
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
loadCacheConfig() loadCacheConfig()
} }
}) }
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
loadCacheConfig()
}
})
} }
...@@ -116,7 +118,7 @@ class SplashPresenter : SplashContract.Presenter { ...@@ -116,7 +118,7 @@ class SplashPresenter : SplashContract.Presenter {
private fun initConfig(mNovelInitEntity: NovelInitEntity) { private fun initConfig(mNovelInitEntity: NovelInitEntity) {
EventUtils.onEvent("SplashPresenter_initConfig") EventUtils.onEvent("SplashPresenter_initConfig")
Config.init(mActivity)
NetConfig.Other.HELP_AND_FEEDBACK_URL = mNovelInitEntity?.help NetConfig.Other.HELP_AND_FEEDBACK_URL = mNovelInitEntity?.help
NetConfig.Other.PRIVACY_PROTOCOL_URL = mNovelInitEntity?.agreement NetConfig.Other.PRIVACY_PROTOCOL_URL = mNovelInitEntity?.agreement
NetConfig.Other.FENLEI_URL = mNovelInitEntity?.cate NetConfig.Other.FENLEI_URL = mNovelInitEntity?.cate
...@@ -144,7 +146,7 @@ class SplashPresenter : SplashContract.Presenter { ...@@ -144,7 +146,7 @@ class SplashPresenter : SplashContract.Presenter {
Constant.SdkKey.kdxf_app_id = mNovelInitEntity.global_config?.ad_sdk_cfg?.kdxf?.app_id Constant.SdkKey.kdxf_app_id = mNovelInitEntity.global_config?.ad_sdk_cfg?.kdxf?.app_id
Constant.PLAY_URL = mNovelInitEntity.h5_url?.PlayUrl Constant.PLAY_URL = mNovelInitEntity.h5_url?.PlayUrl
Constant.ISENTERTAINMENT = mNovelInitEntity.switch?.isEntertainment?:1 Constant.ISENTERTAINMENT = mNovelInitEntity.switch?.isEntertainment ?: 1
Constant.qq = mNovelInitEntity?.switch?.qq ?: 0 Constant.qq = mNovelInitEntity?.switch?.qq ?: 0
//广点通广告配置信息 //广点通广告配置信息
val gdtStr = Utils.obj2Str(mNovelInitEntity.global_config?.ad_sdk_cfg?.gdt) val gdtStr = Utils.obj2Str(mNovelInitEntity.global_config?.ad_sdk_cfg?.gdt)
...@@ -155,20 +157,20 @@ class SplashPresenter : SplashContract.Presenter { ...@@ -155,20 +157,20 @@ class SplashPresenter : SplashContract.Presenter {
Constant.SdkKey.gdt_feed = gdt?.slot_cfg?.feed?.key Constant.SdkKey.gdt_feed = gdt?.slot_cfg?.feed?.key
Constant.SdkKey.gdt_bookrack = gdt?.slot_cfg?.bookrack?.key Constant.SdkKey.gdt_bookrack = gdt?.slot_cfg?.bookrack?.key
Constant.SdkKey.gdt_news_content_3img = Constant.SdkKey.gdt_news_content_3img =
gdt?.slot_cfg?.news_content_3img?.key gdt?.slot_cfg?.news_content_3img?.key
Constant.SdkKey.gdt_news_content_bigimg = Constant.SdkKey.gdt_news_content_bigimg =
gdt?.slot_cfg?.news_content_bigimg?.key gdt?.slot_cfg?.news_content_bigimg?.key
Constant.SdkKey.gdt_date_coins = Constant.SdkKey.gdt_date_coins =
gdt?.slot_cfg?.novel_time_award?.key gdt?.slot_cfg?.novel_time_award?.key
?: "" ?: ""
Constant.SdkKey.gdt_prize_draw_bottom = Constant.SdkKey.gdt_prize_draw_bottom =
gdt?.slot_cfg?.prize_draw_bottom?.key gdt?.slot_cfg?.prize_draw_bottom?.key
?: "" ?: ""
Constant.SdkKey.gdt_prize_draw_result = Constant.SdkKey.gdt_prize_draw_result =
gdt?.slot_cfg?.prize_draw_result?.key gdt?.slot_cfg?.prize_draw_result?.key
?: ""
Constant.SdkKey.gdt_sign = gdt?.slot_cfg?.signIn_result?.key
?: "" ?: ""
Constant.SdkKey.gdt_sign = gdt?.slot_cfg?.signIn_result?.key
?: ""
} }
//穿山甲广告配置 //穿山甲广告配置
...@@ -180,77 +182,77 @@ class SplashPresenter : SplashContract.Presenter { ...@@ -180,77 +182,77 @@ class SplashPresenter : SplashContract.Presenter {
Constant.SdkKey.byte_dance_feed = jrtt?.slot_cfg?.feed?.key Constant.SdkKey.byte_dance_feed = jrtt?.slot_cfg?.feed?.key
Constant.SdkKey.byte_dance_bookrack = jrtt?.slot_cfg?.bookrack?.key Constant.SdkKey.byte_dance_bookrack = jrtt?.slot_cfg?.bookrack?.key
Constant.SdkKey.byte_dance_mini_video = Constant.SdkKey.byte_dance_mini_video =
jrtt?.slot_cfg?.mini_video?.key jrtt?.slot_cfg?.mini_video?.key
Constant.SdkKey.byte_dance_news_content_3img = Constant.SdkKey.byte_dance_news_content_3img =
jrtt?.slot_cfg?.news_content_3img?.key jrtt?.slot_cfg?.news_content_3img?.key
Constant.SdkKey.byte_dance_news_content_bigimg = Constant.SdkKey.byte_dance_news_content_bigimg =
jrtt?.slot_cfg?.bubble_popup?.key jrtt?.slot_cfg?.bubble_popup?.key
Constant.SdkKey.byte_dance_novel_content_bottom = Constant.SdkKey.byte_dance_novel_content_bottom =
jrtt?.slot_cfg?.novel_content_bottom?.key jrtt?.slot_cfg?.novel_content_bottom?.key
Constant.SdkKey.byte_dance_novel_content_bigimg = Constant.SdkKey.byte_dance_novel_content_bigimg =
jrtt?.slot_cfg?.novel_content_bigimg?.key jrtt?.slot_cfg?.novel_content_bigimg?.key
Constant.SdkKey.byte_dance_novel_detail = Constant.SdkKey.byte_dance_novel_detail =
jrtt?.slot_cfg?.novel_detail?.key jrtt?.slot_cfg?.novel_detail?.key
Constant.SdkKey.byte_dance_exciting_video = Constant.SdkKey.byte_dance_exciting_video =
jrtt?.slot_cfg?.exciting_video?.key jrtt?.slot_cfg?.exciting_video?.key
Constant.SdkKey.byte_dance_date_coins = Constant.SdkKey.byte_dance_date_coins =
jrtt?.slot_cfg?.novel_time_award?.key jrtt?.slot_cfg?.novel_time_award?.key
?: "" ?: ""
Constant.SdkKey.signin_popup_bigimage = Constant.SdkKey.signin_popup_bigimage =
jrtt?.slot_cfg?.signin_popup_bigimage?.key jrtt?.slot_cfg?.signin_popup_bigimage?.key
?: "" ?: ""
Constant.SdkKey.chengjiu_popup_video = Constant.SdkKey.chengjiu_popup_video =
jrtt?.slot_cfg?.chengjiu_popup_video?.key jrtt?.slot_cfg?.chengjiu_popup_video?.key
?: "" ?: ""
Constant.SdkKey.chengjiu_popup_bigimage = Constant.SdkKey.chengjiu_popup_bigimage =
jrtt?.slot_cfg?.chengjiu_popup_bigimage?.key jrtt?.slot_cfg?.chengjiu_popup_bigimage?.key
?: "" ?: ""
Constant.SdkKey.new_user_award_bigimage = Constant.SdkKey.new_user_award_bigimage =
jrtt?.slot_cfg?.new_user_award_bigimage?.key jrtt?.slot_cfg?.new_user_award_bigimage?.key
?: "" ?: ""
Constant.SdkKey.byte_dance_video_feed = Constant.SdkKey.byte_dance_video_feed =
jrtt?.slot_cfg?.novel_short_video_feed?.key jrtt?.slot_cfg?.novel_short_video_feed?.key
?: "" ?: ""
Constant.SdkKey.byte_dance_prize_draw_bottom = Constant.SdkKey.byte_dance_prize_draw_bottom =
jrtt?.slot_cfg?.prize_draw_bottom?.key jrtt?.slot_cfg?.prize_draw_bottom?.key
?: "" ?: ""
Constant.SdkKey.byte_dance_prize_draw_result = Constant.SdkKey.byte_dance_prize_draw_result =
jrtt?.slot_cfg?.prize_draw_result?.key jrtt?.slot_cfg?.prize_draw_result?.key
?: ""
Constant.SdkKey.byte_dance_sign = jrtt?.slot_cfg?.signIn_result?.key
?: "" ?: ""
Constant.SdkKey.byte_dance_sign = jrtt?.slot_cfg?.signIn_result?.key
?: ""
Constant.SdkKey.byte_dance_mini_video_list = Constant.SdkKey.byte_dance_mini_video_list =
jrtt?.slot_cfg?.mini_video_list?.key jrtt?.slot_cfg?.mini_video_list?.key
?: ""
Constant.SdkKey.byte_dance_splash = jrtt?.slot_cfg?.splash?.key
?: "" ?: ""
Constant.SdkKey.byte_dance_splash = jrtt?.slot_cfg?.splash?.key
?: ""
Constant.SdkKey.byte_dance_prize_draw_video = Constant.SdkKey.byte_dance_prize_draw_video =
jrtt?.slot_cfg?.prize_draw_video?.key jrtt?.slot_cfg?.prize_draw_video?.key
?: "" ?: ""
Constant.SdkKey.transform_limit_Video = Constant.SdkKey.transform_limit_Video =
jrtt?.slot_cfg?.transform_limit_Video?.key jrtt?.slot_cfg?.transform_limit_Video?.key
?: "" ?: ""
Constant.SdkKey.daily_active_video = Constant.SdkKey.daily_active_video =
jrtt?.slot_cfg?.daily_active_video?.key jrtt?.slot_cfg?.daily_active_video?.key
?: "" ?: ""
Constant.SdkKey.daily_active_bigimage = Constant.SdkKey.daily_active_bigimage =
jrtt?.slot_cfg?.daily_active_bigimage?.key jrtt?.slot_cfg?.daily_active_bigimage?.key
?: "" ?: ""
Constant.superMasterTab = mNovelInitEntity.switch?.superMasterTab ?: 0 Constant.superMasterTab = mNovelInitEntity.switch?.superMasterTab ?: 0
Constant.SdkKey.novel_svideos_awardt_video = Constant.SdkKey.novel_svideos_awardt_video =
jrtt?.slot_cfg?.novel_svideos_awardt_video?.key jrtt?.slot_cfg?.novel_svideos_awardt_video?.key
Constant.SdkKey.novel_mini_award_video = Constant.SdkKey.novel_mini_award_video =
jrtt?.slot_cfg?.novel_mini_award_video?.key jrtt?.slot_cfg?.novel_mini_award_video?.key
Constant.SdkKey.novel_feed_award_video = Constant.SdkKey.novel_feed_award_video =
jrtt?.slot_cfg?.novel_feed_award_video?.key jrtt?.slot_cfg?.novel_feed_award_video?.key
Constant.SdkKey.signin_popup = jrtt?.slot_cfg?.signin_popup?.key Constant.SdkKey.signin_popup = jrtt?.slot_cfg?.signin_popup?.key
Constant.SdkKey.bubble_popup = jrtt?.slot_cfg?.bubble_popup?.key Constant.SdkKey.bubble_popup = jrtt?.slot_cfg?.bubble_popup?.key
Constant.SdkKey.signin_popup_video = Constant.SdkKey.signin_popup_video =
jrtt?.slot_cfg?.signin_popup_video?.key jrtt?.slot_cfg?.signin_popup_video?.key
Constant.SdkKey.bubble_popup_video = Constant.SdkKey.bubble_popup_video =
jrtt?.slot_cfg?.bubble_popup_video?.key jrtt?.slot_cfg?.bubble_popup_video?.key
Constant.SdkKey.exciting_video = jrtt?.slot_cfg?.exciting_video?.key Constant.SdkKey.exciting_video = jrtt?.slot_cfg?.exciting_video?.key
} }
...@@ -358,58 +360,58 @@ class SplashPresenter : SplashContract.Presenter { ...@@ -358,58 +360,58 @@ class SplashPresenter : SplashContract.Presenter {
private fun deviceLogin() { private fun deviceLogin() {
EventUtils.onEvent("SplashPresenter_deviceLogin") EventUtils.onEvent("SplashPresenter_deviceLogin")
ApiClient.userApi.deveiceLogin().compose(RxSchedulers.observableIO2Main()) ApiClient.userApi.deveiceLogin().compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<UserInfoEntity>() { .subscribe(object : BaseObserver<UserInfoEntity>() {
override fun onSuccess(result: UserInfoEntity) { override fun onSuccess(result: UserInfoEntity) {
val token = result.token val token = result.token
if (!TextUtils.isEmpty(token)) { if (!TextUtils.isEmpty(token)) {
EventUtils.onEvent("SplashPresenter_deviceLogin_success") EventUtils.onEvent("SplashPresenter_deviceLogin_success")
SettingPreference.setToken(token) SettingPreference.setToken(token)
SettingPreference.saveToken(token) SettingPreference.saveToken(token)
} else { } else {
EventUtils.onEvent("SplashPresenter_deviceLogin_fail") EventUtils.onEvent("SplashPresenter_deviceLogin_fail")
SettingPreference.setToken("") SettingPreference.setToken("")
SettingPreference.saveToken("") SettingPreference.saveToken("")
}
getUserInfo()
} }
getUserInfo()
}
override fun onFailure(e: Throwable, code: String, errorMsg: String?) { override fun onFailure(e: Throwable, code: String, errorMsg: String?) {
EventUtils.onEvent("SplashPresenter_deviceLogin_fail") EventUtils.onEvent("SplashPresenter_deviceLogin_fail")
if (!TextUtils.equals(code, "200")) { if (!TextUtils.equals(code, "200")) {
Constant.Param.uid = "" Constant.Param.uid = ""
Constant.Param.token = "" Constant.Param.token = ""
SettingPreference.setUid("") SettingPreference.setUid("")
SettingPreference.setToken("") SettingPreference.setToken("")
SettingPreference.saveUserInfo(null) SettingPreference.saveUserInfo(null)
}
getUserInfo()
} }
}) getUserInfo()
}
})
} }
fun getUserInfo() { fun getUserInfo() {
EventUtils.onEvent("SplashPresenter_getUserInfo") EventUtils.onEvent("SplashPresenter_getUserInfo")
ApiClient.userApi.getUserInfo().compose(RxSchedulers.observableIO2Main()) ApiClient.userApi.getUserInfo().compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<UserInfoEntity>() { .subscribe(object : BaseObserver<UserInfoEntity>() {
override fun onSuccess(result: UserInfoEntity) { override fun onSuccess(result: UserInfoEntity) {
val uid = result.uid val uid = result.uid
if (TextUtils.isEmpty(uid)) { if (TextUtils.isEmpty(uid)) {
EventUtils.onEvent("SplashPresenter_getUserInfo_fail")
} else {
EventUtils.onEvent("SplashPresenter_getUserInfo_success")
SettingPreference.saveUserInfo(result)
SettingPreference.setTrackId(result.gaodeTrackId ?: 0L)
SettingPreference.setTerminalId(result.gaodeTerminalId ?: 0L)
SettingPreference.setUid(uid)
}
mView.jumpPage()
}
override fun onFailure(e: Throwable, code: String?, errorMsg: String?) {
EventUtils.onEvent("SplashPresenter_getUserInfo_fail") EventUtils.onEvent("SplashPresenter_getUserInfo_fail")
mView.jumpPage() } else {
EventUtils.onEvent("SplashPresenter_getUserInfo_success")
SettingPreference.saveUserInfo(result)
SettingPreference.setTrackId(result.gaodeTrackId ?: 0L)
SettingPreference.setTerminalId(result.gaodeTerminalId ?: 0L)
SettingPreference.setUid(uid)
} }
}) mView.jumpPage()
}
override fun onFailure(e: Throwable, code: String?, errorMsg: String?) {
EventUtils.onEvent("SplashPresenter_getUserInfo_fail")
mView.jumpPage()
}
})
} }
} }
\ No newline at end of file
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