Commit 3c930a51 authored by jyx's avatar jyx

代码优化

parent f0bcc351
...@@ -99,10 +99,7 @@ class ExpressManager { ...@@ -99,10 +99,7 @@ class ExpressManager {
* 2:如果是信息流自渲染广告,设置广告图片期望的图片宽高 ,不能为0 * 2:如果是信息流自渲染广告,设置广告图片期望的图片宽高 ,不能为0
* 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数) * 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数)
*/ */
.setImageAcceptedSize( .setImageAcceptedSize(UIUtils.getAdWidth(activity).toInt(), 0)
UIUtils.getAdWidth(activity).toInt(),
0
)
.setAdCount(1)//请求广告数量为1到3条 (优先采用平台配置的数量) .setAdCount(1)//请求广告数量为1到3条 (优先采用平台配置的数量)
.build() .build()
...@@ -166,7 +163,6 @@ class ExpressManager { ...@@ -166,7 +163,6 @@ class ExpressManager {
} }
fun getAdView(callback: ExpressAdCallback?) { fun getAdView(callback: ExpressAdCallback?) {
val isOversped = TimeRender.isOverspedMin(adLoadTime, AdManager.AD_NO_SHOWTIME_OUT) val isOversped = TimeRender.isOverspedMin(adLoadTime, AdManager.AD_NO_SHOWTIME_OUT)
// 若上一个广告还在加载中则返回 // 若上一个广告还在加载中则返回
if (isLoadSuccess == 1) { if (isLoadSuccess == 1) {
......
...@@ -4,7 +4,6 @@ import android.annotation.SuppressLint ...@@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.View import android.view.View
import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import com.bytedance.hume.readapk.HumeSDK import com.bytedance.hume.readapk.HumeSDK
......
...@@ -117,16 +117,16 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -117,16 +117,16 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
super_short_video_view.setOnPageChangeListener { super_short_video_view.setOnPageChangeListener {
if (super_short_video_view.isAdPosition(it)) { if (super_short_video_view.isAdPosition(it)) {
fm_bottom.visibility = View.GONE fm_bottom.visibility = View.GONE
ll_lucky.visibility = View.GONE
super_short_video_view.pause() super_short_video_view.pause()
return@setOnPageChangeListener return@setOnPageChangeListener
} }
fm_bottom.visibility = View.VISIBLE fm_bottom.visibility = View.VISIBLE
val readPosition = getRealPosition(it) val readIndex = getRealIndex(it)
showVipCountDialog(readIndex)
showVipCountDialog(readPosition) localShowLucky(readIndex)
localShowLucky(readPosition)
// VIdeoindex -> seeIndex // VIdeoindex -> seeIndex
val data = super_short_video_view.data val data = super_short_video_view.data
...@@ -261,16 +261,12 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -261,16 +261,12 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
return return
} }
val readPosition = getRealPosition(position) val readPosition = getRealPosition(position + 1)
if (readPosition != position) {
super_short_video_view.pause()
}
super_short_video_view.onItemClick(readPosition) super_short_video_view.onItemClick(readPosition)
Handler(Looper.getMainLooper()).postDelayed({ Handler(Looper.getMainLooper()).postDelayed({
showVipCountDialog(readPosition) showVipCountDialog(position + 1)
localShowLucky(readPosition) localShowLucky(position + 1)
}, 300) }, 300)
} }
...@@ -361,10 +357,14 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -361,10 +357,14 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
} }
} }
private fun showVipCountDialog(position: Int) { /**
* @param index 当前下标的集数
*/
private fun showVipCountDialog(index: Int) {
if (isFinishing) return if (isFinishing) return
if (position == 0 || mVedioBean!!.tipMaxIndex == 0 || mVedioBean!!.tipMaxIndex - 1 < position) { if (mVedioBean!!.tipMaxIndex == 0 || index == 1 || mVedioBean!!.tipMaxIndex < index ||
index > mVedioBean!!.unlockIndex) {
return return
} }
...@@ -376,21 +376,25 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -376,21 +376,25 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
} }
private fun localShowLucky(position: Int) { /**
* @param index 当前下标的集数
*/
private fun localShowLucky(index: Int) {
val localLucky = AppPreferencesManager.get() val localLucky = AppPreferencesManager.get()
.getBoolean(Constant.LUCKY_FLAG, false) .getBoolean(Constant.LUCKY_FLAG, false)
val data = super_short_video_view.data
if (UserManager.getInstance().vipFlag) {
ll_lucky.visibility = View.GONE
return
}
if (mVedioBean != null && (isLuckyShow || localLucky)) { if (mVedioBean != null && (isLuckyShow || localLucky)) {
// if (position > mVedioBean!!.unlockIndex - 1) { if (index > mVedioBean!!.unlockIndex) {
if (data[position].itemType != MULTI_ITEM_1 || UserManager.getInstance().vipFlag
|| position > mVedioBean!!.unlockIndex - 1
) {
// 解锁界面 // 解锁界面
ll_lucky.visibility = View.GONE ll_lucky.visibility = View.GONE
} else { } else {
// 超过免费剧 // 超过免费剧
if (position >= mVedioBean!!.freeIndex) { if (index > mVedioBean!!.freeIndex) {
ll_lucky.visibility = View.VISIBLE ll_lucky.visibility = View.VISIBLE
} else { } else {
ll_lucky.visibility = View.GONE ll_lucky.visibility = View.GONE
...@@ -399,14 +403,29 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -399,14 +403,29 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
} }
} }
// 获取当前下标真正代表的集数
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 { private fun getRealPosition(position: Int): Int {
var readPosition = position var readPosition = position
val data = super_short_video_view.data val data = super_short_video_view.data
for (i in 0 until data.size) { if (data != null && data.size > 0) {
if (data[i].itemType == MULTI_ITEM_1) { for (i in 0 until data.size) {
if (data[i].video!!.vedioIndex == position + 1) { if (data[i].itemType == MULTI_ITEM_1) {
readPosition = i if (data[i].video!!.vedioIndex == position) {
break readPosition = i
break
}
} }
} }
} }
......
...@@ -118,6 +118,10 @@ public class SuperShortVideoView extends RelativeLayout { ...@@ -118,6 +118,10 @@ public class SuperShortVideoView extends RelativeLayout {
addAdView(position); addAdView(position);
onPageSelectedMethod(position); onPageSelectedMethod(position);
if (mCurrentPosition == mAdapter.getData().size() - 1) {
mAdapter.notifyItemChanged(mCurrentPosition);
}
break; break;
case RecyclerView.SCROLL_STATE_DRAGGING://拖动 case RecyclerView.SCROLL_STATE_DRAGGING://拖动
break; break;
......
...@@ -18,7 +18,6 @@ import com.mints.helivideo.ad.express.ExpressAdCallback ...@@ -18,7 +18,6 @@ import com.mints.helivideo.ad.express.ExpressAdCallback
import com.mints.helivideo.ad.express.ExpressManager import com.mints.helivideo.ad.express.ExpressManager
import com.mints.helivideo.manager.UserManager import com.mints.helivideo.manager.UserManager
import com.mints.helivideo.mvp.model.* import com.mints.helivideo.mvp.model.*
import com.mints.helivideo.utils.LogUtil
import com.mints.helivideo.utils.UIUtils import com.mints.helivideo.utils.UIUtils
import com.mints.helivideo.video.tx.TXVideoBaseView import com.mints.helivideo.video.tx.TXVideoBaseView
......
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