Commit 797a007a authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 31bda680
package com.mints.goodmoney.ui.fragment
import android.Manifest
import android.os.Bundle
import android.text.TextUtils
import android.webkit.WebChromeClient
......@@ -7,9 +8,11 @@ import com.component.dly.xzzq_ywsdk.YwSDK_WebActivity
import com.github.lzyzsd.jsbridge.CallBackFunction
import com.github.lzyzsd.jsbridge.DefaultHandler
import com.mints.goodmoney.BuildConfig
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.R
import com.mints.goodmoney.common.AppConfig
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.manager.MokuManager
import com.mints.goodmoney.manager.UserManager
import com.mints.goodmoney.manager.YwhzManager
import com.mints.goodmoney.mvp.model.PanActionInfo
......@@ -19,7 +22,9 @@ import com.mints.goodmoney.mvp.views.PanView
import com.mints.goodmoney.ui.activitys.*
import com.mints.goodmoney.ui.fragment.base.BaseFragment
import com.mints.library.utils.json.JsonUtil
import com.tbruyelle.rxpermissions.RxPermissions
import kotlinx.android.synthetic.main.fragment_main_pan.*
import net.grandcentrix.tray.AppPreferences
/**
* 描述:大转盘
......@@ -31,6 +36,7 @@ class PanFragment : BaseFragment(), PanView {
private val panPresenter by lazy { PanPresenter() }
private val userManager by lazy { UserManager.getInstance() }
private val carrierType = Constant.CARRIER_CHALLENGE_TURN
private val ps by lazy { AppPreferences(context) }
override fun getContentViewLayoutID() = R.layout.fragment_main_pan
......@@ -39,8 +45,11 @@ class PanFragment : BaseFragment(), PanView {
if (!TextUtils.isEmpty(userManager.userID)) {
// 登录成功的用户初始化鱼丸盒子
if (userManager.userIsLogin()) {
YwhzManager.init(baseApplication)
// if (userManager.userIsLogin()) {
// YwhzManager.init(baseApplication)
// }
if (!TextUtils.isEmpty(MintsApplication.OAID)) {
MokuManager.initOaid(MintsApplication.OAID)
}
}
}
......@@ -145,17 +154,18 @@ class PanFragment : BaseFragment(), PanView {
readyGo(WrapperActivity::class.java, bundle)
}
3 -> {
if (!userManager.userIsLogin()) {
readyGo(WxLoginActivity::class.java)
return
}
try {
activity?.let { YwSDK_WebActivity.open(it) }
} catch (e: Exception) {
e.printStackTrace()
showToast("请重新退出账号登录")
}
// if (!userManager.userIsLogin()) {
// readyGo(WxLoginActivity::class.java)
// return
// }
//
// try {
// activity?.let { YwSDK_WebActivity.open(it) }
// } catch (e: Exception) {
// e.printStackTrace()
// showToast("请重新退出账号登录")
// }
gotoMoku()
}
4 -> {
val activity: MainActivity? = activity as MainActivity?
......@@ -193,4 +203,23 @@ class PanFragment : BaseFragment(), PanView {
bundle.putInt(Constant.WRAPPER_TYPE, Constant.WRAPPER_TYPE_WZ)
readyGo(WrapperActivity::class.java, bundle)
}
private fun gotoMoku() {
RxPermissions(requireActivity())
.request(Manifest.permission.READ_PHONE_STATE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
.subscribe { granted: Boolean ->
if (granted) {
MokuManager.gotoMoku(requireContext())
if (ps.getBoolean(Constant.MOKU_FLAG_GUIDE, true)) {
readyGo(MokuGuideActivity::class.java)
ps.put(Constant.MOKU_FLAG_GUIDE, false)
}
} else {
showMissingPermissionDialog("设备,存储")
}
}
}
}
\ No newline at end of file
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