Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_vedio
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_vedio
Commits
7c1bd235
Commit
7c1bd235
authored
May 22, 2024
by
mengcuiguang2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除穿山甲短剧sdk
parent
1f094cd7
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
21 additions
and
1745 deletions
+21
-1745
build.gradle
video/app/build.gradle
+9
-9
AndroidManifest.xml
video/app/src/main/AndroidManifest.xml
+0
-12
SDK_Setting_5538933.json
video/app/src/main/assets/SDK_Setting_5538933.json
+0
-58
LocalVedioManager.kt
...ain/java/com/duben/skitworld/manager/LocalVedioManager.kt
+1
-36
AboutusActivity.kt
.../java/com/duben/skitworld/ui/activitys/AboutusActivity.kt
+1
-33
MainActivity.kt
...ain/java/com/duben/skitworld/ui/activitys/MainActivity.kt
+0
-2
RecommendFragment.kt
...java/com/duben/skitworld/ui/fragment/RecommendFragment.kt
+10
-8
DPHolderManager.kt
...ain/java/com/duben/skitworld/video/csj/DPHolderManager.kt
+0
-37
DramaApiDetailActivity.kt
...a/com/duben/skitworld/video/csj/DramaApiDetailActivity.kt
+0
-966
DramaTabFragment.kt
...in/java/com/duben/skitworld/video/csj/DramaTabFragment.kt
+0
-402
OnRecyViewListener.kt
.../java/com/duben/skitworld/video/csj/OnRecyViewListener.kt
+0
-18
RecyViewLayoutManager.kt
...va/com/duben/skitworld/video/csj/RecyViewLayoutManager.kt
+0
-152
drama_home_frag_wrapper.xml
video/app/src/main/res/layout/drama_home_frag_wrapper.xml
+0
-12
No files found.
video/app/build.gradle
View file @
7c1bd235
...
...
@@ -210,15 +210,15 @@ dependencies {
// umeng 接入
// 穿山甲短剧
implementation
(
"com.pangle.cn:pangrowth-sdk:3.9.0.2"
)
{
exclude
group:
'com.pangle.cn'
,
module:
'pangrowth-game-sdk'
exclude
group:
'com.pangle.cn'
,
module:
'pangrowth-novel-sdk'
exclude
group:
'com.pangle.cn'
,
module:
'pangrowth-luckycat-sdk'
exclude
group:
'com.pangle.cn'
,
module:
'partner-luckycat-api-sdk'
exclude
group:
'com.pangle.cn'
,
module:
'pangrowth-reward-sdk'
exclude
group:
'com.pangle.cn'
,
module:
'partner-live-sdk'
exclude
group:
'com.tencent.mm.opensdk'
,
module:
'wechat-sdk-android'
}
//
implementation("com.pangle.cn:pangrowth-sdk:3.9.0.2") {
//
exclude group: 'com.pangle.cn', module: 'pangrowth-game-sdk'
//
exclude group: 'com.pangle.cn', module: 'pangrowth-novel-sdk'
//
exclude group: 'com.pangle.cn', module: 'pangrowth-luckycat-sdk'
//
exclude group: 'com.pangle.cn', module: 'partner-luckycat-api-sdk'
//
exclude group: 'com.pangle.cn', module: 'pangrowth-reward-sdk'
//
exclude group: 'com.pangle.cn', module: 'partner-live-sdk'
//
exclude group: 'com.tencent.mm.opensdk', module: 'wechat-sdk-android'
//
}
// 穿山甲聚合 接入【穿山甲、快手】
implementation
"com.pangle.cn:mediation-sdk:6.1.0.4"
...
...
video/app/src/main/AndroidManifest.xml
View file @
7c1bd235
...
...
@@ -169,11 +169,6 @@
android:exported=
"false"
android:theme=
"@style/TransparentTheme"
/>
<activity
android:name=
".video.csj.DramaApiDetailActivity"
android:exported=
"false"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activitys.WatchRecordActivity"
android:exported=
"false"
...
...
@@ -196,13 +191,6 @@
android:exported=
"true"
/>
<!-- 短剧SDK -->
<provider
android:name=
"com.bytedance.sdk.dp.act.DPProvider"
android:authorities=
"${applicationId}.BDDPProvider"
android:exported=
"false"
/>
<!-- 自有下载 -->
<provider
android:name=
"androidx.core.content.FileProvider"
...
...
video/app/src/main/assets/SDK_Setting_5538933.json
deleted
100644 → 0
View file @
1f094cd7
{
"init"
:
{
"site_id"
:
"5533187"
,
"app_id"
:
"601108"
,
"partner"
:
"pangle_601108"
,
"secure_key"
:
"8447a94765c7f22e9fe2e8ad84b992c7"
,
"secure_key_d"
:
"3a57b978ebdd87a9f68677740f908282"
},
"feed"
:
{
"news_list_ad_code_id"
:
""
,
"news_first_ad_code_id"
:
""
,
"news_second_ad_code_id"
:
""
,
"video_first_ad_code_id"
:
""
,
"video_second_ad_code_id"
:
""
,
"related_ad_code_id"
:
""
,
"news_draw_ad_code_id"
:
"957422056"
,
"news_draw_native_ad_code_id"
:
"957422061"
,
"news_outer_list_ad_code_id"
:
""
,
"news_outer_first_ad_code_id"
:
""
,
"news_outer_second_ad_code_id"
:
""
,
"outer_video_second_ad_code_id"
:
""
,
"outer_related_ad_code_id"
:
""
,
"news_outer_draw_ad_code_id"
:
"957422065"
,
"news_outer_draw_native_ad_code_id"
:
"957422052"
,
"news_interstitial_code_id"
:
""
},
"small_video"
:
{
"draw_ad_code_id"
:
"957422058"
,
"draw_native_ad_code_id"
:
"957422060"
,
"grid_ad_code_id"
:
"957422063"
,
"grid_draw_ad_code_id"
:
"957422068"
,
"grid_draw_native_ad_code_id"
:
"957422053"
,
"video_card_ad_code_id"
:
"957422050"
,
"video_card_draw_ad_code_id"
:
"957422067"
,
"video_card_draw_native_ad_code_id"
:
"957422049"
,
"interstitial_ad_code_id"
:
""
,
"interstitial_note_ad_code_id"
:
"957422066"
,
"staggered_grid_ad_code_id"
:
"957422064"
,
"staggered_grid_draw_ad_code_id"
:
"957422058"
,
"staggered_grid_draw_native_ad_code_id"
:
"957422060"
,
"draw_interstitial_ad_code_id"
:
"957422059"
,
"draw_fullscreen_interstitial_ad_code_id"
:
"957422054"
,
"draw_banner_code_id"
:
"957422055"
,
"drama_rewarded_ad_code_id"
:
"957422062"
,
"drama_rewarded_ad_code_id_02"
:
"957422051"
,
"drama_draw_ad_code_id"
:
"957422057"
},
"novel"
:
{
"status"
:
0
,
"pre_ad_code_id"
:
""
,
"mid_ad_code_id"
:
""
,
"exciting_ad_code_id"
:
""
,
"interstitial_code_id"
:
""
,
"banner_ad_code_id"
:
""
,
"end_ad_code_id"
:
""
},
"live"
:
null
}
\ No newline at end of file
video/app/src/main/java/com/duben/skitworld/manager/LocalVedioManager.kt
View file @
7c1bd235
...
...
@@ -4,9 +4,6 @@ import android.app.Activity
import
android.content.Intent
import
android.os.Bundle
import
android.text.TextUtils
import
com.bytedance.sdk.dp.DPDrama
import
com.bytedance.sdk.dp.DPSdk
import
com.bytedance.sdk.dp.IDPWidgetFactory
import
com.duben.skitworld.ad.express.ExpressManager
import
com.duben.library.utils.json.JsonUtil
import
com.duben.skitworld.common.AppConfig
...
...
@@ -14,7 +11,6 @@ import com.duben.skitworld.common.Constant
import
com.duben.skitworld.mvp.model.VedioBean
import
com.duben.skitworld.utils.AppPreferencesManager
import
com.duben.skitworld.utils.ToastUtil
import
com.duben.skitworld.video.csj.DramaApiDetailActivity
import
com.duben.skitworld.video.tx.newrecommend.NewTxVideoActivity
import
com.duben.skitworld.video.tx.TxVideoActivity
...
...
@@ -109,7 +105,7 @@ object LocalVedioManager {
bundle
.
putBoolean
(
Constant
.
VEDIO_THIRD
,
isThirdId
)
readyGo
(
activity
,
TxVideoActivity
::
class
.
java
,
bundle
)
}
else
if
(
data
?.
createType
==
2
)
{
requestDrama
(
activity
,
data
)
// 穿山甲
}
else
{
//推荐短剧
val
bundle
=
Bundle
()
...
...
@@ -122,37 +118,6 @@ object LocalVedioManager {
}
}
// 请求穿山甲数据
private
fun
requestDrama
(
activity
:
Activity
,
data
:
VedioBean
?)
{
if
(
DPSdk
.
isStartSuccess
()
&&
data
!=
null
)
{
DPSdk
.
factory
().
requestDrama
(
arrayListOf
(
data
.
thirdId
.
toLong
()),
object
:
IDPWidgetFactory
.
DramaCallback
{
override
fun
onError
(
p0
:
Int
,
p1
:
String
?)
{
ToastUtil
.
show
(
activity
,
"网络错误!"
)
}
override
fun
onSuccess
(
dataList
:
MutableList
<
out
DPDrama
>?,
info
:
MutableMap
<
String
,
Any
>?
)
{
dataList
?.
takeIf
{
it
.
isNotEmpty
()
}
?.
first
()
?.
let
{
DramaApiDetailActivity
.
outerDrama
=
it
//穿山甲短剧
val
bundle
=
Bundle
()
bundle
.
putString
(
Constant
.
VEDIO_BEAN
,
JsonUtil
.
toJson
(
data
))
readyGo
(
activity
,
DramaApiDetailActivity
::
class
.
java
,
bundle
)
}
}
}
)
}
else
{
ToastUtil
.
show
(
activity
,
"网络错误!"
)
}
}
fun
readyGo
(
activity
:
Activity
,
clazz
:
Class
<
*
>,
bundle
:
Bundle
)
{
val
intent
=
Intent
(
activity
,
clazz
)
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
...
...
video/app/src/main/java/com/duben/skitworld/ui/activitys/AboutusActivity.kt
View file @
7c1bd235
...
...
@@ -8,9 +8,6 @@ import android.widget.ImageView
import
android.widget.TextView
import
android.widget.Toast
import
com.bytedance.hume.readapk.HumeSDK
import
com.bytedance.sdk.dp.DPDrama
import
com.bytedance.sdk.dp.DPSdk
import
com.bytedance.sdk.dp.IDPWidgetFactory
import
com.duben.skitworld.BuildConfig
import
com.duben.skitworld.MintsApplication
import
com.duben.skitworld.R
...
...
@@ -96,36 +93,7 @@ class AboutusActivity : BaseActivity(), View.OnClickListener {
tvAboutasPolicy
.
setOnClickListener
(
this
)
findViewById
<
TextView
>(
R
.
id
.
tv_about_address
).
setOnLongClickListener
{
if
(
BuildConfig
.
DEBUG
)
{
if
(
DPSdk
.
isStartSuccess
())
{
DPSdk
.
factory
().
requestAllDrama
(
1
,
Int
.
MAX_VALUE
,
true
,
object
:
IDPWidgetFactory
.
DramaCallback
{
override
fun
onError
(
code
:
Int
,
msg
:
String
?)
{
Log
.
d
(
"AboutusActivity"
,
"request failed, code = $code, msg = $msg"
)
Toast
.
makeText
(
this
@AboutusActivity
,
"请求失败"
,
Toast
.
LENGTH_SHORT
)
.
show
()
}
override
fun
onSuccess
(
dataList
:
MutableList
<
out
DPDrama
>?,
info
:
MutableMap
<
String
,
Any
>?
)
{
Toast
.
makeText
(
this
@AboutusActivity
,
"请求成功"
,
Toast
.
LENGTH_SHORT
)
.
show
()
val
json
=
JsonUtil
.
toJson
(
dataList
)
Log
.
d
(
"AboutusActivity"
,
"request success, drama = "
+
json
)
Log
.
d
(
"AboutusActivity"
,
"request success, dataList size = "
+
dataList
!!
.
size
)
TrackManager
.
getInstance
().
commitCsjShotInfo
(
json
)
}
})
}
else
{
Toast
.
makeText
(
this
@AboutusActivity
,
"sdk还未初始化"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
return
@setOnLongClickListener
true
...
...
video/app/src/main/java/com/duben/skitworld/ui/activitys/MainActivity.kt
View file @
7c1bd235
...
...
@@ -23,7 +23,6 @@ import com.duben.skitworld.ui.fragment.RecommendFragment
import
com.duben.skitworld.ui.fragment.VipEnjoyFragment
import
com.duben.skitworld.ui.widgets.DialogListener
import
com.duben.skitworld.ui.widgets.PhoneDialog
import
com.duben.skitworld.video.csj.DPHolderManager
import
kotlinx.android.synthetic.main.activity_main.*
/**
...
...
@@ -56,7 +55,6 @@ class MainActivity : BaseActivity(), View.OnClickListener {
}
override
fun
initViewsAndEvents
()
{
DPHolderManager
.
initDpSdk
(
MintsApplication
.
getContext
());
audioManager
=
getSystemService
(
Context
.
AUDIO_SERVICE
)
as
AudioManager
...
...
video/app/src/main/java/com/duben/skitworld/ui/fragment/RecommendFragment.kt
View file @
7c1bd235
...
...
@@ -14,7 +14,6 @@ import com.duben.skitworld.manager.UserManager
import
com.duben.skitworld.ui.activitys.MainActivity
import
com.duben.skitworld.ui.adapter.RecommendPageAdapter
import
com.duben.skitworld.ui.fragment.base.BaseFragment
import
com.duben.skitworld.video.csj.DramaTabFragment
import
com.duben.skitworld.video.tx.TxVideoFragment
import
com.duben.library.utils.nodoubleclick.AntiShake
import
kotlinx.android.synthetic.main.fragment_recommend.*
...
...
@@ -49,13 +48,16 @@ class RecommendFragment : BaseFragment(), View.OnClickListener {
tabsData
.
add
(
"推荐"
)
fragments
.
clear
()
if
(
mCurrentNewFlag
)
{
fragments
.
add
(
FollowVideoFragment
.
newInstance
())
fragments
.
add
(
TxVideoFragment
.
newInstance
())
}
else
{
fragments
.
add
(
FollowVideoFragment
.
newInstance
())
fragments
.
add
(
DramaTabFragment
())
}
fragments
.
add
(
FollowVideoFragment
.
newInstance
())
fragments
.
add
(
TxVideoFragment
.
newInstance
())
// if (mCurrentNewFlag) {
// fragments.add(FollowVideoFragment.newInstance())
// fragments.add(TxVideoFragment.newInstance())
// } else {
// fragments.add(FollowVideoFragment.newInstance())
// fragments.add(DramaTabFragment())
// }
vpAdapter
=
RecommendPageAdapter
(
fragments
,
this
)
vp2_recommend
.
adapter
=
vpAdapter
...
...
video/app/src/main/java/com/duben/skitworld/video/csj/DPHolderManager.kt
deleted
100644 → 0
View file @
1f094cd7
package
com.duben.skitworld.video.csj
import
android.content.Context
import
android.util.Log
import
com.bytedance.sdk.dp.DPSdk
import
com.bytedance.sdk.dp.DPSdkConfig
/**
* 穿山甲短剧SDK
*/
object
DPHolderManager
{
const
val
TAG
=
"DPHolderManager"
var
isDPStarted
=
false
fun
initDpSdk
(
context
:
Context
)
{
//1. 初始化,最好放到application.onCreate()执行
val
configBuilder
=
DPSdkConfig
.
Builder
().
debug
(
true
)
DPSdk
.
init
(
context
,
"SDK_Setting_5538933.json"
,
configBuilder
.
build
())
startDpSdk
()
}
fun
startDpSdk
()
{
DPSdk
.
start
{
isSuccess
,
message
->
//请确保使用Sdk时Sdk已经成功启动
//isSuccess=true表示启动成功
//启动失败,可以再次调用启动接口(建议最多不要超过3次)
isDPStarted
=
isSuccess
Log
.
e
(
TAG
,
"start result=$isSuccess, msg=$message"
)
}
}
}
\ No newline at end of file
video/app/src/main/java/com/duben/skitworld/video/csj/DramaApiDetailActivity.kt
deleted
100644 → 0
View file @
1f094cd7
package
com.duben.skitworld.video.csj
import
android.app.Dialog
import
android.os.Bundle
import
android.os.Handler
import
android.os.Looper
import
android.util.Log
import
android.view.View
import
android.widget.Button
import
android.widget.FrameLayout
import
android.widget.ImageView
import
android.widget.LinearLayout
import
com.airbnb.lottie.LottieAnimationView
import
com.airbnb.lottie.LottieComposition
import
com.airbnb.lottie.LottieCompositionFactory
import
com.airbnb.lottie.LottieDrawable
import
com.bytedance.sdk.dp.*
import
com.google.gson.Gson
import
com.duben.skitworld.R
import
com.duben.skitworld.ad.AdManager
import
com.duben.skitworld.ad.AdStatusListener
import
com.duben.skitworld.ad.NoPreAdManager
import
com.duben.skitworld.ad.express.ExpressAdCallback
import
com.duben.skitworld.ad.express.ExpressManager
import
com.duben.skitworld.common.Constant
import
com.duben.skitworld.manager.LocalVedioManager
import
com.duben.skitworld.manager.UserManager
import
com.duben.skitworld.mvp.model.IndexList
import
com.duben.skitworld.mvp.model.NineShowBean
import
com.duben.skitworld.mvp.model.VedioBean
import
com.duben.skitworld.mvp.presenters.VideoPresenter
import
com.duben.skitworld.mvp.views.VideoView
import
com.duben.skitworld.ui.activitys.NineActivity
import
com.duben.skitworld.ui.activitys.VipActivity
import
com.duben.skitworld.ui.activitys.base.BaseActivity
import
com.duben.skitworld.ui.adapter.VideoEpisodeAdapter
import
com.duben.skitworld.ui.widgets.DialogListener
import
com.duben.skitworld.ui.widgets.VideoEpisodeDialog
import
com.duben.skitworld.ui.widgets.VipCountDialog
import
com.duben.skitworld.utils.AppPreferencesManager
import
com.duben.skitworld.utils.SpanUtils
import
com.duben.skitworld.utils.UIUtils
import
com.duben.library.utils.GlideUtils
import
com.duben.library.utils.nodoubleclick.AntiShake
import
com.duben.skitworld.common.AppConfig
import
com.duben.skitworld.mvp.model.VipBean
import
com.duben.skitworld.ui.widgets.DetailAdDialog
import
kotlinx.android.synthetic.main.drama_activity_api_detail.*
import
kotlinx.android.synthetic.main.drama_activity_api_detail.iv_lucky_gif
import
kotlinx.android.synthetic.main.drama_activity_api_detail.ll_lucky
import
kotlinx.android.synthetic.main.drama_activity_api_detail.tv_lucky_status
/**
* @author Assen
* @date 2023/7/6
* @desc
*/
class
DramaApiDetailActivity
:
BaseActivity
(),
VideoEpisodeAdapter
.
OnEpisodeClickListener
,
VideoView
,
View
.
OnClickListener
{
companion
object
{
private
const
val
TAG
=
"DramaApiDetailActivity"
var
outerDrama
:
DPDrama
?
=
null
}
private
val
videoPresenter
by
lazy
{
VideoPresenter
()
}
private
var
mVipFlag
=
UserManager
.
getInstance
().
vipFlag
private
var
dpWidget
:
IDPWidget
?
=
null
private
var
isInited
=
false
private
var
drama
:
DPDrama
?
=
null
private
var
tipList
:
ArrayList
<
String
>?
=
null
private
var
orderTagsList
:
ArrayList
<
String
>?
=
null
private
var
isLuckyShow
=
false
private
var
unlockCallback
:
IDPDramaListener
.
Callback
?
=
null
private
var
mInitUnlockIndex
=
0
//可免费观看的最大集数
private
var
mUnlockIndexMap
=
mutableMapOf
<
Long
,
Int
>()
// 已经解锁的集数
private
var
mHasUnlockIndexMap
=
mutableMapOf
<
Long
,
MutableList
<
Int
>>()
private
var
blockView
:
View
?
=
null
private
var
unlockBtn
:
Button
?
=
null
private
var
leaveBtn
:
ImageView
?
=
null
private
var
vipBtn
:
Button
?
=
null
private
var
lastIndex
=
1
private
var
enableInfiniteScroll
=
true
private
var
enableCustomReport
=
false
private
var
hideLeftTopTips
=
false
private
var
hideMore
=
true
private
var
freeSet
=
5
private
var
lockSet
=
2
private
var
isThirdId
=
false
private
var
isPlayNext
=
false
private
var
mode
=
DPDramaDetailConfig
.
SPECIFIC_DETAIL
private
var
mVedioBean
:
VedioBean
?
=
null
private
var
mCurrentIndex
=
0
private
var
currentDramaIndex
=
0
private
var
detailAdDialog
:
DetailAdDialog
?
=
null
override
fun
getBundleExtras
(
extras
:
Bundle
?)
{
val
json
=
extras
?.
getString
(
Constant
.
VEDIO_BEAN
)
isThirdId
=
extras
?.
getBoolean
(
Constant
.
VEDIO_THIRD
,
false
)
==
true
isPlayNext
=
extras
?.
getBoolean
(
Constant
.
VEDIO_NEXT
,
false
)
==
true
mVedioBean
=
Gson
().
fromJson
(
json
,
VedioBean
::
class
.
java
)
orderTagsList
=
mVedioBean
?.
orderTags
freeSet
=
mVedioBean
!!
.
unlockIndex
lockSet
=
if
(
mVedioBean
!!
.
adGiveVedioNum
==
0
)
1
else
mVedioBean
!!
.
adGiveVedioNum
hideLeftTopTips
=
true
mode
=
DPDramaDetailConfig
.
SPECIFIC_DETAIL
enableInfiniteScroll
=
false
enableCustomReport
=
false
super
.
getBundleExtras
(
extras
)
}
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
drama_activity_api_detail
override
fun
initViewsAndEvents
()
{
videoPresenter
.
attachView
(
this
)
mVedioBean
?.
let
{
videoPresenter
.
getIndexList
(
it
.
thirdId
,
true
)
}
videoPresenter
.
getVipProducts
()
if
(!
UserManager
.
getInstance
().
vipFlag
)
{
ExpressManager
.
instance
.
preLoadAd
()
}
fm_bottom
.
setOnClickListener
{
if
(
AntiShake
.
check
(
it
.
id
))
return
@setOnClickListener
showEpisodeDialog
()
}
blockView
=
findViewById
<
LinearLayout
>(
R
.
id
.
block_view
)
blockView
?.
isClickable
=
true
unlockBtn
=
findViewById
(
R
.
id
.
unlock
)
leaveBtn
=
findViewById
(
R
.
id
.
leave
)
vipBtn
=
findViewById
(
R
.
id
.
vip
)
if
(
UserManager
.
getInstance
().
newFlag
)
{
// 匹配
vipBtn
!!
.
visibility
=
View
.
VISIBLE
}
else
{
// 未匹配
vipBtn
!!
.
visibility
=
View
.
GONE
}
blockView
?.
visibility
=
View
.
GONE
drama
=
outerDrama
drama
?.
let
{
if
(
isPlayNext
)
mVedioBean
!!
.
seeIndex
+
1
it
.
index
=
mVedioBean
!!
.
seeIndex
mCurrentIndex
=
mVedioBean
!!
.
seeIndex
mInitUnlockIndex
=
mVedioBean
!!
.
unlockIndex
mUnlockIndexMap
[
it
.
id
]
=
mInitUnlockIndex
mHasUnlockIndexMap
[
it
.
id
]
=
arrayListOf
(
mInitUnlockIndex
)
title_tv
.
text
=
it
.
title
if
(
mVedioBean
!!
.
completeStatus
==
0
)
{
episode_tv
.
text
=
String
.
format
(
"共%d集 已完结"
,
it
.
total
)
}
else
{
episode_tv
.
text
=
String
.
format
(
"共%d集 更新中"
,
it
.
total
)
}
info_tv
.
text
=
String
.
format
(
"第%d集"
,
mVedioBean
!!
.
seeIndex
)
if
(!
UserManager
.
getInstance
().
newFlag
)
{
unlock
.
text
=
String
.
format
(
"观看激励视频"
)
unlock
.
visibility
=
View
.
VISIBLE
}
else
{
unlock
.
visibility
=
View
.
GONE
}
tv_title
.
text
=
if
(
AppConfig
.
firstVipPrice
==
0.0
)
"解锁后续剧集"
else
"${AppConfig.firstVipPrice}元解锁后续剧集"
if
(
mVedioBean
!!
.
collect
==
0
)
{
setCollectImage
(
zan_iv
)
}
else
{
setCancelCollectImage
(
zan_iv
)
}
zan_num_tv
.
text
=
mVedioBean
!!
.
hot
}
ll_collect
.
setOnClickListener
(
this
)
ll_lucky
.
setOnClickListener
(
this
)
if
(
DPSdk
.
isStartSuccess
())
{
init
()
}
}
override
fun
isApplyKitKatTranslucency
()
=
true
private
fun
init
()
{
if
(
isInited
)
{
return
}
initWidget
()
dpWidget
?.
let
{
widget
->
supportFragmentManager
.
beginTransaction
().
replace
(
R
.
id
.
fl_container
,
widget
.
fragment
)
.
commit
()
leaveBtn
?.
setOnClickListener
{
finish
()
}
vipBtn
?.
setOnClickListener
{
val
bundle
=
Bundle
()
bundle
.
putString
(
VipActivity
.
VEDIO_ID
,
mVedioBean
!!
.
vedioId
.
toString
())
bundle
.
putString
(
VipActivity
.
THIRD_ID
,
mVedioBean
!!
.
thirdId
)
bundle
.
putBoolean
(
VipActivity
.
IS_DETAIL
,
true
)
readyGo
(
VipActivity
::
class
.
java
,
bundle
)
}
}
isInited
=
true
}
private
fun
initWidget
()
{
drama
?.
let
{
drama
->
dpWidget
=
DPSdk
.
factory
().
createDramaDetail
(
DPWidgetDramaDetailParams
.
obtain
()
.
detailConfig
(
DPDramaDetailConfig
.
obtain
(
mode
)
.
bottomOffset
(
20
)
.
infiniteScrollEnabled
(
enableInfiniteScroll
)
.
hideLeftTopTips
(
hideLeftTopTips
,
null
)
.
showCellularToast
(
true
)
.
hideMore
(
hideMore
)
.
listener
(
dramaListener
)
.
adListener
(
dramaAdListener
)
.
setCustomReport
(
enableCustomReport
)
{
context
,
id
->
// 举报
}
)
.
id
(
drama
.
id
)
.
index
(
drama
.
index
)
// .currentDuration(currentDuration)
)
}
}
override
fun
onDestroy
()
{
dpWidget
?.
destroy
()
ExpressManager
.
instance
.
destroy
()
super
.
onDestroy
()
}
override
fun
onResume
()
{
super
.
onResume
()
// videoPresenter.showTurn()
if
(
mVipFlag
!=
UserManager
.
getInstance
().
vipFlag
&&
UserManager
.
getInstance
().
vipFlag
)
{
// 重置状态
resetData
()
}
// vip界面返回弹出广告弹窗
if
(
AppConfig
.
showVipAdDialog
&&
!
UserManager
.
getInstance
().
vipFlag
)
{
Handler
(
Looper
.
getMainLooper
()).
postDelayed
({
adDialog
()
AppConfig
.
showVipAdDialog
=
false
},
300
)
}
}
override
fun
onPause
()
{
super
.
onPause
()
}
private
val
dramaAdListener
:
IDPAdListener
=
object
:
IDPAdListener
()
{
override
fun
onDPAdRequest
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdRequest map = $map"
)
}
override
fun
onDPAdRequestSuccess
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdRequestSuccess map = $map"
)
}
override
fun
onDPAdRequestFail
(
code
:
Int
,
msg
:
String
?,
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdRequestFail map = $map"
)
}
override
fun
onDPAdFillFail
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdFillFail map = $map"
)
}
override
fun
onDPAdShow
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdShow map = $map"
)
}
override
fun
onDPAdPlayStart
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdPlayStart: map = $map"
)
}
override
fun
onDPAdPlayPause
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdPlayPause map = $map"
)
}
override
fun
onDPAdPlayContinue
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdPlayContinue map = $map"
)
}
override
fun
onDPAdPlayComplete
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdPlayComplete map = $map"
)
}
override
fun
onDPAdClicked
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdClicked map = $map"
)
}
}
private
var
dramaListener
:
IDPDramaListener
=
object
:
IDPDramaListener
()
{
override
fun
onDPSeekTo
(
position
:
Int
,
time
:
Long
)
{
super
.
onDPSeekTo
(
position
,
time
)
Log
.
d
(
TAG
,
"onDPSeekTo:"
)
}
override
fun
onDPPageChange
(
position
:
Int
,
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPPageChange
(
position
,
map
)
Log
.
d
(
TAG
,
"onDPPageChange:"
+
map
?.
toString
())
}
override
fun
onDPVideoPlay
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPVideoPlay
(
map
)
Log
.
d
(
TAG
,
"onDPVideoPlay:"
+
map
?.
toString
())
(
map
?.
get
(
"index"
)
as
?
Int
?)
?.
let
{
lastIndex
=
it
}
}
override
fun
onDPVideoPause
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPVideoPause
(
map
)
Log
.
d
(
TAG
,
"onDPVideoPause:"
+
map
?.
toString
())
}
override
fun
onDPVideoContinue
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPVideoContinue
(
map
)
Log
.
d
(
TAG
,
"onDPVideoContinue:"
+
map
?.
toString
())
}
override
fun
onDPVideoCompletion
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPVideoCompletion
(
map
)
Log
.
d
(
TAG
,
"onDPVideoCompletion:"
+
map
?.
toString
())
}
override
fun
onDPVideoOver
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPVideoOver
(
map
)
Log
.
d
(
TAG
,
"onDPVideoOver:"
+
map
?.
toString
())
}
override
fun
onDPClose
()
{
super
.
onDPClose
()
Log
.
d
(
TAG
,
"onDPClose"
)
}
override
fun
onDPRequestStart
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPRequestStart
(
map
)
Log
.
d
(
TAG
,
"onDPRequestStart:"
+
map
?.
toString
())
}
override
fun
onDPRequestFail
(
code
:
Int
,
msg
:
String
?,
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPRequestFail
(
code
,
msg
,
map
)
Log
.
d
(
TAG
,
"onDPRequestFail:"
+
map
?.
toString
())
}
override
fun
onDPRequestSuccess
(
list
:
MutableList
<
MutableMap
<
String
,
Any
>>?)
{
super
.
onDPRequestSuccess
(
list
)
list
?.
forEach
{
Log
.
d
(
TAG
,
"onDPRequestSuccess:$it"
)
}
}
override
fun
isNeedBlock
(
drama
:
DPDrama
?,
index
:
Int
,
map
:
MutableMap
<
String
,
Any
>?
):
Boolean
{
drama
?:
return
false
Log
.
d
(
TAG
,
"isNeedBlock: index = $index"
)
val
unlockIndex
=
mUnlockIndexMap
[
drama
.
id
]
?:
mInitUnlockIndex
val
hasUnlockList
=
mHasUnlockIndexMap
[
drama
.
id
]
?:
mutableListOf
()
Log
.
d
(
TAG
,
"isNeedBlock: index = $index"
+
" "
+
unlockIndex
+
"s"
+
drama
.
id
+
mHasUnlockIndexMap
+
" --- "
+
(
index
>
unlockIndex
&&
hasUnlockList
.
contains
(
index
).
not
())
)
info_tv
.
text
=
String
.
format
(
"第%d集"
,
index
)
mCurrentIndex
=
index
showVipCountDialog
(
index
-
1
)
localShowLucky
(
index
-
1
)
val
needBlock
=
index
>
unlockIndex
&&
hasUnlockList
.
contains
(
index
).
not
()
if
(!
needBlock
)
{
blockView
?.
visibility
=
View
.
GONE
// 上送视频信息,若未解锁不上送
if
(
mCurrentIndex
<=
mVedioBean
!!
.
unlockIndex
)
{
mVedioBean
!!
.
seeIndex
=
index
mVedioBean
!!
.
orderTags
=
orderTagsList
LocalVedioManager
.
commitVedio
(
mVedioBean
!!
)
}
}
return
needBlock
}
override
fun
showAdIfNeeded
(
drama
:
DPDrama
?,
callback
:
Callback
?,
map
:
MutableMap
<
String
,
Any
>?
)
{
super
.
showAdIfNeeded
(
drama
,
callback
,
map
)
drama
?:
return
Log
.
d
(
TAG
,
"showAdIfNeeded:"
+
map
?.
toString
())
blockView
?.
visibility
=
View
.
VISIBLE
unlockCallback
=
callback
currentDramaIndex
=
dpWidget
?.
currentDramaIndex
!!
// 展示广告
val
unlockText
=
String
.
format
(
"解锁%s·第%d-%d集"
,
drama
.
title
,
mInitUnlockIndex
+
1
,
mInitUnlockIndex
+
lockSet
)
AppConfig
.
detailDialogUnlockText
=
unlockText
if
(!
UserManager
.
getInstance
().
newFlag
)
{
tv_title
.
text
=
unlockText
}
else
{
tv_title
.
text
=
if
(
AppConfig
.
firstVipPrice
==
0.0
)
"解锁后续剧集"
else
"${AppConfig.firstVipPrice}元解锁后续剧集"
}
showAdView
()
dpWidget
?.
let
{
widget
->
unlockBtn
?.
setOnClickListener
{
val
carrierType
=
Constant
.
CARRIERTYPE_CSJ_VEDIO
AdManager
.
instance
.
showAd
(
this
@DramaApiDetailActivity
,
carrierType
,
object
:
AdStatusListener
{
var
canFail
=
false
override
fun
adSuccess
()
{
canFail
=
true
}
override
fun
adFail
()
{
if
(
canFail
)
return
NoPreAdManager
.
loadVideoAd
(
this
@DramaApiDetailActivity
,
carrierType
,
object
:
AdStatusListener
{
override
fun
adFail
()
{
showToast
(
"广告太火爆了,请稍候再试"
)
}
override
fun
adSuccess
()
{
}
override
fun
adClose
(
vo
:
HashMap
<
String
,
Any
>?)
{
vo
?.
let
{
if
(
isThirdId
)
{
it
[
"thirdId"
]
=
""
+
mVedioBean
!!
.
thirdId
}
else
{
it
[
"vedioId"
]
=
""
+
mVedioBean
!!
.
vedioId
}
videoPresenter
.
unlock
(
it
)
}
// 更新解锁集数
for
(
i
in
1
until
lockSet
)
{
val
hasUnlockList
:
MutableList
<
Int
>
=
mHasUnlockIndexMap
[
drama
.
id
]
?:
mutableListOf
()
hasUnlockList
.
add
(
widget
.
currentDramaIndex
+
i
)
mHasUnlockIndexMap
[
drama
.
id
]
=
hasUnlockList
}
mInitUnlockIndex
=
mUnlockIndexMap
[
drama
.
id
]
!!
+
lockSet
mUnlockIndexMap
[
drama
.
id
]
=
mUnlockIndexMap
[
drama
.
id
]
!!
+
lockSet
mVedioBean
!!
.
unlockIndex
=
mInitUnlockIndex
// 播放当前集
mVedioBean
!!
.
seeIndex
=
mCurrentIndex
mVedioBean
!!
.
orderTags
=
orderTagsList
LocalVedioManager
.
commitVedio
(
mVedioBean
!!
)
blockView
?.
visibility
=
View
.
GONE
callback
?.
onDramaRewardArrived
()
// 解锁当前集
}
})
}
override
fun
adClose
(
vo
:
HashMap
<
String
,
Any
>?)
{
vo
?.
let
{
if
(
isThirdId
)
{
it
[
"thirdId"
]
=
""
+
mVedioBean
!!
.
thirdId
}
else
{
it
[
"vedioId"
]
=
""
+
mVedioBean
!!
.
vedioId
}
videoPresenter
.
unlock
(
it
)
}
// 更新解锁集数
for
(
i
in
1
until
lockSet
)
{
val
hasUnlockList
:
MutableList
<
Int
>
=
mHasUnlockIndexMap
[
drama
.
id
]
?:
mutableListOf
()
hasUnlockList
.
add
(
widget
.
currentDramaIndex
+
i
)
mHasUnlockIndexMap
[
drama
.
id
]
=
hasUnlockList
}
mInitUnlockIndex
=
mUnlockIndexMap
[
drama
.
id
]
!!
+
lockSet
mUnlockIndexMap
[
drama
.
id
]
=
mUnlockIndexMap
[
drama
.
id
]
!!
+
lockSet
mVedioBean
!!
.
unlockIndex
=
mInitUnlockIndex
blockView
?.
visibility
=
View
.
GONE
// 播放当前集
mVedioBean
!!
.
seeIndex
=
mCurrentIndex
mVedioBean
!!
.
orderTags
=
orderTagsList
LocalVedioManager
.
commitVedio
(
mVedioBean
!!
)
callback
?.
onDramaRewardArrived
()
// 解锁当前集
}
})
}
}
}
override
fun
onDramaSwitch
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDramaSwitch
(
map
)
Log
.
d
(
TAG
,
"onDramaSwitch:"
+
map
?.
toString
())
val
title
=
map
?.
get
(
"title"
)
as
?
String
?
val
total
=
map
?.
get
(
"total"
)
as
?
Int
?
episode_tv
.
text
=
String
.
format
(
"共%d集 已完结"
,
total
)
}
override
fun
onDramaGalleryClick
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDramaGalleryClick
(
map
)
map
?.
let
{
Log
.
d
(
TAG
,
"onDramaGalleryClick: $it"
)
}
}
override
fun
onDramaGalleryShow
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDramaGalleryShow
(
map
)
map
?.
let
{
Log
.
d
(
TAG
,
"onDramaGalleryShow: $it"
)
}
}
override
fun
onRewardDialogShow
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onRewardDialogShow
(
map
)
map
?.
let
{
Log
.
d
(
TAG
,
"onRewardDialogShow: $it"
)
}
}
override
fun
onUnlockDialogAction
(
action
:
String
?,
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onUnlockDialogAction
(
action
,
map
)
map
?.
let
{
Log
.
d
(
TAG
,
"onUnlockDialogAction: action=$action map=$it"
)
}
}
}
private
var
dialog
:
VideoEpisodeDialog
?
=
null
private
fun
showEpisodeDialog
()
{
if
(
mVedioBean
==
null
&&
dialog
!=
null
&&
dialog
!!
.
isShowing
)
return
dialog
=
VideoEpisodeDialog
(
this
,
mVedioBean
,
object
:
DialogListener
()
{
override
fun
onClick
(
dialog
:
Dialog
?,
v
:
View
?)
{
super
.
onClick
(
dialog
,
v
)
dialog
?.
dismiss
()
}
})
dialog
?.
setOnEpisodeClickListener
(
this
)
val
index
=
if
(
mCurrentIndex
==
0
)
0
else
mCurrentIndex
-
1
dialog
?.
setCurrentIndex
(
index
)
dialog
?.
show
()
}
override
fun
onEpisodeClick
(
position
:
Int
)
{
dialog
?.
dismiss
()
if
(
position
+
1
>
mInitUnlockIndex
)
{
dpWidget
?.
let
{
widget
->
widget
.
currentDramaIndex
=
mInitUnlockIndex
+
1
}
return
}
dpWidget
?.
let
{
widget
->
widget
.
currentDramaIndex
=
position
+
1
}
}
override
fun
getIndexListSuc
(
indexList
:
IndexList
)
{
tipList
=
indexList
.
tip
}
override
fun
getIndexListFail
()
{
}
override
fun
collectSuc
()
{
mVedioBean
!!
.
collect
=
1
playCollectAnim
(
zan_iv
)
}
override
fun
collectFail
()
{
}
override
fun
cancelCollectSuc
()
{
mVedioBean
!!
.
collect
=
0
playCancelCollectAnim
(
zan_iv
)
}
override
fun
cancelCollectFail
()
{
}
override
fun
unlockSuc
(
indexList
:
IndexList
)
{
}
override
fun
unlockFail
()
{
}
override
fun
showTurnSuc
(
data
:
NineShowBean
)
{
AppPreferencesManager
.
get
()
.
put
(
Constant
.
LUCKY_FLAG
,
data
.
isShow
)
isLuckyShow
=
data
.
isShow
if
(
isLuckyShow
)
{
val
complete
=
data
.
complete
val
need
=
data
.
need
if
(
complete
>=
need
)
{
tv_lucky_status
.
text
=
SpanUtils
()
.
append
(
"可领取"
)
.
setForegroundColor
(
resources
.
getColor
(
R
.
color
.
apk_uninstalled
))
.
create
()
}
else
{
tv_lucky_status
.
text
=
SpanUtils
()
.
append
(
complete
.
toString
())
.
setForegroundColor
(
resources
.
getColor
(
R
.
color
.
red
))
.
append
(
"/"
)
.
append
(
need
.
toString
())
.
create
()
}
// 匹配
// ll_lucky.visibility = View.VISIBLE
}
else
{
// 未匹配
// ll_lucky.visibility = View.GONE
}
localShowLucky
(
mCurrentIndex
-
1
)
}
override
fun
getVipProductSuc
(
data
:
VipBean
)
{
if
(
data
.
list
!=
null
&&
data
.
list
.
size
>
0
)
{
AppConfig
.
firstVipPrice
=
data
.
list
.
get
(
0
).
price
}
}
private
fun
playCollectAnim
(
view
:
LottieAnimationView
)
{
val
lottieDrawable
=
LottieDrawable
()
LottieCompositionFactory
.
fromAsset
(
context
,
"home_collect.json"
)
.
addListener
{
result
:
LottieComposition
?
->
lottieDrawable
.
setImagesAssetsFolder
(
"images/"
)
lottieDrawable
.
composition
=
result
lottieDrawable
.
loop
(
false
)
lottieDrawable
.
playAnimation
()
}
view
.
setImageDrawable
(
lottieDrawable
)
}
private
fun
playCancelCollectAnim
(
view
:
LottieAnimationView
)
{
val
lottieDrawable
=
LottieDrawable
()
LottieCompositionFactory
.
fromAsset
(
context
,
"home_cancel_collect.json"
)
.
addListener
{
result
:
LottieComposition
?
->
lottieDrawable
.
setImagesAssetsFolder
(
"images/"
)
lottieDrawable
.
composition
=
result
lottieDrawable
.
loop
(
false
)
lottieDrawable
.
playAnimation
()
}
view
.
setImageDrawable
(
lottieDrawable
)
}
override
fun
onClick
(
v
:
View
?)
{
if
(
AntiShake
.
check
(
v
?.
id
))
return
when
(
v
?.
id
)
{
R
.
id
.
ll_collect
->
{
if
(
mVedioBean
!!
.
collect
==
0
)
{
if
(
isThirdId
)
{
videoPresenter
.
collect
(
""
+
mVedioBean
!!
.
thirdId
)
}
else
{
videoPresenter
.
collect
(
""
+
mVedioBean
!!
.
vedioId
)
}
}
else
{
if
(
isThirdId
)
{
videoPresenter
.
cancelCollect
(
""
+
mVedioBean
!!
.
thirdId
)
}
else
{
videoPresenter
.
cancelCollect
(
""
+
mVedioBean
!!
.
vedioId
)
}
}
}
R
.
id
.
ll_lucky
->
{
readyGo
(
NineActivity
::
class
.
java
)
}
else
->
{}
}
}
private
fun
showVipCountDialog
(
position
:
Int
)
{
if
(
position
==
0
||
mVedioBean
!!
.
tipMaxIndex
==
0
||
mVedioBean
!!
.
tipMaxIndex
-
1
<
position
)
return
VipCountDialog
(
this
,
mVedioBean
!!
,
tipList
)
.
setOnDialogDismiss
(
object
:
VipCountDialog
.
OnDialogDismiss
{
override
fun
onDialogDismiss
()
{}
})
.
show
()
}
private
fun
localShowLucky
(
position
:
Int
)
{
val
localLucky
=
AppPreferencesManager
.
get
()
.
getBoolean
(
Constant
.
LUCKY_FLAG
,
false
)
if
(
mVedioBean
!=
null
&&
(
isLuckyShow
||
localLucky
))
{
if
(
position
>
mVedioBean
!!
.
unlockIndex
-
1
)
{
// 解锁界面
ll_lucky
.
visibility
=
View
.
GONE
}
else
{
// 超过免费剧
if
(
position
>=
mVedioBean
!!
.
freeIndex
)
{
ll_lucky
.
visibility
=
View
.
VISIBLE
context
?.
let
{
GlideUtils
.
loadRoundImageViewGif
(
it
,
R
.
drawable
.
ic_nine
,
iv_lucky_gif
)
}
}
else
{
ll_lucky
.
visibility
=
View
.
GONE
}
}
}
}
private
fun
setCollectImage
(
view
:
LottieAnimationView
)
{
val
lottieDrawable
=
LottieDrawable
()
LottieCompositionFactory
.
fromAsset
(
context
,
"home_collect.json"
)
.
addListener
{
result
:
LottieComposition
?
->
lottieDrawable
.
setImagesAssetsFolder
(
"images/"
)
lottieDrawable
.
composition
=
result
}
view
.
setImageDrawable
(
lottieDrawable
)
}
private
fun
setCancelCollectImage
(
view
:
LottieAnimationView
)
{
val
lottieDrawable
=
LottieDrawable
()
LottieCompositionFactory
.
fromAsset
(
context
,
"home_cancel_collect.json"
)
.
addListener
{
result
:
LottieComposition
?
->
lottieDrawable
.
setImagesAssetsFolder
(
"images/"
)
lottieDrawable
.
composition
=
result
}
view
.
setImageDrawable
(
lottieDrawable
)
}
private
fun
resetData
()
{
if
(
UserManager
.
getInstance
().
vipFlag
)
{
mVedioBean
?.
let
{
//解锁全部集数
it
.
unlockIndex
=
it
.
vedioTotal
it
.
tipMaxIndex
=
0
mInitUnlockIndex
=
it
.
vedioTotal
//设置弹框集数为0
it
.
adGiveVedioNum
=
0
mUnlockIndexMap
=
mutableMapOf
()
mHasUnlockIndexMap
=
mutableMapOf
()
drama
?.
let
{
// 更新解锁集数
for
(
i
in
0
until
mInitUnlockIndex
)
{
val
hasUnlockList
:
MutableList
<
Int
>
=
mutableListOf
()
hasUnlockList
.
add
(
i
+
1
)
mHasUnlockIndexMap
[
it
.
id
]
=
hasUnlockList
}
mUnlockIndexMap
[
it
.
id
]
=
mInitUnlockIndex
mUnlockIndexMap
[
it
.
id
]
=
mUnlockIndexMap
[
it
.
id
]
!!
mVedioBean
!!
.
unlockIndex
=
mInitUnlockIndex
}
// 播放当前集
mVedioBean
!!
.
seeIndex
=
mCurrentIndex
mVedioBean
!!
.
orderTags
=
orderTagsList
LocalVedioManager
.
commitVedio
(
mVedioBean
!!
)
if
(
block_view
?.
visibility
==
View
.
VISIBLE
)
{
blockView
?.
visibility
=
View
.
GONE
//解锁当前集
dpWidget
?.
let
{
widget
->
unlockCallback
?.
onDramaRewardArrived
()
}
}
}
}
}
private
fun
showAdView
()
{
if
(
UserManager
.
getInstance
().
vipFlag
)
return
ExpressManager
.
instance
.
getAdView
(
object
:
ExpressAdCallback
{
override
fun
loadSuccess
(
adView
:
FrameLayout
?)
{
adView
?.
let
{
UIUtils
.
removeFromParent
(
it
)
fl_ad
.
removeAllViews
()
fl_ad
.
addView
(
it
)
}
}
override
fun
renderSuccess
(
adView
:
FrameLayout
?):
Boolean
{
adView
?.
let
{
UIUtils
.
removeFromParent
(
it
)
fl_ad
.
removeAllViews
()
fl_ad
.
addView
(
it
)
}
ExpressManager
.
instance
.
preLoadAd
()
return
false
}
override
fun
loadFail
()
{
}
})
}
private
fun
adDialog
()
{
detailAdDialog
=
DetailAdDialog
(
context
,
object
:
DialogListener
()
{
override
fun
onClick
(
v
:
View
)
{
// if (AntiShake.check(v.id)) return
when
(
v
.
id
)
{
R
.
id
.
iv_detail_ad_next
->
{
val
carrierType
=
Constant
.
CARRIERTYPE_CSJ_VEDIO
AdManager
.
instance
.
showAd
(
this
@DramaApiDetailActivity
,
carrierType
,
object
:
AdStatusListener
{
var
canFail
=
false
override
fun
adSuccess
()
{
canFail
=
true
}
override
fun
adFail
()
{
if
(
canFail
)
return
NoPreAdManager
.
loadVideoAd
(
this
@DramaApiDetailActivity
,
carrierType
,
object
:
AdStatusListener
{
override
fun
adFail
()
{
showToast
(
"广告太火爆了,请稍候再试"
)
}
override
fun
adSuccess
()
{
}
override
fun
adClose
(
vo
:
HashMap
<
String
,
Any
>?)
{
vo
?.
let
{
if
(
isThirdId
)
{
it
[
"thirdId"
]
=
""
+
mVedioBean
!!
.
thirdId
}
else
{
it
[
"vedioId"
]
=
""
+
mVedioBean
!!
.
vedioId
}
videoPresenter
.
unlock
(
it
)
}
// 更新解锁集数
for
(
i
in
1
until
lockSet
)
{
val
hasUnlockList
:
MutableList
<
Int
>
=
mHasUnlockIndexMap
[
drama
?.
id
]
?:
mutableListOf
()
hasUnlockList
.
add
(
currentDramaIndex
+
i
)
mHasUnlockIndexMap
[
drama
!!
.
id
]
=
hasUnlockList
}
mInitUnlockIndex
=
mUnlockIndexMap
[
drama
?.
id
]
!!
+
lockSet
mUnlockIndexMap
[
drama
!!
.
id
]
=
mUnlockIndexMap
[
drama
!!
.
id
]
!!
+
lockSet
mVedioBean
!!
.
unlockIndex
=
mInitUnlockIndex
// 播放当前集
mVedioBean
!!
.
seeIndex
=
mCurrentIndex
mVedioBean
!!
.
orderTags
=
orderTagsList
LocalVedioManager
.
commitVedio
(
mVedioBean
!!
)
blockView
?.
visibility
=
View
.
GONE
unlockCallback
?.
onDramaRewardArrived
()
// 解锁当前集
}
})
}
override
fun
adClose
(
vo
:
HashMap
<
String
,
Any
>?)
{
vo
?.
let
{
if
(
isThirdId
)
{
it
[
"thirdId"
]
=
""
+
mVedioBean
!!
.
thirdId
}
else
{
it
[
"vedioId"
]
=
""
+
mVedioBean
!!
.
vedioId
}
videoPresenter
.
unlock
(
it
)
}
// 更新解锁集数
for
(
i
in
1
until
lockSet
)
{
val
hasUnlockList
:
MutableList
<
Int
>
=
mHasUnlockIndexMap
[
drama
!!
.
id
]
?:
mutableListOf
()
hasUnlockList
.
add
(
currentDramaIndex
+
i
)
mHasUnlockIndexMap
[
drama
!!
.
id
]
=
hasUnlockList
}
mInitUnlockIndex
=
mUnlockIndexMap
[
drama
!!
.
id
]
!!
+
lockSet
mUnlockIndexMap
[
drama
!!
.
id
]
=
mUnlockIndexMap
[
drama
!!
.
id
]
!!
+
lockSet
mVedioBean
!!
.
unlockIndex
=
mInitUnlockIndex
blockView
?.
visibility
=
View
.
GONE
// 播放当前集
mVedioBean
!!
.
seeIndex
=
mCurrentIndex
mVedioBean
!!
.
orderTags
=
orderTagsList
LocalVedioManager
.
commitVedio
(
mVedioBean
!!
)
unlockCallback
?.
onDramaRewardArrived
()
// 解锁当前集
}
})
detailAdDialog
?.
dismiss
()
}
}
}
})
detailAdDialog
!!
.
show
()
}
}
\ No newline at end of file
video/app/src/main/java/com/duben/skitworld/video/csj/DramaTabFragment.kt
deleted
100644 → 0
View file @
1f094cd7
package
com.duben.skitworld.video.csj
import
android.util.Log
import
com.bytedance.sdk.dp.DPDramaDetailConfig
import
com.bytedance.sdk.dp.DPSdk
import
com.bytedance.sdk.dp.DPWidgetDrawParams
import
com.bytedance.sdk.dp.IDPAdListener
import
com.bytedance.sdk.dp.IDPDramaListener
import
com.bytedance.sdk.dp.IDPDrawListener
import
com.bytedance.sdk.dp.IDPWidget
import
com.duben.skitworld.R
import
com.duben.skitworld.common.AppConfig
import
com.duben.skitworld.common.Constant
import
com.duben.skitworld.manager.LocalVedioManager
import
com.duben.skitworld.mvp.model.IndexList
import
com.duben.skitworld.mvp.model.NineShowBean
import
com.duben.skitworld.mvp.model.VipBean
import
com.duben.skitworld.mvp.presenters.VideoPresenter
import
com.duben.skitworld.mvp.views.VideoView
import
com.duben.skitworld.ui.fragment.base.BaseFragment
/**
* Created by limingqi on 2023/1/17
*/
class
DramaTabFragment
:
BaseFragment
(),
VideoView
{
private
val
videoPresenter
by
lazy
{
VideoPresenter
()
}
companion
object
{
private
const
val
TAG
=
"DramaTabFragment"
}
private
var
dpWidget
:
IDPWidget
?
=
null
private
var
isInited
=
false
override
fun
initViewsAndEvents
()
{
if
(
DPSdk
.
isStartSuccess
())
{
init
()
}
}
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
drama_home_frag_wrapper
private
fun
init
()
{
videoPresenter
.
attachView
(
this
)
if
(
isInited
)
{
return
}
initDrawWidget
()
isInited
=
true
}
private
fun
initDrawWidget
()
{
if
(!
DPHolderManager
.
isDPStarted
)
{
this
.
view
?.
postDelayed
({
initDrawWidget
()
},
100
)
return
}
val
dramaDetailConfig
=
DPDramaDetailConfig
.
obtain
(
DPDramaDetailConfig
.
SPECIFIC_DETAIL
)
.
setEnterDelegate
{
context
,
drama
,
current
->
DramaApiDetailActivity
.
outerDrama
=
drama
videoPresenter
.
getIndexList
(
""
+
drama
.
id
,
true
)
}
.
hideMore
(
false
)
.
hideLeftTopTips
(
false
,
null
)
.
listener
(
dramaListener
)
// 短剧详情页视频播放回调
.
adListener
(
dramaAdListener
)
// 短剧详情页激励视频回调
dpWidget
=
DPSdk
.
factory
().
createDraw
(
DPWidgetDrawParams
.
obtain
()
.
adOffset
(
0
)
//单位 dp,为 0 时可以不设置
.
drawContentType
(
DPWidgetDrawParams
.
DRAW_CONTENT_TYPE_ONLY_DRAMA
)
.
drawChannelType
(
DPWidgetDrawParams
.
DRAW_CHANNEL_TYPE_RECOMMEND
)
.
hideClose
(
true
,
null
)
.
hideChannelName
(
true
)
.
dramaDetailConfig
(
dramaDetailConfig
)
.
listener
(
drawListener
)
// 混排流内视频监听
.
adListener
(
drawAdListener
)
// 混排流内广告监听
)
dpWidget
?.
fragment
?.
userVisibleHint
=
userVisibleHint
dpWidget
?.
let
{
if
(
isAdded
.
not
())
{
return
}
childFragmentManager
.
beginTransaction
().
apply
{
replace
(
R
.
id
.
fl_container
,
it
.
fragment
)
this
.
commitNowAllowingStateLoss
()
}
}
}
override
fun
onResume
()
{
super
.
onResume
()
Log
.
d
(
TAG
,
"onResume"
)
if
(
AppConfig
.
fragmentClickFlag
==
Constant
.
FRAGMENT_CLICK_TWO
)
{
dpWidget
?.
fragment
?.
onResume
()
dpWidget
?.
fragment
?.
userVisibleHint
=
true
}
}
override
fun
onPause
()
{
super
.
onPause
()
Log
.
d
(
TAG
,
"onPause"
)
dpWidget
?.
fragment
?.
onPause
()
dpWidget
?.
fragment
?.
userVisibleHint
=
false
}
override
fun
onHiddenChanged
(
hidden
:
Boolean
)
{
super
.
onHiddenChanged
(
hidden
)
dpWidget
?.
fragment
?.
onHiddenChanged
(
hidden
)
}
override
fun
setUserVisibleHint
(
isVisibleToUser
:
Boolean
)
{
super
.
setUserVisibleHint
(
isVisibleToUser
)
// dpWidget?.fragment?.userVisibleHint = isVisibleToUser
}
private
var
dramaListener
:
IDPDramaListener
=
object
:
IDPDramaListener
()
{
override
fun
onDPSeekTo
(
position
:
Int
,
time
:
Long
)
{
super
.
onDPSeekTo
(
position
,
time
)
Log
.
d
(
TAG
,
"onDPSeekTo:"
)
}
override
fun
onDPPageChange
(
position
:
Int
,
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPPageChange
(
position
,
map
)
Log
.
d
(
TAG
,
"onDPPageChange:"
+
map
?.
toString
())
}
override
fun
onDPVideoPlay
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPVideoPlay
(
map
)
Log
.
d
(
TAG
,
"onDPVideoPlay:"
+
map
?.
toString
())
}
override
fun
onDPVideoPause
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPVideoPause
(
map
)
Log
.
d
(
TAG
,
"onDPVideoPause:"
+
map
?.
toString
())
}
override
fun
onDPVideoContinue
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPVideoContinue
(
map
)
Log
.
d
(
TAG
,
"onDPVideoContinue:"
+
map
?.
toString
())
}
override
fun
onDPVideoCompletion
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPVideoCompletion
(
map
)
Log
.
d
(
TAG
,
"onDPVideoCompletion:"
+
map
?.
toString
())
}
override
fun
onDPVideoOver
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPVideoOver
(
map
)
Log
.
d
(
TAG
,
"onDPVideoOver:"
+
map
?.
toString
())
}
override
fun
onDPClose
()
{
super
.
onDPClose
()
Log
.
d
(
TAG
,
"onDPClose"
)
}
override
fun
onDPRequestStart
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPRequestStart
(
map
)
Log
.
d
(
TAG
,
"onDPRequestStart:"
+
map
?.
toString
())
}
override
fun
onDPRequestFail
(
code
:
Int
,
msg
:
String
?,
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDPRequestFail
(
code
,
msg
,
map
)
Log
.
d
(
TAG
,
"onDPRequestFail:"
+
map
?.
toString
())
}
override
fun
onDPRequestSuccess
(
list
:
MutableList
<
MutableMap
<
String
,
Any
>>?)
{
super
.
onDPRequestSuccess
(
list
)
list
?.
forEach
{
it
->
Log
.
d
(
TAG
,
"onDPRequestSuccess:"
+
it
.
toString
())
}
}
override
fun
onDramaSwitch
(
map
:
MutableMap
<
String
,
Any
>?)
{
super
.
onDramaSwitch
(
map
)
Log
.
d
(
TAG
,
"onDramaSwitch:"
+
map
?.
toString
())
}
}
private
val
drawListener
=
object
:
IDPDrawListener
()
{
override
fun
onDPRefreshFinish
()
{
Log
.
d
(
TAG
,
"onDPRefreshFinish"
)
}
override
fun
onDPPageChange
(
position
:
Int
)
{
Log
.
d
(
TAG
,
"onDPPageChange: $position"
)
}
override
fun
onDPVideoPlay
(
map
:
Map
<
String
,
Any
>)
{
Log
.
d
(
TAG
,
"onDPVideoPlay: $map"
)
}
override
fun
onDPVideoCompletion
(
map
:
Map
<
String
,
Any
>)
{
Log
.
d
(
TAG
,
"onDPVideoCompletion: $map"
)
// dpWidget?.pauseForWatchTogether()
// videoPresenter.getIndexList("" + map["drama_id"], true)
}
override
fun
onDPVideoOver
(
map
:
Map
<
String
,
Any
>)
{
Log
.
d
(
TAG
,
"onDPVideoOver: $map"
)
}
override
fun
onDPClose
()
{
Log
.
d
(
TAG
,
"onDPClose"
)
}
override
fun
onDPRequestStart
(
map
:
Map
<
String
,
Any
>?)
{
Log
.
d
(
TAG
,
"onDPRequestStart: $map"
)
}
override
fun
onDPRequestSuccess
(
list
:
List
<
Map
<
String
,
Any
>>)
{
Log
.
d
(
TAG
,
"onDPRequestSuccess: $list"
)
}
override
fun
onDPRequestFail
(
code
:
Int
,
msg
:
String
,
map
:
Map
<
String
,
Any
>?
)
{
Log
.
d
(
TAG
,
"onDPRequestFail: code = $code, msg = $msg, map = $map"
)
}
override
fun
onDPClickAuthorName
(
map
:
Map
<
String
,
Any
>)
{
Log
.
d
(
TAG
,
"onDPClickAuthorName: $map"
)
}
override
fun
onDPClickAvatar
(
map
:
Map
<
String
,
Any
>)
{
Log
.
d
(
TAG
,
"onDPClickAvatar: $map"
)
}
override
fun
onDPClickComment
(
map
:
Map
<
String
,
Any
>)
{
Log
.
d
(
TAG
,
"onDPClickComment: $map"
)
}
override
fun
onDPClickLike
(
isLike
:
Boolean
,
map
:
Map
<
String
,
Any
>
)
{
Log
.
d
(
TAG
,
"onDPClickLike: isLike = $isLike, map = $map"
)
}
override
fun
onDPVideoPause
(
map
:
Map
<
String
,
Any
>)
{
Log
.
d
(
TAG
,
"onDPVideoPause: $map"
)
}
override
fun
onDPVideoContinue
(
map
:
Map
<
String
,
Any
>)
{
Log
.
d
(
TAG
,
"onDPVideoContinue: $map"
)
}
override
fun
onDPClickShare
(
map
:
MutableMap
<
String
,
Any
>?)
{
Log
.
d
(
TAG
,
"onDPClickShare $map"
)
}
}
private
val
dramaAdListener
:
IDPAdListener
=
object
:
IDPAdListener
()
{
override
fun
onDPAdRequest
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdRequest map = $map"
)
}
override
fun
onDPAdRequestSuccess
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdRequestSuccess map = $map"
)
}
override
fun
onDPAdRequestFail
(
code
:
Int
,
msg
:
String
?,
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdRequestFail map = $map"
)
}
override
fun
onDPAdFillFail
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdFillFail map = $map"
)
}
override
fun
onDPAdShow
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdShow map = $map"
)
}
override
fun
onDPAdPlayStart
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdPlayStart: map = $map"
)
}
override
fun
onDPAdPlayPause
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdPlayPause map = $map"
)
}
override
fun
onRewardVerify
(
map
:
MutableMap
<
String
,
Any
>?)
{
Log
.
d
(
TAG
,
"onRewardVerify map = $map"
)
}
override
fun
onSkippedVideo
(
map
:
MutableMap
<
String
,
Any
>?)
{
Log
.
d
(
TAG
,
"onSkippedVideo map = $map"
)
}
override
fun
onDPAdPlayContinue
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdPlayContinue map = $map"
)
}
override
fun
onDPAdPlayComplete
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdPlayComplete map = $map"
)
}
override
fun
onDPAdClicked
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdClicked map = $map"
)
}
}
private
val
drawAdListener
:
IDPAdListener
=
object
:
IDPAdListener
()
{
override
fun
onDPAdRequest
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdRequest map = $map"
)
}
override
fun
onDPAdRequestSuccess
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdRequestSuccess map = $map"
)
}
override
fun
onDPAdRequestFail
(
code
:
Int
,
msg
:
String
?,
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdRequestFail map = $map"
)
}
override
fun
onDPAdFillFail
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdFillFail map = $map"
)
}
override
fun
onDPAdShow
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdShow map = $map"
)
}
override
fun
onDPAdPlayStart
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdPlayStart: map = $map"
)
}
override
fun
onDPAdPlayPause
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdPlayPause map = $map"
)
}
override
fun
onDPAdPlayContinue
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdPlayContinue map = $map"
)
}
override
fun
onDPAdPlayComplete
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdPlayComplete map = $map"
)
}
override
fun
onDPAdClicked
(
map
:
Map
<
String
?
,
Any
?
>)
{
Log
.
d
(
TAG
,
"onDPAdClicked map = $map"
)
}
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
videoPresenter
.
detachView
()
}
override
fun
getIndexListSuc
(
indexList
:
IndexList
)
{
LocalVedioManager
.
startVedioDetailActivityForType
(
requireActivity
(),
indexList
.
vedioMsg
,
true
,
isThirdId
=
true
)
}
override
fun
getIndexListFail
()
{
showToast
(
"网络错误!"
)
}
override
fun
collectSuc
()
{
}
override
fun
collectFail
()
{
}
override
fun
cancelCollectSuc
()
{
}
override
fun
cancelCollectFail
()
{
}
override
fun
unlockSuc
(
indexList
:
IndexList
)
{
}
override
fun
unlockFail
()
{
}
override
fun
showTurnSuc
(
data
:
NineShowBean
)
{
}
override
fun
getVipProductSuc
(
data
:
VipBean
)
{
}
}
\ No newline at end of file
video/app/src/main/java/com/duben/skitworld/video/csj/OnRecyViewListener.kt
deleted
100755 → 0
View file @
1f094cd7
package
com.duben.skitworld.video.csj
/**
* author : ChenWenJie
* email : 1181620038@qq.com
* date : 2020/9/22
* desc : 监听接口
*/
interface
OnRecyViewListener
{
/*初始化完成*/
fun
onInitComplete
()
/*释放的监听*/
fun
onPageRelease
(
isNext
:
Boolean
,
position
:
Int
)
/*选中的监听以及判断是否滑动到底部*/
fun
onPageSelected
(
position
:
Int
,
isBottom
:
Boolean
)
}
\ No newline at end of file
video/app/src/main/java/com/duben/skitworld/video/csj/RecyViewLayoutManager.kt
deleted
100755 → 0
View file @
1f094cd7
package
com.duben.skitworld.video.csj
import
android.content.Context
import
android.view.View
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.PagerSnapHelper
import
androidx.recyclerview.widget.RecyclerView
/**
* author : ChenWenJie
* email : 1181620038@qq.com
* date : 2020/9/22
* desc : 定义管理器,一item一屏 监听滑动状态
*/
class
RecyViewLayoutManager
:
LinearLayoutManager
{
private
var
mPagerSnapHelper
:
PagerSnapHelper
?
=
null
private
var
mOnRecycleViewListener
:
OnRecyViewListener
?
=
null
private
var
mRecyclerView
:
RecyclerView
?
=
null
private
var
mDrift
=
0
//位移,用来判断移动方向
private
val
mChildAttachStateChangeListener
:
RecyclerView
.
OnChildAttachStateChangeListener
=
object
:
RecyclerView
.
OnChildAttachStateChangeListener
{
override
fun
onChildViewDetachedFromWindow
(
view
:
View
)
{
if
(
mDrift
>=
0
)
{
if
(
mOnRecycleViewListener
!=
null
)
{
mOnRecycleViewListener
!!
.
onPageRelease
(
true
,
getPosition
(
view
))
}
}
else
{
if
(
mOnRecycleViewListener
!=
null
)
{
mOnRecycleViewListener
!!
.
onPageRelease
(
false
,
getPosition
(
view
))
}
}
}
override
fun
onChildViewAttachedToWindow
(
view
:
View
)
{
if
(
mOnRecycleViewListener
!=
null
&&
childCount
===
1
)
{
mOnRecycleViewListener
!!
.
onInitComplete
()
}
}
}
constructor
(
context
:
Context
?,
orientation
:
Int
)
:
super
(
context
,
orientation
,
false
)
{
init
()
}
constructor
(
context
:
Context
?,
orientation
:
Int
,
reverseLayout
:
Boolean
)
:
super
(
context
,
orientation
,
reverseLayout
)
{
init
()
}
private
fun
init
()
{
mPagerSnapHelper
=
PagerSnapHelper
()
}
override
fun
onAttachedToWindow
(
view
:
RecyclerView
?)
{
super
.
onAttachedToWindow
(
view
)
mPagerSnapHelper
?.
attachToRecyclerView
(
view
)
mRecyclerView
=
view
mRecyclerView
?.
addOnChildAttachStateChangeListener
(
mChildAttachStateChangeListener
)
}
override
fun
onLayoutChildren
(
recycler
:
RecyclerView
.
Recycler
?,
state
:
RecyclerView
.
State
?)
{
super
.
onLayoutChildren
(
recycler
,
state
)
//
}
/**
* 滑动状态的改变
* 缓慢拖拽-> SCROLL_STATE_DRAGGING
* 快速滚动-> SCROLL_STATE_SETTLING
* 空闲状态-> SCROLL_STATE_IDLE
*
* @param state
*/
override
fun
onScrollStateChanged
(
state
:
Int
)
{
when
(
state
)
{
RecyclerView
.
SCROLL_STATE_IDLE
->
{
val
viewIdle
:
View
=
mPagerSnapHelper
!!
.
findSnapView
(
this
)
!!
val
positionIdle
:
Int
=
getPosition
(
viewIdle
)
if
(
mOnRecycleViewListener
!=
null
&&
getChildCount
()
===
1
)
{
mOnRecycleViewListener
!!
.
onPageSelected
(
positionIdle
,
positionIdle
==
getItemCount
()
-
1
)
}
}
RecyclerView
.
SCROLL_STATE_DRAGGING
->
{
val
viewDrag
:
View
?
=
mPagerSnapHelper
!!
.
findSnapView
(
this
)
!!
val
positionDrag
:
Int
=
getPosition
(
viewDrag
!!
)
}
RecyclerView
.
SCROLL_STATE_SETTLING
->
{
val
viewSettling
:
View
=
mPagerSnapHelper
!!
.
findSnapView
(
this
)
!!
val
positionSettling
:
Int
=
getPosition
(
viewSettling
)
}
}
}
/**
* 监听竖直方向的相对偏移量
*
* @param dy
* @param recycler
* @param state
* @return
*/
override
fun
scrollVerticallyBy
(
dy
:
Int
,
recycler
:
RecyclerView
.
Recycler
?,
state
:
RecyclerView
.
State
?
):
Int
{
mDrift
=
dy
return
super
.
scrollVerticallyBy
(
dy
,
recycler
,
state
)
}
/**
* 监听水平方向的相对偏移量
*
* @param dx
* @param recycler
* @param state
* @return
*/
override
fun
scrollHorizontallyBy
(
dx
:
Int
,
recycler
:
RecyclerView
.
Recycler
?,
state
:
RecyclerView
.
State
?
):
Int
{
mDrift
=
dx
return
super
.
scrollHorizontallyBy
(
dx
,
recycler
,
state
)
}
/**
* 设置监听
*
* @param listener
*/
fun
setOnViewPagerListener
(
listener
:
OnRecyViewListener
?)
{
mOnRecycleViewListener
=
listener
}
companion
object
{
private
const
val
TAG
=
"ViewPagerLayoutManager"
}
}
video/app/src/main/res/layout/drama_home_frag_wrapper.xml
deleted
100644 → 0
View file @
1f094cd7
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<FrameLayout
android:id=
"@+id/fl_container"
android:keepScreenOn=
"true"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
</FrameLayout>
\ 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