finish part of authorize logic and retrofit add function

This commit is contained in:
unknown
2020-03-26 18:23:16 +08:00
parent df3d31b9b6
commit 207f7eb771
27 changed files with 386 additions and 146 deletions

View File

@@ -51,10 +51,9 @@ ext {
// 公司服务 - 埋点
analytics : "com.elegant.analytics:analytics:1.1.19",
// retrofit
retrofit : "com.squareup.retrofit2:retrofit:2.3.0",
retrofitadapter : "com.squareup.retrofit2:adapter-rxjava2:2.3.0",
retrofitconvertergson : "com.squareup.retrofit2:converter-gson:2.3.0",
retrofit : "com.squareup.retrofit2:retrofit:2.6.0",
retrofitadapter : "com.squareup.retrofit2:adapter-rxjava2:2.6.0",
retrofitconvertergson : "com.squareup.retrofit2:converter-gson:2.6.0",
retrofitconverterscalars : "com.squareup.retrofit2:converter-scalars:2.1.0",

View File

@@ -11,22 +11,36 @@ import retrofit2.converter.gson.GsonConverterFactory;
public final class RetrofitFactory {
private static final Map< String, Retrofit> sRpcServiceMap = new ArrayMap< String,Retrofit>();
private static final Map<String, Retrofit> sRpcServiceMap = new ArrayMap<String, Retrofit>();
private static final Map<String, Retrofit> sRpcNoAdapterServiceMap = new ArrayMap<String, Retrofit>();
private RetrofitFactory(){}
private RetrofitFactory() {
}
public static synchronized Retrofit getInstance( String baseUrl) {
public static synchronized Retrofit getInstance(String baseUrl) {
Retrofit target = sRpcServiceMap.get(baseUrl);
if(target == null){
if (target == null) {
target = new Retrofit.Builder().
client(OkHttpFactory.getInstance()).
baseUrl(baseUrl).
addCallAdapterFactory( RxJava2CallAdapterFactory.create()).
addCallAdapterFactory(RxJava2CallAdapterFactory.create()).
addConverterFactory(GsonConverterFactory.create()).
build();
sRpcServiceMap.put(baseUrl,target);
sRpcServiceMap.put(baseUrl, target);
}
return target;
}
public static synchronized Retrofit getInstanceNoCallAdapter(String baseUrl) {
Retrofit target = sRpcNoAdapterServiceMap.get(baseUrl);
if (target == null) {
target = new Retrofit.Builder().
client(OkHttpFactory.getInstance()).
baseUrl(baseUrl).
addConverterFactory(GsonConverterFactory.create()).
build();
sRpcNoAdapterServiceMap.put(baseUrl, target);
}
return target;
}
}

View File

@@ -24,7 +24,7 @@ SNAPSHOT_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-snapshots/
USERNAME=xintai
PASSWORD=xintai2018
# 编译模式: false - 依赖本地版本, true - 依赖 maven 版本
RELEASE=false
RELEASE=true
# 模块版本
## 工程内模块
MOGO_MODULE_SHARE_VERSION=1.0.3-SNAPSHOT

View File

@@ -23,30 +23,34 @@ open class IMogoAuthorizeController {
Logger.d(TAG, "invokeAuthorizeContent ---checkAgreementType can not find tag :$tag")
})
}
request<BaseResponse<UserAgreement>> {
loader {
authorizeModel.invokeAuthorizeContent(agreementType)
}
onSuccess {
Logger.d(TAG, "invokeAuthorizeContent onSuccess data: ${it.result}")
getAuthorizeContentListener(tag, { listener ->
if (it.result != null) {
listener.requestContentSuccess(it.result)
} 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")
})
}
onError {
getAuthorizeContentListener(tag, { listener ->
listener.requestContentFailed(it.message
?: "request authorize content failedplease check network")
}, {
Logger.d(TAG, "invokeAuthorizeContent --- can not find listener by this tag :$tag")
})
try {
request<BaseResponse<UserAgreement>> {
loader {
authorizeModel.invokeAuthorizeContent(1)
}
onSuccess {
Logger.d(TAG, "invokeAuthorizeContent onSuccess data: ${it.result}")
getAuthorizeContentListener(tag, { listener ->
if (it.result != null) {
listener.requestContentSuccess(it.result)
} 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")
})
}
onError {
getAuthorizeContentListener(tag, { listener ->
listener.requestContentFailed(it.message
?: "request authorize content failedplease check network")
}, {
Logger.d(TAG, "invokeAuthorizeContent --- can not find listener by this tag :$tag")
})
}
}
}catch (e:Exception){
e.printStackTrace()
}
}

View File

@@ -17,7 +17,9 @@ open abstract class MogoAuthorizeManagerImpl : IMogoAuthorizeInvoke {
override fun invokeAuthorizeContent(tag: String) {
//todo 后面动态代理统一处理校验问题
Logger.d("invokeAuthorizeContent","tag:$tag")
val agreementType = AuthorizeProxy.getAuthorizeType(tag)
Logger.d("invokeAuthorizeContent","agreementType:$agreementType")
baseController.invokeAuthorizeContent(tag, agreementType)
}

View File

@@ -5,7 +5,6 @@ import com.mogo.commons.network.Utils.getSn
import com.mogo.module.authorize.model.BaseResponse
import com.mogo.module.authorize.model.IMogoAuthorizeModel
import com.mogo.module.authorize.model.bean.UpdateAuthorize
import com.mogo.module.authorize.util.ServiceUtil.getNetWorkApi
class MogoAuthorizeMainModel : IMogoAuthorizeModel() {
@@ -14,4 +13,5 @@ class MogoAuthorizeMainModel : IMogoAuthorizeModel() {
val map = mapOf("sn" to getSn(), "data" to updateAuthorize)
return apiCall { getNetWorkApi().updateAuthorize(map) }
}
}

View File

@@ -4,8 +4,8 @@ import android.os.Looper
import com.alibaba.android.arouter.launcher.ARouter
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.util.ServiceUtil.getFragmentManagerApi
import com.mogo.module.authorize.util.SharedPreferenceUtil.hasAuth
import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
@@ -39,7 +39,7 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
Logger.d(TAG, "User is operation authorization, do not repeat invoke")
return
}
pushFragmentToMainView {
pushFragmentToMainView(AUTHORIZE_TYPE_LAUNCHER_MAIN) {
showAuthorizeView = true
}
}
@@ -65,7 +65,7 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
Logger.d(TAG, "ready to forbidden voice")
forbiddenVoice.invoke()
Logger.d(TAG, "ready to push fragment")
pushFragmentToMainView {
pushFragmentToMainView(tag) {
showAuthorizeView = true
}
}
@@ -76,9 +76,9 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
}
}
private inline fun pushFragmentToMainView(push: (() -> Unit)) {
val builderWrapper = FragmentDescriptor.Builder().fragment(AuthorizeFragment()).build()
Logger.d(TAG,"pushFragmentToMainView")
private inline fun pushFragmentToMainView(tag: String, push: (() -> Unit)) {
val builderWrapper = FragmentDescriptor.Builder().fragment(AuthorizeFragment(tag)).build()
Logger.d(TAG, "pushFragmentToMainView")
val mogoService = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation()
if (mogoService is IMogoServiceApis) {
mogoService.fragmentManagerApi.push(builderWrapper)
@@ -87,8 +87,27 @@ class MogoMainAuthorize private constructor() : MogoAuthorizeManagerImpl(), IMog
}
private inline fun popFragmentFromMainView(pop: (() -> Unit)) {
getFragmentManagerApi().pop()
val mogoService = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation()
if (mogoService is IMogoServiceApis) {
mogoService.fragmentManagerApi.pop()
}
pop.invoke()
}
fun authorizeSuccess(tag: String) {
val listener = MogoAuthorizeRegisterHandler.getAuthorizeListener(tag)
if (listener == null) {
Logger.d(TAG, "authorizeSuccess,but listener is null ")
}
listener!!.authorizeSuccess()
}
fun authorizeFailed(tag: String, errorMsg: String) {
val listener = MogoAuthorizeRegisterHandler.getAuthorizeListener(tag)
if (listener == null) {
Logger.d(TAG, "authorizeFailed,but listener is null ")
}
listener!!.authorizeFailed(errorMsg)
}
}

View File

@@ -5,7 +5,6 @@ class ApiException : CommonException {
companion object {
val NULL_REQUEST_DATA_API_EXCEPTION = ApiException(2, "request data is null")
val ENTER_ROOM_API_EXCEPTION = ApiException(3, "roomId is null or already enter room")
}
constructor(code: Int, msg: String) : super(code, msg)

View File

@@ -4,6 +4,7 @@ open class CommonException : Exception {
companion object {
val NETWORK_EXCEPTION = CommonException(1, "network is error")
val NULL_EXCEPTION = CommonException(1, "error msg is null")
}
protected var code: Int = 0

View File

@@ -5,10 +5,18 @@ import com.mogo.commons.mvp.IView
class AuthorizeContract {
interface View : IView {
fun showAuthorizationAgreementContent(agreementId: Long, agreementContent: String, agreementTitle: String, agreementBottom: String, agreementLast: String)
fun readyToAuthorize()
fun showAuthorizationError()
}
interface Biz {
fun invokeAuthorize(invokeTag: String)
fun agreeAuthorize(tag: String, agreementId: Long)
fun disAgreeAuthorize(tag: String, agreementId: Long)
}
}

View File

@@ -1,17 +1,20 @@
package com.mogo.module.authorize.fragment
import android.text.Html
import android.view.View
import com.mogo.commons.mvp.MvpFragment
import com.mogo.module.authorize.R
import com.mogo.module.authorize.authprovider.launcher.MogoMainAuthorize.Companion.mogoAuthShow
import com.mogo.utils.logger.Logger
import kotlinx.android.synthetic.main.module_authorize_fragment.*
class AuthorizeFragment : MvpFragment<AuthorizeContract.View, AuthorizePresenter>(), AuthorizeContract.View, View.OnClickListener {
class AuthorizeFragment(private val invokeTag: String) : MvpFragment<AuthorizeContract.View, AuthorizePresenter>(), AuthorizeContract.View, View.OnClickListener {
companion object {
const val TAG = "AuthorizeFragment"
}
private var agreementId: Long = 0L
override fun getLayoutId(): Int {
return R.layout.module_authorize_fragment
}
@@ -19,24 +22,53 @@ class AuthorizeFragment : MvpFragment<AuthorizeContract.View, AuthorizePresenter
override fun initViews() {
btnAuthorizeAgree.setOnClickListener(this)
btnAuthorizeDisAgree.setOnClickListener(this)
btnAuthorizeLoadingError.setOnClickListener(this)
clLoadingErrorContainer.setOnClickListener(this)
Logger.d(TAG, "invokeTag :$invokeTag")
}
override fun createPresenter(): AuthorizePresenter {
return AuthorizePresenter(this)
return AuthorizePresenter(invokeTag, this)
}
override fun readyToAuthorize() {
clLoadingErrorContainer.visibility = View.GONE
clLoadingContainer.visibility = View.VISIBLE
}
override fun showAuthorizationAgreementContent(
agreementId: Long,
agreementContent: String,
agreementTitle: String,
agreementBottom: String,
agreementLast: String) {
clLoadingContainer.visibility = View.GONE
clAuthorizeContainer.visibility = View.VISIBLE
this.agreementId = agreementId
tvAuthorizeTitle.text = Html.fromHtml(agreementTitle)
tvAuthorizeContent.text = Html.fromHtml(agreementContent)
tvAuthorizeButtonContent.text = Html.fromHtml(agreementBottom)
tvAuthorizeLastContent.text = Html.fromHtml(agreementContent)
}
override fun showAuthorizationError() {
clLoadingContainer.visibility = View.GONE
clLoadingErrorContainer.visibility = View.VISIBLE
}
override fun onClick(v: View) {
when (v.id) {
R.id.btnAuthorizeAgree -> {
closeAuthorizeView()
mPresenter.agreeAuthorize(invokeTag, agreementId)
}
R.id.btnAuthorizeDisAgree -> {
closeAuthorizeView()
mPresenter.disAgreeAuthorize(invokeTag, agreementId)
}
R.id.clLoadingErrorContainer, R.id.btnAuthorizeLoadingError -> {
mPresenter.invokeAuthorize(invokeTag)
}
}
}
private fun closeAuthorizeView(){
mogoAuthShow.hideAuthorizeView()
}
}

View File

@@ -2,14 +2,85 @@ package com.mogo.module.authorize.fragment
import androidx.lifecycle.LifecycleOwner
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.authprovider.module.IMogoAcquireAuthorizeListener
import com.mogo.module.authorize.model.bean.UserAgreement
import com.mogo.module.authorize.model.proxy.AuthorizeProxy
import com.mogo.utils.logger.Logger
class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.Biz {
class AuthorizePresenter : Presenter<AuthorizeContract.View>, AuthorizeContract.Biz, IMogoAuthorizeContentListener, IMogoAcquireAuthorizeListener {
constructor(view: AuthorizeContract.View?) : super(view)
companion object {
const val TAG = "AuthorizePresenter"
}
private var invokeTag: String? = null
constructor(invokeTag: String, view: AuthorizeContract.View?) : super(view) {
this.invokeTag = invokeTag
}
override fun onCreate(owner: LifecycleOwner) {
super.onCreate(owner)
Logger.d(TAG, "onCreate invokeTag:$invokeTag")
invokeAuthorize(invokeTag!!)
}
override fun invokeAuthorize(invokeTag: String) {
mView.readyToAuthorize()
this.invokeTag = invokeTag
mogoAuthShow.registerInvokeAuthorizeContentListener(invokeTag, this)
mogoAuthShow.registerAuthorizeListener(invokeTag, this)
mogoAuthShow.invokeAuthorizeContent(invokeTag)
}
override fun requestContentSuccess(userAgreement: UserAgreement) {
val id = userAgreement.agreementEntity.id
val content = userAgreement.agreementContent[0]
val title = userAgreement.agreementEntity.title
val bottomContent = userAgreement.agreementEntity.agreementButtonFirst
val lastContent = userAgreement.agreementEntity.agreementButtonSecond
mView.showAuthorizationAgreementContent(id, content, title, bottomContent, lastContent)
}
override fun requestContentFailed(errorMsg: String) {
Logger.d(TAG, "requestContentFailed errorMsg:$errorMsg")
mView.showAuthorizationError()
}
override fun agreeAuthorize(tag: String, agreementId: Long) {
mogoAuthShow.agreeAuthorize(tag, agreementId)
}
override fun disAgreeAuthorize(tag: String, agreementId: Long) {
mogoAuthShow.disAgreeAuthorize(tag, agreementId)
}
override fun authorizeSuccess() {
mogoAuthShow.authorizeSuccess(invokeTag!!)
closeAuthorizeView()
}
override fun authorizeFailed(errorMsg: String) {
mogoAuthShow.authorizeFailed(invokeTag!!, errorMsg)
closeAuthorizeView()
}
override fun forbiddenVoiceWhenAuthorize(cmd: String) {
//do nothing
}
private fun closeAuthorizeView() {
mogoAuthShow.hideAuthorizeView()
}
override fun onDestroy(owner: LifecycleOwner) {
super.onDestroy(owner)
Logger.d(TAG, "onDestroy invokeTag : $invokeTag")
invokeTag?.let {
mogoAuthShow.unregisterInvokeAuthorizeContentListener(it)
mogoAuthShow.unregisterAuthorizeListener(it)
}
}
}

View File

@@ -1,8 +1,23 @@
package com.mogo.module.authorize.model
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.module.authorize.constant.HttpConstant
import com.mogo.module.authorize.net.AuthorizeApi
import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
open class BaseRepository {
suspend fun <T : Any> apiCall(call: suspend () -> BaseResponse<T>): BaseResponse<T> {
return call.invoke()
}
fun getNetWorkApi(): AuthorizeApi {
var serviceApi: IMogoServiceApis? = null
val mogoService = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation()
if (mogoService is IMogoServiceApis) {
serviceApi = mogoService
}
return serviceApi!!.networkApi.createNoCallAdapter(AuthorizeApi::class.java, HttpConstant.getNetHost())
}
}

View File

@@ -4,7 +4,6 @@ import com.google.gson.Gson
import com.mogo.commons.network.Utils.getSn
import com.mogo.module.authorize.model.bean.RequestUserAgreement
import com.mogo.module.authorize.model.bean.UserAgreement
import com.mogo.module.authorize.util.ServiceUtil.getNetWorkApi
open class IMogoAuthorizeModel : BaseRepository() {

View File

@@ -8,7 +8,7 @@ class RequestUserAgreement(val agreementType:Int)
data class UserAgreement(var agreementEntity: TUserAgreementEntity, var agreementContent: List<String>)
data class TUserAgreementEntity(
val id: Int, //协议ID
val id: Long, //协议ID
val title: String, //标题
val subhead: String, //副标题
val agreementButtonFirst: String, //底部标题1

View File

@@ -7,25 +7,26 @@ import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Co
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY
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
import java.util.*
class AuthorizeProxy {
companion object {
var allAuthorizeTypes = HashMap<String, IAuthorizeOperation>()
const val TAG = "AuthorizeProxy"
fun getAuthorizeType(authorizeName: String): Int {
if (authorizeName.isNullOrBlank()) {
return -1
}
return allAuthorizeTypes[authorizeName]!!.getAcquireId()
}
}
init {
for ((index, type) in AuthorizeEnum.values().withIndex()) {
type.getOperationName()?.let {
allAuthorizeTypes[it] = type
return when (authorizeName) {
AUTHORIZE_TYPE_LAUNCHER_MAIN,
AUTHORIZE_TYPE_LAUNCHER_SHARE_NOVELTY,
AUTHORIZE_TYPE_LAUNCHER_SHARE_MUSIC -> 0
AUTHORIZE_TYPE_TAN_LU -> 1
AUTHORIZE_TYPE_CALL_CHAT -> 2
AUTHORIZE_TYPE_NOVELTY -> 3
AUTHORIZE_TYPE_AUXILIARY_DRIVING -> 4
else -> -1
}
}
}

View File

@@ -8,14 +8,14 @@ import retrofit2.http.POST
interface AuthorizeApi {
//获取授权内容
//获取授权内容·
@FormUrlEncoded
@POST("yycp-channelManager/agreement/findUserAgreement")
@POST("yycp-channelManager/user/agreement/findUserAgreement")
suspend fun getAuthorizeContent(@FieldMap authorizeContent: Map<String, String>): BaseResponse<UserAgreement>
//更新授权状态
@FormUrlEncoded
@POST("yycp-channelManager/agreement/updateStatus")
@POST("yycp-channelManager/user/agreement/updateStatus")
suspend fun updateAuthorize(@FieldMap updateStatus: Map<String, String>): BaseResponse<Any>
}

View File

@@ -3,7 +3,9 @@ package com.mogo.module.authorize.net
import com.mogo.module.authorize.exception.ApiException
import com.mogo.module.authorize.exception.ApiException.Companion.NULL_REQUEST_DATA_API_EXCEPTION
import com.mogo.module.authorize.exception.CommonException.Companion.NETWORK_EXCEPTION
import com.mogo.module.authorize.exception.CommonException.Companion.NULL_EXCEPTION
import com.mogo.module.authorize.model.BaseResponse
import com.mogo.utils.logger.Logger
import kotlinx.coroutines.*
import java.net.SocketTimeoutException
import java.net.UnknownHostException
@@ -61,11 +63,15 @@ class Request<T> {
}
} catch (e: Exception) {
e.printStackTrace()
if(e == null){
onError?.invoke(NULL_EXCEPTION)
return@launch
}
when (e) {
is UnknownHostException -> onError?.invoke(NETWORK_EXCEPTION)
is TimeoutException -> onError?.invoke(NETWORK_EXCEPTION)
is SocketTimeoutException -> onError?.invoke(NETWORK_EXCEPTION)
else -> onError?.invoke(java.lang.Exception(e.message))
else -> onError?.invoke(java.lang.Exception(e.message?:""))
}
} finally {
onComplete?.invoke()

View File

@@ -1,44 +0,0 @@
package com.mogo.module.authorize.util
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.commons.AbsMogoApplication
import com.mogo.module.authorize.constant.HttpConstant.Companion.getNetHost
import com.mogo.module.authorize.net.AuthorizeApi
import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
import com.mogo.service.fragmentmanager.IMogoFragmentManager
object ServiceUtil {
private lateinit var serviceApi: IMogoServiceApis
init {
initMogoService()
}
private fun initMogoService() {
if (serviceApi == null) {
val mogoService = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation()
if (mogoService is IMogoServiceApis) {
this.serviceApi = mogoService
}
}
}
fun getNetWorkApi(): AuthorizeApi {
checkInit()
return serviceApi.networkApi.create(AuthorizeApi::class.java, getNetHost())
}
fun getFragmentManagerApi(): IMogoFragmentManager {
checkInit()
return serviceApi.fragmentManagerApi
}
private fun checkInit() {
if (serviceApi == null) {
initMogoService()
}
}
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<corners android:radius="@dimen/dp_59" />
<gradient android:endColor="#805CC1FF" android:startColor="#803E7FFC" />
</shape>
</item>
<item>
<shape>
<corners android:radius="@dimen/dp_59" />
<gradient android:endColor="#5CC1FF" android:startColor="#3E7FFC" />
</shape>
</item>
</selector>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_22" />
<gradient
android:endColor="#3F4057"
android:startColor="#50526E " />
</shape>

View File

@@ -5,6 +5,93 @@
android:layout_height="match_parent"
android:background="#000000">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/clLoadingContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_330"
android:layout_marginTop="@dimen/dp_90"
android:layout_marginRight="@dimen/dp_330"
android:layout_marginBottom="@dimen/dp_90"
android:background="@drawable/module_authorize_selector_dark_corner"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/ivAuthorizeLoading"
android:layout_width="@dimen/dp_147"
android:layout_height="@dimen/dp_147"
android:layout_marginTop="@dimen/dp_335"
android:src="@mipmap/module_authorize_loading"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvAuthorizeLoading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_44"
android:text="@string/module_authorize_agreement_loading"
android:textColor="#99FFFFFF"
android:textSize="@dimen/dp_44"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ivAuthorizeLoading" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/clLoadingErrorContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_330"
android:layout_marginTop="@dimen/dp_90"
android:layout_marginRight="@dimen/dp_330"
android:layout_marginBottom="@dimen/dp_90"
android:background="@drawable/module_authorize_selector_dark_corner"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/ivAuthorizeLoadingError"
android:layout_width="@dimen/dp_147"
android:layout_height="@dimen/dp_147"
android:layout_marginTop="@dimen/dp_254"
android:src="@mipmap/module_authorize_loading_error"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvAuthorizeLoadingError"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_33"
android:text="@string/module_authorize_agreement_error"
android:textColor="@android:color/white"
android:textSize="@dimen/dp_44"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ivAuthorizeLoadingError" />
<Button
android:id="@+id/btnAuthorizeLoadingError"
android:layout_width="@dimen/dp_461"
android:layout_height="@dimen/dp_97"
android:layout_marginTop="@dimen/dp_33"
android:text="@string/module_authorize_agreement_retry"
android:textColor="@android:color/white"
android:gravity="center"
android:background="@drawable/module_authorize_selector_blue_corner"
android:textSize="@dimen/dp_44"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvAuthorizeLoadingError" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/clAuthorizeContainer"
android:layout_width="match_parent"
@@ -14,7 +101,7 @@
android:layout_marginRight="@dimen/dp_330"
android:layout_marginBottom="@dimen/dp_90"
android:background="@drawable/module_authorize_shape_drak_top_corner"
android:visibility="visible"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
@@ -47,7 +134,6 @@
android:layout_width="0px"
android:layout_height="0px"
android:layout_marginBottom="@dimen/dp_160"
android:fillViewport="true"
android:scrollbarSize="@dimen/dp_11"
android:scrollbarThumbVertical="@drawable/module_authorize_scrollbar"
app:layout_constraintBottom_toBottomOf="parent"
@@ -63,17 +149,21 @@
<TextView
android:id="@+id/tvAuthorizeContent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:textColor="@android:color/white"
android:textSize="@dimen/dp_44" />
<TextView
android:id="@+id/tvAuthorizeButtonContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:textColor="@android:color/white" />
<TextView
android:id="@+id/tvAuthorizeLastContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:textColor="@android:color/white" />
</LinearLayout>
</ScrollView>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@@ -2,4 +2,7 @@
<string name="app_name">mogo-module-authorize</string>
<string name="module_authorize_agreement_agree">同意</string>
<string name="module_authorize_agreement_disagree">不同意</string>
<string name="module_authorize_agreement_loading">正在加载,请稍等...</string>
<string name="module_authorize_agreement_error">加载失败</string>
<string name="module_authorize_agreement_retry">点击重试</string>
</resources>

View File

@@ -1,8 +1,8 @@
package com.mogo.service.network;
import androidx.annotation.Keep;
import com.alibaba.android.arouter.facade.template.IProvider;
import java.util.Map;
/**
* @author congtaowang
@@ -18,7 +18,19 @@ public interface IMogoNetwork extends IProvider {
*
* @param service 业务类
* @param baseUrl url
* @return 业务类动态代理
* @return 业务类动态代理
*/
@Keep <T> T create(final Class<T> service,String baseUrl);
@Keep
<T> T create(final Class<T> service, String baseUrl);
/**
* 返回无CallAdapter Retrofit代理对象
*
* @param service 业务类
* @param baseUrl url
* @param <T>
* @return 业务类动态代理
*/
@Keep
<T> T createNoCallAdapter(final Class<T> service, String baseUrl);
}

View File

@@ -1,30 +1,10 @@
package com.mogo.service.impl.network;
import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.map.MogoGeoSearch;
import com.mogo.map.MogoInitor;
import com.mogo.map.MogoInputtipsSearch;
import com.mogo.map.MogoLocationClient;
import com.mogo.map.MogoMapUIController;
import com.mogo.map.MogoMarkerManager;
import com.mogo.map.MogoNavi;
import com.mogo.map.MogoPoiSearch;
import com.mogo.map.listener.IMogoMapListener;
import com.mogo.map.listener.MogoMapListenerHandler;
import com.mogo.map.location.IMogoLocationClient;
import com.mogo.map.marker.IMogoMarkerManager;
import com.mogo.map.navi.IMogoNavi;
import com.mogo.map.navi.IMogoNaviListener;
import com.mogo.map.navi.MogoNaviListenerHandler;
import com.mogo.map.search.geo.IMogoGeoSearch;
import com.mogo.map.search.inputtips.IMogoInputtipsSearch;
import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
import com.mogo.map.search.poisearch.IMogoPoiSearch;
import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.map.IMogoMapService;
import com.mogo.service.network.IMogoNetwork;
import com.mogo.utils.network.RetrofitFactory;
@@ -34,15 +14,22 @@ import com.mogo.utils.network.RetrofitFactory;
* <p>
* 网络对外地接口
*/
@Route( path = MogoServicePaths.PATH_SERVICES_NETWORK)
@Route(path = MogoServicePaths.PATH_SERVICES_NETWORK)
public class MogoNetWorkService implements IMogoNetwork {
@Override
public void init( Context context ) {
MogoInitor.init( context );
public void init(Context context) {
MogoInitor.init(context);
}
@Override public <T> T create(Class<T> service,String baseUrl) {
@Override
public <T> T create(Class<T> service, String baseUrl) {
return RetrofitFactory.getInstance(baseUrl).create(service);
}
@Override
public <T> T createNoCallAdapter(Class<T> service, String baseUrl) {
return RetrofitFactory.getInstanceNoCallAdapter(baseUrl).create(service);
}
}