Commit c4ab24f7 authored by fengruiyu's avatar fengruiyu

修改支付之后切换页面问题已解决

parent 24affd8c
......@@ -19,6 +19,7 @@ import com.mints.street.databinding.ActivityMainBinding
import com.mints.street.main.googlemap.GoogleMapFragment
import com.mints.street.main.home.HomeFragment
import com.mints.street.main.my.MyFragment
import com.mints.street.main.my.OpenvipActivity
import com.mints.street.main.vr.VRFragment
import com.mints.street.manager.UserManager
import com.mints.street.manager.oaid.OaidManager
......@@ -37,14 +38,6 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {
override fun getStatusBarHeightView(): View? {
return null
}
public fun verifyMember(){
if (UserManager.INSTANCE.userIsLogin() && UserManager.INSTANCE.getVipFlag()) {
binding.mainViewpager.setCurrentItem(3, false)
} else {
binding.mainViewpager.setCurrentItem(0, false)
}
}
override fun initData() {
super.initData()
......@@ -88,6 +81,16 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {
})
viewModel.checkUpgrade()
}
override fun onResume() {
super.onResume()
if (binding.mainViewpager.currentItem == 0){
if (UserManager.INSTANCE.userIsLogin() && UserManager.INSTANCE.getVipFlag()) {
binding.mainViewpager.setCurrentItem(3, false)
}
}
}
var oldTime: Long = 0
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
when (keyCode) {
......@@ -132,7 +135,7 @@ private fun ViewPager2.initMain(activity: MainActivity): ViewPager2 {
return when (position) {
0 -> {
//首页
HomeFragment(activity)
HomeFragment()
}
1 -> {
//广场
......@@ -148,7 +151,7 @@ private fun ViewPager2.initMain(activity: MainActivity): ViewPager2 {
else -> {
//首页
HomeFragment(activity)
HomeFragment()
}
}
......
......@@ -40,7 +40,7 @@ import me.goldze.mvvmhabit.utils.ToastUtils
* Created by 冯瑞雨 on 2021/7/2.
* 首页页面
*/
class HomeFragment(val mainActivity: MainActivity) : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorEventListener {
class HomeFragment() : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorEventListener {
companion object {
val IS_FIRST_OPEN: String = "isFirstOpen"
}
......@@ -303,7 +303,6 @@ class HomeFragment(val mainActivity: MainActivity) : BaseFragment<FragmentHomeBi
override fun onResume() {
super.onResume()
binding.bmapView.onResume()
mainActivity.verifyMember()
}
override fun onDestroy() {
......
......@@ -69,7 +69,7 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
})
} else {
if ((!UserManager.INSTANCE.userIsLogin() && !UserManager.INSTANCE.getVipFlag())) {
if ((!UserManager.INSTANCE.userIsLogin() || !UserManager.INSTANCE.getVipFlag())) {
startActivity(OpenvipActivity::class.java)
return
}
......
......@@ -23,8 +23,8 @@ class SearchAfterItem(viewModel: SearchMapViewModel,val name:String?
* 点击名称回调回调
*/
val onClick = BindingCommand<Any>(BindingAction {
if(viewModel.index.value==1&&
!UserManager.INSTANCE.userIsLogin() &&
if(viewModel.index.value==1||
!UserManager.INSTANCE.userIsLogin() ||
!UserManager.INSTANCE.getVipFlag()){
viewModel.startActivity(OpenvipActivity::class.java)
return@BindingAction
......
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