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
0448737f
Commit
0448737f
authored
Jul 11, 2024
by
mengcuiguang2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
889ed912
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
92 additions
and
69 deletions
+92
-69
VipActivity.kt
...java/com/duben/miaoquplayletu/ui/activitys/VipActivity.kt
+92
-69
No files found.
video/app/src/main/java/com/duben/miaoquplayletu/ui/activitys/VipActivity.kt
View file @
0448737f
...
@@ -40,6 +40,7 @@ import com.jobo.wxpay.WXPay
...
@@ -40,6 +40,7 @@ import com.jobo.wxpay.WXPay
import
com.jobo.wxpay.WXPayInfoImpl
import
com.jobo.wxpay.WXPayInfoImpl
import
com.youth.banner.listener.OnPageChangeListener
import
com.youth.banner.listener.OnPageChangeListener
import
kotlinx.android.synthetic.main.activity_new_vip.*
import
kotlinx.android.synthetic.main.activity_new_vip.*
import
java.net.URLEncoder
/**
/**
...
@@ -48,8 +49,8 @@ import kotlinx.android.synthetic.main.activity_new_vip.*
...
@@ -48,8 +49,8 @@ import kotlinx.android.synthetic.main.activity_new_vip.*
* 时间:2022/12/22 14:48
* 时间:2022/12/22 14:48
*/
*/
class
VipActivity
:
BaseActivity
(),
VipView
,
View
.
OnClickListener
,
class
VipActivity
:
BaseActivity
(),
VipView
,
View
.
OnClickListener
,
VipAdapter
.
OnItemClickListener
,
VipAdapter
.
OnItemClickListener
,
CompoundButton
.
OnCheckedChangeListener
{
CompoundButton
.
OnCheckedChangeListener
{
companion
object
{
companion
object
{
const
val
IS_DETAIL
=
"IS_DETAIL"
//是否从剧集详情页进入
const
val
IS_DETAIL
=
"IS_DETAIL"
//是否从剧集详情页进入
...
@@ -226,6 +227,21 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -226,6 +227,21 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
return
return
}
}
// 自动签约付费
try
{
if
(
paramsBean
.
params
.
isSign
)
{
AppConfig
.
enterAlipay
=
true
openAutoAlipay
(
paramsBean
.
params
.
params
)
return
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
//支付宝小程序
// openAlipayApp()
// sdk支付
alipay
(
paramsBean
)
alipay
(
paramsBean
)
}
}
}
}
...
@@ -262,7 +278,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -262,7 +278,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
if
(
data
.
expireTime
>
0
)
{
if
(
data
.
expireTime
>
0
)
{
readyGo
(
MainActivity
::
class
.
java
)
readyGo
(
MainActivity
::
class
.
java
)
val
activity
=
val
activity
=
ActivityPageManager
.
getInstance
().
getActivity
(
MainActivity
::
class
.
java
)
ActivityPageManager
.
getInstance
().
getActivity
(
MainActivity
::
class
.
java
)
if
(
activity
!=
null
&&
activity
is
MainActivity
)
{
if
(
activity
!=
null
&&
activity
is
MainActivity
)
{
activity
.
clickTab4Layout
()
activity
.
clickTab4Layout
()
}
}
...
@@ -279,7 +295,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -279,7 +295,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
when
(
keyCode
)
{
when
(
keyCode
)
{
KeyEvent
.
KEYCODE_BACK
->
{
KeyEvent
.
KEYCODE_BACK
->
{
if
(
UserManager
.
getInstance
().
newFlag
if
(
UserManager
.
getInstance
().
newFlag
&&
vipList
!=
null
&&
vipList
!!
.
size
>
0
&&
vipList
!=
null
&&
vipList
!!
.
size
>
0
)
{
)
{
vipAdapter
.
setPosition
(
0
)
vipAdapter
.
setPosition
(
0
)
...
@@ -308,7 +324,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -308,7 +324,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
when
(
v
?.
id
)
{
when
(
v
?.
id
)
{
R
.
id
.
ic_vip_quit
->
{
R
.
id
.
ic_vip_quit
->
{
if
(
UserManager
.
getInstance
().
newFlag
&&
if
(
UserManager
.
getInstance
().
newFlag
&&
vipList
!=
null
&&
vipList
!!
.
size
>
0
vipList
!=
null
&&
vipList
!!
.
size
>
0
)
{
)
{
vipAdapter
.
setPosition
(
0
)
vipAdapter
.
setPosition
(
0
)
vipAdapter
.
notifyDataSetChanged
()
vipAdapter
.
notifyDataSetChanged
()
...
@@ -339,13 +355,13 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -339,13 +355,13 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
}
else
{
}
else
{
if
(
TextUtils
.
equals
(
payType
,
WEIXIN_PAY
))
{
if
(
TextUtils
.
equals
(
payType
,
WEIXIN_PAY
))
{
vipPresenter
.
getVipPayParams
(
vipPresenter
.
getVipPayParams
(
"WEIXIN"
,
"WEIXIN"
,
vipBean
.
pid
,
isAliPayInstalled
()
vipBean
.
pid
,
isAliPayInstalled
()
)
)
}
else
if
(
TextUtils
.
equals
(
payType
,
ALIPAY
))
{
}
else
if
(
TextUtils
.
equals
(
payType
,
ALIPAY
))
{
vipPresenter
.
getVipPayParams
(
vipPresenter
.
getVipPayParams
(
"ALIPAY"
,
"ALIPAY"
,
vipBean
.
pid
,
isAliPayInstalled
()
vipBean
.
pid
,
isAliPayInstalled
()
)
)
}
}
}
}
...
@@ -386,7 +402,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -386,7 +402,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
shimmer_text
?.
postDelayed
({
shimmer_text
?.
postDelayed
({
shimmer_text
?.
startShimmerAnimation
()
shimmer_text
?.
startShimmerAnimation
()
breathAnim
=
breathAnim
=
YoYo
.
with
(
Techniques
.
Pulse
).
duration
(
700
).
repeat
(-
1
).
playOn
(
shimmer_text
)
YoYo
.
with
(
Techniques
.
Pulse
).
duration
(
700
).
repeat
(-
1
).
playOn
(
shimmer_text
)
},
200
)
},
200
)
ic_vip_quit
.
setOnClickListener
(
this
)
ic_vip_quit
.
setOnClickListener
(
this
)
...
@@ -442,18 +458,6 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -442,18 +458,6 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
}
}
fun
alipay
(
wxParanBean
:
WxPayParamBean
)
{
fun
alipay
(
wxParanBean
:
WxPayParamBean
)
{
try
{
// 自动签约付费
if
(
wxParanBean
.
params
.
isSign
)
{
AppConfig
.
enterAlipay
=
true
openAutoAlipay
(
wxParanBean
.
params
.
params
)
return
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
//实例化支付宝支付策略
//实例化支付宝支付策略
val
aliPay
=
AliPay
()
val
aliPay
=
AliPay
()
//构造支付宝订单实体。一般都是由服务端直接返回。
//构造支付宝订单实体。一般都是由服务端直接返回。
...
@@ -478,22 +482,22 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -478,22 +482,22 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
vipPresenter
.
queryVipOrder
(
wxParanBean
.
tid
.
toString
(),
false
)
vipPresenter
.
queryVipOrder
(
wxParanBean
.
tid
.
toString
(),
false
)
mainHandler
.
postDelayed
(
mainHandler
.
postDelayed
(
{
{
if
(
isFinishing
)
return
@postDelayed
if
(
isFinishing
)
return
@postDelayed
// 挽留弹窗存在也不弹
// 挽留弹窗存在也不弹
if
(
payYesDialog
!=
null
&&
payYesDialog
!!
.
isShowing
)
return
@postDelayed
if
(
payYesDialog
!=
null
&&
payYesDialog
!!
.
isShowing
)
return
@postDelayed
if
(
vipList
!=
null
&&
vipList
!!
.
size
>
0
)
{
if
(
vipList
!=
null
&&
vipList
!!
.
size
>
0
)
{
val
vipBean
=
vipList
!!
[
vipAdapter
.
getPosition
()]
val
vipBean
=
vipList
!!
[
vipAdapter
.
getPosition
()]
// 0.01
// 0.01
if
(
vipBean
.
trial
!=
0
)
{
if
(
vipBean
.
trial
!=
0
)
{
showPayCancelDialog
()
showPayCancelDialog
()
}
}
}
}
},
},
2000
2000
)
)
}
}
})
})
...
@@ -549,13 +553,13 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -549,13 +553,13 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
val
vipBean
=
vipList
!!
[
vipAdapter
.
getPosition
()]
val
vipBean
=
vipList
!!
[
vipAdapter
.
getPosition
()]
if
(
TextUtils
.
equals
(
payType
,
WEIXIN_PAY
))
{
if
(
TextUtils
.
equals
(
payType
,
WEIXIN_PAY
))
{
vipPresenter
.
getVipPayParams
(
vipPresenter
.
getVipPayParams
(
"WEIXIN"
,
"WEIXIN"
,
vipBean
.
pid
,
isAliPayInstalled
()
vipBean
.
pid
,
isAliPayInstalled
()
)
)
}
else
if
(
TextUtils
.
equals
(
payType
,
ALIPAY
))
{
}
else
if
(
TextUtils
.
equals
(
payType
,
ALIPAY
))
{
vipPresenter
.
getVipPayParams
(
vipPresenter
.
getVipPayParams
(
"ALIPAY"
,
"ALIPAY"
,
vipBean
.
pid
,
isAliPayInstalled
()
vipBean
.
pid
,
isAliPayInstalled
()
)
)
}
}
}
else
{
}
else
{
...
@@ -602,13 +606,13 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -602,13 +606,13 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
R
.
id
.
tv_agreement_next
->
{
R
.
id
.
tv_agreement_next
->
{
if
(
TextUtils
.
equals
(
payType
,
WEIXIN_PAY
))
{
if
(
TextUtils
.
equals
(
payType
,
WEIXIN_PAY
))
{
vipPresenter
.
getVipPayParams
(
vipPresenter
.
getVipPayParams
(
"WEIXIN"
,
"WEIXIN"
,
vipBean
.
pid
,
isAliPayInstalled
()
vipBean
.
pid
,
isAliPayInstalled
()
)
)
}
else
if
(
TextUtils
.
equals
(
payType
,
ALIPAY
))
{
}
else
if
(
TextUtils
.
equals
(
payType
,
ALIPAY
))
{
vipPresenter
.
getVipPayParams
(
vipPresenter
.
getVipPayParams
(
"ALIPAY"
,
"ALIPAY"
,
vipBean
.
pid
,
isAliPayInstalled
()
vipBean
.
pid
,
isAliPayInstalled
()
)
)
}
}
...
@@ -617,10 +621,10 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -617,10 +621,10 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
}
}
})
})
ruleAgreementDialog
!!
.
setText
(
ruleAgreementDialog
!!
.
setText
(
vipBean
.
remarks
,
vipBean
.
remarks
,
vipBean
.
trialFirstDay
,
vipBean
.
trialFirstDay
,
vipBean
.
price
,
vipBean
.
price
,
vipBean
.
title
vipBean
.
title
)
)
ruleAgreementDialog
!!
.
show
()
ruleAgreementDialog
!!
.
show
()
}
else
{
}
else
{
...
@@ -651,13 +655,13 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -651,13 +655,13 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
}
else
{
}
else
{
if
(
TextUtils
.
equals
(
payType
,
WEIXIN_PAY
))
{
if
(
TextUtils
.
equals
(
payType
,
WEIXIN_PAY
))
{
vipPresenter
.
getVipPayParams
(
vipPresenter
.
getVipPayParams
(
"WEIXIN"
,
"WEIXIN"
,
vipBean
.
pid
,
isAliPayInstalled
()
vipBean
.
pid
,
isAliPayInstalled
()
)
)
}
else
if
(
TextUtils
.
equals
(
payType
,
ALIPAY
))
{
}
else
if
(
TextUtils
.
equals
(
payType
,
ALIPAY
))
{
vipPresenter
.
getVipPayParams
(
vipPresenter
.
getVipPayParams
(
"ALIPAY"
,
"ALIPAY"
,
vipBean
.
pid
,
isAliPayInstalled
()
vipBean
.
pid
,
isAliPayInstalled
()
)
)
}
}
}
}
...
@@ -680,7 +684,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -680,7 +684,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
private
fun
setBanner
(
data
:
List
<
VedioBean
>)
{
private
fun
setBanner
(
data
:
List
<
VedioBean
>)
{
mainHandler
.
postDelayed
({
mainHandler
.
postDelayed
({
val
scrollToBottomAnimator
=
val
scrollToBottomAnimator
=
ValueAnimator
.
ofInt
(
0
,
nsv
.
getChildAt
(
0
).
height
-
nsv
.
height
)
ValueAnimator
.
ofInt
(
0
,
nsv
.
getChildAt
(
0
).
height
-
nsv
.
height
)
scrollToBottomAnimator
.
addUpdateListener
{
animator
->
scrollToBottomAnimator
.
addUpdateListener
{
animator
->
val
value
=
animator
.
animatedValue
as
Int
val
value
=
animator
.
animatedValue
as
Int
nsv
.
scrollTo
(
0
,
value
)
nsv
.
scrollTo
(
0
,
value
)
...
@@ -702,23 +706,23 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -702,23 +706,23 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
val
adapter
=
VipBannerAdapter
(
data
)
val
adapter
=
VipBannerAdapter
(
data
)
// 绑定生命周期
// 绑定生命周期
vip_banner
.
addBannerLifecycleObserver
(
this
)
vip_banner
.
addBannerLifecycleObserver
(
this
)
.
setBannerGalleryEffect
(
80
,
15
,
0.8f
)
.
setBannerGalleryEffect
(
80
,
15
,
0.8f
)
.
setAdapter
(
adapter
)
.
setAdapter
(
adapter
)
.
addOnPageChangeListener
(
object
:
OnPageChangeListener
{
.
addOnPageChangeListener
(
object
:
OnPageChangeListener
{
override
fun
onPageScrolled
(
override
fun
onPageScrolled
(
position
:
Int
,
position
:
Int
,
positionOffset
:
Float
,
positionOffset
:
Float
,
positionOffsetPixels
:
Int
positionOffsetPixels
:
Int
)
{
)
{
}
}
override
fun
onPageSelected
(
position
:
Int
)
{
override
fun
onPageSelected
(
position
:
Int
)
{
GlideUtils
.
loadBlurImageView
(
mContext
,
data
[
position
].
coverImage
,
iv_blur
)
GlideUtils
.
loadBlurImageView
(
mContext
,
data
[
position
].
coverImage
,
iv_blur
)
tv_banner_title
.
text
=
String
.
format
(
"《%1s》"
,
data
[
position
].
title
)
tv_banner_title
.
text
=
String
.
format
(
"《%1s》"
,
data
[
position
].
title
)
}
}
override
fun
onPageScrollStateChanged
(
state
:
Int
)
{}
override
fun
onPageScrollStateChanged
(
state
:
Int
)
{}
})
})
GlideUtils
.
loadBlurImageView
(
mContext
,
data
[
0
].
coverImage
,
iv_blur
)
GlideUtils
.
loadBlurImageView
(
mContext
,
data
[
0
].
coverImage
,
iv_blur
)
tv_banner_title
.
text
=
String
.
format
(
"《%1s》"
,
data
[
0
].
title
)
tv_banner_title
.
text
=
String
.
format
(
"《%1s》"
,
data
[
0
].
title
)
}
}
...
@@ -732,12 +736,12 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -732,12 +736,12 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
vipPresenter
.
getVipPayParams
(
vipPresenter
.
getVipPayParams
(
"ALIPAY"
,
"ALIPAY"
,
vipBean
.
pid
,
isAliPayInstalled
()
vipBean
.
pid
,
isAliPayInstalled
()
)
)
}
}
})
})
.
show
()
.
show
()
}
}
fun
startTimer
()
{
fun
startTimer
()
{
...
@@ -764,4 +768,23 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
...
@@ -764,4 +768,23 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
})
})
timer
!!
.
start
()
timer
!!
.
start
()
}
}
/**
* 跳转支付宝小程序
*/
private
fun
openAlipayApp
()
{
try
{
val
alipayAppId
=
"2021004145639480"
val
path
=
"app_uid="
+
UserManager
.
getInstance
().
userID
//这里是传的参数
val
link
=
URLEncoder
.
encode
(
path
,
"UTF-8"
)
//这里是encode传的参数
val
url
=
// "alipays://platformapi/startapp?appId=2021004129666486&page=pages/loading&query=" + link
"alipays://platformapi/startapp?appId="
+
alipayAppId
+
"&page=pages/loading&query="
+
link
val
uri
=
Uri
.
parse
(
url
)
// url为你要链接的地址
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
,
uri
)
startActivity
(
intent
)
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
}
}
\ 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