Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
L
LuckyFarm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王雪伟
LuckyFarm
Commits
f43a4edd
Commit
f43a4edd
authored
Oct 23, 2020
by
wangxuewei
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/develop_luckyfarm_1.0.1' into develop_luckyfarm_1.0.1
parents
5649d494
332c9fb7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
133 deletions
+135
-133
BaseApplication.kt
app/src/main/java/com/ym/game/application/BaseApplication.kt
+2
-2
SplashPresenter.kt
library/src/main/java/com/ym/library/net/SplashPresenter.kt
+133
-131
No files found.
app/src/main/java/com/ym/game/application/BaseApplication.kt
View file @
f43a4edd
...
...
@@ -30,8 +30,8 @@ class BaseApplication : MultiDexApplication() {
super
.
onCreate
()
//第一步初始化 application
AppliContext
.
init
(
this
)
Config
.
init
(
this
)
NetConfig
.
setBase_Url
(
NetConfig
.
Environment
.
PRODUCT
)
// TODO 上线之后提成成 NetConfig.Environment.PRODUCT
//
Config.init(this)
NetConfig
.
setBase_Url
(
NetConfig
.
Environment
.
DEV
)
// TODO 上线之后提成成 NetConfig.Environment.PRODUCT
Constant
.
appLs
=
"a03d5320d905cf3b"
//appls
AdManager
.
init
(
//TODO 替换id
...
...
library/src/main/java/com/ym/library/net/SplashPresenter.kt
View file @
f43a4edd
...
...
@@ -6,6 +6,7 @@ import android.text.TextUtils
import
android.util.Log
import
com.ayl.ces.jni.CesCore
import
com.ym.library.AppliContext
import
com.ym.library.Config
import
com.ym.library.Constant
import
com.ym.library.utils.*
import
io.reactivex.Observable
...
...
@@ -30,10 +31,10 @@ class SplashPresenter : SplashContract.Presenter {
companion
object
{
val
PERMISSIONS
=
arrayOf
(
Constant
.
Permission
.
PERMISSION_STORAGE
,
Constant
.
Permission
.
PERMISSION_PHONE
,
Constant
.
Permission
.
PERMISSION_COARSE_LOCATION
,
Constant
.
Permission
.
PERMISSION_FINE_LOCATION
Constant
.
Permission
.
PERMISSION_STORAGE
,
Constant
.
Permission
.
PERMISSION_PHONE
,
Constant
.
Permission
.
PERMISSION_COARSE_LOCATION
,
Constant
.
Permission
.
PERMISSION_FINE_LOCATION
// Constant.Permission.CAMERA
)
}
...
...
@@ -48,34 +49,35 @@ class SplashPresenter : SplashContract.Presenter {
val
flag
=
Utils
.
needPermissions
(*
PERMISSIONS
)
e
?.
onNext
(
flag
)
e
?.
onComplete
()
}).
subscribeOn
(
Schedulers
.
io
()).
observeOn
(
AndroidSchedulers
.
mainThread
()).
subscribe
(
object
:
Observer
<
Boolean
>
{
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
}).
subscribeOn
(
Schedulers
.
io
()).
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
object
:
Observer
<
Boolean
>
{
override
fun
onSubscribe
(
d
:
Disposable
)
{
mDisposablePermissions
=
d
}
// 缺少权限时, 进入权限配置页面
if
(
aBoolean
)
{
EventUtils
.
onEvent
(
"SplashPresenter_jumpPermissionsPage"
)
mView
.
jumpPermissionsPage
()
}
else
{
getAppConfig
()
override
fun
onNext
(
aBoolean
:
Boolean
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR1
&&
mView
.
getDestroyed
())
{
return
}
// 缺少权限时, 进入权限配置页面
if
(
aBoolean
)
{
EventUtils
.
onEvent
(
"SplashPresenter_jumpPermissionsPage"
)
mView
.
jumpPermissionsPage
()
}
else
{
getAppConfig
()
}
}
}
override
fun
onError
(
e
:
Throwable
)
{
override
fun
onError
(
e
:
Throwable
)
{
}
}
override
fun
onComplete
()
{
if
(
mDisposablePermissions
!=
null
&&
mDisposablePermissions
?.
isDisposed
==
false
)
{
mDisposablePermissions
?.
dispose
()
override
fun
onComplete
()
{
if
(
mDisposablePermissions
!=
null
&&
mDisposablePermissions
?.
isDisposed
==
false
)
{
mDisposablePermissions
?.
dispose
()
}
}
}
})
})
}
override
fun
getAppConfig
()
{
...
...
@@ -89,19 +91,19 @@ class SplashPresenter : SplashContract.Presenter {
}
ApiClient
.
homeDataApi
.
initNovel
(
url
,
md5
,
cv
).
compose
(
RxSchedulers
.
observableIO2Main
())
.
subscribe
(
object
:
BaseObserver
<
NovelInitEntity
>()
{
override
fun
onSuccess
(
mNovelInitEntity
:
NovelInitEntity
)
{
if
(
mNovelInitEntity
!=
null
)
{
initConfig
(
mNovelInitEntity
)
}
else
{
loadCacheConfig
()
}
}
override
fun
onFailure
(
e
:
Throwable
?,
code
:
String
?,
errorMsg
:
String
?)
{
.
subscribe
(
object
:
BaseObserver
<
NovelInitEntity
>()
{
override
fun
onSuccess
(
mNovelInitEntity
:
NovelInitEntity
)
{
if
(
mNovelInitEntity
!=
null
)
{
initConfig
(
mNovelInitEntity
)
}
else
{
loadCacheConfig
()
}
})
}
override
fun
onFailure
(
e
:
Throwable
?,
code
:
String
?,
errorMsg
:
String
?)
{
loadCacheConfig
()
}
})
}
...
...
@@ -116,7 +118,7 @@ class SplashPresenter : SplashContract.Presenter {
private
fun
initConfig
(
mNovelInitEntity
:
NovelInitEntity
)
{
EventUtils
.
onEvent
(
"SplashPresenter_initConfig"
)
Config
.
init
(
mActivity
)
NetConfig
.
Other
.
HELP_AND_FEEDBACK_URL
=
mNovelInitEntity
?.
help
NetConfig
.
Other
.
PRIVACY_PROTOCOL_URL
=
mNovelInitEntity
?.
agreement
NetConfig
.
Other
.
FENLEI_URL
=
mNovelInitEntity
?.
cate
...
...
@@ -144,7 +146,7 @@ class SplashPresenter : SplashContract.Presenter {
Constant
.
SdkKey
.
kdxf_app_id
=
mNovelInitEntity
.
global_config
?.
ad_sdk_cfg
?.
kdxf
?.
app_id
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
//广点通广告配置信息
val
gdtStr
=
Utils
.
obj2Str
(
mNovelInitEntity
.
global_config
?.
ad_sdk_cfg
?.
gdt
)
...
...
@@ -155,20 +157,20 @@ class SplashPresenter : SplashContract.Presenter {
Constant
.
SdkKey
.
gdt_feed
=
gdt
?.
slot_cfg
?.
feed
?.
key
Constant
.
SdkKey
.
gdt_bookrack
=
gdt
?.
slot_cfg
?.
bookrack
?.
key
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
=
gdt
?.
slot_cfg
?.
news_content_bigimg
?.
key
gdt
?.
slot_cfg
?.
news_content_bigimg
?.
key
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
=
gdt
?.
slot_cfg
?.
prize_draw_bottom
?.
key
?:
""
gdt
?.
slot_cfg
?.
prize_draw_bottom
?.
key
?:
""
Constant
.
SdkKey
.
gdt_prize_draw_result
=
gdt
?.
slot_cfg
?.
prize_draw_result
?.
key
?:
""
Constant
.
SdkKey
.
gdt_sign
=
gdt
?.
slot_cfg
?.
signIn_result
?.
key
gdt
?.
slot_cfg
?.
prize_draw_result
?.
key
?:
""
Constant
.
SdkKey
.
gdt_sign
=
gdt
?.
slot_cfg
?.
signIn_result
?.
key
?:
""
}
//穿山甲广告配置
...
...
@@ -180,77 +182,77 @@ class SplashPresenter : SplashContract.Presenter {
Constant
.
SdkKey
.
byte_dance_feed
=
jrtt
?.
slot_cfg
?.
feed
?.
key
Constant
.
SdkKey
.
byte_dance_bookrack
=
jrtt
?.
slot_cfg
?.
bookrack
?.
key
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
=
jrtt
?.
slot_cfg
?.
news_content_3img
?.
key
jrtt
?.
slot_cfg
?.
news_content_3img
?.
key
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
=
jrtt
?.
slot_cfg
?.
novel_content_bottom
?.
key
jrtt
?.
slot_cfg
?.
novel_content_bottom
?.
key
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
=
jrtt
?.
slot_cfg
?.
novel_detail
?.
key
jrtt
?.
slot_cfg
?.
novel_detail
?.
key
Constant
.
SdkKey
.
byte_dance_exciting_video
=
jrtt
?.
slot_cfg
?.
exciting_video
?.
key
jrtt
?.
slot_cfg
?.
exciting_video
?.
key
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
=
jrtt
?.
slot_cfg
?.
signin_popup_bigimage
?.
key
?:
""
jrtt
?.
slot_cfg
?.
signin_popup_bigimage
?.
key
?:
""
Constant
.
SdkKey
.
chengjiu_popup_video
=
jrtt
?.
slot_cfg
?.
chengjiu_popup_video
?.
key
?:
""
jrtt
?.
slot_cfg
?.
chengjiu_popup_video
?.
key
?:
""
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
=
jrtt
?.
slot_cfg
?.
new_user_award_bigimage
?.
key
?:
""
jrtt
?.
slot_cfg
?.
new_user_award_bigimage
?.
key
?:
""
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
=
jrtt
?.
slot_cfg
?.
prize_draw_bottom
?.
key
?:
""
jrtt
?.
slot_cfg
?.
prize_draw_bottom
?.
key
?:
""
Constant
.
SdkKey
.
byte_dance_prize_draw_result
=
jrtt
?.
slot_cfg
?.
prize_draw_result
?.
key
?:
""
Constant
.
SdkKey
.
byte_dance_sign
=
jrtt
?.
slot_cfg
?.
signIn_result
?.
key
jrtt
?.
slot_cfg
?.
prize_draw_result
?.
key
?:
""
Constant
.
SdkKey
.
byte_dance_sign
=
jrtt
?.
slot_cfg
?.
signIn_result
?.
key
?:
""
Constant
.
SdkKey
.
byte_dance_mini_video_list
=
jrtt
?.
slot_cfg
?.
mini_video_list
?.
key
?:
""
Constant
.
SdkKey
.
byte_dance_splash
=
jrtt
?.
slot_cfg
?.
splash
?.
key
jrtt
?.
slot_cfg
?.
mini_video_list
?.
key
?:
""
Constant
.
SdkKey
.
byte_dance_splash
=
jrtt
?.
slot_cfg
?.
splash
?.
key
?:
""
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
=
jrtt
?.
slot_cfg
?.
transform_limit_Video
?.
key
?:
""
jrtt
?.
slot_cfg
?.
transform_limit_Video
?.
key
?:
""
Constant
.
SdkKey
.
daily_active_video
=
jrtt
?.
slot_cfg
?.
daily_active_video
?.
key
?:
""
jrtt
?.
slot_cfg
?.
daily_active_video
?.
key
?:
""
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
.
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
=
jrtt
?.
slot_cfg
?.
novel_mini_award_video
?.
key
jrtt
?.
slot_cfg
?.
novel_mini_award_video
?.
key
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
.
bubble_popup
=
jrtt
?.
slot_cfg
?.
bubble_popup
?.
key
Constant
.
SdkKey
.
signin_popup_video
=
jrtt
?.
slot_cfg
?.
signin_popup_video
?.
key
jrtt
?.
slot_cfg
?.
signin_popup_video
?.
key
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
}
...
...
@@ -358,58 +360,58 @@ class SplashPresenter : SplashContract.Presenter {
private
fun
deviceLogin
()
{
EventUtils
.
onEvent
(
"SplashPresenter_deviceLogin"
)
ApiClient
.
userApi
.
deveiceLogin
().
compose
(
RxSchedulers
.
observableIO2Main
())
.
subscribe
(
object
:
BaseObserver
<
UserInfoEntity
>()
{
override
fun
onSuccess
(
result
:
UserInfoEntity
)
{
val
token
=
result
.
token
if
(!
TextUtils
.
isEmpty
(
token
))
{
EventUtils
.
onEvent
(
"SplashPresenter_deviceLogin_success"
)
SettingPreference
.
setToken
(
token
)
SettingPreference
.
saveToken
(
token
)
}
else
{
EventUtils
.
onEvent
(
"SplashPresenter_deviceLogin_fail"
)
SettingPreference
.
setToken
(
""
)
SettingPreference
.
saveToken
(
""
)
}
getUserInfo
()
.
subscribe
(
object
:
BaseObserver
<
UserInfoEntity
>()
{
override
fun
onSuccess
(
result
:
UserInfoEntity
)
{
val
token
=
result
.
token
if
(!
TextUtils
.
isEmpty
(
token
))
{
EventUtils
.
onEvent
(
"SplashPresenter_deviceLogin_success"
)
SettingPreference
.
setToken
(
token
)
SettingPreference
.
saveToken
(
token
)
}
else
{
EventUtils
.
onEvent
(
"SplashPresenter_deviceLogin_fail"
)
SettingPreference
.
setToken
(
""
)
SettingPreference
.
saveToken
(
""
)
}
getUserInfo
()
}
override
fun
onFailure
(
e
:
Throwable
,
code
:
String
,
errorMsg
:
String
?)
{
EventUtils
.
onEvent
(
"SplashPresenter_deviceLogin_fail"
)
if
(!
TextUtils
.
equals
(
code
,
"200"
))
{
Constant
.
Param
.
uid
=
""
Constant
.
Param
.
token
=
""
SettingPreference
.
setUid
(
""
)
SettingPreference
.
setToken
(
""
)
SettingPreference
.
saveUserInfo
(
null
)
}
getUserInfo
()
override
fun
onFailure
(
e
:
Throwable
,
code
:
String
,
errorMsg
:
String
?)
{
EventUtils
.
onEvent
(
"SplashPresenter_deviceLogin_fail"
)
if
(!
TextUtils
.
equals
(
code
,
"200"
))
{
Constant
.
Param
.
uid
=
""
Constant
.
Param
.
token
=
""
SettingPreference
.
setUid
(
""
)
SettingPreference
.
setToken
(
""
)
SettingPreference
.
saveUserInfo
(
null
)
}
})
getUserInfo
()
}
})
}
fun
getUserInfo
()
{
EventUtils
.
onEvent
(
"SplashPresenter_getUserInfo"
)
ApiClient
.
userApi
.
getUserInfo
().
compose
(
RxSchedulers
.
observableIO2Main
())
.
subscribe
(
object
:
BaseObserver
<
UserInfoEntity
>()
{
override
fun
onSuccess
(
result
:
UserInfoEntity
)
{
val
uid
=
result
.
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
?)
{
.
subscribe
(
object
:
BaseObserver
<
UserInfoEntity
>()
{
override
fun
onSuccess
(
result
:
UserInfoEntity
)
{
val
uid
=
result
.
uid
if
(
TextUtils
.
isEmpty
(
uid
))
{
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment