Commit bfd37ade authored by jyx's avatar jyx

代码优化

parent 14a925de
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_15" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
......@@ -72,7 +72,6 @@ public class RecommendVideoView extends RelativeLayout {
mSnapHelper.attachToRecyclerView(mRecyclerView);
mAdapter = new TxRecommendVideoAdapter();
mAdapter.setNewInstance(mList);
mAdapter.setOnVideoEndListener(() -> onItemClick(mCurrentPosition + 1));
mLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false) {
@Override
protected int getExtraLayoutSpace(RecyclerView.State state) {
......@@ -119,6 +118,9 @@ public class RecommendVideoView extends RelativeLayout {
private void onPageSelectedMethod(int position) {
if (mOnPageChangeListener != null) mOnPageChangeListener.onPageChange(position);
if (mBaseItemView != null) {
mBaseItemView.pausePlayer();
}
if (position == mUrlList.size()) return;
if (mLastPositionInIDLE != position) {
......@@ -221,4 +223,10 @@ public class RecommendVideoView extends RelativeLayout {
public void setOnCustomChildClickListener(TxRecommendVideoAdapter.OnCustomChildClickListener onCustomChildClickListener) {
mAdapter.setOnCustomChildClickListener(onCustomChildClickListener);
}
private TXVideoBaseView.OnVideoEndListener mOnVideoEndListener;
public void setOnVideoEndListener(TXVideoBaseView.OnVideoEndListener onVideoEndListener) {
mAdapter.setOnVideoEndListener(onVideoEndListener);
}
}
......@@ -142,7 +142,9 @@ public class SuperShortVideoView extends RelativeLayout {
private void onPageSelectedMethod(int position) {
if (mOnPageChangeListener != null) mOnPageChangeListener.onPageChange(position);
if (position == mUrlList.size()) return;
if (position == mUrlList.size()) {
return;
}
if (mLastPositionInIDLE != position) {
View view = mSnapHelper.findSnapView(mLayoutManager);
......
......@@ -244,6 +244,7 @@ public class TXVideoBaseView extends RelativeLayout implements View.OnClickListe
@Override
public void onProgress(Bundle bundle) {
mIvCover.setVisibility(GONE);
handlePlayProgress(bundle);
}
......
......@@ -19,7 +19,7 @@ import com.tencent.rtmp.ui.TXCloudVideoView;
import java.io.File;
public class TXVodPlayerWrapper implements ITXVodPlayListener {
private static final String TAG = "ShortVideoDemo:TXVodPlayerWrapper";
private static final String TAG = "TXVodPlayerWrapper";
private TXVodPlayer mVodPlayer;
private OnPlayEventChangedListener mOnPlayEventChangedListener;
private TxVodStatus mStatus;
......@@ -63,16 +63,20 @@ public class TXVodPlayerWrapper implements ITXVodPlayListener {
}
break;
case PLAY_EVT_RCV_FIRST_I_FRAME:
Log.i(TAG, " onPlayEvent -> PLAY_EVT_RCV_FIRST_I_FRAME");
if (mOnPlayEventChangedListener != null) {
mOnPlayEventChangedListener.onRcvFirstFrame();
}
break;
case PLAY_EVT_PLAY_PROGRESS:
Log.i(TAG, " onPlayEvent -> PLAY_EVT_PLAY_PROGRESS");
if (mOnPlayEventChangedListener != null) {
mOnPlayEventChangedListener.onProgress(bundle);
}
break;
case PLAY_EVT_PLAY_END:
Log.i(TAG, " onPlayEvent -> PLAY_EVT_PLAY_END");
playerStatusChanged(TxVodStatus.TX_VIDEO_PLAYER_STATUS_ENDED);
if (mOnPlayEventChangedListener != null) {
......
......@@ -39,6 +39,14 @@ class TxVideoFragment : BaseFragment(), RecommendView {
override fun initViewsAndEvents() {
recommendPresenter.attachView(this)
recommend_view.setOnVideoEndListener {
videos[recommend_view.currentPosition].recommendIndex++
LocalVedioManager.startVedioDetailActivityForType(
requireActivity(),
videos[recommend_view.currentPosition],
true
)
}
recommend_view.setOnCustomChildClickListener(object :
TxRecommendVideoAdapter.OnCustomChildClickListener {
override fun onCustomChildClick(view: View, position: Int) {
......
......@@ -75,13 +75,15 @@ class TxVideoAdapter : BaseMultiItemQuickAdapter<VideoMultiItemEntity, BaseViewH
setCancelCollectImage(holder.getView(R.id.zan_iv))
}
holder.getView<TXVideoBaseView>(R.id.baseItemView).setOnVideoEndListener(mOnVideoEndListener)
holder.getView<TXVideoBaseView>(R.id.baseItemView)
.setOnVideoEndListener(mOnVideoEndListener)
}
override fun onViewDetachedFromWindow(holder: BaseViewHolder) {
super.onViewDetachedFromWindow(holder)
if (holder.itemViewType == VideoMultiItemEntity.MULTI_ITEM_1) {
holder.getView<TXVideoBaseView>(R.id.baseItemView).pausePlayer()
holder.getView<TXVideoBaseView>(R.id.baseItemView).stopForPlaying()
}
}
......
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