Commit 8c45b704 by YKai

feat:一键登录代码优化

parent f7ccfa3d
...@@ -47,7 +47,6 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -47,7 +47,6 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
private var serviceConnection: ServiceConnection? = null private var serviceConnection: ServiceConnection? = null
private var secretDialog: SecretDialog? = null private var secretDialog: SecretDialog? = null
protected var playService: PlayService? = null protected var playService: PlayService? = null
var oneKeyLoginHelp: OneKeyLoginHelp? = null // 一键登录辅助类
override fun getContentViewId(): Int { override fun getContentViewId(): Int {
return R.id.lce_content_view return R.id.lce_content_view
...@@ -74,7 +73,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -74,7 +73,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
// YDLavManager.instances.init(this, "3387e9b251f3491e9221a9877e8f7830") // YDLavManager.instances.init(this, "3387e9b251f3491e9221a9877e8f7830")
YdlCommonRouterManager.initYdlCommonRoute(PlatformTempCommonRouteImpl()) YdlCommonRouterManager.initYdlCommonRoute(PlatformTempCommonRouteImpl())
oneKeyLoginHelp = OneKeyLoginHelp(this, OneKeyLoginHelp.YDL_USER_APP, OneKeyLoginHelp.ONE_KEY_LOGIN) OneKeyLoginHelp.sdkInit(this, OneKeyLoginHelp.YDL_USER_APP, OneKeyLoginHelp.ONE_KEY_LOGIN)
bindService() bindService()
reLoadData() reLoadData()
...@@ -92,13 +91,10 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -92,13 +91,10 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
// .withBoolean("bind_phone", false) // .withBoolean("bind_phone", false)
// .withBoolean("isFromGuide", true) // .withBoolean("isFromGuide", true)
// .navigation() // .navigation()
oneKeyLoginHelp?.let { if (!OneKeyLoginHelp.isGetTokenSuccess) {
if (!it.isGetTokenSuccess){ OneKeyLoginHelp.setAuthListener()
it.setAuthListener()
}
oneKeyLoginHelp?.getLoginToken(false)
} }
OneKeyLoginHelp.getLoginToken(false)
} }
bt_to_consultant.setOnClickListener { bt_to_consultant.setOnClickListener {
// ARouter.getInstance() // ARouter.getInstance()
...@@ -201,12 +197,10 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -201,12 +197,10 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
} }
bt_to_mine.setOnClickListener { bt_to_mine.setOnClickListener {
// FragmentContainerActivity.start(this, "MineFragment") // FragmentContainerActivity.start(this, "MineFragment")
oneKeyLoginHelp?.let { if (!OneKeyLoginHelp.isGetTokenSuccess) {
if (!it.isGetTokenSuccess){ OneKeyLoginHelp.setAuthListener()
it.setAuthListener()
}
oneKeyLoginHelp?.getLoginToken(true)
} }
OneKeyLoginHelp.getLoginToken(false)
} }
bt_to_privacy.setOnClickListener { bt_to_privacy.setOnClickListener {
......
...@@ -24,31 +24,22 @@ import com.yidianling.common.tools.RxImageTool ...@@ -24,31 +24,22 @@ import com.yidianling.common.tools.RxImageTool
* TokenResultListener内存泄漏 * TokenResultListener内存泄漏
* sdk内部会持有外部设置进来的TokenResultListener,在⼀键登录功能使⽤完毕之后通过 * sdk内部会持有外部设置进来的TokenResultListener,在⼀键登录功能使⽤完毕之后通过
*/ */
class OneKeyLoginHelp { object OneKeyLoginHelp {
private var mPhoneNumberAuthHelper: PhoneNumberAuthHelper? = null private const val YDL_USER_APP_KEY =
private var mActivity: BaseActivity? = null "cl6yPRBkrpRfZpTPkTKoa1+/J+muUvPMPR2HRb0oll24XnyeLPGRDtla7p54HBd3362GfxhNJLYHaaEPHKwl16lDpvNbJ9mm+VbcYQTSX3NK+apSz2/8ul7lMWrGI/1HRyQ9G7njyI3e5BW3FBVqMh3dssocaraDJgbnQds+5ajWM7kklcSy9c8k49TegzBqmj/6ENqNLG1JNgtfTXmBOPQAs9DZVWh+bUN6SfE/tCRuUEb9zriAkP/TY1ouYvXXQU1Ivjy6S7xMJduTNqHrnuUW93D1r1/v"
var isGetTokenSuccess = true private const val YDL_EXPERT_APP_KEY =
"i4Y/PVRAz4P/aqajQF7SOd3JUIKEsJbRurH04azLyX6N2upi292OrLHECRmtTVAqY24HFjwUjW1QjRwJA9aFbNzl3zl7L5DEDBZ4+QSU28vq34HccmAjAeUCC7qCHbN7QLVZqhVpuYUCMZ5fp2NdhANJl/741wHccdPk/Un5c4larDNuv1KEo2OZOds2J1WFiBx7giWtzli4NwMq9x+9sb0aXPZZQ9C9Kr8T/0+/ccYdotwFm7XWenNs/G3Jy1HHVqqOCDecKPbyXR+cV0jBUisSjv+SEUTfpcc3iUGH5OjZyQ6OfaLkdjATsr5K9oVP"
const val YDL_USER_APP = 1
const val YDL_EXPERT_APP = 2
const val PHONE_CHECK = 1 // 本机号码验证
const val ONE_KEY_LOGIN = 2 // 一键登录
private var mAuthType: Int = 1 private var mAuthType: Int = 1
var isGetTokenSuccess = true
var mPhoneNumberAuthHelper: PhoneNumberAuthHelper? = null
private var mActivity: BaseActivity? = null
companion object {
private const val YDL_USER_APP_KEY =
"cl6yPRBkrpRfZpTPkTKoa1+/J+muUvPMPR2HRb0oll24XnyeLPGRDtla7p54HBd3362GfxhNJLYHaaEPHKwl16lDpvNbJ9mm+VbcYQTSX3NK+apSz2/8ul7lMWrGI/1HRyQ9G7njyI3e5BW3FBVqMh3dssocaraDJgbnQds+5ajWM7kklcSy9c8k49TegzBqmj/6ENqNLG1JNgtfTXmBOPQAs9DZVWh+bUN6SfE/tCRuUEb9zriAkP/TY1ouYvXXQU1Ivjy6S7xMJduTNqHrnuUW93D1r1/v"
private const val YDL_EXPERT_APP_KEY =
"i4Y/PVRAz4P/aqajQF7SOd3JUIKEsJbRurH04azLyX6N2upi292OrLHECRmtTVAqY24HFjwUjW1QjRwJA9aFbNzl3zl7L5DEDBZ4+QSU28vq34HccmAjAeUCC7qCHbN7QLVZqhVpuYUCMZ5fp2NdhANJl/741wHccdPk/Un5c4larDNuv1KEo2OZOds2J1WFiBx7giWtzli4NwMq9x+9sb0aXPZZQ9C9Kr8T/0+/ccYdotwFm7XWenNs/G3Jy1HHVqqOCDecKPbyXR+cV0jBUisSjv+SEUTfpcc3iUGH5OjZyQ6OfaLkdjATsr5K9oVP"
const val YDL_USER_APP = 1
const val YDL_EXPERT_APP = 2
const val PHONE_CHECK = 1 // 本机号码验证
const val ONE_KEY_LOGIN = 2 // 一键登录
}
/** fun sdkInit(activity: BaseActivity, authType: Int, loginType: Int) {
* 构造方法
*
* @param activity
* @param authType 1表示用户端一键登录 2表示
* @param loginType 1本机号码校验 2一键登录
*/
constructor(activity: BaseActivity, authType: Int, loginType: Int) {
mActivity = activity mActivity = activity
mAuthType = authType mAuthType = authType
mPhoneNumberAuthHelper = PhoneNumberAuthHelper.getInstance(activity, mTokenListener) mPhoneNumberAuthHelper = PhoneNumberAuthHelper.getInstance(activity, mTokenListener)
...@@ -66,6 +57,8 @@ class OneKeyLoginHelp { ...@@ -66,6 +57,8 @@ class OneKeyLoginHelp {
} }
} }
/** /**
* 设置token监听 * 设置token监听
* *
......
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