fix bug and add need authorize background work
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
package com.mogo.module.authorize.authprovider.biz
|
||||
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_LAUNCHER_MAIN
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeContentListener
|
||||
import com.mogo.module.authorize.model.BaseResponse
|
||||
import com.mogo.module.authorize.model.IMogoAuthorizeModel
|
||||
import com.mogo.module.authorize.model.bean.AgreementData
|
||||
import com.mogo.module.authorize.net.request
|
||||
import com.mogo.module.authorize.util.DateUtil.parseDateToTime
|
||||
import com.mogo.module.authorize.util.SharedPreferenceUtil.getAuthorizeVersion
|
||||
import com.mogo.module.authorize.util.SharedPreferenceUtil.setAuthorizeStatus
|
||||
import com.mogo.module.authorize.util.SharedPreferenceUtil.updateAuthorizeVersion
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
open class IMogoAuthorizeController {
|
||||
@@ -17,47 +20,54 @@ open class IMogoAuthorizeController {
|
||||
private val authorizeModel: IMogoAuthorizeModel by lazy { IMogoAuthorizeModel() }
|
||||
|
||||
fun invokeAuthorizeContent(tag: String, agreementType: Int) {
|
||||
if (agreementType == -1) {
|
||||
realInvokeAuthorizeContent(agreementType, {
|
||||
if (agreementType == -1) {
|
||||
getAuthorizeContentListener(tag, { listener ->
|
||||
listener.requestContentFailed("invokeAuthorizeContent param tag is not right")
|
||||
}, {
|
||||
Logger.d(TAG, "invokeAuthorizeContent ---checkAgreementType can not find tag :$tag")
|
||||
})
|
||||
}
|
||||
}, {
|
||||
getAuthorizeContentListener(tag, { listener ->
|
||||
listener.requestContentFailed("invokeAuthorizeContent param tag is not right")
|
||||
if (it.result != null && it.result.agreement.agreementContent != null) {
|
||||
listener.requestContentSuccess(it.result.agreement)
|
||||
} else {
|
||||
listener.requestContentFailed("request authorize content success ,but result data is :${it.result}")
|
||||
}
|
||||
}, {
|
||||
Logger.d(TAG, "invokeAuthorizeContent ---checkAgreementType can not find tag :$tag")
|
||||
Logger.d(TAG, "invokeAuthorizeContent --- can not find listener by this tag :$tag")
|
||||
})
|
||||
}
|
||||
}, { msg: String ->
|
||||
getAuthorizeContentListener(tag, { listener ->
|
||||
listener.requestContentFailed(msg)
|
||||
}, {
|
||||
Logger.d(TAG, "invokeAuthorizeContent --- can not find listener by this tag :$tag")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
private fun realInvokeAuthorizeContent(agreementType: Int, onStart: (() -> Unit), onSuccess: ((BaseResponse<AgreementData>) -> Unit), onError: ((String) -> Unit)) {
|
||||
onStart.invoke()
|
||||
try {
|
||||
request<BaseResponse<AgreementData>> {
|
||||
loader {
|
||||
authorizeModel.invokeAuthorizeContent(agreementType)
|
||||
}
|
||||
onSuccess {
|
||||
getAuthorizeContentListener(tag, { listener ->
|
||||
if (it.result != null && it.result.agreement.agreementContent != null) {
|
||||
listener.requestContentSuccess(it.result.agreement)
|
||||
} else {
|
||||
listener.requestContentFailed("request authorize content success ,but result data is :${it.result}")
|
||||
}
|
||||
}, {
|
||||
Logger.d(TAG, "invokeAuthorizeContent --- can not find listener by this tag :$tag")
|
||||
})
|
||||
onSuccess.invoke(it)
|
||||
}
|
||||
onError {
|
||||
getAuthorizeContentListener(tag, { listener ->
|
||||
listener.requestContentFailed(it.message
|
||||
?: "request authorize content failed,please check network")
|
||||
}, {
|
||||
Logger.d(TAG, "invokeAuthorizeContent --- can not find listener by this tag :$tag")
|
||||
})
|
||||
onError.invoke(it.message
|
||||
?: "realInvokeAuthorizeContent onError, message is null")
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
onError.invoke(e.message ?: "realInvokeAuthorizeContent has exception, message is null")
|
||||
}
|
||||
}
|
||||
|
||||
private fun realInvokeAuthorizeContent(){
|
||||
|
||||
}
|
||||
|
||||
private inline fun getAuthorizeContentListener(tag: String, blockSuccess: ((IMogoAuthorizeContentListener) -> Unit), blockNull: (() -> Unit)) {
|
||||
val authorizeContentListener = MogoAuthorizeRegisterHandler.getAuthorizeContentListener(tag)
|
||||
if (authorizeContentListener != null) {
|
||||
@@ -67,7 +77,26 @@ open class IMogoAuthorizeController {
|
||||
}
|
||||
}
|
||||
|
||||
fun updateAgreementAndAuthorization(agreementType: Int) {
|
||||
invokeAuthorizeContent(AUTHORIZE_TYPE_LAUNCHER_MAIN, agreementType)
|
||||
fun updateAgreementVersion(agreementType: Int) {
|
||||
realInvokeAuthorizeContent(agreementType, {
|
||||
Logger.d(TAG, "ready to update agreement")
|
||||
}, {
|
||||
if (it.result != null) {
|
||||
val agreement = it.result.agreement
|
||||
val updateTime = agreement.tUserAgreementEntity.updateTime
|
||||
val currentTime = parseDateToTime(updateTime)
|
||||
if (hasNewVersion(currentTime)) {
|
||||
updateAuthorizeVersion(currentTime)
|
||||
setAuthorizeStatus(agreementType, false)
|
||||
}
|
||||
}
|
||||
}, { s: String ->
|
||||
Logger.d(TAG, "updateAgreementAndAuthorization reason:$s")
|
||||
})
|
||||
}
|
||||
|
||||
private fun hasNewVersion(currentTime: Long): Boolean {
|
||||
val oldVersion = getAuthorizeVersion()
|
||||
return currentTime > oldVersion
|
||||
}
|
||||
}
|
||||
@@ -4,23 +4,29 @@ import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeContentListen
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeInvoke
|
||||
import com.mogo.module.authorize.authprovider.module.IMogoAcquireAuthorizeListener
|
||||
import com.mogo.module.authorize.model.proxy.AuthorizeProxy
|
||||
import com.mogo.module.authorize.model.proxy.toAuthorizeType
|
||||
import com.mogo.module.authorize.util.SharedPreferenceUtil.needAuthorization
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
open abstract class MogoAuthorizeManagerImpl : IMogoAuthorizeInvoke {
|
||||
|
||||
companion object {
|
||||
const val TAG = "AuthorizeManagerImpl"
|
||||
}
|
||||
|
||||
private val baseController: IMogoAuthorizeController by lazy { IMogoAuthorizeController() }
|
||||
|
||||
override fun needAuthorize(tag: String): Boolean {
|
||||
val type = AuthorizeProxy.getAuthorizeType(tag)
|
||||
return needAuthorization(type)
|
||||
Logger.d(TAG, "needAuthorize update agreement in background")
|
||||
baseController.updateAgreementVersion(tag.toAuthorizeType())
|
||||
return needAuthorization(tag.toAuthorizeType())
|
||||
}
|
||||
|
||||
override fun invokeAuthorizeContent(tag: String) {
|
||||
//todo 后面动态代理统一处理校验问题
|
||||
Logger.d("invokeAuthorizeContent", "tag:$tag")
|
||||
Logger.d(TAG, "tag:$tag")
|
||||
val agreementType = AuthorizeProxy.getAuthorizeType(tag)
|
||||
Logger.d("invokeAuthorizeContent", "agreementType:$agreementType")
|
||||
Logger.d(TAG, "agreementType:$agreementType")
|
||||
baseController.invokeAuthorizeContent(tag, agreementType)
|
||||
}
|
||||
|
||||
@@ -33,7 +39,7 @@ open abstract class MogoAuthorizeManagerImpl : IMogoAuthorizeInvoke {
|
||||
}
|
||||
|
||||
override fun registerAuthorizeListener(tag: String, listener: IMogoAcquireAuthorizeListener) {
|
||||
Logger.d("AuthorizeManager", "registerAuthorize tag : $tag listener:$listener")
|
||||
Logger.d(TAG, "registerAuthorize tag : $tag listener:$listener")
|
||||
MogoAuthorizeRegisterHandler.registerAuthorizeListener(tag, listener)
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ interface IMogoAuthorizeInvoke : IMogoAuthorizeRegister {
|
||||
/**
|
||||
* 是否需要授权
|
||||
*/
|
||||
fun needAuthorize(tag:String): Boolean
|
||||
fun needAuthorize(tag: String): Boolean
|
||||
|
||||
/**
|
||||
* 获取授权内容
|
||||
|
||||
@@ -13,8 +13,8 @@ class IMogoAuthorizeMainManager : IMogoAuthorizeMainProvider {
|
||||
return mogoAuthShow.hasRegister(tag)
|
||||
}
|
||||
|
||||
override fun needAuthorize(): Boolean {
|
||||
return mogoAuthShow.needAuthorize()
|
||||
override fun needAuthorize(tag: String): Boolean {
|
||||
return mogoAuthShow.needAuthorize(tag)
|
||||
}
|
||||
|
||||
override fun invokeAuthorizeContent(tag: String) {
|
||||
|
||||
@@ -5,7 +5,9 @@ import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeRegisterHandler
|
||||
import com.mogo.module.authorize.model.BaseResponse
|
||||
import com.mogo.module.authorize.model.bean.AGREEMENT_EFFECT
|
||||
import com.mogo.module.authorize.model.bean.AGREEMENT_NOT_EFFECT
|
||||
import com.mogo.module.authorize.model.proxy.toAuthorizeType
|
||||
import com.mogo.module.authorize.net.request
|
||||
import com.mogo.module.authorize.util.SharedPreferenceUtil.setAuthorizeStatus
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
object MogoAuthorizeMainController : IMogoAuthorizeController() {
|
||||
@@ -17,27 +19,28 @@ object MogoAuthorizeMainController : IMogoAuthorizeController() {
|
||||
val acquireAuthListener = MogoAuthorizeRegisterHandler.getAuthorizeListener(tag)
|
||||
updateAuthorize(agrId, AGREEMENT_EFFECT, {
|
||||
if (acquireAuthListener != null) {
|
||||
onSuccess.invoke()
|
||||
setAuthorizeStatus(tag.toAuthorizeType(), true)
|
||||
acquireAuthListener.authorizeSuccess()
|
||||
onSuccess.invoke()
|
||||
} else {
|
||||
Logger.d(TAG, "agreeAuthorize --- can not find listener by this tag :$tag ")
|
||||
}
|
||||
}, {
|
||||
val errorMsg = it ?: "agreeAuthorize failed,please check network"
|
||||
onError.invoke(errorMsg)
|
||||
authorizeFailed(tag, errorMsg)
|
||||
onError.invoke(errorMsg)
|
||||
})
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun disAgreeAuthorize(tag: String, agrId: Long, onSuccess: (() -> Unit), onError: ((String) -> Unit)) {
|
||||
updateAuthorize(agrId, AGREEMENT_NOT_EFFECT, {
|
||||
onSuccess.invoke()
|
||||
authorizeFailed(tag, "UserDisAgree authorize")
|
||||
onSuccess.invoke()
|
||||
}, {
|
||||
val errorMsg = it ?: "disAgreeAuthorize failed,please check network"
|
||||
onError.invoke(errorMsg)
|
||||
authorizeFailed(tag, errorMsg)
|
||||
onError.invoke(errorMsg)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeManagerImpl
|
||||
import com.mogo.module.authorize.authprovider.biz.MogoAuthorizeRegisterHandler
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_LAUNCHER_MAIN
|
||||
import com.mogo.module.authorize.fragment.AuthorizeFragment
|
||||
import com.mogo.module.authorize.model.proxy.AuthorizeProxy
|
||||
import com.mogo.module.authorize.model.proxy.toAuthorizeType
|
||||
import com.mogo.module.authorize.util.SharedPreferenceUtil.hasAuth
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
@@ -61,8 +61,7 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
|
||||
onError.invoke("invoke should be in main thread")
|
||||
return
|
||||
}
|
||||
val type = AuthorizeProxy.getAuthorizeType(tag)
|
||||
if (hasAuth(type)) {
|
||||
if (hasAuth(tag.toAuthorizeType())) {
|
||||
onError.invoke("already authorize,do not repeat operation")
|
||||
return
|
||||
}
|
||||
@@ -89,17 +88,17 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
|
||||
Logger.d(TAG, "pushFragmentToMainView")
|
||||
val mogoService = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation()
|
||||
if (mogoService is IMogoServiceApis) {
|
||||
push.invoke()
|
||||
mogoService.fragmentManagerApi.push(builderWrapper)
|
||||
}
|
||||
push.invoke()
|
||||
}
|
||||
|
||||
private inline fun popFragmentFromMainView(pop: (() -> Unit)) {
|
||||
val mogoService = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation()
|
||||
if (mogoService is IMogoServiceApis) {
|
||||
pop.invoke()
|
||||
mogoService.fragmentManagerApi.pop()
|
||||
}
|
||||
pop.invoke()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import com.mogo.module.authorize.authprovider.module.MogoModuleAuthorize.Compani
|
||||
@Route(path = AuthorizeConstant.PROVIDER_MODULE)
|
||||
class IMogoAuthorizeModuleManager : IMogoAuthorizeModuleProvider {
|
||||
|
||||
override fun needAuthorize(): Boolean {
|
||||
return mogoAuth.needAuthorize()
|
||||
override fun needAuthorize(tag: String): Boolean {
|
||||
return mogoAuth.needAuthorize(tag)
|
||||
}
|
||||
|
||||
override fun invokeAuthorizeForShow() {
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.mogo.commons.mvp.Presenter
|
||||
import com.mogo.module.authorize.authprovider.invoke.IMogoAuthorizeContentListener
|
||||
import com.mogo.module.authorize.authprovider.launcher.MogoMainAuthorize.Companion.mogoAuthShow
|
||||
import com.mogo.module.authorize.model.bean.Agreement
|
||||
import com.mogo.module.authorize.util.DateUtil.parseDateToTime
|
||||
import com.mogo.module.authorize.util.SharedPreferenceUtil.updateAuthorizeVersion
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.Biz, IMogoAuthorizeContentListener {
|
||||
@@ -14,6 +16,7 @@ class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.
|
||||
}
|
||||
|
||||
private var invokeTag: String? = null
|
||||
private var updateTime: Long = 0L
|
||||
|
||||
constructor(invokeTag: String, view: AuthorizeContract.View?) : super(view) {
|
||||
this.invokeTag = invokeTag
|
||||
@@ -42,6 +45,9 @@ class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.
|
||||
val title = userAgreement.tUserAgreementEntity.title
|
||||
val bottomContent = userAgreement.tUserAgreementEntity.agreementButtonFirst
|
||||
val lastContent = userAgreement.tUserAgreementEntity.agreementButtonSecond
|
||||
val tmpUpdate = userAgreement.tUserAgreementEntity.updateTime
|
||||
updateTime = parseDateToTime(tmpUpdate)
|
||||
Logger.d(TAG, "updateTime ===== $updateTime")
|
||||
mView.showAuthorizationAgreementContent(id, content, title, bottomContent, lastContent)
|
||||
} else {
|
||||
mView.showAuthorizationError()
|
||||
@@ -50,15 +56,15 @@ class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.
|
||||
|
||||
override fun requestContentFailed(errorMsg: String) {
|
||||
Logger.d(TAG, "requestContentFailed errorMsg:$errorMsg")
|
||||
// mView.showAuthorizationAgreementContent(0, "123", "123456", "34234", "3543535")
|
||||
mView.showAuthorizationError()
|
||||
}
|
||||
|
||||
override fun agreeAuthorize(tag: String, agreementId: Long) {
|
||||
mogoAuthShow.agreeAuthorize(tag, agreementId, {
|
||||
Logger.d(TAG, "agreeAuthorize success")
|
||||
updateAuthorizeVersion(updateTime)
|
||||
closeAuthorizeView()
|
||||
}, { s: String ->
|
||||
}, {
|
||||
Logger.d(TAG, "agreeAuthorize failed")
|
||||
closeAuthorizeView()
|
||||
})
|
||||
@@ -67,7 +73,7 @@ class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.
|
||||
override fun disAgreeAuthorize(tag: String, agreementId: Long) {
|
||||
mogoAuthShow.disAgreeAuthorize(tag, agreementId, {
|
||||
closeAuthorizeView()
|
||||
}, { s: String ->
|
||||
}, {
|
||||
closeAuthorizeView()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -9,6 +9,11 @@ import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Co
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_NOVELTY
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_TAN_LU
|
||||
|
||||
|
||||
fun String.toAuthorizeType(): Int {
|
||||
return AuthorizeProxy.getAuthorizeType(this)
|
||||
}
|
||||
|
||||
class AuthorizeProxy {
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mogo.module.authorize.util
|
||||
|
||||
import java.util.*
|
||||
|
||||
object DateUtil {
|
||||
|
||||
fun parseDateToTime(tmpDate: String): Long {
|
||||
val time = Date(tmpDate)
|
||||
return time.time
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.mogo.utils.storage.SharedPrefsMgr
|
||||
object SharedPreferenceUtil {
|
||||
|
||||
private const val HAS_AUTH = "HAS_AUTH"
|
||||
private const val AUTHORIZE_UPDATE_TIME = "AUTHORIZE_UPDATE_TIME"
|
||||
|
||||
fun needAuthorization(type: Int): Boolean {
|
||||
return !hasAuth(type)
|
||||
@@ -15,7 +16,15 @@ object SharedPreferenceUtil {
|
||||
return SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).getBoolean(HAS_AUTH + type, false)
|
||||
}
|
||||
|
||||
fun setAuthorizeStatus(type: Int) {
|
||||
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).putBoolean(HAS_AUTH + type, true)
|
||||
fun setAuthorizeStatus(type: Int, authorize: Boolean) {
|
||||
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).putBoolean(HAS_AUTH + type, authorize)
|
||||
}
|
||||
|
||||
fun updateAuthorizeVersion(updateTime: Long) {
|
||||
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).putLong(AUTHORIZE_UPDATE_TIME, updateTime)
|
||||
}
|
||||
|
||||
fun getAuthorizeVersion(): Long {
|
||||
return SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).getLong(AUTHORIZE_UPDATE_TIME, 0L)
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,8 @@ import org.json.JSONObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-07
|
||||
@@ -74,30 +76,30 @@ public class EntrancePresenter extends Presenter<EntranceView> {
|
||||
private IMogoVoiceCmdCallBack mogoVoiceListener = new IMogoVoiceCmdCallBack() {
|
||||
@Override
|
||||
public void onCmdSelected(String cmd) {
|
||||
Log.d(TAG, "免唤醒 mogoVoiceListener needAuthorize = " + mIMogoAuthorizeModuleManager.needAuthorize() + " >>>cmd = " + cmd);
|
||||
Log.d(TAG, "免唤醒 mogoVoiceListener needAuthorize = " + mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE) + " >>>cmd = " + cmd);
|
||||
mVoiceCmdType = cmd;
|
||||
if (cmd.equals(ExtensionsModuleConst.CANCLE_SHARE)
|
||||
|| cmd.equals(ExtensionsModuleConst.CLOSE)) { //取消分享,关闭页面
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
|
||||
} else {
|
||||
ShareControl.getInstance(mContext).dismissDialog();
|
||||
}
|
||||
} else if (cmd.equals(ExtensionsModuleConst.UPLOAD_ROAD_BLOCK)) { //上报拥堵
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
|
||||
} else {
|
||||
uploadRoadCondition();
|
||||
}
|
||||
} else if (cmd.equals(ExtensionsModuleConst.UPLOAD_TRAFFIC_CHECK)) { //上报交通检查
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
|
||||
} else {
|
||||
uploadTrfficCheck();
|
||||
}
|
||||
} else if (cmd.equals(ExtensionsModuleConst.UPLOAD_ROAD_CLOSURE)) { //上报封路
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
|
||||
} else {
|
||||
uploadRoadClosed();
|
||||
}
|
||||
@@ -141,7 +143,7 @@ public class EntrancePresenter extends Presenter<EntranceView> {
|
||||
public void onIntentReceived(String intentStr, Intent intent) {
|
||||
mVoiceCmdType = intentStr;
|
||||
String data = intent.getStringExtra("data");
|
||||
Log.d(TAG, "唤醒 mogoIntentListener intentStr =" + intentStr + ">>data =" + data + " >>> needAuthorize = " + mIMogoAuthorizeModuleManager.needAuthorize());
|
||||
Log.d(TAG, "唤醒 mogoIntentListener intentStr =" + intentStr + ">>data =" + data + " >>> needAuthorize = " + mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE));
|
||||
if (intentStr.equals(ExtensionsModuleConst.GO_TO_SHARE)) { //我要分享 --ok
|
||||
String conditionData = intent.getStringExtra("data");
|
||||
Log.d(TAG, "唤醒 mogoIntentListener intentStr =" + intentStr + ">>conditionData =" + conditionData);
|
||||
@@ -152,30 +154,30 @@ public class EntrancePresenter extends Presenter<EntranceView> {
|
||||
mVoiceCmdShareType = typeString;
|
||||
if (!TextUtils.isEmpty(typeString)) {
|
||||
if (typeString.equals("封路")) {
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
|
||||
} else {
|
||||
Log.d(TAG, "mogoIntentListener 封路 -------> ");
|
||||
uploadRoadClosed();
|
||||
}
|
||||
} else if (typeString.equals("油价")) {
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
|
||||
} else {
|
||||
Log.d(TAG, "mogoIntentListener 油价 -------> ");
|
||||
shareOilPrice();
|
||||
}
|
||||
} else if (typeString.equals("交通检查")) {
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
|
||||
} else {
|
||||
Log.d(TAG, "mogoIntentListener 交通检查 -------> ");
|
||||
uploadTrfficCheck();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
|
||||
} else {
|
||||
ShareControl.getInstance(mContext).showDialog();
|
||||
Log.d(TAG, "mogoIntentListener 我要分享 ----> ");
|
||||
@@ -187,30 +189,30 @@ public class EntrancePresenter extends Presenter<EntranceView> {
|
||||
}
|
||||
} else if (intentStr.equals(ExtensionsModuleConst.UPLOAD_ROAD_CONDITION_AWAKEN)) {
|
||||
//分享路况/上报路况/上报拥堵 唤醒
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
|
||||
} else {
|
||||
uploadRoadCondition();
|
||||
Log.d(TAG, "mogoIntentListener 分享路况 唤醒 ----> ");
|
||||
}
|
||||
} else if (intentStr.equals(ExtensionsModuleConst.SHARE_DIALOG_CLOSE)) { //关闭分享框 唤醒
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
|
||||
} else {
|
||||
ShareControl.getInstance(mContext).dismissDialog();
|
||||
Log.d(TAG, "mogoIntentListener 关闭分享框 唤醒 ----> ");
|
||||
}
|
||||
} else if (intentStr.equals(ExtensionsModuleConst.NO_REPLY_SHARE_DIALOG_CLOSE)) {
|
||||
// 两次未回复关闭对话框
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
|
||||
} else {
|
||||
ShareControl.getInstance(mContext).dismissDialog();
|
||||
Logger.d(TAG, "mogoIntentListener 两次未回复关闭对话框");
|
||||
}
|
||||
} else if (intentStr.equals(ExtensionsModuleConst.UPLOAD_ROAD_CONDITION)) { //上报路况 免唤醒 --ok
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize()) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AuthorizeInvokerConstant.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY);
|
||||
if (mIMogoAuthorizeModuleManager.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_SHARE)) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization(AUTHORIZE_TYPE_LAUNCHER_SHARE);
|
||||
} else {
|
||||
uploadRoadCondition();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.mogo.module.guide
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_LAUNCHER_MAIN
|
||||
import com.mogo.module.authorize.authprovider.module.IMogoAuthorizeModuleManager
|
||||
import com.mogo.module.guide.fragment.GuideFragment
|
||||
import com.mogo.module.guide.util.SharedPreferenceUtil.hasGuide
|
||||
@@ -48,7 +50,7 @@ object GuideBizManager {
|
||||
fun invokeAuthorize() {
|
||||
val authorizeInvoke = ARouter.getInstance().build(AuthorizeConstant.PROVIDER_MODULE).navigation()
|
||||
if (authorizeInvoke is IMogoAuthorizeModuleManager) {
|
||||
if (authorizeInvoke.needAuthorize()) {
|
||||
if (authorizeInvoke.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_MAIN)) {
|
||||
authorizeInvoke.invokeAuthorizeForShow()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user