Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_goodmoney
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
android
android_goodmoney
Commits
9ad12dc7
Commit
9ad12dc7
authored
May 27, 2021
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新mainfragment
parent
29fa5a30
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
100 deletions
+109
-100
MainFragment.kt
...main/java/com/mints/goodmoney/ui/fragment/MainFragment.kt
+109
-100
No files found.
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/MainFragment.kt
View file @
9ad12dc7
...
...
@@ -10,14 +10,10 @@ import android.view.Gravity
import
android.view.View
import
android.widget.FrameLayout
import
android.widget.LinearLayout
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.FragmentTransaction
import
com.daimajia.androidanimations.library.Techniques
import
com.daimajia.androidanimations.library.YoYo
import
com.daimajia.androidanimations.library.YoYo.YoYoString
import
com.kwad.sdk.api.KsAdSDK
import
com.kwad.sdk.api.KsContentPage
import
com.kwad.sdk.api.KsScene
import
com.mints.goodmoney.MintsApplication
import
com.mints.goodmoney.R
import
com.mints.goodmoney.ad.express.PreLoadExpressManager
...
...
@@ -26,6 +22,7 @@ import com.mints.goodmoney.ad.video.VideoAdingManager
import
com.mints.goodmoney.common.AppConfig
import
com.mints.goodmoney.common.Constant
import
com.mints.goodmoney.manager.*
import
com.mints.goodmoney.mvp.model.BaseResponse
import
com.mints.goodmoney.mvp.model.FlowAdRulesBean
import
com.mints.goodmoney.mvp.model.MainVideoMsgBean
import
com.mints.goodmoney.mvp.model.UserTaskMsgBean
...
...
@@ -43,6 +40,11 @@ import com.mints.goodmoney.ui.widgets.seekbar.BubbleUtils
import
com.mints.goodmoney.utils.LogUtil
import
com.mints.goodmoney.utils.TimeRender
import
com.mints.library.utils.CommonUtils
import
com.yilan.sdk.player.ylplayer.YLPlayerConfig
import
com.yilan.sdk.player.ylplayer.callback.OnPlayerCallBack
import
com.yilan.sdk.ui.configs.YLUIConfig
import
com.yilan.sdk.ui.little.YLLittleVideoFragment
import
com.yilan.sdk.ylad.YLAdListener
import
kotlinx.android.synthetic.main.layout_red_bag.*
import
kotlinx.android.synthetic.main.layout_red_box.*
import
net.grandcentrix.tray.AppPreferences
...
...
@@ -62,11 +64,12 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
private
var
bindWxDialog
:
BindWxDialog
?
=
null
private
var
userMsgBean
:
UserTaskMsgBean
?
=
null
//
private lateinit var baseResponse: BaseResponse<UserTaskMsgBean>
private
lateinit
var
baseResponse
:
BaseResponse
<
UserTaskMsgBean
>
// 视频相关
private
var
rewardDoubleCoin
=
0
// 大金币
private
var
rewardCoin
=
0
// 小金币
private
var
littleVideoFragment
:
YLLittleVideoFragment
?
=
null
private
val
videoMaxCount
=
12
// 当前缓存视频id最大数
private
val
videoIdList
by
lazy
{
ArrayList
<
String
>()
}
//记录播放的视频id
...
...
@@ -78,10 +81,6 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
// 广告权重相关
private
var
videoAdingManager
:
VideoAdingManager
?
=
null
// 快手视频相关
private
var
ksFragment
:
Fragment
?
=
null
private
var
mKsContentPage
:
KsContentPage
?
=
null
// 福袋相关
private
var
rope
:
YoYoString
?
=
null
private
var
mRedBoxTimer
:
CountDownTimerSupport
?
=
null
...
...
@@ -126,7 +125,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
override
fun
onHiddenChanged
(
hidden
:
Boolean
)
{
ks
Fragment
?.
onHiddenChanged
(
hidden
)
littleVideo
Fragment
?.
onHiddenChanged
(
hidden
)
if
(
hidden
)
{
onPause
()
...
...
@@ -154,7 +153,8 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
}
ksFragment
?.
onResume
()
registerPlayerCallBack
()
littleVideoFragment
?.
onResume
()
}
}
...
...
@@ -170,13 +170,16 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
override
fun
onPause
()
{
super
.
onPause
()
if
(
AppConfig
.
fragmentClickFlag
==
Constant
.
FRAGMENT_CLICK_ONE
)
{
YLPlayerConfig
.
config
().
unRegisterPlayerCallback
()
}
// 福袋动画停止
stopRedbox
()
// 倒计时红包暂停
pauseDownloadTime
()
destroyTimerRedbox
()
ks
Fragment
?.
onPause
()
littleVideo
Fragment
?.
onPause
()
if
(
isToCreateReward
)
{
// 防止界面切换 重置红包动画
...
...
@@ -189,7 +192,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
override
fun
setUserVisibleHint
(
isVisibleToUser
:
Boolean
)
{
super
.
setUserVisibleHint
(
isVisibleToUser
)
ks
Fragment
?.
userVisibleHint
=
isVisibleToUser
littleVideo
Fragment
?.
userVisibleHint
=
isVisibleToUser
}
override
fun
onDestroyView
()
{
...
...
@@ -205,6 +208,9 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
override
fun
onDestroy
()
{
super
.
onDestroy
()
// 广告回调解绑
YLUIConfig
.
getInstance
().
unRegisterAdListener
()
YLPlayerConfig
.
config
().
unRegisterPlayerCallback
()
homePresenter
.
detachView
()
}
...
...
@@ -218,13 +224,6 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
userMsgBean
=
data
// 高额任务及超级翻倍次数
if
(
data
.
highRatePlan
!=
null
)
{
AppConfig
.
csjHighVideoAdCount
=
data
.
highRatePlan
.
csj
AppConfig
.
ylhHighVideoAdCount
=
data
.
highRatePlan
.
ylh
AppConfig
.
ksHighVideoAdCount
=
data
.
highRatePlan
.
ks
}
if
(
userMsgBean
?.
shareNews
!=
null
)
{
AppConfig
.
wzReadCoin
=
userMsgBean
!!
.
shareNews
.
readCoin
}
...
...
@@ -351,103 +350,70 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
/**
*
快手
视频初始化
*
一览
视频初始化
*/
private
fun
showLittle
()
{
val
adScene
=
KsScene
.
Builder
(
KsManager
.
KS_CONTENT_POSTID
).
build
()
mKsContentPage
=
KsAdSDK
.
getLoadManager
().
loadContentPage
(
adScene
)
registerPlayerCallBack
()
val
transaction
:
FragmentTransaction
=
childFragmentManager
.
beginTransaction
()
if
(
ksFragment
==
null
)
{
ksFragment
=
mKsContentPage
?.
fragment
transaction
.
add
(
R
.
id
.
yilan_fragment_frame_container
,
ksFragment
!!
,
"ks_fragment"
)
val
transaction
:
FragmentTransaction
=
supportFragmentManager
.
beginTransaction
()
if
(
littleVideoFragment
==
null
)
{
littleVideoFragment
=
YLLittleVideoFragment
.
newInstance
()
transaction
.
add
(
R
.
id
.
yilan_fragment_frame_container
,
littleVideoFragment
!!
,
YLLittleVideoFragment
::
class
.
java
.
simpleName
)
}
else
{
transaction
.
show
(
ks
Fragment
!!
)
transaction
.
show
(
littleVideo
Fragment
!!
)
}
transaction
.
commitAllowingStateLoss
()
}
private
fun
registerPlayerCallBack
()
{
mKsContentPage
?.
let
{
it
.
setPageListener
(
object
:
KsContentPage
.
PageListener
{
override
fun
onPagePause
(
p0
:
KsContentPage
.
ContentItem
?)
{
LogUtil
.
d
(
"onPagePause"
)
}
override
fun
onPageResume
(
p0
:
KsContentPage
.
ContentItem
?)
{
LogUtil
.
d
(
"onPageResume"
)
}
override
fun
onPageEnter
(
p0
:
KsContentPage
.
ContentItem
?)
{
LogUtil
.
d
(
"onPageEnter"
)
}
override
fun
onPageLeave
(
p0
:
KsContentPage
.
ContentItem
?)
{
LogUtil
.
d
(
"onPageLeave"
)
}
})
// 视频播放回调
it
.
setVideoListener
(
object
:
KsContentPage
.
VideoListener
{
override
fun
onVideoPlayCompleted
(
p0
:
KsContentPage
.
ContentItem
?)
{
LogUtil
.
d
(
"onVideoPlayCompleted"
)
addVideoIdList
(
p0
!!
.
id
)
pauseDownloadTime
()
YLPlayerConfig
.
config
().
registerPlayerCallBack
(
object
:
OnPlayerCallBack
{
override
fun
onStart
(
pager
:
String
,
videoid
:
String
,
p2
:
String
?)
{
// 防止网络异常时, 第一次加载倒计时红包
if
(
isFirstLoadVideo
)
{
isFirstLoadVideo
=
false
initTimeview
()
}
else
{
resumeDownloadTime
(
videoid
)
}
}
override
fun
onVideoPlayPaused
(
p0
:
KsContentPage
.
ContentItem
?)
{
LogUtil
.
d
(
"onVideoPlayPaused"
)
override
fun
onPause
(
pager
:
String
,
p1
:
String
?,
p2
:
String
?)
{
pauseDownloadTime
()
}
override
fun
onResume
(
pager
:
String
,
videoid
:
String
,
p2
:
String
?)
{
resumeDownloadTime
(
videoid
)
}
pauseDownloadTime
()
}
override
fun
onComplete
(
pager
:
String
,
videoid
:
String
,
p2
:
String
?)
{
override
fun
onVideoPlayStart
(
p0
:
KsContentPage
.
ContentItem
?)
{
LogUtil
.
d
(
"onVideoPlayStart"
)
}
// 防止网络异常时, 第一次加载倒计时红包
if
(
isFirstLoadVideo
)
{
isFirstLoadVideo
=
false
initTimeview
()
}
else
{
resumeDownloadTime
(
p0
!!
.
id
)
}
}
override
fun
onLoopComplete
(
pager
:
String
?,
videoID
:
String
,
taskID
:
String
?,
num
:
Int
)
{
// LogUtil.d(TAG, "registerPlayerCallBack onLoopComplete")
addVideoIdList
(
videoID
)
pauseDownloadTime
()
}
override
fun
onVideoPlayError
(
p0
:
KsContentPage
.
ContentItem
?,
p1
:
Int
,
p2
:
Int
)
{
LogUtil
.
d
(
"onVideoPlayError"
)
override
fun
onStuckStart
(
pager
:
String
,
p1
:
String
?,
p2
:
String
?
)
{
}
pauseDownloadTime
()
}
override
fun
onStuckEnd
(
pager
:
String
,
p1
:
String
?,
p2
:
String
?)
{
}
override
fun
onVideoPlayResume
(
p0
:
KsContentPage
.
ContentItem
?)
{
LogUtil
.
d
(
"onVideoPlayResume"
)
override
fun
onError
(
pager
:
String
,
p1
:
String
?,
p2
:
String
?)
{
// 防止网络异常时, 第一次加载倒计时红包
if
(
isFirstLoadVideo
)
{
isFirstLoadVideo
=
false
initTimeview
()
}
else
{
resumeDownloadTime
(
p0
!!
.
id
)
}
}
})
pauseDownloadTime
()
}
}
override
fun
onStop
(
pager
:
String
,
p1
:
String
?,
p2
:
String
?)
{
// LogUtil.d(TAG, "registerPlayerCallBack onStop")
// pauseDownloadTime()
}
})
}
private
fun
initListener
()
{
val
params
=
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
,
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
)
params
.
setMargins
(
0
,
0
,
0
,
BubbleUtils
.
dp2px
(
41
0
))
params
.
setMargins
(
0
,
0
,
0
,
BubbleUtils
.
dp2px
(
27
0
))
cdvvYilanTime
.
layoutParams
=
params
val
paramsRedBox
=
FrameLayout
.
LayoutParams
(
FrameLayout
.
LayoutParams
.
WRAP_CONTENT
,
FrameLayout
.
LayoutParams
.
WRAP_CONTENT
)
...
...
@@ -458,14 +424,57 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
rl_fragment_main_redbox
.
setOnClickListener
(
this
)
rl_fragment_main_redbox
.
isClickable
=
false
// 广告回调
YLUIConfig
.
getInstance
().
registerAdListener
(
object
:
YLAdListener
()
{
override
fun
onSuccess
(
p0
:
String
?,
p1
:
Int
,
p2
:
String
?,
p3
:
String
?)
{
}
override
fun
onError
(
p0
:
String
?,
p1
:
Int
,
p2
:
String
?,
p3
:
Int
,
p4
:
String
?,
p5
:
String
?)
{
}
override
fun
onRenderError
(
p0
:
String
?,
p1
:
Int
,
p2
:
String
?,
p3
:
Int
,
p4
:
String
?,
p5
:
String
?)
{
}
override
fun
onShow
(
p0
:
String
?,
p1
:
Int
,
p2
:
String
?,
p3
:
String
)
{
resumeAdTime
()
}
override
fun
onClick
(
p0
:
String
?,
p1
:
Int
,
p2
:
String
?,
p3
:
String
?)
{}
override
fun
onSkip
(
p0
:
String
?,
p1
:
Int
,
p2
:
String
?,
p3
:
String
?)
{}
override
fun
onTimeOver
(
p0
:
String
?,
p1
:
Int
,
p2
:
String
?,
p3
:
String
?)
{}
override
fun
onClose
(
p0
:
String
?,
p1
:
Int
,
p2
:
String
?,
p3
:
String
?)
{}
override
fun
onAdEmpty
(
p0
:
String
?,
p1
:
Int
,
p2
:
String
?,
p3
:
String
?)
{}
override
fun
onVideoStart
(
p0
:
String
?,
p1
:
Int
,
p2
:
String
?,
p3
:
String
)
{
}
override
fun
onVideoPause
(
p0
:
String
?,
p1
:
Int
,
p2
:
String
?,
p3
:
String
?)
{
pauseDownloadTime
()
}
override
fun
onVideoResume
(
p0
:
String
?,
p1
:
Int
,
p2
:
String
?,
p3
:
String
?)
{
resumeAdTime
()
}
override
fun
onVideoComplete
(
p0
:
String
?,
p1
:
Int
,
p2
:
String
?,
p3
:
String
?)
{
pauseDownloadTime
()
}
override
fun
onVideoError
(
p0
:
String
?,
p1
:
Int
,
p2
:
String
?,
p3
:
String
?)
{}
})
}
//
private fun resumeAdTime() {
//
// 视频未转满 且 界面切换时可继续加进度
//
if (!isAward) {
//
cdvvYilanTime?.resume()
//
}
//
}
private
fun
resumeAdTime
()
{
// 视频未转满 且 界面切换时可继续加进度
if
(!
isAward
)
{
cdvvYilanTime
?.
resume
()
}
}
/**
* 将播放的id记录到list中
...
...
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