Commit 3c930a51 authored by jyx's avatar jyx

代码优化

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