视频流增加最新Tab
This commit is contained in:
@ -62,6 +62,8 @@ public class Constants {
|
||||
public static final String SP_ADDONS_FUNCS_HAVE_READ = "addons_funcs_have_read";
|
||||
//视频非wifi提醒只提醒一次,重启恢复
|
||||
public static final String SP_NON_WIFI_TIPS = "non_wifi_tips";
|
||||
//首页视频最新tab提示
|
||||
public static final String SP_HOME_NEW_VIDEO_TIPS = "home_new_video";
|
||||
|
||||
//手机号码匹配规则
|
||||
public static final String REGEX_MOBILE = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";
|
||||
|
||||
@ -175,7 +175,7 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
private boolean isSkipped = false;
|
||||
public static boolean isNewFirstLaunch;
|
||||
public String uuid = UUID.randomUUID().toString();
|
||||
// public String uuid = UUID.randomUUID().toString();
|
||||
|
||||
private Handler handler = new Handler();
|
||||
|
||||
|
||||
@ -54,6 +54,7 @@ import com.gh.gamecenter.message.MessageUnreadRepository;
|
||||
import com.gh.gamecenter.message.MessageUnreadViewModel;
|
||||
import com.gh.gamecenter.personal.PersonalFragment;
|
||||
import com.gh.gamecenter.qa.CommunityFragment;
|
||||
import com.gh.gamecenter.video.detail.HomeVideoFragment;
|
||||
import com.gh.gamecenter.video.detail.VideoDetailContainerFragment;
|
||||
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel;
|
||||
import com.halo.assistant.HaloApp;
|
||||
@ -110,9 +111,6 @@ public class MainWrapperFragment extends BaseFragment_ViewPager_Checkable implem
|
||||
@BindView(R.id.main_tab_game_name)
|
||||
TextView mTabGameName;
|
||||
|
||||
// @BindView(R.id.iv_discovery_hint_dot)
|
||||
// protected View mDiscoveryHintIv;
|
||||
|
||||
public static final int INDEX_HOME = 0;
|
||||
public static final int INDEX_GAME = 1;
|
||||
public static final int INDEX_VIDEO = 2;
|
||||
@ -127,7 +125,7 @@ public class MainWrapperFragment extends BaseFragment_ViewPager_Checkable implem
|
||||
private MainWrapperViewModel mViewModel;
|
||||
private MessageUnreadViewModel mMessageUnreadViewModel;
|
||||
private GameTrendsDao mGameTrendsDao;
|
||||
private VideoDetailContainerFragment videoDetailContainerFragment;
|
||||
private HomeVideoFragment homeVideoFragment;
|
||||
private String[] resAssets = {"lottie/tab_home.json", "lottie/tab_game.json", "lottie/tab_video.json", "tab_community.gif", "tab_mine.gif"};
|
||||
|
||||
@Override
|
||||
@ -161,17 +159,17 @@ public class MainWrapperFragment extends BaseFragment_ViewPager_Checkable implem
|
||||
mGameWrapperFragment.setArguments(homeArgs);
|
||||
fragments.add(mGameWrapperFragment);
|
||||
|
||||
videoDetailContainerFragment = new VideoDetailContainerFragment();
|
||||
|
||||
homeVideoFragment = new HomeVideoFragment();
|
||||
Bundle videoArgs = new Bundle();
|
||||
videoArgs.putString(EntranceUtils.KEY_LOCATION, VideoDetailContainerViewModel.Location.VIDEO_CHOICENESS.getValue());
|
||||
videoArgs.putString(EntranceUtils.KEY_PATH, "视频总入口");
|
||||
videoArgs.putString(EntranceUtils.KEY_UUID, ((MainActivity) requireContext()).uuid);
|
||||
//videoArgs.putString(EntranceUtils.KEY_UUID, ((MainActivity) requireContext()).uuid);
|
||||
videoArgs.putBoolean(EntranceUtils.KEY_IS_HOME_VIDEO, true);
|
||||
videoDetailContainerFragment.setArguments(videoArgs);
|
||||
fragments.add(videoDetailContainerFragment);
|
||||
homeVideoFragment.setArguments(videoArgs);
|
||||
fragments.add(homeVideoFragment);
|
||||
|
||||
fragments.add(new CommunityFragment());
|
||||
//fragments.add(new DiscoverFragment());
|
||||
fragments.add(new PersonalFragment());
|
||||
}
|
||||
|
||||
@ -582,8 +580,8 @@ public class MainWrapperFragment extends BaseFragment_ViewPager_Checkable implem
|
||||
|
||||
@Override
|
||||
public boolean onHandleBackPressed() {
|
||||
if (videoDetailContainerFragment != null) {
|
||||
return videoDetailContainerFragment.onHandleBackPressed();
|
||||
if (homeVideoFragment.getCurrentFragment() != null) {
|
||||
return homeVideoFragment.getCurrentFragment().onHandleBackPressed();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -8,19 +8,13 @@ import android.view.Window;
|
||||
|
||||
import com.gh.gamecenter.R;
|
||||
import com.google.android.exoplayer2.DefaultLoadControl;
|
||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||
import com.shuyu.gsyvideoplayer.GSYVideoBaseManager;
|
||||
import com.shuyu.gsyvideoplayer.model.GSYModel;
|
||||
import com.shuyu.gsyvideoplayer.player.IPlayerInitSuccessListener;
|
||||
import com.shuyu.gsyvideoplayer.player.IPlayerManager;
|
||||
import com.shuyu.gsyvideoplayer.utils.CommonUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import tv.danmaku.ijk.media.exo2.Exo2PlayerManager;
|
||||
import tv.danmaku.ijk.media.exo2.IjkExo2MediaPlayer;
|
||||
import tv.danmaku.ijk.media.player.IMediaPlayer;
|
||||
|
||||
import static com.shuyu.gsyvideoplayer.utils.CommonUtil.hideNavKey;
|
||||
|
||||
|
||||
@ -715,11 +715,12 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||
}
|
||||
|
||||
private fun getKey(): String {
|
||||
return if (context is MainActivity) {
|
||||
/* return if (context is MainActivity) {
|
||||
"detail_${(context as MainActivity).uuid}"
|
||||
} else {
|
||||
"detail_${(context as VideoDetailActivity).uuid}"
|
||||
}
|
||||
}*/
|
||||
return "detail_${mViewModel?.uuid}"
|
||||
}
|
||||
|
||||
override fun updateStartImage() {
|
||||
|
||||
@ -0,0 +1,85 @@
|
||||
package com.gh.gamecenter.video.detail
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.gh.base.adapter.FragmentAdapter
|
||||
import com.gh.base.fragment.BaseLazyFragment
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.R
|
||||
import kotlinx.android.synthetic.main.fragment_home_video.*
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
/**
|
||||
* 首页视频页面
|
||||
*/
|
||||
class HomeVideoFragment : BaseLazyFragment() {
|
||||
|
||||
private var mNewHint: View? = null
|
||||
private var newestVideoDetailFragment: VideoDetailContainerFragment? = null
|
||||
private var recommendVideoDetailFragment: VideoDetailContainerFragment? = null
|
||||
private val fragments = ArrayList<Fragment>()
|
||||
private val titles = arrayListOf("最新", "推荐")
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.fragment_home_video
|
||||
|
||||
|
||||
override fun onFragmentFirstVisible() {
|
||||
super.onFragmentFirstVisible()
|
||||
val newestBundle = bundleOf(EntranceUtils.KEY_UUID to UUID.randomUUID().toString())
|
||||
newestBundle.putAll(arguments)
|
||||
newestVideoDetailFragment = VideoDetailContainerFragment()
|
||||
newestVideoDetailFragment?.with(newestBundle)
|
||||
fragments.add(newestVideoDetailFragment!!)
|
||||
|
||||
val recommendBundle = bundleOf(EntranceUtils.KEY_UUID to UUID.randomUUID().toString())
|
||||
recommendBundle.putAll(arguments)
|
||||
recommendVideoDetailFragment = VideoDetailContainerFragment()
|
||||
recommendVideoDetailFragment?.with(recommendBundle)
|
||||
fragments.add(recommendVideoDetailFragment!!)
|
||||
|
||||
mViewPager.apply {
|
||||
offscreenPageLimit = fragments.size
|
||||
adapter = FragmentAdapter(childFragmentManager, fragments, titles)
|
||||
currentItem = 1
|
||||
doOnPageSelected {
|
||||
if (it == 0) {
|
||||
SPUtils.setBoolean(Constants.SP_HOME_NEW_VIDEO_TIPS, true)
|
||||
mNewHint?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
mTabLayout.setupWithViewPager(mViewPager)
|
||||
|
||||
for (i in 0 until mTabLayout.childCount) {
|
||||
val tab = mTabLayout.getTabAt(i) ?: continue
|
||||
val tabView = provideTabView(i, if (tab.text != null) tab.text!!.toString() else "")
|
||||
?: continue
|
||||
tab.customView = tabView
|
||||
}
|
||||
val homeNewVideoTips = SPUtils.getBoolean(Constants.SP_HOME_NEW_VIDEO_TIPS, false)
|
||||
mNewHint?.visibleIf(!homeNewVideoTips)
|
||||
}
|
||||
|
||||
fun getCurrentFragment(): VideoDetailContainerFragment? {
|
||||
return if (mViewPager.currentItem == 0) {
|
||||
newestVideoDetailFragment
|
||||
} else {
|
||||
recommendVideoDetailFragment
|
||||
}
|
||||
}
|
||||
|
||||
private fun provideTabView(position: Int, tabTitle: String): View? {
|
||||
if (position == 0) {
|
||||
val container = LayoutInflater.from(context).inflate(R.layout.home_video_tab_item, null)
|
||||
container.findViewById<TextView>(R.id.content).text = tabTitle
|
||||
mNewHint = container.findViewById<View>(R.id.hint)
|
||||
return container
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
@ -108,10 +108,7 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener {
|
||||
override fun onFragmentFirstVisible() {
|
||||
super.onFragmentFirstVisible()
|
||||
initListener()
|
||||
if (mLocation == VideoDetailContainerViewModel.Location.USER_UPLOADED_VIDEO.value) {
|
||||
titleTv.text = ""
|
||||
} else {
|
||||
titleTv.text = "推荐"
|
||||
if (mLocation != VideoDetailContainerViewModel.Location.USER_UPLOADED_VIDEO.value) {
|
||||
toolbar.inflateMenu(R.menu.menu_video_detail)
|
||||
toolbar.setOnMenuItemClickListener {
|
||||
consume {
|
||||
@ -124,6 +121,7 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener {
|
||||
}
|
||||
}
|
||||
if (!mIsHomeVideo) {
|
||||
titleTv.text = "推荐"
|
||||
toolbar.setNavigationIcon(R.drawable.ic_toolbar_back_white)
|
||||
toolbar.setNavigationOnClickListener { requireActivity().finish() }
|
||||
}
|
||||
@ -495,7 +493,7 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener {
|
||||
super.onFragmentResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
override fun onFragmentPause() {
|
||||
if (mScheduledPlayDisposable != null && !mScheduledPlayDisposable!!.isDisposed) {
|
||||
mScheduledPlayDisposable!!.dispose()
|
||||
mScheduledPlayDisposable = null
|
||||
@ -517,7 +515,7 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener {
|
||||
guideRl.visibility = View.GONE
|
||||
}
|
||||
SPUtils.setBoolean(Constants.SP_SHOW_SLIDE_GUIDE, true)
|
||||
super.onPause()
|
||||
super.onFragmentPause()
|
||||
ExoCacheManager.cancelAll()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user