Commit 797a007a authored by mengcuiguang's avatar mengcuiguang

代码优化

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