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
ccc47162
Commit
ccc47162
authored
Oct 31, 2023
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
db4f3024
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
924 additions
and
0 deletions
+924
-0
AndroidManifest.xml
video/app/src/main/AndroidManifest.xml
+5
-0
NewTxVideoActivity.kt
...ava/com/duben/supertheater/video/tx/NewTxVideoActivity.kt
+743
-0
activity_new_tx_video.xml
video/app/src/main/res/layout/activity_new_tx_video.xml
+176
-0
No files found.
video/app/src/main/AndroidManifest.xml
View file @
ccc47162
...
@@ -162,6 +162,11 @@
...
@@ -162,6 +162,11 @@
android:exported=
"false"
android:exported=
"false"
android:hardwareAccelerated=
"true"
android:hardwareAccelerated=
"true"
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".video.tx.NewTxVideoActivity"
android:exported=
"false"
android:hardwareAccelerated=
"true"
android:screenOrientation=
"portrait"
/>
<activity
<activity
android:name=
".ui.activitys.NineActivity"
android:name=
".ui.activitys.NineActivity"
android:exported=
"false"
android:exported=
"false"
...
...
video/app/src/main/java/com/duben/supertheater/video/tx/NewTxVideoActivity.kt
0 → 100644
View file @
ccc47162
package
com.duben.supertheater.video.tx
import
android.animation.Animator
import
android.animation.ValueAnimator
import
android.app.Dialog
import
android.graphics.Path
import
android.graphics.PathMeasure
import
android.os.Bundle
import
android.os.Handler
import
android.os.Looper
import
android.view.View
import
android.view.animation.LinearInterpolator
import
android.widget.ImageView
import
android.widget.RelativeLayout
import
androidx.core.content.ContextCompat
import
com.daimajia.androidanimations.library.Techniques
import
com.daimajia.androidanimations.library.YoYo
import
com.google.gson.Gson
import
com.duben.supertheater.R
import
com.duben.supertheater.ad.AdManager
import
com.duben.supertheater.ad.AdStatusListener
import
com.duben.supertheater.ad.NoPreAdManager
import
com.duben.supertheater.ad.draw.DrawExpressManager
import
com.duben.supertheater.ad.express.ExpressManager
import
com.duben.supertheater.common.Constant
import
com.duben.supertheater.manager.LocalVedioManager
import
com.duben.supertheater.manager.UserManager
import
com.duben.supertheater.mvp.model.*
import
com.duben.supertheater.mvp.model.IndexList.VedioEpisodeBean
import
com.duben.supertheater.mvp.presenters.VideoPresenter
import
com.duben.supertheater.mvp.views.VideoView
import
com.duben.supertheater.ui.activitys.base.BaseActivity
import
com.duben.supertheater.ui.adapter.VideoEpisodeAdapter
import
com.duben.supertheater.video.tx.adapter.TxVideoAdapter
import
com.duben.library.utils.nodoubleclick.AntiShake
import
com.duben.supertheater.ad.half.HalfScreenManager
import
com.duben.supertheater.common.AppConfig
import
com.duben.supertheater.ui.widgets.*
import
com.duben.supertheater.ui.widgets.countdowntimer.CountDownTimerSupport
import
com.duben.supertheater.ui.widgets.countdowntimer.OnCountDownTimerListener
import
com.duben.supertheater.utils.*
import
kotlinx.android.synthetic.main.activity_new_tx_video.*
import
kotlinx.android.synthetic.main.layout_draw_header.*
import
kotlinx.android.synthetic.main.layout_red_box.*
class
NewTxVideoActivity
:
BaseActivity
(),
View
.
OnClickListener
,
VideoView
,
VideoEpisodeAdapter
.
OnEpisodeClickListener
,
TxVideoAdapter
.
OnCustomChildClickListener
,
CountDownVideoView
.
CountDownVideoListener
{
private
var
mVipFlag
=
UserManager
.
getInstance
().
vipFlag
var
videos
=
ArrayList
<
VedioEpisodeBean
>()
private
var
dialog
:
VideoEpisodeDialog
?
=
null
private
val
videoPresenter
by
lazy
{
VideoPresenter
()
}
private
var
mVedioBean
:
VedioBean
?
=
null
private
var
indexBean
:
IndexList
?
=
null
private
var
tipList
:
ArrayList
<
String
>?
=
null
private
var
orderTagsList
:
ArrayList
<
String
>?
=
null
private
var
isPlayNext
=
false
private
var
playIndex
=
1
private
var
mCash
=
0
private
var
mGold
=
0
private
var
rope
:
YoYo
.
YoYoString
?
=
null
private
var
mTimer
:
CountDownTimerSupport
?
=
null
private
var
mVideoRewardDialog
:
VideoRewardDialog
?
=
null
private
var
mVideoLockDialog
:
VideoLockDialog
?
=
null
// 新人红包
var
newcomerDialog
:
NewcomerDialog
?
=
null
private
val
mainHandler
=
Handler
(
Looper
.
getMainLooper
())
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
activity_new_tx_video
override
fun
initViewsAndEvents
()
{
AppConfig
.
mainShowHalfAd
=
true
HalfScreenManager
.
getInstance
().
preLoadAd
(
this
)
videoPresenter
.
attachView
(
this
)
mVedioBean
?.
let
{
videoPresenter
.
getIndexList
(
""
+
it
.
vedioId
)
}
initView
()
}
override
fun
getBundleExtras
(
extras
:
Bundle
?)
{
val
json
=
extras
?.
getString
(
Constant
.
VEDIO_BEAN
)
isPlayNext
=
extras
?.
getBoolean
(
Constant
.
VEDIO_NEXT
,
false
)
==
true
mVedioBean
=
Gson
().
fromJson
(
json
,
VedioBean
::
class
.
java
)
orderTagsList
=
mVedioBean
?.
orderTags
if
(
isPlayNext
)
{
mVedioBean
?.
let
{
it
.
recommendIndex
=
it
.
recommendIndex
+
1
}
}
super
.
getBundleExtras
(
extras
)
}
override
fun
isApplyKitKatTranslucency
()
=
false
override
fun
onResume
()
{
super
.
onResume
()
super_short_video_view
.
resume
()
if
(
mVipFlag
!=
UserManager
.
getInstance
().
vipFlag
&&
UserManager
.
getInstance
().
vipFlag
)
{
// 重置状态
isPlayNext
=
false
playIndex
=
super_short_video_view
.
currentPosition
mVedioBean
?.
let
{
videoPresenter
.
getIndexList
(
""
+
it
.
vedioId
)
}
}
}
override
fun
onPause
()
{
super
.
onPause
()
super_short_video_view
.
pause
()
}
override
fun
onDestroy
()
{
super_short_video_view
.
onDestroy
()
super
.
onDestroy
()
super_short_video_view
.
releasePlayer
()
// DrawExpressManager.instance.destroy()
ExpressManager
.
instance
.
destroy
()
videoPresenter
.
detachView
()
}
private
fun
initView
()
{
if
(!
UserManager
.
getInstance
().
vipFlag
)
{
ExpressManager
.
instance
.
preLoadAd
()
// DrawExpressManager.instance.preLoadAd()
}
episode_tv
.
text
=
String
.
format
(
"共%d集 %s"
,
mVedioBean
?.
vedioTotal
,
if
(
mVedioBean
?.
completeStatus
==
0
)
"已完结"
else
"更新中"
)
super_short_video_view
.
setOnCustomChildClickListener
(
this
)
super_short_video_view
.
setOnCustomChildClickListener
(
this
)
super_short_video_view
.
setOnPageChangeListener
{
if
(
super_short_video_view
.
isAdPosition
(
it
)
||
super_short_video_view
.
isLuckPosition
(
it
))
{
showLockDialog
()
fm_bottom
.
visibility
=
View
.
GONE
super_short_video_view
.
pause
()
return
@setOnPageChangeListener
}
fm_bottom
.
visibility
=
View
.
VISIBLE
val
readIndex
=
getRealIndex
(
it
)
showVipCountDialog
(
readIndex
)
// videoIndex -> seeIndex
val
data
=
super_short_video_view
.
data
if
(
data
.
size
>
it
&&
data
[
it
].
itemType
==
MULTI_ITEM_1
)
{
mVedioBean
!!
.
seeIndex
=
data
[
it
].
video
!!
.
vedioIndex
mVedioBean
!!
.
orderTags
=
orderTagsList
LocalVedioManager
.
commitVedio
(
mVedioBean
!!
)
}
}
tv_cash
.
text
=
"0"
tv_gold
.
text
=
"0"
leave
.
visibility
=
View
.
VISIBLE
fm_bottom
.
setOnClickListener
(
this
)
leave
.
setOnClickListener
(
this
)
btn_draw_gold
.
setOnClickListener
(
this
)
btn_draw_cash
.
setOnClickListener
(
this
)
}
override
fun
onClick
(
v
:
View
?)
{
if
(
AntiShake
.
check
(
v
?.
id
))
return
when
(
v
?.
id
)
{
R
.
id
.
leave
->
finish
()
R
.
id
.
btn_draw_gold
,
R
.
id
.
btn_draw_cash
->
{
finish
()
if
(
ForegroundOrBackground
.
getMainActivity
()
!=
null
)
{
ForegroundOrBackground
.
getMainActivity
().
clickTab4Layout
()
}
}
R
.
id
.
fm_bottom
->
{
showEpisodeDialog
()
}
else
->
{}
}
}
private
fun
showEpisodeDialog
()
{
if
(
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
?.
setCurrentIndex
(
super_short_video_view
.
realSeeIndex
)
dialog
?.
setOnEpisodeClickListener
(
this
)
dialog
?.
show
()
}
override
fun
getIndexListSuc
(
indexList
:
IndexList
)
{
// 处理推荐页跳转自动播放下一集逻辑
if
(
isPlayNext
)
{
playIndex
=
mVedioBean
!!
.
recommendIndex
-
1
if
(
playIndex
>=
mVedioBean
!!
.
unlockIndex
-
1
)
{
playIndex
=
mVedioBean
!!
.
unlockIndex
-
1
}
}
else
{
playIndex
=
mVedioBean
!!
.
seeIndex
-
1
}
if
(
playIndex
>
mVedioBean
!!
.
vedioTotal
||
playIndex
<=
0
)
playIndex
=
0
tipList
=
indexList
.
tip
mVedioBean
=
indexList
.
vedioMsg
indexBean
=
indexList
videos
.
clear
()
videos
.
addAll
(
indexList
.
list
)
super_short_video_view
.
loadData
(
mVedioBean
,
getAdapterData
(),
playIndex
)
AppConfig
.
firstVedioTime
=
5
// 弹出新人红包
if
(
AppConfig
.
firstVedioTime
>
0
)
{
Handler
(
Looper
.
getMainLooper
()).
postDelayed
({
super_short_video_view
.
pause
()
showNewcomerDialog
(
188800
)
},
AppConfig
.
firstVedioTime
*
1000L
)
}
}
override
fun
getIndexListFail
()
{
}
override
fun
unlockSuc
(
indexList
:
IndexList
)
{
videos
.
addAll
(
indexList
.
list
)
mVedioBean
!!
.
unlockIndex
=
videos
.
size
super_short_video_view
.
loadMoreData
(
getAdapterData
())
}
override
fun
unlockFail
()
{
}
override
fun
rdVedioMsgSuc
(
data
:
RDVideoBean
)
{
mCash
=
data
.
userMsg
.
coin
mGold
=
data
.
userMsg
.
diamonds
tv_cash
.
text
=
"${FormatUtil.getCashFormaet(mCash)}元"
tv_gold
.
text
=
"${mGold}个"
}
override
fun
reportAddCoinMsgSuc
(
coin
:
Int
,
di
:
Int
)
{
cdvv
.
reset
()
videoPresenter
.
rdVedioMsg
()
SoundPoolUtil
.
getInstance
().
getGoldVoice
()
showRewardAnim
(
coin
,
di
)
}
private
fun
isLockIndex
():
Boolean
{
return
super_short_video_view
.
realSeeIndex
>
mVedioBean
!!
.
unlockIndex
}
override
fun
onEpisodeClick
(
position
:
Int
)
{
dialog
?.
dismiss
()
val
data
=
super_short_video_view
.
data
if
(
position
>=
mVedioBean
!!
.
unlockIndex
)
{
super_short_video_view
.
onItemClick
(
data
.
size
-
1
)
return
}
val
readPosition
=
getRealPosition
(
position
+
1
)
super_short_video_view
.
onItemClick
(
readPosition
)
}
private
fun
getAdapterData
():
MutableList
<
VideoMultiItemEntity
>
{
val
data
=
mutableListOf
<
VideoMultiItemEntity
>()
if
(
videos
.
size
>
0
)
{
for
(
video
in
videos
)
{
val
item
=
VideoMultiItemEntity
(
MULTI_ITEM_1
,
video
,
VideoModel
(
video
.
vedioUrl
))
data
.
add
(
item
)
}
if
(
mVedioBean
!!
.
unlockIndex
<
mVedioBean
!!
.
vedioTotal
)
{
val
item
=
VideoMultiItemEntity
(
MULTI_ITEM_2
,
videos
[
0
],
VideoModel
(
videos
[
0
].
vedioUrl
))
data
.
add
(
item
)
}
}
return
data
}
override
fun
onCustomChildClick
(
view
:
View
,
position
:
Int
)
{
when
(
view
.
id
)
{
R
.
id
.
ll_collect
->
{
}
R
.
id
.
leave
->
{
// 返回
finish
()
}
R
.
id
.
unlock
->
{
// 看广告解锁
// val carrierType = Constant.CARRIERTYPE_TX_VEDIO
// showAd(carrierType)
showLockDialog
()
}
R
.
id
.
vip
->
{
// 开通VIP
}
else
->
{}
}
}
/**
* @param index 当前下标的集数
*/
private
fun
showVipCountDialog
(
index
:
Int
)
{
if
(
isFinishing
)
return
if
(
mVedioBean
!!
.
tipMaxIndex
==
0
||
index
==
1
||
mVedioBean
!!
.
tipMaxIndex
<
index
||
index
>
mVedioBean
!!
.
unlockIndex
)
{
return
}
VipCountDialog
(
this
,
mVedioBean
!!
,
tipList
)
.
setOnDialogDismiss
(
object
:
VipCountDialog
.
OnDialogDismiss
{
override
fun
onDialogDismiss
()
{}
})
.
show
()
}
// 获取当前下标真正代表的集数
private
fun
getRealIndex
(
position
:
Int
):
Int
{
var
readIndex
=
position
val
data
=
super_short_video_view
.
data
if
(
data
!=
null
&&
data
.
size
>
0
)
{
if
(
data
[
position
].
itemType
==
MULTI_ITEM_1
)
{
readIndex
=
data
[
position
].
video
!!
.
vedioIndex
}
}
return
readIndex
}
// 用于点击匹配当前剧集对应的具体下标
private
fun
getRealPosition
(
position
:
Int
):
Int
{
var
readPosition
=
position
val
data
=
super_short_video_view
.
data
if
(
data
!=
null
&&
data
.
size
>
0
)
{
for
(
i
in
0
until
data
.
size
)
{
if
(
data
[
i
].
itemType
==
MULTI_ITEM_1
)
{
if
(
data
[
i
].
video
!!
.
vedioIndex
==
position
)
{
readPosition
=
i
break
}
}
}
}
return
readPosition
}
private
fun
showRewardAnim
(
cashReward
:
Int
,
goldReward
:
Int
)
{
if
(
cashReward
<=
0
&&
goldReward
<=
0
)
return
mCash
+=
cashReward
mGold
+=
goldReward
tv_cash
.
text
=
"${FormatUtil.getCashFormaet(mCash)}元"
tv_gold
.
text
=
"${mGold}个"
cl_reward
.
visibility
=
View
.
VISIBLE
iv_cash_reward
.
visibility
=
View
.
VISIBLE
tv_cash_reward
.
visibility
=
View
.
VISIBLE
iv_gold_reward
.
visibility
=
View
.
VISIBLE
tv_gold_reward
.
visibility
=
View
.
VISIBLE
if
(
cashReward
<=
0
)
{
iv_cash_reward
.
visibility
=
View
.
GONE
tv_cash_reward
.
visibility
=
View
.
GONE
}
else
{
tv_cash_reward
.
text
=
"+$cashReward"
mainHandler
.
postDelayed
({
if
(
isFinishing
)
return
@postDelayed
addAnimation
(
iv_cash_reward
,
iv_cash
)
mainHandler
.
postDelayed
({
if
(
isFinishing
)
return
@postDelayed
addAnimation
(
iv_cash_reward
,
iv_cash
)
},
200
)
mainHandler
.
postDelayed
({
if
(
isFinishing
)
return
@postDelayed
addAnimation
(
iv_cash_reward
,
iv_cash
)
},
400
)
mainHandler
.
postDelayed
({
if
(
isFinishing
)
return
@postDelayed
addAnimation
(
iv_cash_reward
,
iv_cash
)
},
800
)
},
100
)
mainHandler
.
postDelayed
({
if
(
isFinishing
)
return
@postDelayed
rope
=
null
rope
=
YoYo
.
with
(
Techniques
.
Pulse
).
duration
(
300
).
playOn
(
rl_cash
)
},
1000
)
}
if
(
goldReward
<=
0
)
{
iv_gold_reward
.
visibility
=
View
.
GONE
tv_gold_reward
.
visibility
=
View
.
GONE
}
else
{
tv_gold_reward
.
text
=
"+$goldReward"
mainHandler
.
postDelayed
({
if
(
isFinishing
)
return
@postDelayed
addAnimation
(
iv_gold_reward
,
iv_gold
)
mainHandler
.
postDelayed
({
if
(
isFinishing
)
return
@postDelayed
addAnimation
(
iv_gold_reward
,
iv_gold
)
},
200
)
mainHandler
.
postDelayed
({
if
(
isFinishing
)
return
@postDelayed
addAnimation
(
iv_gold_reward
,
iv_gold
)
},
400
)
mainHandler
.
postDelayed
({
if
(
isFinishing
)
return
@postDelayed
addAnimation
(
iv_gold_reward
,
iv_gold
)
},
800
)
},
100
)
mainHandler
.
postDelayed
({
if
(
isFinishing
)
return
@postDelayed
rope
=
null
rope
=
YoYo
.
with
(
Techniques
.
Pulse
).
duration
(
300
).
playOn
(
rl_gold
)
},
1000
)
}
mainHandler
.
postDelayed
({
if
(
isFinishing
)
return
@postDelayed
cl_reward
.
visibility
=
View
.
GONE
},
1500
)
}
/**
* 动画
*/
private
fun
addAnimation
(
view
:
ImageView
,
targetView
:
View
)
{
/**
* 贝塞尔曲线中间过程的点的坐标
*/
val
mCurrentPosition
=
FloatArray
(
2
)
// 一、创造出执行动画的主题---imageview
//代码new一个imageview,图片资源是上面的imageview的图片
// (这个图片就是执行动画的图片,从开始位置出发,经过一个抛物线(贝塞尔曲线),移动到购物车里)
val
goods
=
ImageView
(
this
)
goods
.
setImageDrawable
(
view
.
drawable
)
val
params
=
RelativeLayout
.
LayoutParams
(
view
.
width
,
view
.
height
)
container
.
addView
(
goods
,
params
)
val
offsetWidth
=
if
(
view
.
width
>=
targetView
.
width
)
{
view
.
width
-
targetView
.
width
}
else
{
targetView
.
width
-
view
.
width
}
// val offsetHeight = if (view.height >= targetView.height) {
// view.height - targetView.height
// } else {
// targetView.height - view.height
// }
// 二、计算动画开始/结束点的坐标的准备工作
//得到父布局的起始点坐标(用于辅助计算动画开始/结束时的点的坐标)
val
parentLocation
=
IntArray
(
2
)
container
.
getLocationInWindow
(
parentLocation
)
//得到商品图片的坐标(用于计算动画开始的坐标)
val
startLoc
=
IntArray
(
2
)
view
.
getLocationInWindow
(
startLoc
)
//得到购物车图片的坐标(用于计算动画结束后的坐标)
val
endLoc
=
IntArray
(
2
)
targetView
.
getLocationInWindow
(
endLoc
)
// 三、正式开始计算动画开始/结束的坐标
//开始掉落的商品的起始点:商品起始点-父布局起始点+该商品图片的一半
val
startX
=
startLoc
[
0
]
-
parentLocation
[
0
]
+
goods
.
width
/
2
.
toFloat
()
val
startY
=
startLoc
[
1
]
-
parentLocation
[
1
]
+
goods
.
height
/
2
.
toFloat
()
//商品掉落后的终点坐标:购物车起始点-父布局起始点+购物车图片的1/5
val
toX
=
endLoc
[
0
]
-
parentLocation
[
0
].
toFloat
()
// + targetView.width / 5.toFloat()
val
toY
=
endLoc
[
1
]
-
parentLocation
[
1
].
toFloat
()
+
targetView
.
height
/
5
.
toFloat
()
//四、计算中间动画的插值坐标(贝塞尔曲线)(其实就是用贝塞尔曲线来完成起终点的过程)
//开始绘制贝塞尔曲线
val
path
=
Path
()
//移动到起始点(贝塞尔曲线的起点)
path
.
moveTo
(
startX
,
startY
)
//使用二次萨贝尔曲线:注意第一个起始坐标越大,贝塞尔曲线的横向距离就会越大,一般按照下面的式子取即可
//想实现类似抛物线的形式,这里的控制点取的是(startX+toX)/2,startY
path
.
quadTo
((
startX
+
toX
)
/
2
,
startY
,
toX
,
toY
)
//mPathMeasure用来计算贝塞尔曲线的曲线长度和贝塞尔曲线中间插值的坐标,
// 如果是true,path会形成一个闭环,Path用来计算path路径中的点的坐标
//计算path路径中点的坐标
val
mPathMeasure
=
PathMeasure
(
path
,
false
)
//★★★属性动画实现(从0到贝塞尔曲线的长度之间进行插值计算,获取中间过程的距离值)
val
valueAnimator
=
ValueAnimator
.
ofFloat
(
0f
,
mPathMeasure
.
length
)
valueAnimator
.
duration
=
500
// 匀速线性插值器
valueAnimator
.
interpolator
=
LinearInterpolator
()
valueAnimator
.
addUpdateListener
{
animation
->
// 当插值计算进行时,获取中间的每个值,
// 这里这个值是中间过程中的曲线长度(下面根据这个值来得出中间点的坐标值)
val
value
=
animation
.
animatedValue
as
Float
// ★★★★★获取当前点坐标封装到mCurrentPosition
// boolean getPosTan(float distance, float[] pos, float[] tan) :
// 传入一个距离distance(0<=distance<=getLength()),然后会计算当前距
// 离的坐标点和切线,pos会自动填充上坐标,这个方法很重要。
mPathMeasure
.
getPosTan
(
value
,
mCurrentPosition
,
null
)
//mCurrentPosition此时就是中间距离点的坐标值
// 移动的商品图片(动画图片)的坐标设置为该中间点的坐标
goods
.
translationX
=
mCurrentPosition
[
0
]
goods
.
translationY
=
mCurrentPosition
[
1
]
val
transWidth
=
if
(
view
.
width
>
targetView
.
width
)
{
(
targetView
.
width
+
(
offsetWidth
*
((
mPathMeasure
.
length
-
value
)
/
mPathMeasure
.
length
))).
toInt
()
}
else
{
(
targetView
.
width
-
(
offsetWidth
*
((
mPathMeasure
.
length
-
value
)
/
mPathMeasure
.
length
))).
toInt
()
}
// val transHeight = if (view.height > targetView.height) {
// (targetView.height + (offsetHeight * ((mPathMeasure.length - value) / mPathMeasure.length))).toInt()
// } else {
// (targetView.height - (offsetHeight * ((mPathMeasure.length - value) / mPathMeasure.length))).toInt()
// }
val
ls
=
goods
.
layoutParams
ls
.
width
=
transWidth
ls
.
height
=
transWidth
goods
.
layoutParams
=
ls
}
// 五、 开始执行动画
valueAnimator
.
start
()
// 六、动画结束后的处理
valueAnimator
.
addListener
(
object
:
Animator
.
AnimatorListener
{
override
fun
onAnimationStart
(
animation
:
Animator
)
{}
//当动画结束后:
override
fun
onAnimationEnd
(
animation
:
Animator
)
{
// 把移动的图片imageview从父布局里移除
container
.
removeView
(
goods
)
}
override
fun
onAnimationCancel
(
animation
:
Animator
)
{}
override
fun
onAnimationRepeat
(
animation
:
Animator
)
{}
})
}
private
fun
startAutoPop
()
{
mTimer
=
CountDownTimerSupport
(
5000
,
1000
)
mTimer
?.
setOnCountDownTimerListener
(
object
:
OnCountDownTimerListener
{
override
fun
onTick
(
millisUntilFinished
:
Long
)
{}
override
fun
onFinish
()
{
if
(
isFinishing
)
return
if
(!
cdvv
.
isOver
)
return
super_short_video_view
.
pause
()
showRedboxDialog
()
}
})
mTimer
?.
start
()
}
private
fun
showRedboxDialog
()
{
SoundPool2Util
.
getInstance
().
getHongbaoVoice
()
mVideoRewardDialog
=
VideoRewardDialog
(
this
,
FormatUtil
.
getCashFormaet
(
mCash
).
toFloat
(),
object
:
DialogListener
()
{
override
fun
onClick
(
dialog
:
Dialog
?,
v
:
View
?)
{
super
.
onClick
(
dialog
,
v
)
when
(
v
?.
id
)
{
R
.
id
.
ll
->
{
dialog
?.
dismiss
()
showAd
(
Constant
.
CARRIERTYPE_VEDIO
)
}
R
.
id
.
ib_close
->
{
dialog
?.
dismiss
()
super_short_video_view
.
resume
()
}
}
}
}
)
mVideoRewardDialog
?.
show
()
}
private
fun
showAd
(
carrierType
:
String
)
{
AdManager
.
instance
.
showAd
(
this
@NewTxVideoActivity
,
carrierType
,
object
:
AdStatusListener
{
var
canFail
=
false
override
fun
adSuccess
()
{
canFail
=
true
}
override
fun
adFail
()
{
if
(
canFail
)
return
showLoading
(
"正在获取视频"
,
false
)
NoPreAdManager
.
loadVideoAd
(
this
@NewTxVideoActivity
,
carrierType
,
object
:
AdStatusListener
{
override
fun
adFail
()
{
hideLoading
()
showToast
(
"广告太火爆了,请稍候再试"
)
}
override
fun
adSuccess
()
{
hideLoading
()
}
override
fun
adClose
(
vo
:
HashMap
<
String
,
Any
>?)
{
hideLoading
()
when
(
carrierType
)
{
Constant
.
CARRIERTYPE_VEDIO_UNLOCK
->
{
vo
?.
let
{
vo
[
"vedioId"
]
=
mVedioBean
!!
.
vedioId
videoPresenter
.
unlock
(
vo
)
}
}
Constant
.
CARRIERTYPE_VEDIO
->
{
videoPresenter
.
reportAddCoinMsg
(
carrierType
,
vo
?.
get
(
"ecpmId"
)
as
String
)
}
Constant
.
CARRIERTYPE_REWARD_FIRST
->
{
showRewardAnim
(
188800
,
0
)
}
else
->
{}
}
}
})
}
override
fun
adClose
(
vo
:
HashMap
<
String
,
Any
>?)
{
when
(
carrierType
)
{
Constant
.
CARRIERTYPE_VEDIO_UNLOCK
->
{
vo
?.
let
{
vo
[
"vedioId"
]
=
mVedioBean
!!
.
vedioId
videoPresenter
.
unlock
(
vo
)
}
}
Constant
.
CARRIERTYPE_VEDIO
->
{
videoPresenter
.
reportAddCoinMsg
(
carrierType
,
vo
?.
get
(
"ecpmId"
)
as
String
)
}
Constant
.
CARRIERTYPE_REWARD_FIRST
->
{
SoundPoolUtil
.
getInstance
().
getGoldVoice
()
showRewardAnim
(
188800
,
0
)
}
else
->
{}
}
}
})
}
override
fun
onLoadingFinish
()
{
tv_tips
.
visibility
=
View
.
VISIBLE
triangle
.
visibility
=
View
.
VISIBLE
startAutoPop
()
}
private
fun
showLockDialog
()
{
if
(
mVideoLockDialog
!=
null
&&
mVideoLockDialog
!!
.
isShowing
)
return
val
lockSet
=
if
(
mVedioBean
!!
.
adGiveVedioNum
==
0
)
1
else
mVedioBean
!!
.
adGiveVedioNum
mVideoLockDialog
=
VideoLockDialog
(
this
,
SpanUtils
()
.
append
(
"解锁"
)
.
append
(
" $lockSet "
)
.
setFontSize
(
BubbleUtils
.
sp2px
(
32
))
.
setForegroundColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
red
))
.
append
(
"集剧情"
)
.
create
(),
object
:
DialogListener
()
{
override
fun
onClick
(
dialog
:
Dialog
?,
v
:
View
?)
{
super
.
onClick
(
dialog
,
v
)
dialog
?.
dismiss
()
showAd
(
Constant
.
CARRIERTYPE_VEDIO_UNLOCK
)
}
}
)
mVideoLockDialog
?.
show
()
}
/**
* 新人弹窗
*/
private
fun
showNewcomerDialog
(
rewardCoin
:
Int
)
{
SoundPool2Util
.
getInstance
().
getHongbaoVoice
()
newcomerDialog
=
NewcomerDialog
(
this
,
rewardCoin
,
object
:
DialogListener
()
{
override
fun
onClick
(
dialog
:
Dialog
?,
v
:
View
)
{
when
(
v
.
id
)
{
R
.
id
.
tv_newcomer_time
->
{
newcomerDialog
?.
dismiss
()
super_short_video_view
.
resume
()
showRewardAnim
(
188800
,
0
)
}
}
}
})
newcomerDialog
?.
setAdListener
(
object
:
NewcomerDialog
.
AdListener
{
override
fun
showAd
()
{
newcomerDialog
?.
dismiss
()
showAd
(
Constant
.
CARRIERTYPE_REWARD_FIRST
)
}
})
newcomerDialog
!!
.
show
()
}
}
\ No newline at end of file
video/app/src/main/res/layout/activity_new_tx_video.xml
0 → 100644
View file @
ccc47162
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/container"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"#77090909"
android:orientation=
"vertical"
>
<com.duben.supertheater.video.tx.SuperShortVideoView
android:id=
"@+id/super_short_video_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom"
android:layout_marginStart=
"15dp"
android:layout_marginBottom=
"100dp"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/title_tv"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:ellipsize=
"end"
android:gravity=
"center"
android:maxEms=
"9"
android:maxLines=
"1"
android:textColor=
"#fff"
android:textSize=
"16sp"
android:textStyle=
"bold"
/>
<TextView
android:id=
"@+id/info_tv"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:ellipsize=
"end"
android:maxEms=
"14"
android:maxLines=
"3"
android:textColor=
"#fff"
android:textSize=
"14sp"
/>
</LinearLayout>
<ImageView
android:id=
"@+id/iv_pause"
android:layout_width=
"70dp"
android:layout_height=
"70dp"
android:layout_gravity=
"center"
android:background=
"@drawable/shape_round_trans"
android:src=
"@mipmap/player_pause"
android:visibility=
"gone"
/>
<include
layout=
"@layout/layout_draw_header"
/>
</FrameLayout>
<FrameLayout
android:id=
"@+id/fm_bottom"
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
android:layout_gravity=
"bottom"
android:background=
"@color/black"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/dp_40"
android:layout_gravity=
"center"
android:layout_marginStart=
"20dp"
android:layout_marginEnd=
"20dp"
android:background=
"@drawable/shape_half_trans"
android:gravity=
"center_vertical"
android:orientation=
"horizontal"
android:paddingStart=
"@dimen/dp_10"
android:paddingEnd=
"@dimen/dp_10"
>
<ImageView
android:layout_width=
"20dp"
android:layout_height=
"20dp"
android:src=
"@mipmap/ic_video_epsiode"
/>
<TextView
android:id=
"@+id/episode_tv"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"10dp"
android:layout_weight=
"1"
android:text=
"共100集 已完结 >"
android:textColor=
"@color/white"
/>
<ImageView
android:layout_width=
"20dp"
android:layout_height=
"20dp"
android:src=
"@mipmap/ic_arrow_top"
/>
</LinearLayout>
</FrameLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/cl_reward"
android:layout_width=
"match_parent"
android:layout_height=
"260dp"
android:layout_gravity=
"center"
android:layout_marginStart=
"40dp"
android:layout_marginEnd=
"40dp"
android:background=
"@drawable/shape_half_trans"
android:visibility=
"gone"
>
<TextView
android:id=
"@+id/tv_reward"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"20dp"
android:drawablePadding=
"15dp"
android:text=
"恭喜获得"
android:textColor=
"@color/white"
android:textSize=
"22sp"
app:drawableEndCompat=
"@mipmap/vs_icon_anim_star"
app:drawableStartCompat=
"@mipmap/vs_icon_anim_star"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<ImageView
android:id=
"@+id/iv_cash_reward"
android:layout_width=
"60dp"
android:layout_height=
"60dp"
android:layout_marginTop=
"40dp"
android:layout_marginEnd=
"20dp"
android:src=
"@mipmap/ic_redpkg"
app:layout_constraintEnd_toStartOf=
"@id/iv_gold_reward"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/tv_reward"
/>
<ImageView
android:id=
"@+id/iv_gold_reward"
android:layout_width=
"60dp"
android:layout_height=
"60dp"
android:layout_marginStart=
"20dp"
android:layout_marginTop=
"40dp"
android:src=
"@mipmap/ic_yuanbao"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@id/iv_cash_reward"
app:layout_constraintTop_toBottomOf=
"@id/tv_reward"
/>
<TextView
android:id=
"@+id/tv_cash_reward"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"20dp"
android:text=
"+5"
android:textColor=
"@color/red"
android:textSize=
"30sp"
app:layout_constraintEnd_toEndOf=
"@id/iv_cash_reward"
app:layout_constraintStart_toStartOf=
"@id/iv_cash_reward"
app:layout_constraintTop_toBottomOf=
"@id/iv_cash_reward"
/>
<TextView
android:id=
"@+id/tv_gold_reward"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"20dp"
android:text=
"+5"
android:textColor=
"@color/red"
android:textSize=
"30sp"
app:layout_constraintEnd_toEndOf=
"@id/iv_gold_reward"
app:layout_constraintStart_toStartOf=
"@id/iv_gold_reward"
app:layout_constraintTop_toBottomOf=
"@id/iv_gold_reward"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</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