feat:增加首页动态切换Tab
This commit is contained in:
@@ -3,14 +3,12 @@ package com.nnbc123.app.home.fragment
|
||||
import android.graphics.Color
|
||||
import android.view.Gravity
|
||||
import android.widget.LinearLayout
|
||||
import com.chuhai.utils.ktx.getColorById
|
||||
import com.chuhai.utils.ktx.singleClick
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.adapter.RoomVPAdapter
|
||||
import com.nnbc123.app.base.BaseBindingFragment
|
||||
import com.nnbc123.app.databinding.HomeFragmentBinding
|
||||
import com.nnbc123.app.home.activity.MoreRoomActivity
|
||||
import com.nnbc123.app.home.adapter.HomeMagicIndicatorAdapter
|
||||
import com.nnbc123.app.home.helper.OpenRoomHelper
|
||||
import com.nnbc123.app.ui.search.SearchActivity
|
||||
@@ -19,6 +17,7 @@ import com.nnbc123.app.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.nnbc123.core.DemoCache
|
||||
import com.nnbc123.core.UriProvider
|
||||
import com.nnbc123.core.initial.InitialModel
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.library.annatation.ActLayoutRes
|
||||
@@ -65,6 +64,9 @@ class HomeFragment2 : BaseBindingFragment<HomeFragmentBinding>() {
|
||||
commonNavigator.setTitleWrapContent(true)
|
||||
commonNavigator.setTitleGravity(Gravity.CENTER_VERTICAL)
|
||||
val magicIndicatorAdapter = HomeMagicIndicatorAdapter(context, tagList)
|
||||
magicIndicatorAdapter.setOnItemSelectListener { position, view ->
|
||||
mBinding.viewPager.currentItem = position
|
||||
}
|
||||
magicIndicatorAdapter.normalColor = Color.parseColor("#696D7A")
|
||||
magicIndicatorAdapter.selectedColor = Color.parseColor("#2B2D33")
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
@@ -74,5 +76,11 @@ class HomeFragment2 : BaseBindingFragment<HomeFragmentBinding>() {
|
||||
mBinding.viewPager.adapter =
|
||||
RoomVPAdapter(childFragmentManager, fragmentList)
|
||||
ViewPagerHelper.bind(mBinding.magicIndicator, mBinding.viewPager)
|
||||
InitialModel.get().cacheInitInfo?.defaultTab?.let {
|
||||
val tab = it - 1
|
||||
if (it >= 0 && it < tagList.size) {
|
||||
mBinding.viewPager.currentItem = tab
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -228,6 +228,8 @@ public class InitInfo implements Serializable {
|
||||
|
||||
private List<H5Uri> h5Uris;
|
||||
|
||||
private int defaultTab;
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="delombok">
|
||||
@SuppressWarnings("all")
|
||||
public InitInfo() {
|
||||
@@ -907,6 +909,7 @@ public class InitInfo implements Serializable {
|
||||
final Object this$trtcAppId = this.getTrtcAppId();
|
||||
final Object other$trtcAppId = other.getTrtcAppId();
|
||||
if (this$trtcAppId == null ? other$trtcAppId != null : !this$trtcAppId.equals(other$trtcAppId)) return false;
|
||||
if (this.getDefaultTab() != other.getDefaultTab()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -991,9 +994,18 @@ public class InitInfo implements Serializable {
|
||||
result = result * PRIME + ($officialMsgUids == null ? 43 : $officialMsgUids.hashCode());
|
||||
final Object $trtcAppId = this.getTrtcAppId();
|
||||
result = result * PRIME + ($trtcAppId == null ? 43 : $trtcAppId.hashCode());
|
||||
result = result * PRIME + this.getDefaultTab();
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getDefaultTab() {
|
||||
return defaultTab;
|
||||
}
|
||||
|
||||
public void setDefaultTab(int defaultTab) {
|
||||
this.defaultTab = defaultTab;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public String toString() {
|
||||
|
Reference in New Issue
Block a user