Commit c4ab24f7 authored by fengruiyu's avatar fengruiyu

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

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