Commit 5d58753c authored by mengcuiguang's avatar mengcuiguang

Merge branch 'dev_huanleduanju_0814' of...

Merge branch 'dev_huanleduanju_0814' of http://gitlab.mints-id.com/android/android_vedio into dev_huanleduanju_0814
parents cda8590c 3521812f
package com.duben.happyplaylet.manager
import android.app.Activity
import android.app.ActivityOptions
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import com.bytedance.sdk.dp.DPDrama
import com.bytedance.sdk.dp.DPSdk
import com.bytedance.sdk.dp.IDPWidgetFactory
......@@ -11,7 +13,6 @@ import com.duben.happyplaylet.ad.express.ExpressManager
import com.duben.library.utils.json.JsonUtil
import com.duben.happyplaylet.common.Constant
import com.duben.happyplaylet.mvp.model.VedioBean
import com.duben.happyplaylet.ui.activitys.RecommendActivity
import com.duben.happyplaylet.utils.AppPreferencesManager
import com.duben.happyplaylet.utils.ToastUtil
import com.duben.happyplaylet.video.csj.DramaApiDetailActivity
......@@ -97,6 +98,7 @@ object LocalVedioManager {
fun startVedioDetailActivityForType(
activity: Activity,
data: VedioBean?,
view: View? = null,
isPlayNext: Boolean = false,
isThirdId: Boolean = false
) {
......@@ -106,7 +108,7 @@ object LocalVedioManager {
bundle.putString(Constant.VEDIO_BEAN, JsonUtil.toJson(data))
bundle.putBoolean(Constant.VEDIO_NEXT, isPlayNext)
bundle.putBoolean(Constant.VEDIO_THIRD, isThirdId)
readyGo(activity, TxVideoActivity::class.java, bundle)
readyGo(activity, TxVideoActivity::class.java, bundle, view)
} else if (data?.createType == 3) {
//推荐短剧
val bundle = Bundle()
......@@ -152,12 +154,15 @@ object LocalVedioManager {
}
}
fun readyGo(activity: Activity, clazz: Class<*>, bundle: Bundle) {
fun readyGo(activity: Activity, clazz: Class<*>, bundle: Bundle, view: View? = null) {
val intent = Intent(activity, clazz)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
if (null != bundle) {
intent.putExtras(bundle)
}
if (view != null) {
val options = ActivityOptions.makeSceneTransitionAnimation(activity, view, "iv_trans")
activity.startActivity(intent, options?.toBundle())
} else {
activity.startActivity(intent)
}
}
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import android.net.Uri
import android.os.Bundle
import android.view.KeyEvent
import android.view.View
import android.view.Window
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
......@@ -22,6 +23,7 @@ import com.duben.happyplaylet.ui.fragment.RecommendFragment
import com.duben.happyplaylet.ui.widgets.DialogListener
import com.duben.happyplaylet.ui.widgets.PhoneDialog
import com.duben.happyplaylet.video.csj.DPHolderManager
import com.duben.happyplaylet.video.tx.TxVideoFragment
import kotlinx.android.synthetic.main.activity_main.*
/**
......@@ -43,6 +45,8 @@ class MainActivity : BaseActivity(), View.OnClickListener {
private var mainFragment: Fragment? = null
private var recommendFragment: Fragment? = null
private var myFragment: Fragment? = null
private var txVideoFragment: Fragment? = null
private var currentFragment: Fragment? = null
private var phoneDialog: PhoneDialog? = null
......@@ -51,6 +55,9 @@ class MainActivity : BaseActivity(), View.OnClickListener {
}
override fun initViewsAndEvents() {
// 过渡动画
window.requestFeature(Window.FEATURE_CONTENT_TRANSITIONS)
DPHolderManager.initDpSdk(MintsApplication.getContext());
audioManager = getSystemService(Context.AUDIO_SERVICE) as AudioManager
......@@ -159,10 +166,15 @@ class MainActivity : BaseActivity(), View.OnClickListener {
*/
fun clickTab2Layout() {
AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_TWO
if (recommendFragment == null) {
recommendFragment = RecommendFragment()
// if (recommendFragment == null) {
// recommendFragment = RecommendFragment()
// }
// addOrShowFragment(supportFragmentManager.beginTransaction(), recommendFragment!!)
if (txVideoFragment == null) {
txVideoFragment = TxVideoFragment()
}
addOrShowFragment(supportFragmentManager.beginTransaction(), recommendFragment!!)
addOrShowFragment(supportFragmentManager.beginTransaction(), txVideoFragment!!)
tabIvLoan!!.isSelected = false
tabIvRecommend!!.isSelected = true
tabIvMy!!.isSelected = false
......
package com.duben.happyplaylet.ui.widgets
import android.view.View
import androidx.recyclerview.widget.OrientationHelper
import androidx.recyclerview.widget.PagerSnapHelper
import androidx.recyclerview.widget.RecyclerView
class TopPagerSnapHelper : PagerSnapHelper() {
override fun calculateDistanceToFinalSnap(
layoutManager: RecyclerView.LayoutManager,
targetView: View
): IntArray {
val out = IntArray(2)
if (layoutManager.canScrollHorizontally()) {
out[0] = distanceToCenter(
targetView,
getHorizontalHelper(layoutManager)
)
} else {
out[0] = 0
}
if (layoutManager.canScrollVertically()) {
out[1] = distanceToTop(
targetView,
getVerticalHelper(layoutManager)
)
} else {
out[1] = 0
}
return out
// return super.calculateDistanceToFinalSnap(layoutManager, targetView)
}
private fun distanceToCenter(targetView: View, helper: OrientationHelper): Int {
val childCenter = (helper.getDecoratedStart(targetView)
+ helper.getDecoratedMeasurement(targetView) / 2)
val containerCenter = helper.startAfterPadding + helper.totalSpace / 2
return childCenter - containerCenter
}
private fun distanceToTop(targetView: View, helper: OrientationHelper): Int {
return helper.getDecoratedStart(targetView) - helper.startAfterPadding
}
private var mVerticalHelper: OrientationHelper? = null
private var mHorizontalHelper: OrientationHelper? = null
private fun getVerticalHelper(layoutManager: RecyclerView.LayoutManager): OrientationHelper {
if (mVerticalHelper == null || mVerticalHelper!!.layoutManager !== layoutManager) {
mVerticalHelper = OrientationHelper.createVerticalHelper(layoutManager)
}
return mVerticalHelper!!
}
private fun getHorizontalHelper(layoutManager: RecyclerView.LayoutManager): OrientationHelper {
if (mHorizontalHelper == null || mHorizontalHelper!!.layoutManager !== layoutManager) {
mHorizontalHelper = OrientationHelper.createHorizontalHelper(layoutManager)
}
return mHorizontalHelper!!
}
}
\ No newline at end of file
......@@ -362,6 +362,7 @@ class DramaTabFragment : BaseFragment(), VideoView {
LocalVedioManager.startVedioDetailActivityForType(
requireActivity(),
indexList.vedioMsg,
null,
true,
isThirdId = true
)
......
......@@ -19,6 +19,7 @@ import androidx.recyclerview.widget.SimpleItemAnimator;
import com.duben.happyplaylet.ad.draw.HomeDrawExpressManager;
import com.duben.happyplaylet.manager.UserManager;
import com.duben.happyplaylet.mvp.model.VideoMultiItemEntity2;
import com.duben.happyplaylet.ui.widgets.TopPagerSnapHelper;
import com.duben.happyplaylet.video.tx.adapter.TxRecommendVideoAdapter;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
......@@ -45,8 +46,6 @@ public class RecommendVideoView extends RelativeLayout {
private int mCurrentPosition = 0;
private List<VideoMultiItemEntity2> mList = new ArrayList<>();
public RecommendVideoView(Context context) {
this(context, null);
}
......@@ -61,17 +60,11 @@ public class RecommendVideoView extends RelativeLayout {
}
public void loadData(List<VedioBean> list) {
if (this.mList != null) {
this.mList.clear();
}
this.mList = getAdapterData(list);
mAdapter.setNewInstance(this.mList);
mAdapter.setNewInstance(getAdapterData(list));
}
public void loadMoreData(List<VedioBean> list) {
this.mList.addAll(getAdapterData(list));
mAdapter.notifyItemRangeInserted(this.mList.size() - list.size(), list.size());
mAdapter.addData(getAdapterData(list));
}
public void init(Context context) {
......@@ -81,7 +74,7 @@ public class RecommendVideoView extends RelativeLayout {
mRecyclerView = mRootView.findViewById(R.id.rv_super_short_video);
mSmartRefreshLayout = mRootView.findViewById(R.id.src_video);
mSmartRefreshLayout.setEnableRefresh(false);
mSnapHelper = new PagerSnapHelper();
mSnapHelper = new TopPagerSnapHelper();
mSnapHelper.attachToRecyclerView(mRecyclerView);
mAdapter = new TxRecommendVideoAdapter();
mAdapter.setNewInstance(getAdapterData(null));
......@@ -136,7 +129,7 @@ public class RecommendVideoView extends RelativeLayout {
private void onPageSelectedMethod(int position) {
if (mOnPageChangeListener != null) mOnPageChangeListener.onPageChange(position);
if (mList == null || position >= mList.size() || this.mList.get(position).getItemType() != MULTI_ITEM_1) {
if (position >= getData().size() || getData().get(position).getItemType() != MULTI_ITEM_1) {
mBaseItemView.stopForPlaying();
return;
}
......@@ -150,9 +143,9 @@ public class RecommendVideoView extends RelativeLayout {
Log.i(TAG, "onPageSelected " + position);
List<VideoModel> tempUrlList = initUrlList(position, MAX_PLAYER_COUNT_ON_PASS);
mPlayerManager.updateManager(tempUrlList);
TXVodPlayerWrapper txVodPlayerWrapper = mPlayerManager.getPlayer(mList.get(position).getVideoModel());
TXVodPlayerWrapper txVodPlayerWrapper = mPlayerManager.getPlayer(getData().get(position).getVideoModel());
if (txVodPlayerWrapper != null) {
Log.i(TAG, "txVodPlayerWrapper " + txVodPlayerWrapper + "url-- " + mList.get(position).getVideoModel().videoURL);
Log.i(TAG, "txVodPlayerWrapper " + txVodPlayerWrapper + "url-- " + getData().get(position).getVideoModel().videoURL);
Log.i(TAG, "txVodPlayerWrapper " + txVodPlayerWrapper);
mBaseItemView.setTXVodPlayer(txVodPlayerWrapper);
}
......@@ -173,7 +166,7 @@ public class RecommendVideoView extends RelativeLayout {
*/
private List<VideoModel> initUrlList(int startIndex, int maxCount) {
List<VideoModel> videoModels = new ArrayList<>();
for (VideoMultiItemEntity2 videoMultiItemEntity2 : this.mList) {
for (VideoMultiItemEntity2 videoMultiItemEntity2 : getData()) {
videoModels.add(videoMultiItemEntity2.getVideoModel());
}
int i = startIndex - 1;
......@@ -260,7 +253,7 @@ public class RecommendVideoView extends RelativeLayout {
}
public List<VideoMultiItemEntity2> getData() {
return mList;
return mAdapter.getData();
}
private List<VideoMultiItemEntity2> getAdapterData(List<VedioBean> list) {
......@@ -285,8 +278,7 @@ public class RecommendVideoView extends RelativeLayout {
if (HomeDrawExpressManager.Companion.getInstance().getAdIsLoadSuc()) {
VideoMultiItemEntity2 itemAD = new VideoMultiItemEntity2(MULTI_ITEM_3, null, new VideoModel(""));
mList.add(position + 1, itemAD);
mAdapter.notifyItemInserted(position + 1);
mAdapter.addData(position + 1, itemAD);
lastAddAdPosition = position + 1;
}
}
......
......@@ -49,6 +49,7 @@ class TxVideoFragment : BaseFragment(), RecommendView {
LocalVedioManager.startVedioDetailActivityForType(
requireActivity(),
recommend_view.data[recommend_view.currentPosition].video,
null,
true
)
}
......@@ -60,6 +61,7 @@ class TxVideoFragment : BaseFragment(), RecommendView {
LocalVedioManager.startVedioDetailActivityForType(
requireActivity(),
recommend_view.data[position].video,
null,
true
)
}
......
......@@ -70,6 +70,7 @@ class TxRecommendVideoAdapter :
mOnCustomChildClickListener?.onCustomChildClick(it, holder.adapterPosition)
}
holder.getView<View>(R.id.ll_bottom).setOnClickListener {
mOnCustomChildClickListener?.onCustomChildClick(it, holder.adapterPosition)
}
......
......@@ -11,6 +11,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/iv_cover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:transitionName="iv_trans" />
<ImageView
android:id="@+id/close_iv"
android:layout_width="50dp"
......@@ -64,12 +70,12 @@
android:id="@+id/ll_lucky"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="1dp"
android:visibility="gone"
android:layout_gravity="bottom|right"
android:layout_marginEnd="1dp"
android:layout_marginBottom="220dp"
android:gravity="center"
android:orientation="vertical">
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:layout_width="80dp"
......
......@@ -2,11 +2,12 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black">
android:background="@color/white">
<com.duben.happyplaylet.video.tx.RecommendVideoView
android:id="@+id/recommend_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:layout_marginTop="100dp" />
</FrameLayout>
\ No newline at end of file
......@@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="560dp"
android:background="#77090909">
<com.duben.happyplaylet.video.tx.TXVideoBaseView
......@@ -89,7 +89,6 @@
</LinearLayout>
<LinearLayout
android:id="@+id/ll_collect"
android:layout_width="wrap_content"
......
......@@ -6,10 +6,10 @@
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/src_video"
app:srlEnableRefresh="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srlAccentColor="@color/black"
app:srlEnableRefresh="false"
app:srlPrimaryColor="#f0f2f5">
<androidx.recyclerview.widget.RecyclerView
......
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