Commit 35428122 authored by jyx's avatar jyx

添加推荐加载功能,未解锁视频不上送后台

parent 0a543b6c
......@@ -28,18 +28,33 @@ class FollowAdapter(var activity: Activity) :
}
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.info_tv).text = "观看至第${item.seeIndex}集"
holder.getView<TextView>(R.id.info_tv).text = "观看至第${item.seeIndex}集"
holder.getView<TextView>(R.id.complete_tv).text =
if (item.completeStatus == 0) "已完结" else "更新中"
GlideUtils.loadImageViewGifForCenterCrop(context, item.coverImage, holder.getView(R.id.image_iv))
GlideUtils.loadImageViewGifForCenterCrop(
context,
item.coverImage,
holder.getView(R.id.image_iv)
)
}
// 设置编辑状态
fun setEditStyle(showEdit: Boolean) {
this.showEdit = showEdit
// 清除选中状态
if (!this.showEdit) {
for (datum in data) {
datum.isChecked = false
}
}
notifyDataSetChanged()
}
// 设置编辑状态
fun getEditStyle(): Boolean {
return this.showEdit
}
// 全选
fun fullChoice() {
for (datum in data) {
......
......@@ -68,6 +68,7 @@ class FollowVideoFragment : BaseFragment(), FollowView {
return@setOnItemLongClickListener false
}
followAdapter?.setOnItemClickListener { adapter, view, position ->
if (followAdapter?.getEditStyle() == true) return@setOnItemClickListener
LocalVedioManager.startVedioDetailActivityForType(
requireActivity(),
datas[position]
......
......@@ -360,12 +360,17 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
if (mUnlockIndexMap[drama.id]!! > index) {
blockView?.visibility = View.GONE
}
mVedioBean!!.seeIndex = index
mVedioBean!!.orderTags = orderTagsList
LocalVedioManager.commitVedio(mVedioBean!!)
showVipCountDialog(index - 1)
return index > unlockIndex && hasUnlockList.contains(index).not()
val needBlock = index > unlockIndex && hasUnlockList.contains(index).not()
if (!needBlock) {
// 上送视频信息,若未解锁不上送
mVedioBean!!.seeIndex = index
mVedioBean!!.orderTags = orderTagsList
LocalVedioManager.commitVedio(mVedioBean!!)
showVipCountDialog(index - 1)
}
return needBlock
}
override fun showAdIfNeeded(
......
......@@ -11,6 +11,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.PagerSnapHelper;
import androidx.recyclerview.widget.RecyclerView;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.xinfu.helivideo.R;
import com.xinfu.helivideo.mvp.model.VedioBean;
import com.xinfu.helivideo.video.tx.adapter.TxRecommendVideoAdapter;
......@@ -24,6 +26,7 @@ public class RecommendVideoView extends RelativeLayout {
private static final int MAX_PLAYER_COUNT_ON_PASS = 3;
private RecyclerView mRecyclerView;
private SmartRefreshLayout mSmartRefreshLayout;
private TxRecommendVideoAdapter mAdapter;
private List<VideoModel> mUrlList;
private LinearLayoutManager mLayoutManager;
......@@ -69,11 +72,23 @@ public class RecommendVideoView extends RelativeLayout {
mAdapter.setNewInstance(mList);
}
public void loadMoreData(List<VedioBean> list) {
List<VideoModel> videoList = new ArrayList();
for (int i = 0; i < list.size(); i++) {
videoList.add(new VideoModel(list.get(i).getRecommendUrl()));
}
this.mList.addAll(list);
mUrlList.addAll(videoList);
mAdapter.notifyItemRangeInserted(this.mList.size() - list.size(), list.size());
}
public void init(Context context) {
View mRootView = LayoutInflater.from(context).inflate(R.layout.super_short_video_view, null);
addView(mRootView);
mPlayerManager = new PlayerManager(getContext());
mRecyclerView = mRootView.findViewById(R.id.rv_super_short_video);
mSmartRefreshLayout = mRootView.findViewById(R.id.src_video);
mSmartRefreshLayout.setEnableRefresh(false);
mUrlList = new ArrayList<>();
mSnapHelper = new PagerSnapHelper();
mSnapHelper.attachToRecyclerView(mRecyclerView);
......@@ -86,7 +101,7 @@ public class RecommendVideoView extends RelativeLayout {
}
};
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setItemViewCacheSize(6);
mRecyclerView.setItemViewCacheSize(10);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setDrawingCacheEnabled(true);
mRecyclerView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
......@@ -125,6 +140,8 @@ public class RecommendVideoView extends RelativeLayout {
private void onPageSelectedMethod(int position) {
if (mOnPageChangeListener != null) mOnPageChangeListener.onPageChange(position);
if (position >= mUrlList.size()) return;
if (mLastPositionInIDLE != position) {
View view = mSnapHelper.findSnapView(mLayoutManager);
if (view == null) {
......@@ -135,7 +152,7 @@ public class RecommendVideoView extends RelativeLayout {
List<VideoModel> tempUrlList = initUrlList(position, MAX_PLAYER_COUNT_ON_PASS);
mPlayerManager.updateManager(tempUrlList);
TXVodPlayerWrapper txVodPlayerWrapper = mPlayerManager.getPlayer(mUrlList.get(position));
if(txVodPlayerWrapper!=null){
if (txVodPlayerWrapper != null) {
Log.i(TAG, "txVodPlayerWrapper " + txVodPlayerWrapper + "url-- " + mUrlList.get(position).videoURL);
Log.i(TAG, "txVodPlayerWrapper " + txVodPlayerWrapper);
mBaseItemView.setTXVodPlayer(txVodPlayerWrapper);
......@@ -234,4 +251,19 @@ public class RecommendVideoView extends RelativeLayout {
public void setOnVideoEndListener(TXVideoBaseView.OnVideoEndListener onVideoEndListener) {
mAdapter.setOnVideoEndListener(onVideoEndListener);
}
public void hideLoadMore() {
mSmartRefreshLayout.finishLoadMore();
mSmartRefreshLayout.postDelayed(new Runnable() {
@Override
public void run() {
mRecyclerView.smoothScrollToPosition(mCurrentPosition);
}
}, 200);
}
public void setOnLoadMoreListener(OnLoadMoreListener onLoadMoreListener) {
mSmartRefreshLayout.setOnLoadMoreListener(onLoadMoreListener);
}
}
......@@ -15,7 +15,6 @@ import com.xinfu.helivideo.ui.fragment.base.BaseFragment
import com.xinfu.helivideo.video.tx.adapter.TxRecommendVideoAdapter
import kotlinx.android.synthetic.main.fragment_tx_video.*
/**
* @author Assen
* @date 2023/7/5
......@@ -26,6 +25,7 @@ class TxVideoFragment : BaseFragment(), RecommendView {
private val recommendPresenter by lazy { RecommendPresenter() }
var videos = arrayListOf<VedioBean>()
private var recommendPage = 1 // 分页
companion object {
fun newInstance(): Fragment {
......@@ -41,6 +41,10 @@ class TxVideoFragment : BaseFragment(), RecommendView {
recommendPresenter.autoList()
recommend_view.setOnLoadMoreListener {
recommendPage++
recommendPresenter.autoList()
}
recommend_view.setOnVideoEndListener {
videos[recommend_view.currentPosition].recommendIndex++
LocalVedioManager.startVedioDetailActivityForType(
......@@ -118,9 +122,20 @@ class TxVideoFragment : BaseFragment(), RecommendView {
}
override fun autoListSuc(list: BannerList) {
videos.clear()
videos.addAll(list.list)
recommend_view.loadData(videos)
val list1 = arrayListOf<VedioBean>()
for (i in 0..2) {
list1.add(list.list[i])
}
if (recommendPage == 1) {
videos.clear()
videos.addAll(list1)
recommend_view.loadData(list1)
} else {
videos.addAll(list1)
recommend_view.loadMoreData(list1)
recommend_view.hideLoadMore()
}
}
override fun autoListFail() {
......
......@@ -2,7 +2,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="206dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="6dp"
android:orientation="vertical"
......@@ -13,13 +13,12 @@
android:id="@+id/image_iv"
android:layout_width="match_parent"
android:layout_height="150dp"
android:scaleType="fitXY"
android:scaleType="centerCrop"
android:src="@mipmap/ic_launcher_main"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -31,11 +30,11 @@
android:id="@+id/complete_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:gravity="right"
android:paddingLeft="6dp"
android:paddingStart="6dp"
android:paddingTop="2dp"
android:paddingRight="8dp"
android:layout_alignParentRight="true"
android:paddingEnd="8dp"
android:paddingBottom="2dp"
android:text="已完结"
android:textColor="@color/white"
......@@ -44,7 +43,7 @@
<TextView
android:id="@+id/title_tv"
android:layout_width="106dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:ellipsize="end"
......@@ -70,25 +69,21 @@
<FrameLayout
android:id="@+id/fm_mask"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_half_trans2"
app:layout_constraintEnd_toEndOf="@id/image_iv"
app:layout_constraintStart_toStartOf="@id/image_iv"
app:layout_constraintTop_toTopOf="@id/image_iv">
android:layout_height="match_parent"
android:background="@drawable/shape_half_trans2">
<CheckBox
android:id="@+id/cb"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@null"
android:button="@null"
android:drawableEnd="@drawable/selector_cb"
android:minWidth="100dp"
android:paddingTop="10dp"
android:paddingEnd="6dp"
android:paddingBottom="174dp" />
android:paddingBottom="170dp" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_super_short_video"
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/src_video"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
app:srlAccentColor="@color/black"
app:srlPrimaryColor="#f0f2f5">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_super_short_video"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</RelativeLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment