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()
} }
......
package com.mints.wisdomclean.ui.fragment package com.mints.wisdomclean.ui.fragment
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater
import android.view.View import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.OrientationHelper import androidx.recyclerview.widget.OrientationHelper
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import cn.jzvd.Jzvd import cn.jzvd.Jzvd
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.VedioBean
import com.mints.wisdomclean.mvp.presenters.RecommendPresenter import com.mints.wisdomclean.mvp.presenters.RecommendPresenter
import com.mints.wisdomclean.mvp.views.RecommendView import com.mints.wisdomclean.mvp.views.RecommendView
import com.mints.wisdomclean.ui.fragment.base.BaseFragment import com.mints.wisdomclean.ui.fragment.base.BaseFragment
import com.mints.wisdomclean.video.* import com.mints.wisdomclean.video.*
import kotlinx.android.synthetic.main.fragment_watch_video.* import kotlinx.android.synthetic.main.fragment_watch_video.recy
/** /**
* @author Assen * @author Assen
...@@ -31,31 +36,45 @@ class WatchVideoFragment : BaseFragment(), RecommendView { ...@@ -31,31 +36,45 @@ class WatchVideoFragment : BaseFragment(), RecommendView {
} }
} }
private var mCurrentPosition = -1 private var mCurrentPosition = 0
lateinit var adapter: RecommendVideoAdapter lateinit var adapter: RecommendVideoAdapter
var videos = arrayListOf<VideoBean>() var videos = arrayListOf<VedioBean>()
override fun initViewsAndEvents() { override fun initViewsAndEvents() {
recommendPresenter.attachView(this) recommendPresenter.attachView(this)
initData()
val layoutManager = RecyViewLayoutManager(requireContext(), OrientationHelper.VERTICAL) val layoutManager = RecyViewLayoutManager(requireContext(), OrientationHelper.VERTICAL)
recy.layoutManager = layoutManager recy.layoutManager = layoutManager
adapter = RecommendVideoAdapter(requireActivity()) adapter = RecommendVideoAdapter(requireActivity())
recy.adapter = adapter recy.adapter = adapter
//预加载下一个 //预加载下一个
adapter.setNewInstance(videos) adapter.setNewInstance(videos)
val emptyView =
LayoutInflater.from(requireContext()).inflate(R.layout.item_empty_video, null)
adapter.setEmptyView(emptyView)
adapter.addChildClickViewIds(R.id.ll_bottom, R.id.ll_collect) adapter.addChildClickViewIds(R.id.ll_bottom, R.id.ll_collect)
adapter.setOnItemChildClickListener { adapter, view, position -> adapter.setOnItemChildClickListener { adapter, view, position ->
when (view.id) { when (view.id) {
R.id.ll_bottom -> { R.id.ll_bottom -> {
val bundle = Bundle() videos[position].seeIndex++
readyGo(VideoActivity::class.java, bundle) LocalVedioManager.startVedioDetailActivityForType(
requireActivity(),
videos[position],
true
)
// val bundle = Bundle()
// readyGo(VideoActivity::class.java, bundle)
} }
R.id.ll_collect -> { R.id.ll_collect -> {
if (videos[position].collect == 0) {
videos[position].collect = 1
recommendPresenter.collect("" + videos[position].vedioId)
} else {
recommendPresenter.cancelCollect("" + videos[position].vedioId)
videos[position].collect = 0
}
} }
else -> {} else -> {}
} }
...@@ -63,15 +82,19 @@ class WatchVideoFragment : BaseFragment(), RecommendView { ...@@ -63,15 +82,19 @@ class WatchVideoFragment : BaseFragment(), RecommendView {
adapter.setOnVideoCompletion(object : JzvdStdTikTok.OnVideoCompletion { adapter.setOnVideoCompletion(object : JzvdStdTikTok.OnVideoCompletion {
override fun onVideoCompletion() { override fun onVideoCompletion() {
showToast("即将为您播放下一集") showToast("即将为您播放下一集")
val bundle = Bundle()
readyGo(VideoActivity::class.java, bundle) videos[mCurrentPosition].seeIndex++
// recy.smoothScrollToPosition(mCurrentPosition + 1) LocalVedioManager.startVedioDetailActivityForType(
requireActivity(),
videos[mCurrentPosition],
true
)
} }
}) })
layoutManager.setOnViewPagerListener(object : OnRecyViewListener { layoutManager.setOnViewPagerListener(object : OnRecyViewListener {
override fun onInitComplete() { override fun onInitComplete() {
mCurrentPosition = 0 // mCurrentPosition = 0
//初始化 自动播放 //初始化 自动播放
autoPlayVideo() autoPlayVideo()
...@@ -91,7 +114,6 @@ class WatchVideoFragment : BaseFragment(), RecommendView { ...@@ -91,7 +114,6 @@ class WatchVideoFragment : BaseFragment(), RecommendView {
} }
if (isBottom) { if (isBottom) {
//是最底部,执行加载更多数据 //是最底部,执行加载更多数据
loadData()
} }
autoPlayVideo() autoPlayVideo()
mCurrentPosition = position mCurrentPosition = position
...@@ -103,6 +125,8 @@ class WatchVideoFragment : BaseFragment(), RecommendView { ...@@ -103,6 +125,8 @@ class WatchVideoFragment : BaseFragment(), RecommendView {
recy.addOnChildAttachStateChangeListener(object : recy.addOnChildAttachStateChangeListener(object :
RecyclerView.OnChildAttachStateChangeListener { RecyclerView.OnChildAttachStateChangeListener {
override fun onChildViewDetachedFromWindow(view: View) { override fun onChildViewDetachedFromWindow(view: View) {
if (view !is ConstraintLayout) return
val jzvd: Jzvd = view.findViewById(R.id.jz_video) val jzvd: Jzvd = view.findViewById(R.id.jz_video)
if (jzvd != null && Jzvd.CURRENT_JZVD != null && if (jzvd != null && Jzvd.CURRENT_JZVD != null &&
jzvd.jzDataSource.containsTheUrl(Jzvd.CURRENT_JZVD.jzDataSource.currentUrl) jzvd.jzDataSource.containsTheUrl(Jzvd.CURRENT_JZVD.jzDataSource.currentUrl)
...@@ -124,6 +148,8 @@ class WatchVideoFragment : BaseFragment(), RecommendView { ...@@ -124,6 +148,8 @@ class WatchVideoFragment : BaseFragment(), RecommendView {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
Jzvd.goOnPlayOnResume() Jzvd.goOnPlayOnResume()
recommendPresenter.autoList()
} }
override fun onPause() { override fun onPause() {
...@@ -143,6 +169,7 @@ class WatchVideoFragment : BaseFragment(), RecommendView { ...@@ -143,6 +169,7 @@ class WatchVideoFragment : BaseFragment(), RecommendView {
if (recy == null || recy.getChildAt(0) == null) { if (recy == null || recy.getChildAt(0) == null) {
return return
} }
if (recy.getChildAt(0) !is ConstraintLayout) return
val player: JzvdStdTikTok = recy.getChildAt(0).findViewById(R.id.jz_video) val player: JzvdStdTikTok = recy.getChildAt(0).findViewById(R.id.jz_video)
if (player != null) { if (player != null) {
player.startVideoAfterPreloading() player.startVideoAfterPreloading()
...@@ -150,116 +177,6 @@ class WatchVideoFragment : BaseFragment(), RecommendView { ...@@ -150,116 +177,6 @@ class WatchVideoFragment : BaseFragment(), RecommendView {
} }
} }
//加载
fun loadData() {
videos.add(
VideoBean(
6,
"遵义观察 ",
"https://p9-dy.byteimg.com/aweme/100x100/2e1ce00021ee51a2aacdc.jpeg?from=4010531038",
"老伴咱走!",
"https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200fe10000bloib0nrri6bf7b1k4fg&ratio=720p&line=0",
"https://p29-dy.byteimg.com/obj/tos-cn-p-0015/601c6d730167431184c5412e81cd32d1?from=2563711402_large"
)
)
videos.add(
VideoBean(
7,
"BTV养生堂 ",
"https://p6-dy-ipv6.byteimg.com/aweme/100x100/3151700027839b153b924.jpeg?from=4010531038",
"湿气过重,快收藏这个中医调理方!!",
"https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200f730000bpebr0dqg5balrfhqlog&ratio=720p&line=0",
"https://p3-dy-ipv6.byteimg.com/obj/tos-cn-p-0015/0e99f0aca9764e7da53be1096a3bd641_1583136211?from=2563711402_large"
)
)
videos.add(
VideoBean(
8,
"河南都市频道 ",
"https://p9-dy.byteimg.com/aweme/100x100/312a8000720705660b806.jpeg?from=4010531038",
"痛心!手扶梯绞断女童两根手指!带娃搭扶梯的一定要注意了!(上)!",
"https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200f250000bgsu5vamac2seo2gp53g&ratio=720p&line=0",
"https://p1-dy-ipv6.byteimg.com/obj/160b4000aa3f373bd14cd?from=2563711402_large"
)
)
videos.add(
VideoBean(
9,
"科学小妙招 ",
"https://p26-dy.byteimg.com/aweme/100x100/312090000434b4dd10244.jpeg?from=4010531038",
"不喜欢的衣服扔了可惜,这样改造一下非常酷#生活小妙招 #生活小技巧 #废物利用 @抖音小助手",
"https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200fe10000bq2bf7s9hq5lufbuoflg&ratio=720p&line=0",
"https://p9-dy.byteimg.com/obj/tos-cn-p-0015/9a6784fcbf9b43849081d7a3388db08d_1585756125?from=2563711402_large"
)
)
videos.add(
VideoBean(
10,
"一起装修网 ",
"https://p29-dy.byteimg.com/aweme/100x100/f77d000eae902034a2bf.jpeg?from=4010531038",
"#装修 #黑幕重重 怎样选购浴室柜?揭露浴室柜增项(增项:镜子,水龙头,软管等)@胡 一刀",
"https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0300f9a0000belnavkqn5hfpb70b5kg&ratio=720p&line=0",
"https://p29-dy.byteimg.com/obj/c8f200068c30b23f1024?from=2563711402_large"
)
)
}
fun initData() {
videos.add(
VideoBean(
1,
"中韩夫妇与两宝",
"https://p29-dy.byteimg.com/aweme/100x100/2f9480001ea8cc615d6a9.jpeg?from=401053103",
"家有一老如有一宝,不分国界",
"https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200fe90000bs854d21rirdcdon9fk0&ratio=720p&line=0",
"https://p6-dy-ipv6.byteimg.com/img/tos-cn-p-0015/2263f31dfb304120a5fb5d6655b230c5_1594905185~tplv-dmt-logom:tos-cn-i-0813/65302cd29d2d4043a98de10a7723d33d.image?from=2563711402_large"
)
)
videos.add(
VideoBean(
2,
"央视新闻",
"https://p6-dy-ipv6.byteimg.com/aweme/100x100/30e520009a01cad2d810e.jpeg?from=4010531038",
"高三考生注意了!今年高考时间推迟一个月,为7月7日至7月8日",
"https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200fe90000bs854d21rirdcdon9fk0&ratio=720p&line=0",
"https://p29-dy.byteimg.com/obj/tos-cn-p-0015/f79a5fe204e24bbbbfc55a76a81f5c2c_1585626014?from=2563711402_large"
)
)
videos.add(
VideoBean(
3,
"查查和张张",
"https://p6-dy-ipv6.byteimg.com/aweme/100x100/30e520009a01cad2d810e.jpeg?from=4010531038",
"#情侣 #春节 就没有我解决不了的婆媳关系 嘿嘿@Singing哥 @抖音小助手",
"https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200f670000bomln43d82dvbadk5a00&ratio=720p&line=0",
"https://p29-dy.byteimg.com/obj/tos-cn-p-0015/f61dcb8127204a8cb7a322bf816c0b3e_1580030882?from=2563711402_large"
)
)
videos.add(
VideoBean(
4,
"大鹏(宇宙简史)",
"https://p3-dy-ipv6.byteimg.com/aweme/100x100/1e1170002093b2ff1d0f7.jpeg?from=4010531038",
"2018下半年所以天文奇观!还有流星雨哦!千万不要错过了",
"https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200f4e0000bddrstnff778g23hs6mg&ratio=720p&line=0",
"https://p6-dy-ipv6.byteimg.com/obj/9dfb0003c8c228b763eb?from=2563711402_large"
)
)
videos.add(
VideoBean(
5,
"胖爹带娃",
"https://p3-dy-ipv6.byteimg.com/aweme/100x100/26ec600005035c9b87288.jpeg?from=4010531038",
"带孩子出门玩耍一定要记得这一点!接力下去,别以为危险离我们很远@抖音小助手 #暑假安全",
"https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200f4e0000bddrstnff778g23hs6mg&ratio=720p&line=0",
"https://p9-dy.byteimg.com/obj/2c5c600050a7b42352869?from=2563711402_large"
)
)
}
override fun onDetach() { override fun onDetach() {
super.onDetach() super.onDetach()
recommendPresenter.detachView() recommendPresenter.detachView()
...@@ -281,5 +198,15 @@ class WatchVideoFragment : BaseFragment(), RecommendView { ...@@ -281,5 +198,15 @@ class WatchVideoFragment : BaseFragment(), RecommendView {
} }
override fun autoListSuc(list: BannerList) {
videos.clear()
videos.addAll(list.list)
adapter?.notifyDataSetChanged()
}
override fun autoListFail() {
}
} }
\ No newline at end of file
...@@ -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