class Splsah : AppCompatActivity() {
var countDanw:CountDownTimer?=null
var totalMinus=4;
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splsah)
countDanw=object :CountDownTimer(4*1000,1000){
override fun onFinish() {
startActivity<MainActivity>()
finish()
}
override fun onTick(millisUntilFinished: Long) {
totalMinus--
textView_Tg.text="跳过(${totalMinus})"
}
}
countDanw?.start()
}
}
class MainActivity : BaseActivity() {
//对话框
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val hasNet=NetHttp.hasNet(this)
if(hasNet){
alert("1.更新了编程语言使用Kotlin\n2.优化了内存","更新"){
positiveButton("更新",{
toast("正在更新...")
})
negativeButton("取消",{
toast("取消更新...")
})
}.show()
}else{
toast("当前没有网络")
}
}
val syFragment=SyFragment()
val yyFragment=YyFragment()
val vipFragment=VipFragment()
val wdFragment=WdFragment()
override fun initData(){
initBotton()
supportFragmentManager.beginTransaction()
.replace(R.id.frameLayout_id,syFragment).commit()
}
override fun setLayoutId()=R.layout.activity_main
override fun initBotton() {
val tabTitle= arrayOf("首页","影院","VIP","我的")
val tabIconN= arrayOf(R.drawable.home_n,R.drawable.movie_n,R.drawable.movie_n,R.drawable.my_n)
val tabIconP= arrayOf(R.drawable.home_p,R.drawable.movie_p,R.drawable.movie_p,R.drawable.my_p)
for (i in 0..3){
if(i==0){
tabLayout_id.addTab(tabLayout_id.newTab().setIcon(tabIconP[i]).setText(tabTitle[i]))
}else{
tabLayout_id.addTab(tabLayout_id.newTab().setIcon(tabIconN[i]).setText(tabTitle[i]))
}
}
tabLayout_id.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener{
override fun onTabReselected(p0: TabLayout.Tab?) {
}
override fun onTabUnselected(p0: TabLayout.Tab?) {
p0?.apply {
setIcon(tabIconN[position])
}
}
override fun onTabSelected(p0: TabLayout.Tab?) {
p0?.apply {
textView_SY.text=tabTitle[position]
setIcon(tabIconP[position])
when(position){
0 -> supportFragmentManager.beginTransaction().replace(R.id.frameLayout_id,syFragment).commit()
1 -> supportFragmentManager.beginTransaction().replace(R.id.frameLayout_id,yyFragment).commit()
2 -> supportFragmentManager.beginTransaction().replace(R.id.frameLayout_id,vipFragment).commit()
3 -> supportFragmentManager.beginTransaction().replace(R.id.frameLayout_id,wdFragment).commit()
}
}
}
})
}
}```