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
95e8b401
Commit
95e8b401
authored
Nov 18, 2020
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化好兔广告监听
parent
bd3f4c28
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
168 additions
and
68 deletions
+168
-68
HorizChannelFragment.kt
...a/com/mints/goodmoney/ui/fragment/HorizChannelFragment.kt
+49
-41
MainFragment.kt
...main/java/com/mints/goodmoney/ui/fragment/MainFragment.kt
+44
-21
MoneyFragment.kt
...ain/java/com/mints/goodmoney/ui/fragment/MoneyFragment.kt
+7
-0
MyViewPager.java
...main/java/com/mints/goodmoney/ui/widgets/MyViewPager.java
+56
-0
fragment_main_dh.xml
GoodMoney/app/src/main/res/layout/fragment_main_dh.xml
+11
-5
fragment_main_money.xml
GoodMoney/app/src/main/res/layout/fragment_main_money.xml
+1
-1
No files found.
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/HorizChannelFragment.kt
View file @
95e8b401
...
...
@@ -14,6 +14,7 @@ import com.mints.goodmoney.mvp.presenters.HorizChannelPresenter
import
com.mints.goodmoney.mvp.views.HorizChannelView
import
com.mints.goodmoney.ui.activitys.AwardActivity
import
com.mints.goodmoney.ui.fragment.base.BaseFragment
import
com.mints.goodmoney.utils.LogUtil
import
com.yilan.sdk.player.ylplayer.YLPlayerConfig
import
com.yilan.sdk.player.ylplayer.callback.OnPlayerCallBack
import
com.yilan.sdk.ui.category.ChannelFragment
...
...
@@ -23,6 +24,8 @@ import net.grandcentrix.tray.AppPreferences
class
HorizChannelFragment
:
BaseFragment
(),
HorizChannelView
,
View
.
OnClickListener
{
private
val
TAG
=
HorizChannelFragment
::
class
.
java
.
simpleName
private
val
horizChannelPresenter
by
lazy
{
HorizChannelPresenter
()
}
private
val
ps
by
lazy
{
AppPreferences
(
context
)
}
...
...
@@ -79,58 +82,61 @@ class HorizChannelFragment : BaseFragment(), HorizChannelView, View.OnClickListe
val
transaction
:
FragmentTransaction
=
childFragmentManager
.
beginTransaction
()
if
(
channelFragment
==
null
)
{
// 设置点击的item播放状态,callback返回true标识用户已经处理了event,返回false,标识使用播放器内部逻辑处理event。
YLPlayerConfig
.
config
().
registerPlayerCallBack
(
object
:
OnPlayerCallBack
{
override
fun
onStart
(
p0
:
String
?,
videoid
:
String
,
p2
:
String
?)
{
// 防止网络异常时, 第一次加载倒计时红包
if
(
isFirstLoadVideo
)
{
isFirstLoadVideo
=
false
initTimeView
()
}
else
{
resumeDownloadTime
(
videoid
)
}
}
channelFragment
=
ChannelFragment
()
transaction
.
add
(
R
.
id
.
yilan_fragment_frame_container
,
channelFragment
!!
,
ChannelFragment
::
class
.
java
.
simpleName
)
}
else
{
transaction
.
show
(
channelFragment
!!
)
}
transaction
.
commitAllowingStateLoss
()
override
fun
onPause
(
p0
:
String
?,
p1
:
String
?,
p2
:
String
?)
{
pauseDownloadTime
()
}
}
private
fun
registerPlayerCallBack
()
{
// 设置点击的item播放状态,callback返回true标识用户已经处理了event,返回false,标识使用播放器内部逻辑处理event。
YLPlayerConfig
.
config
().
registerPlayerCallBack
(
object
:
OnPlayerCallBack
{
override
fun
onResume
(
p0
:
String
?,
videoid
:
String
,
p2
:
String
?)
{
override
fun
onStart
(
p0
:
String
?,
videoid
:
String
,
p2
:
String
?)
{
// 防止网络异常时, 第一次加载倒计时红包
if
(
isFirstLoadVideo
)
{
isFirstLoadVideo
=
false
initTimeView
()
}
else
{
resumeDownloadTime
(
videoid
)
}
}
override
fun
onComplete
(
p0
:
String
?,
videoid
:
String
,
p2
:
String
?)
{
override
fun
onPause
(
p0
:
String
?,
p1
:
String
?,
p2
:
String
?)
{
LogUtil
.
d
(
TAG
,
"onPause pager:${p0}"
)
pauseDownloadTime
()
}
}
override
fun
onResume
(
p0
:
String
?,
videoid
:
String
,
p2
:
String
?)
{
resumeDownloadTime
(
videoid
)
}
override
fun
onLoopComplete
(
pager
:
String
?,
videoID
:
String
,
taskID
:
String
?,
num
:
Int
)
{
addVedioIdList
(
videoID
)
pauseDownloadTime
()
}
override
fun
onComplete
(
p0
:
String
?,
videoid
:
String
,
p2
:
String
?)
{
override
fun
onStuckStart
(
p0
:
String
?,
p1
:
String
?,
p2
:
String
?)
{
}
}
override
fun
onStuckEnd
(
p0
:
String
?,
p1
:
String
?,
p2
:
String
?)
{
}
override
fun
onLoopComplete
(
pager
:
String
?,
videoID
:
String
,
taskID
:
String
?,
num
:
Int
)
{
addVedioIdList
(
videoID
)
pauseDownloadTime
()
}
override
fun
onError
(
p0
:
String
?,
p1
:
String
?,
p2
:
String
?)
{
pauseDownloadTime
()
}
override
fun
onStuckStart
(
p0
:
String
?,
p1
:
String
?,
p2
:
String
?)
{
}
override
fun
onStop
(
p0
:
String
?,
p1
:
String
?,
p2
:
String
?)
{
pauseDownloadTime
()
}
})
override
fun
onStuckEnd
(
p0
:
String
?,
p1
:
String
?,
p2
:
String
?)
{
}
channelFragment
=
ChannelFragment
()
transaction
.
add
(
R
.
id
.
yilan_fragment_frame_container
,
channelFragment
!!
,
ChannelFragment
::
class
.
java
.
simpleName
)
}
else
{
transaction
.
show
(
channelFragment
!!
)
}
transaction
.
commitAllowingStateLoss
()
override
fun
onError
(
p0
:
String
?,
p1
:
String
?,
p2
:
String
?)
{
pauseDownloadTime
()
}
override
fun
onStop
(
p0
:
String
?,
p1
:
String
?,
p2
:
String
?)
{
pauseDownloadTime
()
}
})
}
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
fragment_horiz_channel
...
...
@@ -174,13 +180,16 @@ class HorizChannelFragment : BaseFragment(), HorizChannelView, View.OnClickListe
// 调用金币视频信息接口
horizChannelPresenter
.
getSmallHomeVedioBaseMsg
()
registerPlayerCallBack
()
channelFragment
?.
onResume
()
}
}
override
fun
onPause
()
{
super
.
onPause
()
if
(
AppConfig
.
fragmentClickFlag
==
Constant
.
FRAGMENT_CLICK_CHANNEL
)
{
YLPlayerConfig
.
config
().
unRegisterPlayerCallback
()
}
channelFragment
?.
onPause
()
// pauseDownloadTime()
}
...
...
@@ -257,7 +266,6 @@ class HorizChannelFragment : BaseFragment(), HorizChannelView, View.OnClickListe
cdvvYilanTime
?.
setCountDownVedioListener
(
null
)
horizChannelPresenter
.
detachView
()
YLPlayerConfig
.
config
().
unRegisterPlayerCallback
()
}
}
\ No newline at end of file
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/MainFragment.kt
View file @
95e8b401
...
...
@@ -104,6 +104,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
homePresenter
.
userLogin
()
}
registerPlayerCallBack
()
littleVideoFragment
?.
onResume
()
}
}
...
...
@@ -116,7 +117,9 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
override
fun
onPause
()
{
super
.
onPause
()
if
(
AppConfig
.
fragmentClickFlag
==
Constant
.
FRAGMENT_CLICK_MAIN
)
{
YLPlayerConfig
.
config
().
unRegisterPlayerCallback
()
}
littleVideoFragment
?.
onPause
()
}
...
...
@@ -129,7 +132,6 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
super
.
onDestroy
()
cdvvYilanTime
?.
setCountDownVedioListener
(
null
)
YLPlayerConfig
.
config
().
unRegisterPlayerCallback
()
homePresenter
.
detachView
()
}
...
...
@@ -222,8 +224,17 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
if
(
littleVideoFragment
==
null
)
{
littleVideoFragment
=
YLLittleVideoFragment
.
newInstance
()
transaction
.
add
(
R
.
id
.
yilan_fragment_frame_container
,
littleVideoFragment
!!
,
YLLittleVideoFragment
::
class
.
java
.
simpleName
)
YLPlayerConfig
.
config
().
registerPlayerCallBack
(
object
:
OnPlayerCallBack
{
override
fun
onStart
(
p0
:
String
?,
videoid
:
String
,
p2
:
String
?)
{
}
else
{
transaction
.
show
(
littleVideoFragment
!!
)
}
transaction
.
commitAllowingStateLoss
()
}
private
fun
registerPlayerCallBack
()
{
YLPlayerConfig
.
config
().
registerPlayerCallBack
(
object
:
OnPlayerCallBack
{
override
fun
onStart
(
pager
:
String
,
videoid
:
String
,
p2
:
String
?)
{
if
(
TextUtils
.
equals
(
YLPlayerConfig
.
PAGE_LITTLE
,
"PAGE_LITTLE"
))
{
// 防止网络异常时, 第一次加载倒计时红包
if
(
isFirstLoadVedio
)
{
isFirstLoadVedio
=
false
...
...
@@ -233,44 +244,56 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
LogUtil
.
d
(
TAG
,
"onStart videoid:${videoid}"
)
}
}
override
fun
onPause
(
p0
:
String
?,
p1
:
String
?,
p2
:
String
?)
{
override
fun
onPause
(
pager
:
String
,
p1
:
String
?,
p2
:
String
?)
{
LogUtil
.
d
(
TAG
,
"onPause pager:${pager}"
)
if
(
TextUtils
.
equals
(
YLPlayerConfig
.
PAGE_LITTLE
,
"PAGE_LITTLE"
))
{
pauseDownloadTime
()
}
}
override
fun
onResume
(
pager
:
String
,
videoid
:
String
,
p2
:
String
?)
{
if
(
TextUtils
.
equals
(
YLPlayerConfig
.
PAGE_LITTLE
,
"PAGE_LITTLE"
))
{
override
fun
onResume
(
p0
:
String
?,
videoid
:
String
,
p2
:
String
?)
{
resumeDownloadTime
(
videoid
)
}
}
override
fun
onComplete
(
p0
:
String
?,
videoid
:
String
,
p2
:
String
?)
{
override
fun
onComplete
(
pager
:
String
,
videoid
:
String
,
p2
:
String
?)
{
}
override
fun
onLoopComplete
(
pager
:
String
?,
videoID
:
String
,
taskID
:
String
?,
num
:
Int
)
{
if
(
TextUtils
.
equals
(
YLPlayerConfig
.
PAGE_LITTLE
,
"PAGE_LITTLE"
))
{
}
override
fun
onLoopComplete
(
pager
:
String
?,
videoID
:
String
,
taskID
:
String
?,
num
:
Int
)
{
addVedioIdList
(
videoID
)
pauseDownloadTime
()
LogUtil
.
d
(
TAG
,
"onLoopComplete pager:${pager} videoID:${videoID} taskID:${taskID} num:${num}"
)
}
}
override
fun
onStuckStart
(
p0
:
String
?
,
p1
:
String
?,
p2
:
String
?)
{
}
override
fun
onStuckStart
(
pager
:
String
,
p1
:
String
?,
p2
:
String
?)
{
}
override
fun
onStuckEnd
(
p0
:
String
?,
p1
:
String
?,
p2
:
String
?)
{
}
override
fun
onStuckEnd
(
pager
:
String
,
p1
:
String
?,
p2
:
String
?)
{
}
override
fun
onError
(
pager
:
String
,
p1
:
String
?,
p2
:
String
?)
{
if
(
TextUtils
.
equals
(
YLPlayerConfig
.
PAGE_LITTLE
,
"PAGE_LITTLE"
))
{
override
fun
onError
(
p0
:
String
?,
p1
:
String
?,
p2
:
String
?)
{
pauseDownloadTime
()
}
}
override
fun
onStop
(
pager
:
String
,
p1
:
String
?,
p2
:
String
?)
{
if
(
TextUtils
.
equals
(
YLPlayerConfig
.
PAGE_LITTLE
,
"PAGE_LITTLE"
))
{
override
fun
onStop
(
p0
:
String
?,
p1
:
String
?,
p2
:
String
?)
{
pauseDownloadTime
()
}
})
}
else
{
transaction
.
show
(
littleVideoFragment
!!
)
}
transaction
.
commitAllowingStateLoss
()
}
})
}
/**
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/MoneyFragment.kt
View file @
95e8b401
...
...
@@ -86,6 +86,13 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
vpFragmentMoney
.
currentItem
=
if
(
curPosition
==
1
)
0
else
curPosition
return
}
// if (tab.position == 1) {
// vpFragmentMoney.setCanScroll(false)
// } else {
// vpFragmentMoney.setCanScroll(true)
// }
curPosition
=
tab
.
position
}
}
\ No newline at end of file
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/widgets/MyViewPager.java
0 → 100644
View file @
95e8b401
package
com
.
mints
.
goodmoney
.
ui
.
widgets
;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
android.view.MotionEvent
;
import
androidx.viewpager.widget.ViewPager
;
public
class
MyViewPager
extends
ViewPager
{
public
MyViewPager
(
Context
context
)
{
super
(
context
);
}
public
MyViewPager
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
// TODO Auto-generated constructor stub
}
private
boolean
isCanScroll
=
true
;
public
void
setCanScroll
(
boolean
isCanScroll
)
{
this
.
isCanScroll
=
isCanScroll
;
}
@Override
public
boolean
onTouchEvent
(
MotionEvent
arg0
)
{
if
(
isCanScroll
)
{
return
super
.
onTouchEvent
(
arg0
);
}
else
{
return
false
;
}
}
@Override
public
boolean
onInterceptTouchEvent
(
MotionEvent
arg0
)
{
if
(
isCanScroll
)
{
return
super
.
onInterceptTouchEvent
(
arg0
);
}
else
{
return
false
;
}
}
}
GoodMoney/app/src/main/res/layout/fragment_main_dh.xml
View file @
95e8b401
...
...
@@ -10,13 +10,18 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
<
Image
View
<
Text
View
android:id=
"@+id/ivDhBack"
android:layout_width=
"
30dp
"
android:layout_height=
"
30dp
"
android:layout_width=
"
wrap_content
"
android:layout_height=
"
wrap_content
"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"10dp"
android:src=
"@mipmap/ic_arrow_back"
/>
android:gravity=
"center_vertical"
android:layout_marginLeft=
"20dp"
android:text=
"返回"
android:drawablePadding=
"2dp"
android:textColor=
"@color/black"
android:textSize=
"16sp"
android:drawableLeft=
"@mipmap/ic_arrow_back"
/>
<TextView
android:id=
"@+id/tvDhRefresh"
...
...
@@ -28,6 +33,7 @@
android:paddingRight=
"30dp"
android:text=
"重新加载"
android:textColor=
"@color/black"
android:layout_marginLeft=
"20dp"
android:textSize=
"16sp"
/>
</RelativeLayout>
...
...
GoodMoney/app/src/main/res/layout/fragment_main_money.xml
View file @
95e8b401
...
...
@@ -20,7 +20,7 @@
app:xTabIndicatorWidth=
"10dp"
app:xTabTextSize=
"15sp"
/>
<
androidx.viewpager.widget.
ViewPager
<
com.mints.goodmoney.ui.widgets.My
ViewPager
android:id=
"@+id/vpFragmentMoney"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
...
...
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