Commit f8b20b46 authored by jyx's avatar jyx

代码优化

parent ba5db096
...@@ -74,7 +74,7 @@ object GlideUtils { ...@@ -74,7 +74,7 @@ object GlideUtils {
Glide.with(mContext!!).load(path).apply( Glide.with(mContext!!).load(path).apply(
RequestOptions().transform( RequestOptions().transform(
CenterCrop(), CenterCrop(),
RoundedCorners(BubbleUtils.dp2px(20)) RoundedCorners(BubbleUtils.dp2px(10))
) )
).dontAnimate().into(mImageView!!) ).dontAnimate().into(mImageView!!)
} }
......
...@@ -5,6 +5,8 @@ object Constant { ...@@ -5,6 +5,8 @@ object Constant {
const val PAGE_SIZE = 12 const val PAGE_SIZE = 12
const val LOCAL_VEDIO = "LOCAL_VEDIO" const val LOCAL_VEDIO = "LOCAL_VEDIO"
const val VEDIO_BEAN = "VEDIO_BEAN" const val VEDIO_BEAN = "VEDIO_BEAN"
const val VEDIO_NEXT = "VEDIO_NEXT"
const val VEDIO_THIRD = "VEDIO_THIRD"
/** /**
* 首次弹出权限声明 * 首次弹出权限声明
......
...@@ -82,11 +82,18 @@ object LocalVedioManager { ...@@ -82,11 +82,18 @@ object LocalVedioManager {
/** /**
* 根据类型跳转对应视频详情页 [自有或穿山甲] * 根据类型跳转对应视频详情页 [自有或穿山甲]
*/ */
fun startVedioDetailActivityForType(activity: Activity, data: VedioBean?) { fun startVedioDetailActivityForType(
activity: Activity,
data: VedioBean?,
isPlayNext: Boolean = false,
isThirdId: Boolean = false
) {
if (data?.createType == 1) { if (data?.createType == 1) {
//自有短剧 //自有短剧
val bundle = Bundle() val bundle = Bundle()
bundle.putString(Constant.VEDIO_BEAN, JsonUtil.toJson(data)) bundle.putString(Constant.VEDIO_BEAN, JsonUtil.toJson(data))
bundle.putBoolean(Constant.VEDIO_NEXT, isPlayNext)
bundle.putBoolean(Constant.VEDIO_THIRD, isThirdId)
readyGo(activity, VideoActivity::class.java, bundle) readyGo(activity, VideoActivity::class.java, bundle)
} else { } else {
requestDrama(activity, data) requestDrama(activity, data)
......
...@@ -23,6 +23,24 @@ public class VedioBean implements Serializable { ...@@ -23,6 +23,24 @@ public class VedioBean implements Serializable {
private int vedioId;// 视频id,服务器标识 private int vedioId;// 视频id,服务器标识
private String hot;// 播放量 private String hot;// 播放量
private int adGiveVedioNum;// 广告解锁数量 private int adGiveVedioNum;// 广告解锁数量
private String recommendUrl;// 推荐视频地址
private int recommendIndex;// 推荐视频第几集
public String getRecommendUrl() {
return recommendUrl;
}
public void setRecommendUrl(String recommendUrl) {
this.recommendUrl = recommendUrl;
}
public int getRecommendIndex() {
return recommendIndex;
}
public void setRecommendIndex(int recommendIndex) {
this.recommendIndex = recommendIndex;
}
public int getAdGiveVedioNum() { public int getAdGiveVedioNum() {
return adGiveVedioNum; return adGiveVedioNum;
......
...@@ -11,11 +11,9 @@ import java.util.HashMap ...@@ -11,11 +11,9 @@ import java.util.HashMap
class FollowPresenter : BasePresenter<FollowView>() { class FollowPresenter : BasePresenter<FollowView>() {
fun getCollectList(videoId: String) { fun getCollectList() {
val vo = HashMap<String, Any>()
vo["videoId"] = videoId
AppHttpManager.getInstance(loanApplication) AppHttpManager.getInstance(loanApplication)
.call(loanService.collectList(vo), .call(loanService.collectList(),
object : BaseSubscriber<BaseResponse<BannerList>>() { object : BaseSubscriber<BaseResponse<BannerList>>() {
override fun onCompleted() { override fun onCompleted() {
if (isLinkView) return if (isLinkView) return
......
...@@ -4,12 +4,50 @@ import com.google.gson.JsonObject ...@@ -4,12 +4,50 @@ import com.google.gson.JsonObject
import com.mints.library.net.neterror.BaseSubscriber import com.mints.library.net.neterror.BaseSubscriber
import com.mints.library.net.neterror.Throwable import com.mints.library.net.neterror.Throwable
import com.mints.wisdomclean.manager.AppHttpManager import com.mints.wisdomclean.manager.AppHttpManager
import com.mints.wisdomclean.mvp.model.BannerList
import com.mints.wisdomclean.mvp.model.BaseResponse import com.mints.wisdomclean.mvp.model.BaseResponse
import com.mints.wisdomclean.mvp.views.RecommendView import com.mints.wisdomclean.mvp.views.RecommendView
import java.util.HashMap import java.util.HashMap
class RecommendPresenter : BasePresenter<RecommendView>() { class RecommendPresenter : BasePresenter<RecommendView>() {
fun autoList() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.autoList(), object : BaseSubscriber<BaseResponse<BannerList>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<BannerList>) {
if (isLinkView) return
view.hideLoading()
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> view.autoListSuc(baseResponse.data)
else -> {
view.autoListFail()
view.showToast(message)
}
}
}
override fun onError(e: Throwable?) {
if (isLinkView) return
view.hideLoading()
view.showToast(e?.message)
view.autoListFail()
}
})
}
fun collect(videoId: String) { fun collect(videoId: String) {
val vo = HashMap<String, Any>() val vo = HashMap<String, Any>()
vo["videoId"] = videoId vo["videoId"] = videoId
......
...@@ -11,9 +11,13 @@ import java.util.HashMap ...@@ -11,9 +11,13 @@ import java.util.HashMap
class VideoPresenter : BasePresenter<VideoView>() { class VideoPresenter : BasePresenter<VideoView>() {
fun getIndexList(videoId: String) { fun getIndexList(thirdId: String, csj: Boolean = false) {
val vo = HashMap<String, Any>() val vo = HashMap<String, Any>()
vo["vedioId"] = videoId if (csj) {
vo["thirdId"] = thirdId
} else {
vo["vedioId"] = thirdId
}
AppHttpManager.getInstance(loanApplication) AppHttpManager.getInstance(loanApplication)
.call(loanService.getIndexList(vo), .call(loanService.getIndexList(vo),
object : BaseSubscriber<BaseResponse<IndexList>>() { object : BaseSubscriber<BaseResponse<IndexList>>() {
......
package com.mints.wisdomclean.mvp.views package com.mints.wisdomclean.mvp.views
import com.mints.wisdomclean.mvp.model.BannerList
interface RecommendView : BaseView { interface RecommendView : BaseView {
...@@ -9,4 +11,8 @@ interface RecommendView : BaseView { ...@@ -9,4 +11,8 @@ interface RecommendView : BaseView {
fun cancelCollectSuc() fun cancelCollectSuc()
fun cancelCollectFail() fun cancelCollectFail()
fun autoListSuc(list: BannerList)
fun autoListFail()
} }
\ No newline at end of file
...@@ -232,7 +232,7 @@ public interface LoanService { ...@@ -232,7 +232,7 @@ public interface LoanService {
* @return * @return
*/ */
@POST("api/vedio/collectList") @POST("api/vedio/collectList")
Observable<BaseResponse<BannerList>> collectList(@Body Map<String, Object> vo); Observable<BaseResponse<BannerList>> collectList();
/** /**
* 最新一条记录 * 最新一条记录
...@@ -256,6 +256,12 @@ public interface LoanService { ...@@ -256,6 +256,12 @@ public interface LoanService {
@POST("api/vedio/reportIndex") @POST("api/vedio/reportIndex")
Observable<BaseResponse<Object>> reportIndex(@Body Map<String, Object> vo); Observable<BaseResponse<Object>> reportIndex(@Body Map<String, Object> vo);
/**
* 推荐
*/
@POST("api/vedio/autoList")
Observable<BaseResponse<BannerList>> autoList();
/** /**
* 默认http工厂 * 默认http工厂
*/ */
......
...@@ -301,6 +301,12 @@ class MainActivity : BaseActivity(), View.OnClickListener { ...@@ -301,6 +301,12 @@ class MainActivity : BaseActivity(), View.OnClickListener {
} }
} }
fun showEditView(show: Boolean) {
recommendFragment?.let {
(it as RecommendFragment).showEditView(show)
}
}
fun showEdit(isEdit: Boolean) { fun showEdit(isEdit: Boolean) {
if (isEdit) { if (isEdit) {
ll_edit.visibility = View.VISIBLE ll_edit.visibility = View.VISIBLE
......
...@@ -22,10 +22,10 @@ class FollowAdapter(var activity: Activity) : ...@@ -22,10 +22,10 @@ class FollowAdapter(var activity: Activity) :
override fun convert(holder: BaseViewHolder, item: VedioBean) { override fun convert(holder: BaseViewHolder, item: VedioBean) {
holder.getView<View>(R.id.fm_mask).visibility = if (showEdit) View.VISIBLE else View.GONE holder.getView<View>(R.id.fm_mask).visibility = if (showEdit) View.VISIBLE else View.GONE
holder.getView<TextView>(R.id.title_tv).text = item.title holder.getView<TextView>(R.id.title_tv).text = item.title
holder.getView<TextView>(R.id.info_tv).text = item.scriptName holder.getView<TextView>(R.id.info_tv).text = item.vedioDesc
holder.getView<TextView>(R.id.complete_tv).text = holder.getView<TextView>(R.id.complete_tv).text =
if (item.completeStatus == 0) "已完结" else "更新中" if (item.completeStatus == 0) "已完结" else "更新中"
GlideUtils.loadImageViewNoAnim(context, item.coverImage, holder.getView(R.id.image_iv)) GlideUtils.loadImageViewNoAnim2(context, item.coverImage, holder.getView(R.id.image_iv))
} }
// 设置编辑状态 // 设置编辑状态
......
...@@ -6,6 +6,7 @@ import android.view.View ...@@ -6,6 +6,7 @@ import android.view.View
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import com.mints.wisdomclean.R import com.mints.wisdomclean.R
import com.mints.wisdomclean.manager.LocalVedioManager
import com.mints.wisdomclean.mvp.model.BannerList import com.mints.wisdomclean.mvp.model.BannerList
import com.mints.wisdomclean.mvp.model.VedioBean import com.mints.wisdomclean.mvp.model.VedioBean
import com.mints.wisdomclean.mvp.presenters.FollowPresenter import com.mints.wisdomclean.mvp.presenters.FollowPresenter
...@@ -38,6 +39,7 @@ class FollowVideoFragment : BaseFragment(), FollowView { ...@@ -38,6 +39,7 @@ class FollowVideoFragment : BaseFragment(), FollowView {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
followPresenter.getCollectList()
} }
override fun initViewsAndEvents() { override fun initViewsAndEvents() {
...@@ -59,6 +61,12 @@ class FollowVideoFragment : BaseFragment(), FollowView { ...@@ -59,6 +61,12 @@ class FollowVideoFragment : BaseFragment(), FollowView {
followAdapter = FollowAdapter(requireActivity()) followAdapter = FollowAdapter(requireActivity())
followAdapter.setEmptyView(emptyView) followAdapter.setEmptyView(emptyView)
followAdapter.setNewInstance(datas) followAdapter.setNewInstance(datas)
followAdapter.setOnItemClickListener { adapter, view, position ->
LocalVedioManager.startVedioDetailActivityForType(
requireActivity(),
datas[position]
)
}
rv_follow.adapter = followAdapter rv_follow.adapter = followAdapter
} }
...@@ -75,15 +83,25 @@ class FollowVideoFragment : BaseFragment(), FollowView { ...@@ -75,15 +83,25 @@ class FollowVideoFragment : BaseFragment(), FollowView {
return datas.isEmpty() return datas.isEmpty()
} }
private fun showEditView(show: Boolean) {
(requireActivity() as MainActivity).showEditView(show)
}
override fun getCollectListSuc(bannerList: BannerList) { override fun getCollectListSuc(bannerList: BannerList) {
if (bannerList.list.isNotEmpty()) { if (bannerList.list.isNotEmpty()) {
datas.clear()
datas.addAll(bannerList.list) datas.addAll(bannerList.list)
followAdapter.setNewInstance(datas) followAdapter.setNewInstance(datas)
followAdapter.notifyDataSetChanged()
showEditView(true)
} else {
showEditView(false)
} }
} }
override fun getCollectListFail() { override fun getCollectListFail() {
showEditView(false)
} }
override fun cancelCollectSuc() { override fun cancelCollectSuc() {
......
...@@ -10,9 +10,11 @@ import com.google.android.material.tabs.TabLayoutMediator ...@@ -10,9 +10,11 @@ import com.google.android.material.tabs.TabLayoutMediator
import com.mints.wisdomclean.R import com.mints.wisdomclean.R
import com.mints.wisdomclean.common.AppConfig import com.mints.wisdomclean.common.AppConfig
import com.mints.wisdomclean.common.Constant import com.mints.wisdomclean.common.Constant
import com.mints.wisdomclean.manager.UserManager
import com.mints.wisdomclean.ui.activitys.MainActivity import com.mints.wisdomclean.ui.activitys.MainActivity
import com.mints.wisdomclean.ui.adapter.RecommendPageAdapter import com.mints.wisdomclean.ui.adapter.RecommendPageAdapter
import com.mints.wisdomclean.ui.fragment.base.BaseFragment import com.mints.wisdomclean.ui.fragment.base.BaseFragment
import com.mints.wisdomclean.video.DramaTabFragment
import kotlinx.android.synthetic.main.fragment_recommend.* import kotlinx.android.synthetic.main.fragment_recommend.*
/** /**
...@@ -22,6 +24,8 @@ import kotlinx.android.synthetic.main.fragment_recommend.* ...@@ -22,6 +24,8 @@ import kotlinx.android.synthetic.main.fragment_recommend.*
*/ */
class RecommendFragment : BaseFragment(), View.OnClickListener { class RecommendFragment : BaseFragment(), View.OnClickListener {
private var mCurrentNewFlag = false
private var mSelectTabIndex = -1 private var mSelectTabIndex = -1
private val tabsData = mutableListOf<String>() private val tabsData = mutableListOf<String>()
private val fragments = mutableListOf<Fragment>() private val fragments = mutableListOf<Fragment>()
...@@ -37,11 +41,18 @@ class RecommendFragment : BaseFragment(), View.OnClickListener { ...@@ -37,11 +41,18 @@ class RecommendFragment : BaseFragment(), View.OnClickListener {
override fun getContentViewLayoutID() = R.layout.fragment_recommend override fun getContentViewLayoutID() = R.layout.fragment_recommend
private fun initVp2() { private fun initVp2() {
mCurrentNewFlag = UserManager.getInstance().newFlag
tabsData.add("追剧") tabsData.add("追剧")
tabsData.add("推荐") tabsData.add("推荐")
fragments.add(FollowVideoFragment.newInstance()) if (mCurrentNewFlag) {
fragments.add(WatchVideoFragment.newInstance()) fragments.add(FollowVideoFragment.newInstance())
fragments.add(WatchVideoFragment.newInstance())
} else {
fragments.add(FollowVideoFragment.newInstance())
fragments.add(DramaTabFragment())
}
vpAdapter = RecommendPageAdapter(fragments, this) vpAdapter = RecommendPageAdapter(fragments, this)
vp2_recommend.adapter = vpAdapter vp2_recommend.adapter = vpAdapter
...@@ -132,6 +143,21 @@ class RecommendFragment : BaseFragment(), View.OnClickListener { ...@@ -132,6 +143,21 @@ class RecommendFragment : BaseFragment(), View.OnClickListener {
super.onResume() super.onResume()
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_TWO) { if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_TWO) {
if (mCurrentNewFlag != UserManager.getInstance().newFlag) {
mCurrentNewFlag = UserManager.getInstance().newFlag
if (mCurrentNewFlag) {
// 匹配用户自有
fragments.clear()
fragments.add(FollowVideoFragment.newInstance())
fragments.add(WatchVideoFragment.newInstance())
} else {
// 未匹配用户展示穿山甲
fragments.clear()
fragments.add(FollowVideoFragment.newInstance())
fragments.add(DramaTabFragment())
}
vpAdapter?.notifyDataSetChanged()
}
} }
} }
...@@ -171,6 +197,14 @@ class RecommendFragment : BaseFragment(), View.OnClickListener { ...@@ -171,6 +197,14 @@ class RecommendFragment : BaseFragment(), View.OnClickListener {
(requireActivity() as MainActivity).showBlack(showBlack) (requireActivity() as MainActivity).showBlack(showBlack)
} }
fun showEditView(show: Boolean) {
if (show) {
iv_edit.visibility = View.VISIBLE
} else {
iv_edit.visibility = View.GONE
}
}
fun fullChoice() { fun fullChoice() {
(fragments[0] as FollowVideoFragment).getAdapter().fullChoice() (fragments[0] as FollowVideoFragment).getAdapter().fullChoice()
} }
......
...@@ -129,6 +129,13 @@ class VideoEpisodeDialog( ...@@ -129,6 +129,13 @@ class VideoEpisodeDialog(
} }
} }
fun changeLockStatus(unlockIndex: Int) {
for (i in 0 until mData.size) {
mData[i].lock = i > unlockIndex
}
adapter?.notifyDataSetChanged()
}
fun setCurrentIndex(position: Int) { fun setCurrentIndex(position: Int) {
for (mDatum in mData) { for (mDatum in mData) {
mDatum.playing = false mDatum.playing = false
......
...@@ -84,6 +84,9 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -84,6 +84,9 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
private var freeSet = 5 private var freeSet = 5
private var lockSet = 2 private var lockSet = 2
private var isThirdId = false
private var isPlayNext = false
private var mode = DPDramaDetailConfig.SPECIFIC_DETAIL private var mode = DPDramaDetailConfig.SPECIFIC_DETAIL
private val isFromCard by lazy { intent?.getBooleanExtra(IS_FROM_CARD, false) ?: false } private val isFromCard by lazy { intent?.getBooleanExtra(IS_FROM_CARD, false) ?: false }
...@@ -93,10 +96,14 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -93,10 +96,14 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
override fun getBundleExtras(extras: Bundle?) { override fun getBundleExtras(extras: Bundle?) {
val json = extras?.getString(Constant.VEDIO_BEAN) val json = extras?.getString(Constant.VEDIO_BEAN)
isThirdId = extras?.getBoolean(Constant.VEDIO_THIRD, false) == true
isPlayNext = extras?.getBoolean(Constant.VEDIO_NEXT, false) == true
mVedioBean = Gson().fromJson(json, VedioBean::class.java) mVedioBean = Gson().fromJson(json, VedioBean::class.java)
freeSet = mVedioBean!!.unlockIndex freeSet = mVedioBean!!.unlockIndex
lockSet = mVedioBean!!.adGiveVedioNum // lockSet = mVedioBean!!.adGiveVedioNum
lockSet = 3
hideLeftTopTips = true hideLeftTopTips = true
mode = DPDramaDetailConfig.SPECIFIC_DETAIL mode = DPDramaDetailConfig.SPECIFIC_DETAIL
enableInfiniteScroll = false enableInfiniteScroll = false
...@@ -334,6 +341,11 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -334,6 +341,11 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
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(
TAG,
"isNeedBlock: index = $index" + " " + unlockIndex + "s" + drama.id + mHasUnlockIndexMap
)
return index > unlockIndex && hasUnlockList.contains(index).not() return index > unlockIndex && hasUnlockList.contains(index).not()
} }
...@@ -362,14 +374,24 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -362,14 +374,24 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
override fun adClose(vo: HashMap<String, Any>?) { override fun adClose(vo: HashMap<String, Any>?) {
vo?.let { vo?.let {
it["vedioId"] = "" + mVedioBean!!.vedioId if (isThirdId) {
it["thirdId"] = "" + mVedioBean!!.thirdId
} else {
it["vedioId"] = "" + mVedioBean!!.vedioId
}
videoPresenter.unlock(it) videoPresenter.unlock(it)
} }
val hasUnlockList: MutableList<Int> =
mHasUnlockIndexMap[drama.id] ?: mutableListOf() // 更新解锁集数
hasUnlockList.add(widget.currentDramaIndex) for (i in 0 until lockSet) {
mHasUnlockIndexMap[drama.id] = hasUnlockList val hasUnlockList: MutableList<Int> =
mHasUnlockIndexMap[drama.id] ?: mutableListOf()
hasUnlockList.add(widget.currentDramaIndex + lockSet)
mHasUnlockIndexMap[drama.id] = hasUnlockList
}
mUnlockIndexMap[drama.id] = mUnlockIndexMap[drama.id]!! + lockSet
blockView?.visibility = View.GONE blockView?.visibility = View.GONE
callback?.onDramaRewardArrived() // 解锁当前集 callback?.onDramaRewardArrived() // 解锁当前集
} }
...@@ -509,9 +531,17 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -509,9 +531,17 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
when (v?.id) { when (v?.id) {
R.id.ll_collect -> { R.id.ll_collect -> {
if (mVedioBean!!.collect == 0) { if (mVedioBean!!.collect == 0) {
videoPresenter.collect("" + mVedioBean!!.vedioId) if (isThirdId) {
videoPresenter.collect("" + mVedioBean!!.thirdId)
} else {
videoPresenter.collect("" + mVedioBean!!.vedioId)
}
} else { } else {
videoPresenter.cancelCollect("" + mVedioBean!!.vedioId) if (isThirdId) {
videoPresenter.cancelCollect("" + mVedioBean!!.thirdId)
} else {
videoPresenter.cancelCollect("" + mVedioBean!!.vedioId)
}
} }
} }
else -> {} else -> {}
......
package com.mints.wisdomclean.video package com.mints.wisdomclean.video
import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.bytedance.sdk.dp.DPDramaDetailConfig import com.bytedance.sdk.dp.DPDramaDetailConfig
import com.bytedance.sdk.dp.DPSdk import com.bytedance.sdk.dp.DPSdk
...@@ -14,19 +10,22 @@ import com.bytedance.sdk.dp.IDPDramaListener ...@@ -14,19 +10,22 @@ import com.bytedance.sdk.dp.IDPDramaListener
import com.bytedance.sdk.dp.IDPDrawListener import com.bytedance.sdk.dp.IDPDrawListener
import com.bytedance.sdk.dp.IDPWidget import com.bytedance.sdk.dp.IDPWidget
import com.mints.wisdomclean.R import com.mints.wisdomclean.R
import com.mints.wisdomclean.manager.LocalVedioManager
import com.mints.wisdomclean.mvp.model.IndexList
import com.mints.wisdomclean.mvp.presenters.VideoPresenter
import com.mints.wisdomclean.mvp.views.VideoView
import com.mints.wisdomclean.ui.fragment.base.BaseFragment import com.mints.wisdomclean.ui.fragment.base.BaseFragment
/** /**
* Created by limingqi on 2023/1/17 * Created by limingqi on 2023/1/17
*/ */
class DramaTabFragment : BaseFragment() { class DramaTabFragment : BaseFragment(), VideoView {
companion object { private val videoPresenter by lazy { VideoPresenter() }
private const val TAG = "DramaTabFragment"
private const val FREE_SET = -1 companion object {
private const val LOCK_SET = -1 private const val TAG = "DramaTabFragment"
} }
private var dpWidget: IDPWidget? = null private var dpWidget: IDPWidget? = null
...@@ -42,6 +41,8 @@ class DramaTabFragment : BaseFragment() { ...@@ -42,6 +41,8 @@ class DramaTabFragment : BaseFragment() {
override fun getContentViewLayoutID() = R.layout.drama_home_frag_wrapper override fun getContentViewLayoutID() = R.layout.drama_home_frag_wrapper
private fun init() { private fun init() {
videoPresenter.attachView(this)
if (isInited) { if (isInited) {
return return
} }
...@@ -57,15 +58,16 @@ class DramaTabFragment : BaseFragment() { ...@@ -57,15 +58,16 @@ class DramaTabFragment : BaseFragment() {
return return
} }
val dramaDetailConfig = DPDramaDetailConfig.obtain(DPDramaDetailConfig.COMMON_DETAIL) val dramaDetailConfig = DPDramaDetailConfig.obtain(DPDramaDetailConfig.SPECIFIC_DETAIL)
.freeSet(FREE_SET) .setEnterDelegate { context, drama, current ->
.lockSet(LOCK_SET) DramaApiDetailActivity.outerDrama = drama
videoPresenter.getIndexList("" + drama.id, true)
}
.hideMore(false) .hideMore(false)
.hideLeftTopTips(false, null) .hideLeftTopTips(false, null)
.listener(dramaListener) // 短剧详情页视频播放回调 .listener(dramaListener) // 短剧详情页视频播放回调
.adListener(dramaAdListener) // 短剧详情页激励视频回调 .adListener(dramaAdListener) // 短剧详情页激励视频回调
dpWidget = DPSdk.factory().createDraw( dpWidget = DPSdk.factory().createDraw(
DPWidgetDrawParams.obtain() DPWidgetDrawParams.obtain()
.adOffset(0) //单位 dp,为 0 时可以不设置 .adOffset(0) //单位 dp,为 0 时可以不设置
...@@ -338,5 +340,41 @@ class DramaTabFragment : BaseFragment() { ...@@ -338,5 +340,41 @@ class DramaTabFragment : BaseFragment() {
} }
} }
override fun onDestroy() {
super.onDestroy()
videoPresenter.detachView()
}
override fun getIndexListSuc(indexList: IndexList) {
LocalVedioManager.startVedioDetailActivityForType(
requireActivity(),
indexList.vedioMsg,
true,
isThirdId = true
)
}
override fun getIndexListFail() {
showToast("网络错误!")
}
override fun collectSuc() {
}
override fun collectFail() {
}
override fun cancelCollectSuc() {
}
override fun cancelCollectFail() {
}
override fun unlockSuc(indexList: IndexList) {
}
override fun unlockFail() {
}
} }
\ No newline at end of file
...@@ -14,6 +14,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter ...@@ -14,6 +14,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.mints.wisdomclean.MintsApplication import com.mints.wisdomclean.MintsApplication
import com.mints.wisdomclean.R import com.mints.wisdomclean.R
import com.mints.wisdomclean.mvp.model.VedioBean
/** /**
* author : ChenWenJie * author : ChenWenJie
...@@ -22,15 +23,15 @@ import com.mints.wisdomclean.R ...@@ -22,15 +23,15 @@ import com.mints.wisdomclean.R
* desc : 适配器 * desc : 适配器
*/ */
class RecommendVideoAdapter(var activity: Activity) : class RecommendVideoAdapter(var activity: Activity) :
BaseQuickAdapter<VideoBean, BaseViewHolder>(R.layout.item_video_recommend) { BaseQuickAdapter<VedioBean, BaseViewHolder>(R.layout.item_video_recommend) {
override fun convert(holder: BaseViewHolder, item: VideoBean) { override fun convert(holder: BaseViewHolder, item: VedioBean) {
//用户名 //用户名
holder.setText(R.id.username_tv, item.user_name) holder.setText(R.id.username_tv, item.title)
//标题 //标题
holder.setText(R.id.usertitle_tv, item.video_title) holder.setText(R.id.usertitle_tv, "第" + item.recommendIndex + "集")
//缩略图 //缩略图
Glide.with(activity).load(item.video_image) Glide.with(activity).load(item.coverImage)
.into(holder.getView<JzvdStdTikTok>(R.id.jz_video).posterImageView) .into(holder.getView<JzvdStdTikTok>(R.id.jz_video).posterImageView)
var isPlay = false var isPlay = false
...@@ -49,11 +50,11 @@ class RecommendVideoAdapter(var activity: Activity) : ...@@ -49,11 +50,11 @@ class RecommendVideoAdapter(var activity: Activity) :
if (holder.layoutPosition + 1 < itemCount) { if (holder.layoutPosition + 1 < itemCount) {
val item1 = getItem(holder.layoutPosition + 1) val item1 = getItem(holder.layoutPosition + 1)
//缓存下一个 10秒 //缓存下一个 10秒
proxy!!.preLoad(item1.video_path, 10) proxy!!.preLoad(item1.recommendUrl, 10)
} }
//缓存当前,播放当前 //缓存当前,播放当前
val proxyUrl = proxy?.getProxyUrl(item.video_path).toString() //设置视 val proxyUrl = proxy?.getProxyUrl(item.recommendUrl).toString() //设置视
setPlay(holder.getView(R.id.jz_video), proxyUrl) setPlay(holder.getView(R.id.jz_video), proxyUrl)
} }
......
...@@ -45,18 +45,24 @@ class VideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -45,18 +45,24 @@ class VideoActivity : BaseActivity(), View.OnClickListener, VideoView,
private var mVedioBean: VedioBean? = null private var mVedioBean: VedioBean? = null
private var indexBean: IndexList? = null private var indexBean: IndexList? = null
private var isPlayNext = false
private var playIndex = 1
override fun getContentViewLayoutID() = R.layout.activity_video override fun getContentViewLayoutID() = R.layout.activity_video
override fun initViewsAndEvents() { override fun initViewsAndEvents() {
videoPresenter.attachView(this) videoPresenter.attachView(this)
mVedioBean?.let { videoPresenter.getIndexList("" + it.vedioId) } mVedioBean?.let { videoPresenter.getIndexList("" + it.vedioId) }
if (isPlayNext) {
playIndex = mVedioBean!!.recommendIndex
}
initView() initView()
} }
override fun getBundleExtras(extras: Bundle?) { override fun getBundleExtras(extras: Bundle?) {
val json = extras?.getString(Constant.VEDIO_BEAN) val json = extras?.getString(Constant.VEDIO_BEAN)
isPlayNext = extras?.getBoolean(Constant.VEDIO_NEXT, false) == true
mVedioBean = Gson().fromJson(json, VedioBean::class.java) mVedioBean = Gson().fromJson(json, VedioBean::class.java)
super.getBundleExtras(extras) super.getBundleExtras(extras)
...@@ -98,8 +104,6 @@ class VideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -98,8 +104,6 @@ class VideoActivity : BaseActivity(), View.OnClickListener, VideoView,
adapter.setNewInstance(getAdapterData()) adapter.setNewInstance(getAdapterData())
val emptyView = LayoutInflater.from(this).inflate(R.layout.item_empty_video, null) val emptyView = LayoutInflater.from(this).inflate(R.layout.item_empty_video, null)
adapter.setEmptyView(emptyView) adapter.setEmptyView(emptyView)
//指定位置其他页面跳转过来。直接定位指定posion 这里不需要。
// recy.scrollToPosition(postion);
adapter.setOnCustomChildClickListener(this) adapter.setOnCustomChildClickListener(this)
adapter.setOnVideoCompletion(object : JzvdStdTikTok.OnVideoCompletion { adapter.setOnVideoCompletion(object : JzvdStdTikTok.OnVideoCompletion {
...@@ -217,12 +221,19 @@ class VideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -217,12 +221,19 @@ class VideoActivity : BaseActivity(), View.OnClickListener, VideoView,
} }
override fun getIndexListSuc(indexList: IndexList) { override fun getIndexListSuc(indexList: IndexList) {
indexBean = indexList
mVedioBean = indexList.vedioMsg mVedioBean = indexList.vedioMsg
indexBean = indexList
videos.clear() videos.clear()
videos.addAll(indexList.list) videos.addAll(indexList.list)
adapter.setNewInstance(getAdapterData()) adapter.setNewInstance(getAdapterData())
adapter.notifyDataSetChanged() adapter.notifyDataSetChanged()
// 处理推荐页跳转自动播放下一集逻辑
if (!isPlayNext) {
playIndex = mVedioBean!!.seeIndex - 1
}
mCurrentPosition = playIndex
recy.scrollToPosition(playIndex)
} }
override fun getIndexListFail() { override fun getIndexListFail() {
...@@ -245,6 +256,7 @@ class VideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -245,6 +256,7 @@ class VideoActivity : BaseActivity(), View.OnClickListener, VideoView,
} }
override fun unlockSuc(indexList: IndexList) { override fun unlockSuc(indexList: IndexList) {
dialog?.changeLockStatus(videos.size)
videos.addAll(indexList.list) videos.addAll(indexList.list)
adapter.setNewInstance(getAdapterData()) adapter.setNewInstance(getAdapterData())
adapter.notifyDataSetChanged() adapter.notifyDataSetChanged()
......
...@@ -4,6 +4,7 @@ import android.util.Log ...@@ -4,6 +4,7 @@ import android.util.Log
import android.view.View import android.view.View
import android.widget.Button import android.widget.Button
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView
import cn.jzvd.Jzvd import cn.jzvd.Jzvd
import cn.jzvd.JzvdStd import cn.jzvd.JzvdStd
import com.airbnb.lottie.LottieAnimationView import com.airbnb.lottie.LottieAnimationView
...@@ -46,6 +47,7 @@ class VideoAdapter(private var vedioBean: VedioBean) : ...@@ -46,6 +47,7 @@ class VideoAdapter(private var vedioBean: VedioBean) :
holder.getView<View>(R.id.vip).setOnClickListener { holder.getView<View>(R.id.vip).setOnClickListener {
mOnCustomChildClickListener?.onCustomChildClick(it, holder.adapterPosition) mOnCustomChildClickListener?.onCustomChildClick(it, holder.adapterPosition)
} }
holder.getView<TextView>(R.id.unlock).text = "看广告解锁" + vedioBean!!.adGiveVedioNum + "集"
holder.getView<View>(R.id.leave).visibility = View.GONE holder.getView<View>(R.id.leave).visibility = View.GONE
holder.getView<View>(R.id.leave).setOnClickListener { holder.getView<View>(R.id.leave).setOnClickListener {
mOnCustomChildClickListener?.onCustomChildClick(it, holder.adapterPosition) mOnCustomChildClickListener?.onCustomChildClick(it, holder.adapterPosition)
...@@ -57,7 +59,7 @@ class VideoAdapter(private var vedioBean: VedioBean) : ...@@ -57,7 +59,7 @@ class VideoAdapter(private var vedioBean: VedioBean) :
private fun initVideoHolder(holder: BaseViewHolder, item: VideoMultiItemEntity) { private fun initVideoHolder(holder: BaseViewHolder, item: VideoMultiItemEntity) {
//标题 //标题
holder.setText(R.id.title_tv, item.video.title) holder.setText(R.id.title_tv, vedioBean.title)
//介绍 //介绍
holder.setText(R.id.info_tv, "第" + item.video.vedioIndex + "集") holder.setText(R.id.info_tv, "第" + item.video.vedioIndex + "集")
//收藏数量 //收藏数量
......
...@@ -138,8 +138,8 @@ ...@@ -138,8 +138,8 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center"
android:background="#10ffffff" android:background="#10ffffff"
android:gravity="center"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
...@@ -168,10 +168,8 @@ ...@@ -168,10 +168,8 @@
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
<ImageView <ImageView
android:id="@+id/leave" android:id="@+id/leave"
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#99000000"> android:background="#99000000">
<View
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="180dp"> android:layout_height="240dp">
<ImageView <ImageView
android:id="@+id/image_iv" android:id="@+id/image_iv"
android:layout_width="100dp" android:layout_width="106dp"
android:layout_height="120dp" android:layout_height="180dp"
android:scaleType="fitXY"
android:src="@mipmap/ic_launcher_main" android:src="@mipmap/ic_launcher_main"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
...@@ -18,7 +19,7 @@ ...@@ -18,7 +19,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:layout_marginBottom="10dp" android:layout_marginBottom="4dp"
android:text="已完结" android:text="已完结"
android:textColor="@color/white" android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="@id/image_iv" app:layout_constraintBottom_toBottomOf="@id/image_iv"
...@@ -26,9 +27,11 @@ ...@@ -26,9 +27,11 @@
<TextView <TextView
android:id="@+id/title_tv" android:id="@+id/title_tv"
android:layout_width="wrap_content" android:layout_width="106dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:ellipsize="end"
android:maxLines="1"
android:text="重回80年代" android:text="重回80年代"
android:textColor="@color/black" android:textColor="@color/black"
app:layout_constraintStart_toStartOf="@id/image_iv" app:layout_constraintStart_toStartOf="@id/image_iv"
...@@ -36,9 +39,11 @@ ...@@ -36,9 +39,11 @@
<TextView <TextView
android:id="@+id/info_tv" android:id="@+id/info_tv"
android:layout_width="wrap_content" android:layout_width="106dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:ellipsize="end"
android:maxLines="1"
android:text="重回80年代" android:text="重回80年代"
android:textColor="@color/gray" android:textColor="@color/gray"
android:textSize="12sp" android:textSize="12sp"
...@@ -47,8 +52,8 @@ ...@@ -47,8 +52,8 @@
<FrameLayout <FrameLayout
android:id="@+id/fm_mask" android:id="@+id/fm_mask"
android:layout_width="100dp" android:layout_width="106dp"
android:layout_height="180dp" android:layout_height="240dp"
android:background="@drawable/shape_half_trans2" android:background="@drawable/shape_half_trans2"
app:layout_constraintEnd_toEndOf="@id/image_iv" app:layout_constraintEnd_toEndOf="@id/image_iv"
app:layout_constraintStart_toStartOf="@id/image_iv" app:layout_constraintStart_toStartOf="@id/image_iv"
...@@ -63,7 +68,7 @@ ...@@ -63,7 +68,7 @@
android:button="@null" android:button="@null"
android:drawableEnd="@drawable/selector_cb" android:drawableEnd="@drawable/selector_cb"
android:paddingEnd="6dp" android:paddingEnd="6dp"
android:paddingBottom="140dp" /> android:paddingBottom="196dp" />
</FrameLayout> </FrameLayout>
......
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