Commit 8c45b704 by YKai

feat:一键登录代码优化

parent f7ccfa3d
......@@ -47,7 +47,6 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
private var serviceConnection: ServiceConnection? = null
private var secretDialog: SecretDialog? = null
protected var playService: PlayService? = null
var oneKeyLoginHelp: OneKeyLoginHelp? = null // 一键登录辅助类
override fun getContentViewId(): Int {
return R.id.lce_content_view
......@@ -74,7 +73,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
// YDLavManager.instances.init(this, "3387e9b251f3491e9221a9877e8f7830")
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()
reLoadData()
......@@ -92,13 +91,10 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
// .withBoolean("bind_phone", false)
// .withBoolean("isFromGuide", true)
// .navigation()
oneKeyLoginHelp?.let {
if (!it.isGetTokenSuccess){
it.setAuthListener()
}
oneKeyLoginHelp?.getLoginToken(false)
if (!OneKeyLoginHelp.isGetTokenSuccess) {
OneKeyLoginHelp.setAuthListener()
}
OneKeyLoginHelp.getLoginToken(false)
}
bt_to_consultant.setOnClickListener {
// ARouter.getInstance()
......@@ -201,12 +197,10 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
}
bt_to_mine.setOnClickListener {
// FragmentContainerActivity.start(this, "MineFragment")
oneKeyLoginHelp?.let {
if (!it.isGetTokenSuccess){
it.setAuthListener()
}
oneKeyLoginHelp?.getLoginToken(true)
if (!OneKeyLoginHelp.isGetTokenSuccess) {
OneKeyLoginHelp.setAuthListener()
}
OneKeyLoginHelp.getLoginToken(false)
}
bt_to_privacy.setOnClickListener {
......
......@@ -24,31 +24,22 @@ import com.yidianling.common.tools.RxImageTool
* TokenResultListener内存泄漏
* sdk内部会持有外部设置进来的TokenResultListener,在⼀键登录功能使⽤完毕之后通过
*/
class OneKeyLoginHelp {
private var mPhoneNumberAuthHelper: PhoneNumberAuthHelper? = null
private var mActivity: BaseActivity? = null
var isGetTokenSuccess = true
object OneKeyLoginHelp {
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 // 一键登录
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 // 一键登录
}
/**
* 构造方法
*
* @param activity
* @param authType 1表示用户端一键登录 2表示
* @param loginType 1本机号码校验 2一键登录
*/
constructor(activity: BaseActivity, authType: Int, loginType: Int) {
fun sdkInit(activity: BaseActivity, authType: Int, loginType: Int) {
mActivity = activity
mAuthType = authType
mPhoneNumberAuthHelper = PhoneNumberAuthHelper.getInstance(activity, mTokenListener)
......@@ -66,6 +57,8 @@ class OneKeyLoginHelp {
}
}
/**
* 设置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