Commit e2f9aea3 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 7b02cff9
...@@ -417,6 +417,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, ...@@ -417,6 +417,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
//策略场景类调起支付方法开始支付,以及接收回调。 //策略场景类调起支付方法开始支付,以及接收回调。
RxPay.pay(wxPay, this, wxPayInfoImpl, object : IPayCallback { RxPay.pay(wxPay, this, wxPayInfoImpl, object : IPayCallback {
override fun success() { override fun success() {
AppConfig.showVipAdDialog = false
UserManager.getInstance().vipFlag = true UserManager.getInstance().vipFlag = true
vipPresenter.queryVipOrder(wxParanBean.tid.toString(), true) vipPresenter.queryVipOrder(wxParanBean.tid.toString(), true)
} }
...@@ -454,6 +455,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, ...@@ -454,6 +455,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
//策略场景类调起支付方法开始支付,以及接收回调。 //策略场景类调起支付方法开始支付,以及接收回调。
RxPay.pay(aliPay, this, alipayInfoImpl, object : IPayCallback { RxPay.pay(aliPay, this, alipayInfoImpl, object : IPayCallback {
override fun success() { override fun success() {
AppConfig.showVipAdDialog = false
UserManager.getInstance().vipFlag = true UserManager.getInstance().vipFlag = true
vipPresenter.queryVipOrder(wxParanBean.tid.toString(), true) vipPresenter.queryVipOrder(wxParanBean.tid.toString(), true)
} }
......
...@@ -2,6 +2,8 @@ package com.duben.xixiplaylet.video.csj ...@@ -2,6 +2,8 @@ package com.duben.xixiplaylet.video.csj
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log import android.util.Log
import android.view.View import android.view.View
import android.widget.Button import android.widget.Button
...@@ -42,6 +44,7 @@ import com.duben.library.utils.GlideUtils ...@@ -42,6 +44,7 @@ import com.duben.library.utils.GlideUtils
import com.duben.library.utils.nodoubleclick.AntiShake import com.duben.library.utils.nodoubleclick.AntiShake
import com.duben.xixiplaylet.common.AppConfig import com.duben.xixiplaylet.common.AppConfig
import com.duben.xixiplaylet.mvp.model.VipBean import com.duben.xixiplaylet.mvp.model.VipBean
import com.duben.xixiplaylet.ui.widgets.DetailAdDialog
import kotlinx.android.synthetic.main.drama_activity_api_detail.* 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.iv_lucky_gif
import kotlinx.android.synthetic.main.drama_activity_api_detail.ll_lucky import kotlinx.android.synthetic.main.drama_activity_api_detail.ll_lucky
...@@ -54,7 +57,7 @@ import kotlinx.android.synthetic.main.fragment_main.* ...@@ -54,7 +57,7 @@ import kotlinx.android.synthetic.main.fragment_main.*
* @desc * @desc
*/ */
class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClickListener, class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClickListener,
VideoView, View.OnClickListener { VideoView, View.OnClickListener {
companion object { companion object {
private const val TAG = "DramaApiDetailActivity" private const val TAG = "DramaApiDetailActivity"
...@@ -109,6 +112,10 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -109,6 +112,10 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
private var mVedioBean: VedioBean? = null private var mVedioBean: VedioBean? = null
private var mCurrentIndex = 0 private var mCurrentIndex = 0
private var currentDramaIndex = 0
private var detailAdDialog: DetailAdDialog? = null
override fun getBundleExtras(extras: Bundle?) { override fun getBundleExtras(extras: Bundle?) {
val json = extras?.getString(Constant.VEDIO_BEAN) val json = extras?.getString(Constant.VEDIO_BEAN)
...@@ -183,7 +190,8 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -183,7 +190,8 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
unlock.visibility = View.GONE unlock.visibility = View.GONE
} }
tv_title.text = if (AppConfig.firstVipPrice == 0.0) "解锁后续剧集" else "${AppConfig.firstVipPrice}元解锁后续剧集" tv_title.text =
if (AppConfig.firstVipPrice == 0.0) "解锁后续剧集" else "${AppConfig.firstVipPrice}元解锁后续剧集"
if (mVedioBean!!.collect == 0) { if (mVedioBean!!.collect == 0) {
...@@ -211,7 +219,7 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -211,7 +219,7 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
dpWidget?.let { widget -> dpWidget?.let { widget ->
supportFragmentManager.beginTransaction().replace(R.id.fl_container, widget.fragment) supportFragmentManager.beginTransaction().replace(R.id.fl_container, widget.fragment)
.commit() .commit()
leaveBtn?.setOnClickListener { leaveBtn?.setOnClickListener {
finish() finish()
...@@ -220,6 +228,7 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -220,6 +228,7 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
val bundle = Bundle() val bundle = Bundle()
bundle.putString(VipActivity.VEDIO_ID, mVedioBean!!.vedioId.toString()) bundle.putString(VipActivity.VEDIO_ID, mVedioBean!!.vedioId.toString())
bundle.putString(VipActivity.THIRD_ID, mVedioBean!!.thirdId) bundle.putString(VipActivity.THIRD_ID, mVedioBean!!.thirdId)
bundle.putBoolean(VipActivity.IS_DETAIL, true)
readyGo(VipActivity::class.java, bundle) readyGo(VipActivity::class.java, bundle)
} }
} }
...@@ -230,22 +239,22 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -230,22 +239,22 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
private fun initWidget() { private fun initWidget() {
drama?.let { drama -> drama?.let { drama ->
dpWidget = DPSdk.factory().createDramaDetail( dpWidget = DPSdk.factory().createDramaDetail(
DPWidgetDramaDetailParams.obtain() DPWidgetDramaDetailParams.obtain()
.detailConfig( .detailConfig(
DPDramaDetailConfig.obtain(mode) DPDramaDetailConfig.obtain(mode)
.bottomOffset(20) .bottomOffset(20)
.infiniteScrollEnabled(enableInfiniteScroll) .infiniteScrollEnabled(enableInfiniteScroll)
.hideLeftTopTips(hideLeftTopTips, null) .hideLeftTopTips(hideLeftTopTips, null)
.showCellularToast(true) .showCellularToast(true)
.hideMore(hideMore) .hideMore(hideMore)
.listener(dramaListener) .listener(dramaListener)
.adListener(dramaAdListener) .adListener(dramaAdListener)
.setCustomReport(enableCustomReport) { context, id -> .setCustomReport(enableCustomReport) { context, id ->
// 举报 // 举报
} }
) )
.id(drama.id) .id(drama.id)
.index(drama.index) .index(drama.index)
// .currentDuration(currentDuration) // .currentDuration(currentDuration)
) )
} }
...@@ -266,6 +275,14 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -266,6 +275,14 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
// 重置状态 // 重置状态
resetData() resetData()
} }
// vip界面返回弹出广告弹窗
if (AppConfig.showVipAdDialog && !UserManager.getInstance().vipFlag) {
Handler(Looper.getMainLooper()).postDelayed({
adDialog()
AppConfig.showVipAdDialog = false
}, 300)
}
} }
override fun onPause() { override fun onPause() {
...@@ -377,18 +394,18 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -377,18 +394,18 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
} }
override fun isNeedBlock( override fun isNeedBlock(
drama: DPDrama?, drama: DPDrama?,
index: Int, index: Int,
map: MutableMap<String, Any>? map: MutableMap<String, Any>?
): Boolean { ): Boolean {
drama ?: return false drama ?: return false
Log.d(TAG, "isNeedBlock: index = $index") Log.d(TAG, "isNeedBlock: index = $index")
val unlockIndex = mUnlockIndexMap[drama.id] ?: mInitUnlockIndex val unlockIndex = mUnlockIndexMap[drama.id] ?: mInitUnlockIndex
val hasUnlockList = mHasUnlockIndexMap[drama.id] ?: mutableListOf() val hasUnlockList = mHasUnlockIndexMap[drama.id] ?: mutableListOf()
Log.d( Log.d(
TAG, TAG,
"isNeedBlock: index = $index" + " " + unlockIndex + "s" + drama.id + mHasUnlockIndexMap + "isNeedBlock: index = $index" + " " + unlockIndex + "s" + drama.id + mHasUnlockIndexMap +
" --- " + (index > unlockIndex && hasUnlockList.contains(index).not()) " --- " + (index > unlockIndex && hasUnlockList.contains(index).not())
) )
info_tv.text = String.format("第%d集", index) info_tv.text = String.format("第%d集", index)
...@@ -411,30 +428,31 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -411,30 +428,31 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
} }
override fun showAdIfNeeded( override fun showAdIfNeeded(
drama: DPDrama?, drama: DPDrama?,
callback: Callback?, callback: Callback?,
map: MutableMap<String, Any>? map: MutableMap<String, Any>?
) { ) {
super.showAdIfNeeded(drama, callback, map) super.showAdIfNeeded(drama, callback, map)
drama ?: return drama ?: return
Log.d(TAG, "showAdIfNeeded:" + map?.toString()) Log.d(TAG, "showAdIfNeeded:" + map?.toString())
blockView?.visibility = View.VISIBLE blockView?.visibility = View.VISIBLE
unlockCallback = callback unlockCallback = callback
currentDramaIndex = dpWidget?.currentDramaIndex!!
// 展示广告 // 展示广告
if (!UserManager.getInstance().newFlag) { if (!UserManager.getInstance().newFlag) {
tv_title.text = String.format( tv_title.text = String.format(
"解锁%s·第%d-%d集", "解锁%s·第%d-%d集",
drama.title, drama.title,
mInitUnlockIndex + 1, mInitUnlockIndex + 1,
mInitUnlockIndex + lockSet mInitUnlockIndex + lockSet
) )
} else { } else {
tv_title.text = if (AppConfig.firstVipPrice == 0.0) "解锁后续剧集" else "${AppConfig.firstVipPrice}元解锁后续剧集" tv_title.text =
if (AppConfig.firstVipPrice == 0.0) "解锁后续剧集" else "${AppConfig.firstVipPrice}元解锁后续剧集"
} }
...@@ -444,18 +462,18 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -444,18 +462,18 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
unlockBtn?.setOnClickListener { unlockBtn?.setOnClickListener {
val carrierType = Constant.CARRIERTYPE_CSJ_VEDIO val carrierType = Constant.CARRIERTYPE_CSJ_VEDIO
AdManager.instance.showAd(this@DramaApiDetailActivity, carrierType, AdManager.instance.showAd(this@DramaApiDetailActivity, carrierType,
object : AdStatusListener { object : AdStatusListener {
var canFail = false var canFail = false
override fun adSuccess() { override fun adSuccess() {
canFail = true canFail = true
} }
override fun adFail() { override fun adFail() {
if (canFail) return if (canFail) return
NoPreAdManager.loadVideoAd( NoPreAdManager.loadVideoAd(
this@DramaApiDetailActivity, this@DramaApiDetailActivity,
carrierType, object : AdStatusListener { carrierType, object : AdStatusListener {
override fun adFail() { override fun adFail() {
showToast("广告太火爆了,请稍候再试") showToast("广告太火爆了,请稍候再试")
} }
...@@ -476,14 +494,14 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -476,14 +494,14 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
// 更新解锁集数 // 更新解锁集数
for (i in 1 until lockSet) { for (i in 1 until lockSet) {
val hasUnlockList: MutableList<Int> = val hasUnlockList: MutableList<Int> =
mHasUnlockIndexMap[drama.id] mHasUnlockIndexMap[drama.id]
?: mutableListOf() ?: mutableListOf()
hasUnlockList.add(widget.currentDramaIndex + i) hasUnlockList.add(widget.currentDramaIndex + i)
mHasUnlockIndexMap[drama.id] = hasUnlockList mHasUnlockIndexMap[drama.id] = hasUnlockList
} }
mInitUnlockIndex = mUnlockIndexMap[drama.id]!! + lockSet mInitUnlockIndex = mUnlockIndexMap[drama.id]!! + lockSet
mUnlockIndexMap[drama.id] = mUnlockIndexMap[drama.id] =
mUnlockIndexMap[drama.id]!! + lockSet mUnlockIndexMap[drama.id]!! + lockSet
mVedioBean!!.unlockIndex = mInitUnlockIndex mVedioBean!!.unlockIndex = mInitUnlockIndex
// 播放当前集 // 播放当前集
...@@ -495,37 +513,37 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -495,37 +513,37 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
callback?.onDramaRewardArrived() // 解锁当前集 callback?.onDramaRewardArrived() // 解锁当前集
} }
}) })
} }
override fun adClose(vo: HashMap<String, Any>?) { override fun adClose(vo: HashMap<String, Any>?) {
vo?.let { vo?.let {
if (isThirdId) { if (isThirdId) {
it["thirdId"] = "" + mVedioBean!!.thirdId it["thirdId"] = "" + mVedioBean!!.thirdId
} else { } else {
it["vedioId"] = "" + mVedioBean!!.vedioId it["vedioId"] = "" + mVedioBean!!.vedioId
}
videoPresenter.unlock(it)
} }
videoPresenter.unlock(it)
}
// 更新解锁集数 // 更新解锁集数
for (i in 1 until lockSet) { for (i in 1 until lockSet) {
val hasUnlockList: MutableList<Int> = val hasUnlockList: MutableList<Int> =
mHasUnlockIndexMap[drama.id] ?: mutableListOf() mHasUnlockIndexMap[drama.id] ?: mutableListOf()
hasUnlockList.add(widget.currentDramaIndex + i) hasUnlockList.add(widget.currentDramaIndex + i)
mHasUnlockIndexMap[drama.id] = hasUnlockList 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() // 解锁当前集
} }
}) 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() // 解锁当前集
}
})
} }
} }
} }
...@@ -633,7 +651,7 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -633,7 +651,7 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
override fun showTurnSuc(data: NineShowBean) { override fun showTurnSuc(data: NineShowBean) {
AppPreferencesManager.get() AppPreferencesManager.get()
.put(Constant.LUCKY_FLAG, data.isShow) .put(Constant.LUCKY_FLAG, data.isShow)
isLuckyShow = data.isShow isLuckyShow = data.isShow
if (isLuckyShow) { if (isLuckyShow) {
val complete = data.complete val complete = data.complete
...@@ -641,16 +659,16 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -641,16 +659,16 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
if (complete >= need) { if (complete >= need) {
tv_lucky_status.text = SpanUtils() tv_lucky_status.text = SpanUtils()
.append("可领取") .append("可领取")
.setForegroundColor(resources.getColor(R.color.apk_uninstalled)) .setForegroundColor(resources.getColor(R.color.apk_uninstalled))
.create() .create()
} else { } else {
tv_lucky_status.text = SpanUtils() tv_lucky_status.text = SpanUtils()
.append(complete.toString()) .append(complete.toString())
.setForegroundColor(resources.getColor(R.color.red)) .setForegroundColor(resources.getColor(R.color.red))
.append("/") .append("/")
.append(need.toString()) .append(need.toString())
.create() .create()
} }
// 匹配 // 匹配
...@@ -672,24 +690,24 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -672,24 +690,24 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
private fun playCollectAnim(view: LottieAnimationView) { private fun playCollectAnim(view: LottieAnimationView) {
val lottieDrawable = LottieDrawable() val lottieDrawable = LottieDrawable()
LottieCompositionFactory.fromAsset(context, "home_collect.json") LottieCompositionFactory.fromAsset(context, "home_collect.json")
.addListener { result: LottieComposition? -> .addListener { result: LottieComposition? ->
lottieDrawable.setImagesAssetsFolder("images/") lottieDrawable.setImagesAssetsFolder("images/")
lottieDrawable.composition = result lottieDrawable.composition = result
lottieDrawable.loop(false) lottieDrawable.loop(false)
lottieDrawable.playAnimation() lottieDrawable.playAnimation()
} }
view.setImageDrawable(lottieDrawable) view.setImageDrawable(lottieDrawable)
} }
private fun playCancelCollectAnim(view: LottieAnimationView) { private fun playCancelCollectAnim(view: LottieAnimationView) {
val lottieDrawable = LottieDrawable() val lottieDrawable = LottieDrawable()
LottieCompositionFactory.fromAsset(context, "home_cancel_collect.json") LottieCompositionFactory.fromAsset(context, "home_cancel_collect.json")
.addListener { result: LottieComposition? -> .addListener { result: LottieComposition? ->
lottieDrawable.setImagesAssetsFolder("images/") lottieDrawable.setImagesAssetsFolder("images/")
lottieDrawable.composition = result lottieDrawable.composition = result
lottieDrawable.loop(false) lottieDrawable.loop(false)
lottieDrawable.playAnimation() lottieDrawable.playAnimation()
} }
view.setImageDrawable(lottieDrawable) view.setImageDrawable(lottieDrawable)
} }
...@@ -722,15 +740,15 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -722,15 +740,15 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
private fun showVipCountDialog(position: Int) { private fun showVipCountDialog(position: Int) {
if (position == 0 || mVedioBean!!.tipMaxIndex == 0 || mVedioBean!!.tipMaxIndex - 1 < position) return if (position == 0 || mVedioBean!!.tipMaxIndex == 0 || mVedioBean!!.tipMaxIndex - 1 < position) return
VipCountDialog(this, mVedioBean!!, tipList) VipCountDialog(this, mVedioBean!!, tipList)
.setOnDialogDismiss(object : VipCountDialog.OnDialogDismiss { .setOnDialogDismiss(object : VipCountDialog.OnDialogDismiss {
override fun onDialogDismiss() {} override fun onDialogDismiss() {}
}) })
.show() .show()
} }
private fun localShowLucky(position: Int) { private fun localShowLucky(position: Int) {
val localLucky = AppPreferencesManager.get() val localLucky = AppPreferencesManager.get()
.getBoolean(Constant.LUCKY_FLAG, false) .getBoolean(Constant.LUCKY_FLAG, false)
if (mVedioBean != null && (isLuckyShow || localLucky)) { if (mVedioBean != null && (isLuckyShow || localLucky)) {
if (position > mVedioBean!!.unlockIndex - 1) { if (position > mVedioBean!!.unlockIndex - 1) {
// 解锁界面 // 解锁界面
...@@ -739,7 +757,13 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -739,7 +757,13 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
// 超过免费剧 // 超过免费剧
if (position >= mVedioBean!!.freeIndex) { if (position >= mVedioBean!!.freeIndex) {
ll_lucky.visibility = View.VISIBLE ll_lucky.visibility = View.VISIBLE
context?.let { GlideUtils.loadRoundImageViewGif(it, R.drawable.ic_nine, iv_lucky_gif) } context?.let {
GlideUtils.loadRoundImageViewGif(
it,
R.drawable.ic_nine,
iv_lucky_gif
)
}
} else { } else {
ll_lucky.visibility = View.GONE ll_lucky.visibility = View.GONE
} }
...@@ -750,20 +774,20 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -750,20 +774,20 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
private fun setCollectImage(view: LottieAnimationView) { private fun setCollectImage(view: LottieAnimationView) {
val lottieDrawable = LottieDrawable() val lottieDrawable = LottieDrawable()
LottieCompositionFactory.fromAsset(context, "home_collect.json") LottieCompositionFactory.fromAsset(context, "home_collect.json")
.addListener { result: LottieComposition? -> .addListener { result: LottieComposition? ->
lottieDrawable.setImagesAssetsFolder("images/") lottieDrawable.setImagesAssetsFolder("images/")
lottieDrawable.composition = result lottieDrawable.composition = result
} }
view.setImageDrawable(lottieDrawable) view.setImageDrawable(lottieDrawable)
} }
private fun setCancelCollectImage(view: LottieAnimationView) { private fun setCancelCollectImage(view: LottieAnimationView) {
val lottieDrawable = LottieDrawable() val lottieDrawable = LottieDrawable()
LottieCompositionFactory.fromAsset(context, "home_cancel_collect.json") LottieCompositionFactory.fromAsset(context, "home_cancel_collect.json")
.addListener { result: LottieComposition? -> .addListener { result: LottieComposition? ->
lottieDrawable.setImagesAssetsFolder("images/") lottieDrawable.setImagesAssetsFolder("images/")
lottieDrawable.composition = result lottieDrawable.composition = result
} }
view.setImageDrawable(lottieDrawable) view.setImageDrawable(lottieDrawable)
} }
...@@ -837,4 +861,106 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -837,4 +861,106 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
}) })
} }
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
...@@ -94,7 +94,7 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -94,7 +94,7 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
} }
// vip界面返回弹出广告弹窗 // vip界面返回弹出广告弹窗
if (AppConfig.showVipAdDialog) { if (AppConfig.showVipAdDialog && !UserManager.getInstance().vipFlag) {
Handler(Looper.getMainLooper()).postDelayed({ Handler(Looper.getMainLooper()).postDelayed({
adDialog() adDialog()
AppConfig.showVipAdDialog = false AppConfig.showVipAdDialog = false
......
...@@ -2,6 +2,8 @@ package com.duben.xixiplaylet.video.tx.newrecommend ...@@ -2,6 +2,8 @@ package com.duben.xixiplaylet.video.tx.newrecommend
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.View import android.view.View
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import com.google.gson.Gson import com.google.gson.Gson
...@@ -27,6 +29,7 @@ import com.duben.xixiplaylet.video.tx.VideoModel ...@@ -27,6 +29,7 @@ import com.duben.xixiplaylet.video.tx.VideoModel
import com.duben.library.utils.GlideUtils import com.duben.library.utils.GlideUtils
import com.duben.library.utils.nodoubleclick.AntiShake import com.duben.library.utils.nodoubleclick.AntiShake
import com.duben.xixiplaylet.common.AppConfig import com.duben.xixiplaylet.common.AppConfig
import com.duben.xixiplaylet.ui.widgets.DetailAdDialog
import com.duben.xixiplaylet.ui.widgets.DialogListener import com.duben.xixiplaylet.ui.widgets.DialogListener
import com.duben.xixiplaylet.ui.widgets.VideoEpisodeDialog import com.duben.xixiplaylet.ui.widgets.VideoEpisodeDialog
import kotlinx.android.synthetic.main.activity_new_tx_video.* import kotlinx.android.synthetic.main.activity_new_tx_video.*
...@@ -42,6 +45,7 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -42,6 +45,7 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
private var mAllData = arrayListOf<VedioEpisodeBean>() private var mAllData = arrayListOf<VedioEpisodeBean>()
private var dialog: VideoEpisodeDialog? = null private var dialog: VideoEpisodeDialog? = null
private var detailAdDialog: DetailAdDialog? = null
private val videoPresenter by lazy { VideoPresenter() } private val videoPresenter by lazy { VideoPresenter() }
...@@ -81,6 +85,14 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -81,6 +85,14 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
playIndex = new_super_short_video_view.currentPosition playIndex = new_super_short_video_view.currentPosition
mVedioBean?.let { videoPresenter.getIndexList("" + it.vedioId) } mVedioBean?.let { videoPresenter.getIndexList("" + it.vedioId) }
} }
// vip界面返回弹出广告弹窗
if (AppConfig.showVipAdDialog && !UserManager.getInstance().vipFlag) {
Handler(Looper.getMainLooper()).postDelayed({
adDialog()
AppConfig.showVipAdDialog = false
}, 300)
}
} }
override fun onPause() { override fun onPause() {
...@@ -285,37 +297,7 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -285,37 +297,7 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
} }
R.id.unlock -> { R.id.unlock -> {
// 看广告解锁 // 看广告解锁
val carrierType = Constant.CARRIERTYPE_TX_VEDIO showAd()
AdManager.instance.showAd(this, carrierType,
object : AdStatusListener {
var canFail = false
override fun adSuccess() {
canFail = true
}
override fun adFail() {
if (canFail) return
NoPreAdManager.loadVideoAd(
this@NewTxVideoActivity,
carrierType, object : AdStatusListener {
override fun adFail() {
showToast("广告太火爆了,请稍候再试")
}
override fun adSuccess() {
}
override fun adClose(vo: HashMap<String, Any>?) {
updateEpisodeData(position, vo)
}
})
}
override fun adClose(vo: HashMap<String, Any>?) {
updateEpisodeData(position, vo)
}
})
} }
R.id.vip -> { R.id.vip -> {
// 开通VIP // 开通VIP
...@@ -323,6 +305,7 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -323,6 +305,7 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
bundle.putString(VipActivity.VEDIO_ID, mVedioBean!!.vedioId.toString()) bundle.putString(VipActivity.VEDIO_ID, mVedioBean!!.vedioId.toString())
bundle.putString(VipActivity.THIRD_ID, mVedioBean!!.thirdId) bundle.putString(VipActivity.THIRD_ID, mVedioBean!!.thirdId)
bundle.putBoolean(VipActivity.IS_RECOMMEND, true) bundle.putBoolean(VipActivity.IS_RECOMMEND, true)
bundle.putBoolean(VipActivity.IS_DETAIL, true)
readyGo(VipActivity::class.java, bundle) readyGo(VipActivity::class.java, bundle)
} }
...@@ -330,6 +313,40 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -330,6 +313,40 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
} }
} }
private fun showAd() {
val carrierType = Constant.CARRIERTYPE_TX_VEDIO
AdManager.instance.showAd(this, carrierType,
object : AdStatusListener {
var canFail = false
override fun adSuccess() {
canFail = true
}
override fun adFail() {
if (canFail) return
NoPreAdManager.loadVideoAd(
this@NewTxVideoActivity,
carrierType, object : AdStatusListener {
override fun adFail() {
showToast("广告太火爆了,请稍候再试")
}
override fun adSuccess() {
}
override fun adClose(vo: HashMap<String, Any>?) {
updateEpisodeData(position, vo)
}
})
}
override fun adClose(vo: HashMap<String, Any>?) {
updateEpisodeData(position, vo)
}
})
}
private fun updateEpisodeData(position: Int, vo: HashMap<String, Any>?) { private fun updateEpisodeData(position: Int, vo: HashMap<String, Any>?) {
vo?.let { vo?.let {
// 解锁剧集 // 解锁剧集
...@@ -358,4 +375,20 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -358,4 +375,20 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
} }
return readPosition return readPosition
} }
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 -> {
showAd()
detailAdDialog?.dismiss()
}
}
}
})
detailAdDialog!!.show()
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment