diff --git a/foudations/mogo-utils/src/main/java/com/mogo/utils/sqlite/proxy/BaseDaoProxyLog.kt b/foudations/mogo-utils/src/main/java/com/mogo/utils/sqlite/proxy/BaseDaoProxyLog.kt index 0d64420bb2..5724539c61 100644 --- a/foudations/mogo-utils/src/main/java/com/mogo/utils/sqlite/proxy/BaseDaoProxyLog.kt +++ b/foudations/mogo-utils/src/main/java/com/mogo/utils/sqlite/proxy/BaseDaoProxyLog.kt @@ -1,7 +1,6 @@ package com.mogo.utils.sqlite.proxy import com.mogo.utils.logger.Logger -import com.mogo.utils.network.utils.GsonUtil import java.lang.reflect.InvocationHandler import java.lang.reflect.Method import java.lang.reflect.Proxy @@ -39,11 +38,10 @@ class BaseDaoProxyLog : InvocationHandler { */ @Throws(Throwable::class) override fun invoke(proxy: Any, method: Method, args: Array): Any? { - var result: Any? = null //反射方法前调用 Logger.i("SQL数据库管理", "当前执行>>${method.name}>>") //反射执行方法 相当于调用target.sayHelllo; - result = method.invoke(target, *args) + val result: Any? = method.invoke(target, *args) //反射方法后调用. Logger.i("SQL数据库管理", "执行结果>>$result") return result diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/aspect/LogAspectj.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/aspect/LogAspectj.kt index 7faffebb36..57993c1b46 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/aspect/LogAspectj.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/aspect/LogAspectj.kt @@ -45,7 +45,7 @@ class LogAspectj { var stopNanos = System.nanoTime() var lengthMill = TimeUnit.NANOSECONDS.toMillis(stopNanos - startNanos) - exitMethod(joinPoint, result as Any?, lengthMill) + exitMethod(joinPoint, result, lengthMill) } private fun enterMethod(joinPoint: ProceedingJoinPoint) { @@ -59,7 +59,7 @@ class LogAspectj { var builder = StringBuilder("\u21E2 ") builder.append(methodName).append('(') - parameterValues.forEachIndexed { index, any -> + parameterValues.forEachIndexed { index, _ -> if (index > 0) { builder.append(",") } diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/CommonConfig.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/CommonConfig.kt index bd77b496b5..4c3cea008d 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/CommonConfig.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/CommonConfig.kt @@ -1,14 +1,6 @@ package com.zhidao.roadcondition.model -fun CommonConfig.isActiveNonNull():Boolean{ - return active!=null -} - -//fun CommonConfig.isPromotionNonNull():Boolean{ -// return promotion!=null -//} - class CommonConfig { var active:Active //活动配置 diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/proxy/ActiveInfoTypeProxy.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/proxy/ActiveInfoTypeProxy.kt index 9de15bbf20..9fcca8ea88 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/proxy/ActiveInfoTypeProxy.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/proxy/ActiveInfoTypeProxy.kt @@ -1,16 +1,13 @@ package com.zhidao.roadcondition.model.proxy import androidx.annotation.IntDef -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - const val INFO_TYPE_GONE = 0 const val INFO_TYPE_SHOW = 1 @IntDef(INFO_TYPE_GONE, INFO_TYPE_SHOW) -@Retention(RetentionPolicy.SOURCE) +@Retention(AnnotationRetention.SOURCE) annotation class ActiveInfoType fun isActiveShow(@ActiveInfoType type: Int): Boolean { diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/proxy/InformationsTypeProxy.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/proxy/InformationsTypeProxy.kt index 80c20bef95..d297bf97c8 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/proxy/InformationsTypeProxy.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/model/proxy/InformationsTypeProxy.kt @@ -1,8 +1,6 @@ package com.zhidao.roadcondition.model.proxy import androidx.annotation.IntDef -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy const val INFO_TYPE_IMG = 0 //图片 @@ -12,5 +10,5 @@ const val INFO_TYPE_WORD = 3 @IntDef(INFO_TYPE_IMG, INFO_TYPE_VIDEO, INFO_TYPE_VOICE, INFO_TYPE_WORD) -@Retention(RetentionPolicy.SOURCE) +@Retention(AnnotationRetention.SOURCE) annotation class InformationsType diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/net/CoroutineChain.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/net/CoroutineChain.kt index e81d57dfe0..3e09016656 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/net/CoroutineChain.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/net/CoroutineChain.kt @@ -36,7 +36,7 @@ class CoroutineChain { return request(loader, true) } - fun LifecycleOwner.request(loader: suspend () -> T, needAutoCancel: Boolean = true): Deferred { + private fun LifecycleOwner.request(loader: suspend () -> T, needAutoCancel: Boolean = true): Deferred { val deferred = GlobalScope.async(Dispatchers.IO, start = CoroutineStart.LAZY) { loader() } @@ -58,9 +58,9 @@ class CoroutineChain { } catch (e: Exception) { e.printStackTrace() when (e) { - is UnknownHostException -> onError?.invoke(ApiException.NETWORK_API_EXCEPTION) - is TimeoutException -> onError?.invoke(ApiException.NETWORK_API_EXCEPTION) - is SocketTimeoutException -> onError?.invoke(ApiException.NETWORK_API_EXCEPTION) + is UnknownHostException -> onError.invoke(ApiException.NETWORK_API_EXCEPTION) + is TimeoutException -> onError.invoke(ApiException.NETWORK_API_EXCEPTION) + is SocketTimeoutException -> onError.invoke(ApiException.NETWORK_API_EXCEPTION) else -> onError(e) } } finally { diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/net/HttpClient.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/net/HttpClient.kt index fd779d7027..d32a5a7896 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/net/HttpClient.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/net/HttpClient.kt @@ -12,7 +12,7 @@ import java.util.* import java.util.concurrent.TimeUnit -class HttpClient { +class HttpClient private constructor(baseUrl: String) { companion object { const val DEFAULT_CONNECT_TIME = 30L @@ -52,10 +52,10 @@ class HttpClient { } - private lateinit var retrofit: Retrofit - private lateinit var httpApi: HttpApi + private var retrofit: Retrofit + private var httpApi: HttpApi - private constructor(baseUrl: String) { + init { retrofit = Retrofit.Builder() .client(getOkHttpClient()) .addConverterFactory(GsonConverterFactory.create()) diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/net/PostCommonBody.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/net/PostCommonBody.kt index b192178f6e..8bc8eec8db 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/net/PostCommonBody.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/net/PostCommonBody.kt @@ -32,12 +32,12 @@ class PostCommonBody : RequestBody { } override fun writeTo(sink: BufferedSink) { - if (content.isNullOrEmpty()) { + if (content.isEmpty()) { throw NullPointerException("content == null") } val bytes = content.toByteArray(charset) - Util.checkOffsetAndCount(bytes!!.size.toLong(), 0, bytes!!.size.toLong()) - sink.write(bytes, 0, bytes!!.size) + Util.checkOffsetAndCount(bytes.size.toLong(), 0, bytes.size.toLong()) + sink.write(bytes, 0, bytes.size) } } \ No newline at end of file diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CarCorderController.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CarCorderController.kt index a0ce977eba..1e214e38c2 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CarCorderController.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CarCorderController.kt @@ -44,13 +44,13 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { } fun registerTakePhotoInterceptor(interceptor: TakePhotoInterceptor) { - interceptor?.apply { + interceptor.apply { interceptors.add(this) } } fun unregisterTakePhotoInterceptor(interceptor: TakePhotoInterceptor) { - interceptor?.apply { + interceptor.apply { interceptors.remove(interceptor) } } @@ -146,14 +146,14 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { fun release() { zdCarCoderController.release() - interceptors?.clear() + interceptors.clear() } //拍照失败回调 override fun onTakePhotoFail(photoType: Int, camera: Int) { trackGetPhoto(3) interceptors.forEach { - it?.onTakePhotoFail(photoType, camera) + it.onTakePhotoFail(photoType, camera) } val isCustom = CustomStatusHandler.pollPhotoStatus() val entity = TakeEntity(isCustom, 0L) @@ -184,7 +184,7 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { if (isCustom) { CosStatusController().sendInformationDirectly( INFO_TYPE_IMG, - mutableMapOf("pic" to "" as String), + mutableMapOf("pic" to ""), mType, entity, mainInfoId, @@ -208,8 +208,8 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { var interceptor = false interceptors.forEach { - interceptor = it?.intercept() - it?.onTakePhotoSuccess(photoType, camera, photoPath) + interceptor = it.intercept() + it.onTakePhotoSuccess(photoType, camera, photoPath) } if (interceptor) { return @@ -343,11 +343,11 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback { val entity = CustomStatusHandler.pollVideoStatus() entity?.let { - InformationUploadController.release(entity.id) - Log.e(TAG, "getVideo onTakeVideoFail entity?.isCustom =" + entity?.isCustom) - if (entity?.isCustom) { + InformationUploadController.release(it.id) + Log.e(TAG, "getVideo onTakeVideoFail entity?.isCustom =" + it.isCustom) +// if (it.isCustom) { // sendGetInfoFailedReceiver(mType) - } +// } } //失败了,传空地址,发起请求 diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosCallbackMapController.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosCallbackMapController.kt index a7f80df795..b81c988bff 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosCallbackMapController.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosCallbackMapController.kt @@ -27,11 +27,11 @@ object CosCallbackMapController : CosStatusCallback { this.uploadFailed = uploadFailed } - fun registerCallback(paths: List, callback: CosStatusCallback) { + fun registerCallback(paths: List?, callback: CosStatusCallback) { paths?.let { list -> list.forEach { path -> path?.let { - map[path] = callback + map[it] = callback } } } diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt index a0a1be0287..d07e501c69 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt @@ -43,7 +43,7 @@ class CosStatusController : CosStatusCallback { private var mLatitude: Double = 0.0 //上传文件 - fun uploadFile(picPath: MutableList, entity: TakeEntity, type: String, mainInfoId: Long, + fun uploadFile(picPath: MutableList?, entity: TakeEntity, type: String, mainInfoId: Long, fromType: String, longitude: Double, latitude: Double) { CosCallbackMapController.registerCallback(picPath, this) // CosLogger.setLogStatus(true) @@ -56,6 +56,9 @@ class CosStatusController : CosStatusCallback { this.mLatitude = latitude Log.d(TAG, "uploadFile type===$type ---- mainInfoId =$mainInfoId ----mFromType = $mFromType ---- picPath = $picPath ") trackUploadCos(3) + if(picPath == null){ + return + } if (picPath.contains("backPic")) return //参数说明: paths:本地文件路径;(注:上传的本地路径不要重复);config:文件上传的优先级 mPicEventId = @@ -171,7 +174,7 @@ class CosStatusController : CosStatusCallback { mLatitude ) } - Log.d(TAG, "delete file: ${localPath!!}") + Log.d(TAG, "delete file: $localPath") CosCallbackMapController.unregisterCallback(localPath) deletePicFile(localPath) } diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainService.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainService.kt index 07098f76a9..b08225ddde 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainService.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainService.kt @@ -195,12 +195,12 @@ class MainService : Service() { "MainService", "getImageEvent url = " + getImageSuccessEvent.getImageUrl() + ">>>>type =" + getImageSuccessEvent.getType() ) - sendMarkerInfoReceiver( - info.latitude, - info.longitude, - getImageSuccessEvent.getImageUrl(), - getImageSuccessEvent.getType() - ) +// sendMarkerInfoReceiver( +// info.latitude, +// info.longitude, +// getImageSuccessEvent.getImageUrl(), +// getImageSuccessEvent.getType() +// ) } private fun sendMarkerInfoReceiver(lat: Double, lon: Double, imageUrl: String?, type: String?) { diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainServiceController.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainServiceController.kt index 2631ca3bae..551ee77343 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainServiceController.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/MainServiceController.kt @@ -270,7 +270,7 @@ class MainServiceController { ) { Log.d(TAG, " geoLocation -- poiType = $poiType") LocationUtil.getInstance() - .geoCodeLocation(locationInfo.toLatLngPoint(), { locInfo: LocationInfo -> + .geoCodeLocation(locationInfo.toLatLngPoint(), { Log.d(TAG, "geoLocation -------start -->") postInformationMessage( getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType,mainInfoId,longitude,latitude), diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/util/FileUtil.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/util/FileUtil.kt index ff4354b6f9..7a4b783f14 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/util/FileUtil.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/util/FileUtil.kt @@ -50,9 +50,8 @@ fun deleteAllFile(file: File?) { //判断文件不为null或文件目录存在 val files: Array = file.listFiles() //遍历该目录下的文件对象 for (f in files) { - val name: String = file.getName() //判断子目录是否存在子目录,如果是文件则删除 - if (f.isDirectory()) { + if (f.isDirectory) { deleteAllFile(f) } else { f.delete() diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/IMogoAuthorizeController.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/IMogoAuthorizeController.kt index 5e2ad53c7d..d7ce7c1a7d 100644 --- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/IMogoAuthorizeController.kt +++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/IMogoAuthorizeController.kt @@ -61,7 +61,7 @@ open class IMogoAuthorizeController { }) } - private fun realInvokeAuthorizeContent(agreementType: Int, onStart: (() -> Unit), onSuccess: ((BaseResponse) -> Unit), onError: ((String) -> Unit), needContent: Boolean = false) { + private fun realInvokeAuthorizeContent(agreementType: Int, onStart: (() -> Unit), onSuccess: ((BaseResponse) -> Unit), onError: ((String) -> Unit), needContent: Boolean = false) { onStart.invoke() try { request> { diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/MogoAuthorizeManagerImpl.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/MogoAuthorizeManagerImpl.kt index 6c91ab12fc..b154557c44 100644 --- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/MogoAuthorizeManagerImpl.kt +++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/MogoAuthorizeManagerImpl.kt @@ -8,7 +8,7 @@ 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 { +abstract class MogoAuthorizeManagerImpl : IMogoAuthorizeInvoke { companion object { const val TAG = "AuthorizeManagerImpl" diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/MogoAuthorizeProvider.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/MogoAuthorizeProvider.kt index dd4df21e58..475ec62561 100644 --- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/MogoAuthorizeProvider.kt +++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/authprovider/biz/MogoAuthorizeProvider.kt @@ -1,3 +1,5 @@ +@file:Suppress("DEPRECATION") + package com.mogo.module.authorize.authprovider.biz import android.content.Context @@ -11,7 +13,6 @@ import com.mogo.map.marker.IMogoMarkerClickListener import com.mogo.map.navi.IMogoNaviListener import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant.Companion.PATH_AGREEMENT_MODULE_NAME import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant.Companion.AUTHORIZE_TYPE_LAUNCHER_MAIN -import com.mogo.module.authorize.authprovider.launcher.MogoMainAuthorize import com.mogo.module.authorize.authprovider.launcher.MogoMainAuthorize.Companion.mogoAuthShow import com.mogo.module.authorize.util.SharedPreferenceUtil.hasGuide import com.mogo.service.MogoServicePaths diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/layout/AuthorizeController.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/layout/AuthorizeController.kt index 80af518b8b..c0fef82e20 100644 --- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/layout/AuthorizeController.kt +++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/layout/AuthorizeController.kt @@ -42,9 +42,9 @@ class AuthorizeController { agreementContent: (id: Long, content: String, title: String, bottomContent: String, lastContent: String) -> Unit, agreementError: () -> Unit) { Logger.d(TAG, "requestContentSuccess userAgreement:$userAgreement") - if (userAgreement.agreementContent.isNotEmpty()) { + if (userAgreement.agreementContent!= null && userAgreement.agreementContent!!.isNotEmpty()) { val id = userAgreement.tUserAgreementEntity.id - val content = userAgreement.agreementContent[0] + val content = userAgreement.agreementContent!![0] val title = userAgreement.tUserAgreementEntity.title val bottomContent = userAgreement.tUserAgreementEntity.agreementButtonFirst val lastContent = userAgreement.tUserAgreementEntity.agreementButtonSecond diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/layout/AuthorizeDialog.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/layout/AuthorizeDialog.kt index 5a428731f6..dfba896633 100644 --- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/layout/AuthorizeDialog.kt +++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/layout/AuthorizeDialog.kt @@ -10,6 +10,7 @@ import com.mogo.commons.AbsMogoApplication import com.mogo.commons.debug.DebugConfig import com.mogo.module.authorize.R import com.mogo.module.authorize.util.AnalyticsUtil +import com.mogo.module.authorize.util.HtmlUtil import com.mogo.module.authorize.voice.IVoiceAuthorizeIntentListener import com.mogo.module.authorize.voice.IVoiceCommandListener import com.mogo.module.authorize.voice.VoiceUtil @@ -22,14 +23,15 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.async import kotlinx.coroutines.withContext -class AuthorizeDialog : BaseFloatDialog, View.OnClickListener, IVoiceCommandListener, IVoiceAuthorizeIntentListener { +class AuthorizeDialog(invokeTag: String, context: Context) : BaseFloatDialog(context), + View.OnClickListener, IVoiceCommandListener, IVoiceAuthorizeIntentListener { companion object { const val TAG = "AuthorizeDialog" } - private var mContext: Context? = null - private var invokeTag: String? = null + private var mContext: Context? = context + private var invokeTag: String? = invokeTag private var agreementId: Long = 0L @@ -48,9 +50,7 @@ class AuthorizeDialog : BaseFloatDialog, View.OnClickListener, IVoiceCommandList private var authorizeController: AuthorizeController? = null - constructor(invokeTag: String, context: Context) : super(context) { - mContext = context - this.invokeTag = invokeTag + init { initView() } @@ -62,24 +62,24 @@ class AuthorizeDialog : BaseFloatDialog, View.OnClickListener, IVoiceCommandList private fun setWrapContent() { val mWindow = window - if(DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_BYD){ - if (mWindow != null && CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X) { - val lp = mWindow.attributes - lp.width = 1920 - lp.height = 1080 - mWindow.attributes = lp - }else{ - val lp = mWindow.attributes - lp.width = 1024 - lp.height = 600 - mWindow.attributes = lp - } - }else{ - if (mWindow != null) { - val lp = mWindow.attributes + mWindow?.let { + if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_BYD) { + if (CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X) { + val lp = it.attributes + lp.width = 1920 + lp.height = 1080 + it.attributes = lp + } else { + val lp = it.attributes + lp.width = 1024 + lp.height = 600 + it.attributes = lp + } + } else { + val lp = it.attributes lp.width = 1920 lp.height = 1000 - mWindow.attributes = lp + it.attributes = lp } } } @@ -132,15 +132,15 @@ class AuthorizeDialog : BaseFloatDialog, View.OnClickListener, IVoiceCommandList this.agreementId = agreementId clLoadAuthorizeContainer?.visibility = View.GONE clContainer?.visibility = View.VISIBLE - tvTitle?.text = Html.fromHtml(agreementTitle) + tvTitle?.text = HtmlUtil.getSpanned(agreementTitle) GlobalScope.async(Dispatchers.IO) { - val spannable = Html.fromHtml(agreementContent) + val spannable = HtmlUtil.getSpanned(agreementContent) withContext(Dispatchers.Main) { tvContent?.text = spannable } } - tvButtonContent?.text = Html.fromHtml(agreementBottom) - tvLastContent?.text = Html.fromHtml(agreementLast) + tvButtonContent?.text = HtmlUtil.getSpanned(agreementBottom) + tvLastContent?.text = HtmlUtil.getSpanned(agreementLast) } private fun showAuthorizationError() { diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/layout/AuthorizeLayout.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/layout/AuthorizeLayout.kt deleted file mode 100644 index adc6968eb1..0000000000 --- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/layout/AuthorizeLayout.kt +++ /dev/null @@ -1,179 +0,0 @@ -package com.mogo.module.authorize.layout - -import android.text.Html -import android.view.LayoutInflater -import android.view.View -import android.widget.Button -import android.widget.TextView -import androidx.constraintlayout.widget.ConstraintLayout -import com.mogo.commons.AbsMogoApplication -import com.mogo.module.authorize.R -import com.mogo.module.authorize.util.AnalyticsUtil -import com.mogo.module.authorize.util.AnalyticsUtil.INVOKE_TRACK_AUTHORIZE_CLICK -import com.mogo.module.authorize.util.AnalyticsUtil.INVOKE_TRACK_AUTHORIZE_SHOW -import com.mogo.module.authorize.voice.IVoiceAuthorizeIntentListener -import com.mogo.module.authorize.voice.IVoiceCommandListener -import com.mogo.module.authorize.voice.VoiceUtil -import com.mogo.utils.logger.Logger -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.async -import kotlinx.coroutines.withContext - -class AuthorizeLayout(private val invokeTag: String) : View.OnClickListener, IVoiceCommandListener, IVoiceAuthorizeIntentListener { - - companion object { - const val TAG = "AuthorizeLayout" - } - - private var agreementId: Long = 0L - - private var clTopParent: ConstraintLayout? = null - private var clErrorContainer: ConstraintLayout? = null - private var clLoadAuthorizeContainer: ConstraintLayout? = null - private var clContainer: ConstraintLayout? = null - private var clAuthorizeLoading: ConstraintLayout? = null - private var btnAgree: Button? = null - private var btnDisAgree: Button? = null - private var btnLoadingError: Button? = null - private var tvTitle: TextView? = null - private var tvContent: TextView? = null - private var tvButtonContent: TextView? = null - private var tvLastContent: TextView? = null - - private lateinit var layoutInflater: View - private var authorizeController: AuthorizeController? = null - - fun getLayoutView(): View { - layoutInflater = LayoutInflater.from(AbsMogoApplication.getApp().applicationContext).inflate(getLayoutId(), null) - initViews(layoutInflater) - return layoutInflater - } - - fun getLayoutId(): Int { - return R.layout.module_authorize_fragment - } - - fun initViews(mRootView: View) { - Logger.d(TAG, "initView ") - AnalyticsUtil.track(INVOKE_TRACK_AUTHORIZE_SHOW) - init(mRootView) - Logger.d(TAG, "invokeTag :$invokeTag") - authorizeController = AuthorizeController(invokeTag) - invokeAuthorizationContent() - VoiceUtil.registerAll(this, this) - } - - private fun init(mRootView: View) { - clTopParent = mRootView.findViewById(R.id.clAuthorizeTopParent) - clErrorContainer = mRootView.findViewById(R.id.clLoadingErrorContainer) - clLoadAuthorizeContainer = mRootView.findViewById(R.id.clLoadingAuthorizeContainer) - clContainer = mRootView.findViewById(R.id.clAuthorizeContainer) - clAuthorizeLoading = mRootView.findViewById(R.id.clAuthorizeLoading) - btnAgree = mRootView.findViewById(R.id.btnAuthorizeAgree) - btnDisAgree = mRootView.findViewById(R.id.btnAuthorizeDisAgree) - btnLoadingError = mRootView.findViewById(R.id.btnAuthorizeLoadingError) - tvTitle = mRootView.findViewById(R.id.tvAuthorizeTitle) - tvContent = mRootView.findViewById(R.id.tvAuthorizeContent) - tvButtonContent = mRootView.findViewById(R.id.tvAuthorizeButtonContent) - tvLastContent = mRootView.findViewById(R.id.tvAuthorizeLastContent) - btnAgree?.setOnClickListener(this) - btnDisAgree?.setOnClickListener(this) - btnLoadingError?.setOnClickListener(this) - clTopParent?.setOnClickListener(this) - clContainer?.setOnClickListener(this) - clErrorContainer?.setOnClickListener(this) - clLoadAuthorizeContainer?.setOnClickListener(this) - clAuthorizeLoading?.setOnClickListener(this) - } - - private fun readyToAuthorize() { - clErrorContainer?.visibility = View.GONE - clLoadAuthorizeContainer?.visibility = View.VISIBLE - } - - private fun showAuthorizationAgreementContent( - agreementId: Long, - agreementContent: String, - agreementTitle: String, - agreementBottom: String, - agreementLast: String) { - VoiceUtil.speak(AbsMogoApplication.getApp().applicationContext.resources.getString(R.string.module_authorize_agreement_tip), AbsMogoApplication.getApp().applicationContext, this) - this.agreementId = agreementId - clLoadAuthorizeContainer?.visibility = View.GONE - clContainer?.visibility = View.VISIBLE - tvTitle?.text = Html.fromHtml(agreementTitle) - GlobalScope.async(Dispatchers.IO) { - val spannable = Html.fromHtml(agreementContent) - withContext(Dispatchers.Main) { - tvContent?.text = spannable - } - } - tvButtonContent?.text = Html.fromHtml(agreementBottom) - tvLastContent?.text = Html.fromHtml(agreementLast) - } - - private fun showAuthorizationError() { - clLoadAuthorizeContainer?.visibility = View.GONE - clErrorContainer?.visibility = View.VISIBLE - } - - private fun voiceAuthorizeError() { - VoiceUtil.speak(AbsMogoApplication.getApp().applicationContext.getString(R.string.module_authorize_failed), AbsMogoApplication.getApp().applicationContext, this) - Logger.d(TAG, "onDestroy") - VoiceUtil.unregisterAll(AbsMogoApplication.getApp().applicationContext, this) - } - - override fun onClick(v: View) { - when (v.id) { - R.id.btnAuthorizeAgree -> { - AnalyticsUtil.track(INVOKE_TRACK_AUTHORIZE_CLICK, hashMapOf("operation_type" to 1, "operation_result" to 1)) - agreeAuthorize() - } - R.id.btnAuthorizeDisAgree -> { - AnalyticsUtil.track(INVOKE_TRACK_AUTHORIZE_CLICK, hashMapOf("operation_type" to 1, "operation_result" to 2)) - disAgreeAuthorize() - } - R.id.clLoadingErrorContainer, R.id.btnAuthorizeLoadingError -> { - invokeAuthorizationContent() - } - R.id.clAuthorizeTopParent-> { - Logger.i(TAG,"dismiss authorizeView") - authorizeController?.onDestroy() - } - } - } - - override fun onVoiceCmdAgree() { - AnalyticsUtil.track(INVOKE_TRACK_AUTHORIZE_CLICK, hashMapOf("operation_type" to 2, "operation_result" to 1)) - agreeAuthorize() - } - - override fun onVoiceCmdDisAgree() { - AnalyticsUtil.track(INVOKE_TRACK_AUTHORIZE_CLICK, hashMapOf("operation_type" to 2, "operation_result" to 2)) - disAgreeAuthorize() - } - - private fun agreeAuthorize() { - authorizeController?.agreeAuthorize(invokeTag, agreementId) { - voiceAuthorizeError() - } - } - - private fun disAgreeAuthorize() { - authorizeController?.disAgreeAuthorize(invokeTag, agreementId) { - voiceAuthorizeError() - } - } - - private fun invokeAuthorizationContent() { - authorizeController?.invokeAuthorizationContent(invokeTag, { - readyToAuthorize() - }, { id: Long, content: String, title: String, bottomContent: String, lastContent: String -> - showAuthorizationAgreementContent(id, content, title, bottomContent, lastContent) - }, { - showAuthorizationError() - }) - } - -} \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/model/bean/Agreement.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/model/bean/Agreement.kt index bec8a198d5..11c0443050 100644 --- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/model/bean/Agreement.kt +++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/model/bean/Agreement.kt @@ -21,7 +21,7 @@ data class AgreementStatus(val agreementStatus:Int) data class AgreementData(val agreement: Agreement) -data class Agreement(var tUserAgreementEntity: TUserAgreementEntity, var agreementContent: List) +data class Agreement(var tUserAgreementEntity: TUserAgreementEntity, var agreementContent: List?) data class TUserAgreementEntity( val id: Long, //协议ID diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/net/CoroutineDSL.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/net/CoroutineDSL.kt index f9d611409a..c74c2e36b9 100644 --- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/net/CoroutineDSL.kt +++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/net/CoroutineDSL.kt @@ -62,7 +62,7 @@ class Request { } } catch (e: Exception) { e.printStackTrace() - if (e == null) { + if (e.message == null) { onError?.invoke(NULL_EXCEPTION) return@launch } diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/util/DateUtil.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/util/DateUtil.kt index cba4cd0248..87c05a7ac5 100644 --- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/util/DateUtil.kt +++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/util/DateUtil.kt @@ -4,6 +4,7 @@ import java.util.* object DateUtil { + @Suppress("DEPRECATION") fun parseDateToTime(tmpDate: String): Long { val time = Date(tmpDate) return time.time diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/util/HtmlUtil.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/util/HtmlUtil.kt new file mode 100644 index 0000000000..e714a1e97d --- /dev/null +++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/util/HtmlUtil.kt @@ -0,0 +1,20 @@ +package com.mogo.module.authorize.util + +import android.os.Build +import android.text.Html +import android.text.Spanned + +class HtmlUtil { + + companion object{ + fun getSpanned(content: String): Spanned { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY) + } else { + @Suppress("DEPRECATION") + Html.fromHtml(content) + } + } + } + +} \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/view/AutoSplitTextView.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/view/AutoSplitTextView.kt deleted file mode 100644 index e3983a4a7e..0000000000 --- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/view/AutoSplitTextView.kt +++ /dev/null @@ -1,53 +0,0 @@ -package com.mogo.module.authorize.view - -import android.content.Context -import android.graphics.Canvas -import android.graphics.Paint -import android.util.AttributeSet -import android.widget.TextView - -class AutoSplitTextView : TextView { - - private var textShowWidth: Float = 0f - private var paint: Paint? = null - - constructor(context: Context?) : super(context, null) - constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) { - init() - } - - constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init() - } - - private fun init() { - paint = Paint() - } - - - override fun onDraw(canvas: Canvas) { - super.onDraw(canvas) - textShowWidth = (this.measuredWidth - paddingLeft - paddingRight).toFloat() - var lineCount = 0 - if (text.toString().isNullOrBlank()) return - val textCharArray = text.toString().toCharArray() - var drawWidth = 0f - var charWidth: Float - for (i in 0..textCharArray.size) { - charWidth = paint!!.measureText(textCharArray, i, 1) - if (textCharArray[i] == '\n') { - lineCount++ - drawWidth = 0f - continue - } - if (textShowWidth - drawWidth < charWidth) { - lineCount++ - drawWidth = 0f - } - canvas.drawText(textCharArray, i, 1, paddingLeft + drawWidth, (lineCount + 1) * textSize, paint) - drawWidth += charWidth - } - height = (lineCount + 1) * textSize as Int - } - -} \ No newline at end of file diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/voice/IVoiceAuthorizeIntentListener.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/voice/IVoiceAuthorizeIntentListener.kt index f5d2a4fcb6..6199f36637 100644 --- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/voice/IVoiceAuthorizeIntentListener.kt +++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/voice/IVoiceAuthorizeIntentListener.kt @@ -11,7 +11,7 @@ interface IVoiceAuthorizeIntentListener : IMogoIntentListener, IVoiceBusinessLis override fun onIntentReceived(cmd: String?, intent: Intent?) { Logger.i(IVoiceIntentTAG, "cmd -> $cmd") if (intent != null && cmd != null) { - VoiceManager.handleOnIntentCmd(cmd, intent, this) + VoiceManager.handleOnIntentCmd(cmd,this) } } diff --git a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/voice/VoiceManager.kt b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/voice/VoiceManager.kt index 8fdef5a631..90438ff580 100644 --- a/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/voice/VoiceManager.kt +++ b/modules/mogo-module-authorize/src/main/java/com/mogo/module/authorize/voice/VoiceManager.kt @@ -25,7 +25,7 @@ object VoiceManager { } } - fun handleOnIntentCmd(cmd: String, intent: Intent, listener: IVoiceAuthorizeIntentListener) { + fun handleOnIntentCmd(cmd: String, listener: IVoiceAuthorizeIntentListener) { Logger.i(TAG, "handleOnIntentCmd: cmd -> $cmd") when (cmd) { VOICE_INTENT_AGREE -> { diff --git a/modules/mogo-module-push/src/main/java/com/mogo/module/push/repository/PushRepository.kt b/modules/mogo-module-push/src/main/java/com/mogo/module/push/repository/PushRepository.kt index 9c50449846..e82b470a0e 100644 --- a/modules/mogo-module-push/src/main/java/com/mogo/module/push/repository/PushRepository.kt +++ b/modules/mogo-module-push/src/main/java/com/mogo/module/push/repository/PushRepository.kt @@ -37,8 +37,7 @@ class PushRepository(mContext: Context) { PushRepository(appContext) } - @JvmField - val TAG: String = "PushRepository.kt" + private const val TAG: String = "PushRepository.kt" } // 被中断的push消息仅再次展示一次 @@ -74,13 +73,13 @@ class PushRepository(mContext: Context) { Log.d("PushRepository", "pushBean = $bean") if (bean != null) { AnalyticsUtils.track(Config.NEWS_ARRIVE, "title", bean.title) - if (bean.mainSchema == null || bean.mainSchema == "") { + if (bean.mainSchema.isBlank()) { bean.mainSchema = "" } - if (bean.imageUrl == null || bean.imageUrl == "null") { + if (bean.imageUrl.isBlank()) { bean.imageUrl = "" } - if (bean.appIcon == null || bean.appIcon == "null") { + if (bean.appIcon.isBlank()) { bean.appIcon = "" } pushBeanQueue.offer(bean) @@ -144,10 +143,7 @@ class PushRepository(mContext: Context) { startIterate() } - private inline fun needDelay(bean: PushBean): Boolean { - if (bean == null) { - return false - } + private fun needDelay(bean: PushBean): Boolean { if (locationClient.lastKnowLocation != null) { if (bean.speedLimit > 0 && bean.speedLimit <= locationClient.lastKnowLocation.speed * 18 / 5) { Log.d("PushRepository", "speedLimit" + locationClient.lastKnowLocation.speed) diff --git a/modules/mogo-module-push/src/main/java/com/mogo/module/push/utils/AnimatorUtils.kt b/modules/mogo-module-push/src/main/java/com/mogo/module/push/utils/AnimatorUtils.kt index e121e2e957..bdbb7f46e3 100644 --- a/modules/mogo-module-push/src/main/java/com/mogo/module/push/utils/AnimatorUtils.kt +++ b/modules/mogo-module-push/src/main/java/com/mogo/module/push/utils/AnimatorUtils.kt @@ -6,12 +6,12 @@ import androidx.core.view.get import androidx.core.view.isNotEmpty import com.mogo.utils.logger.Logger -val TAG: String = "AnimatorUtils.kt" +const val TAG: String = "AnimatorUtils.kt" fun startClearAnimator(root: ViewGroup, runnable: Runnable) { if (root.isNotEmpty()) { var view: View - var size = root.childCount - 1 + val size = root.childCount - 1 for (i in size downTo 0) { view = root[i] view.animate().translationX(-view.width.toFloat()).apply { @@ -27,7 +27,7 @@ fun startClearAnimator(root: ViewGroup, runnable: Runnable) { } } } else { - runnable?.apply { + runnable.apply { run() } } diff --git a/modules/mogo-module-push/src/main/java/com/mogo/module/push/view/FloatView.kt b/modules/mogo-module-push/src/main/java/com/mogo/module/push/view/FloatView.kt index e8b8971d26..71a4f3237c 100644 --- a/modules/mogo-module-push/src/main/java/com/mogo/module/push/view/FloatView.kt +++ b/modules/mogo-module-push/src/main/java/com/mogo/module/push/view/FloatView.kt @@ -49,7 +49,7 @@ class FloatView constructor( fun inflateView(@LayoutRes layoutId: Int) } - open abstract inner class PushView(context: Context) : FrameLayout(context), + abstract inner class PushView(context: Context) : FrameLayout(context), PushViewController { lateinit var appIcon: ImageView lateinit var titleIconContainer: View @@ -95,7 +95,7 @@ class FloatView constructor( fun hasButtons(bean: PushBean?): Boolean { bean?.buttons?.forEach { - if (!it?.text?.isNullOrEmpty()) { + if (!it.text?.isNullOrEmpty()) { return true } } diff --git a/modules/mogo-module-push/src/main/java/com/mogo/module/push/viewmodel/PushViewModel.kt b/modules/mogo-module-push/src/main/java/com/mogo/module/push/viewmodel/PushViewModel.kt index 6c48a688bc..4952c897e8 100644 --- a/modules/mogo-module-push/src/main/java/com/mogo/module/push/viewmodel/PushViewModel.kt +++ b/modules/mogo-module-push/src/main/java/com/mogo/module/push/viewmodel/PushViewModel.kt @@ -6,7 +6,6 @@ import android.util.Log import com.mogo.commons.voice.AIAssist import com.mogo.commons.voice.IMogoVoiceCmdCallBack import com.mogo.module.push.Config -import com.zhidao.auto.platform.voice.VoiceClient import com.mogo.module.push.model.PushBean import com.mogo.module.push.repository.PushRepository import com.mogo.module.push.utils.AnalyticsUtils @@ -119,8 +118,8 @@ class PushViewModel( } field?.showTimeoutShadow = field?.showTimeout?:0 Log.d("yilz", "pushbean = $value") - if (value != null && value!!.imageUrl == null) { - value!!.imageUrl = "" + if (value.imageUrl.isBlank()) { + value.imageUrl = "" } if (floatView == null) { floatView = FloatView(this, mContext) diff --git a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/manager/SettingManager.kt b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/manager/SettingManager.kt index 064460aa8c..f3ea72cd5a 100644 --- a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/manager/SettingManager.kt +++ b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/manager/SettingManager.kt @@ -49,41 +49,41 @@ object SettingManager : IMogoSettingManager { private var isGpsSimulator: Boolean = false override fun getPathPrefer(): Int { - return settings!!.getInt(KEY_PAHT_PREFER, 0) + return settings.getInt(KEY_PAHT_PREFER, 0) } override fun getVolume(): Int { - return settings!!.getInt(KEY_VOLUME, 0) + return settings.getInt(KEY_VOLUME, 0) } override fun getVoiceStyle(): Int { - return settings!!.getInt(KEY_VOICE_STYLE, R.id.rb_navi_detail) + return settings.getInt(KEY_VOICE_STYLE, R.id.rb_navi_detail) } override fun getMapType(): Int { - return settings!!.getInt(KEY_MAP_TYPE, R.id.rb_navi_day) + return settings.getInt(KEY_MAP_TYPE, R.id.rb_navi_day) } fun setPathPrefer(type: Int) { - settings!!.edit() + settings.edit() .putInt(KEY_PAHT_PREFER, type) .apply() } fun setVolume(type: Int) { - settings!!.edit() + settings.edit() .putInt(KEY_VOLUME, type) .apply() } fun setVoiceStyle(type: Int) { - settings!!.edit() + settings.edit() .putInt(KEY_VOICE_STYLE, type) .apply() } fun setMapType(type: Int) { - settings!!.edit() + settings.edit() .putInt(KEY_MAP_TYPE, type) .apply() } diff --git a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/CategorySearchFragment.kt b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/CategorySearchFragment.kt index c25914c4aa..f021babef5 100644 --- a/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/CategorySearchFragment.kt +++ b/modules/mogo-module-search/src/main/java/com/mogo/module/navi/ui/search/CategorySearchFragment.kt @@ -19,7 +19,6 @@ import com.mogo.module.common.map.Scene import com.mogo.module.common.utils.CarSeries import com.mogo.module.navi.R import com.mogo.module.navi.constants.SearchApisHolder -import com.mogo.module.navi.manager.AddressManager import com.mogo.module.navi.ui.adapter.SearchCategoryAdapter import com.mogo.module.navi.ui.base.BaseFragment import com.mogo.module.navi.uitls.BitmapUtils @@ -34,17 +33,16 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa override fun onCmdSelected(cmd: String?) { if (cmd?.startsWith("position") == true) { - var index = cmd.substring(8) + val index = cmd.substring(8) mAdapter.current = index.toInt() updateMarker(false) goPath() } } - private val TAG: String = "CategorySearchFragment" private var addMarkers: ArrayList = ArrayList() - var arrayList = ArrayList() - var locationList = ArrayList() + private var arrayList = ArrayList() + private var locationList = ArrayList() private lateinit var cmds: ArrayList @@ -57,13 +55,13 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa arrayList.clear() locationList.clear() - for (index in 0 until datums!!.size) { - var decodeResource = BitmapFactory.decodeResource( + for (index in datums!!.indices) { + val decodeResource = BitmapFactory.decodeResource( resources, if (mAdapter.current == index) R.mipmap.icon_search_category_checked else R.mipmap.icon_search_category_unchecked ) - var createWaterMask = BitmapUtils.createWaterMask( + val createWaterMask = BitmapUtils.createWaterMask( context, decodeResource, (index + 1).toString(), @@ -76,15 +74,15 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa .owner("CategorySearchFragment") .`object`(index) // .anchor(0.5f, 1f) - .longitude(datums[index].point?.lng ?: 0.0) + .longitude(datums[index].point?.lon ?: 0.0) arrayList.add(options) if (locationList.size < 3) { locationList.add(datums[index].point) } - var int2String = StringUtils.int2String(index + 1) + val int2String = StringUtils.int2String(index + 1) AIAssist.getInstance(context).registerUnWakeupCommand("position${index}", arrayOf("第${int2String}个", "第${int2String}条"), this) - cmds.add("position" + index) + cmds.add("position$index") } addMarkers() @@ -92,7 +90,7 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa private fun addMarkers() { addMarkers.clear() - var marginBounder = resources.getDimensionPixelSize(R.dimen.dp_60) * 2 + val marginBounder = resources.getDimensionPixelSize(R.dimen.dp_60) * 2 SearchApisHolder.getUiControllerApis().showBounds(TAG, locationList[0], locationList, @@ -101,7 +99,7 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa ) for (options in arrayList) { - var addMarker = SearchApisHolder.getMarkerManager().addMarker(TAG, options) + val addMarker = SearchApisHolder.getMarkerManager().addMarker(TAG, options) addMarker.onMarkerClickListener = this addMarkers.add(addMarker) } @@ -109,7 +107,7 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa private fun registerVoice() { for (index in 0 until cmds.size) { - var int2String = StringUtils.int2String(index + 1) + val int2String = StringUtils.int2String(index + 1) AIAssist.getInstance(context).registerUnWakeupCommand("position${index}", arrayOf("第${int2String}个", "第${int2String}条"), this) } } @@ -125,7 +123,7 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa } override fun onMarkerClicked(marker: IMogoMarker?): Boolean { - var index = marker?.mogoMarkerOptions?.`object` as Int + val index = marker?.mogoMarkerOptions?.`object` as Int mAdapter.current = index rv_search_result.smoothScrollToPosition(index) updateMarker() @@ -142,7 +140,7 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa category = arguments?.getString("category") mSearchPresenter = CategoryPresenter(this) lifecycle.addObserver(mSearchPresenter) - cmds = ArrayList() + cmds = ArrayList() } override fun getLayoutId(): Int { @@ -168,7 +166,7 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa goPath() } mAdapter.setOnClickListener { - var position = it.getTag(R.id.tag_position) as Int + val position = it.getTag(R.id.tag_position) as Int mAdapter.current = position updateMarker() } @@ -183,13 +181,12 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa } private fun updateMarker(moveToCenter: Boolean = true) { - - addMarkers?.get(mAdapter.lastPosition)?.setIcon(getMarkerIcon(mAdapter.lastPosition)) - var current = addMarkers?.get(mAdapter.current) - current?.setIcon(getMarkerIcon(mAdapter.current)) - current?.setToTop() - arrayList.get(mAdapter.lastPosition).icon(getMarkerIcon(mAdapter.lastPosition)) - arrayList.get(mAdapter.current).icon(getMarkerIcon(mAdapter.current)) + addMarkers[mAdapter.lastPosition].setIcon(getMarkerIcon(mAdapter.lastPosition)) + val current = addMarkers[mAdapter.current] + current.setIcon(getMarkerIcon(mAdapter.current)) + current.setToTop() + arrayList[mAdapter.lastPosition].icon(getMarkerIcon(mAdapter.lastPosition)) + arrayList[mAdapter.current].icon(getMarkerIcon(mAdapter.current)) if (moveToCenter) { SearchApisHolder.getStatusManager().setUserInteractionStatus(TAG, true, false) SearchApisHolder.getUiControllerApis().moveToCenter(current.position, CarSeries.CAR_SERIES_F80X == CarSeries.getSeries()) @@ -197,7 +194,7 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa } private fun getMarkerIcon(index: Int): Bitmap { - var decodeResource = BitmapFactory.decodeResource( + val decodeResource = BitmapFactory.decodeResource( resources, if (mAdapter.current == index) R.mipmap.icon_search_category_checked else R.mipmap.icon_search_category_unchecked ) @@ -232,13 +229,16 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa } companion object { + + private const val TAG: String = "CategorySearchFragment" + fun newInstance(category: String): Fragment { MapCenterPointStrategy.setMapCenterPointByScene(SearchApisHolder.getUiControllerApis(), Scene.CATEGORY_SEARCH) - var bundle = Bundle() + val bundle = Bundle() bundle.putString("category", category) - var categorySerachFragment = CategorySearchFragment() - categorySerachFragment.arguments = bundle - return categorySerachFragment + val categorySearchFragment = CategorySearchFragment() + categorySearchFragment.arguments = bundle + return categorySearchFragment } } } diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/TrafficUploadProvider.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/TrafficUploadProvider.kt index a3b7ec23aa..35e0a91cb2 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/TrafficUploadProvider.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/TrafficUploadProvider.kt @@ -1,3 +1,5 @@ +@file:Suppress("DEPRECATION") + package com.mogo.module.share import android.content.Context diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/TrafficUploadManager.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/TrafficUploadManager.kt index 670b32b095..0afb54004e 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/TrafficUploadManager.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/TrafficUploadManager.kt @@ -46,19 +46,19 @@ class TrafficUploadManager : IMogoTrafficSearchListener { override fun onTrafficSearchInfo(trafficResult: MogoTrafficResult?) { val map = hashMapOf("upload" to 1) //调用高德接口成功 MogoApisHandler.getInstance().apis.analyticsApi.track(TRACK_UPLOAD_INVOKE, map) - trafficResult?.let { trafficResult -> + trafficResult?.let { val uploadTrafficEntity = UploadTrafficEntity() val roadTrafficStatusList: MutableList = ArrayList() - val trafficStatusInfoList = trafficResult.trafficStatusInfos - trafficStatusInfoList.forEach { + val trafficStatusInfoList = it.trafficStatusInfos + trafficStatusInfoList.forEach { info -> val roadTrafficStatus = RoadTrafficStatus() - roadTrafficStatus.angle = it.angle - roadTrafficStatus.direction = it.direction + roadTrafficStatus.angle = info.angle + roadTrafficStatus.direction = info.direction roadTrafficStatus.isSegment = false roadTrafficStatus.length = 0 - roadTrafficStatus.roadName = it.name - roadTrafficStatus.status = it.status.toInt() - roadTrafficStatus.mogoLatLngList = it.mogoLatLngs + roadTrafficStatus.roadName = info.name + roadTrafficStatus.status = info.status.toInt() + roadTrafficStatus.mogoLatLngList = info.mogoLatLngs roadTrafficStatusList.add(roadTrafficStatus) } uploadTrafficEntity.roadTrafficStatuses = roadTrafficStatusList diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/UploadHelper.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/UploadHelper.kt index 4bd01b72f7..66921a0a6f 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/UploadHelper.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/UploadHelper.kt @@ -6,7 +6,6 @@ import com.mogo.commons.voice.AIAssist import com.mogo.map.MogoLatLng import com.mogo.module.common.entity.MarkerPoiTypeEnum import com.mogo.module.share.R -import com.mogo.module.share.TanluManager import com.mogo.module.share.constant.ShareConstants.* import com.mogo.service.share.TanluUploadParams import com.mogo.utils.NetworkUtils @@ -68,10 +67,10 @@ object UploadHelper { private fun showVoiceTip(context: Context, type: String) { var shareItemSum = SharedPrefsMgr.getInstance(context).getInt(KEY_CLICK_SHARE_ITEM_BUTTON, 0) - var intervalTime = SharedPrefsMgr.getInstance(context).getLong(KEY_CLICK_SHARE_ITEM_TIME, 0) + val intervalTime = SharedPrefsMgr.getInstance(context).getLong(KEY_CLICK_SHARE_ITEM_TIME, 0) if (shareItemSum < VOICE_ALERT_COUNT) { - Log.d("UploadHelper", "shareItemSum = $shareItemSum --- intervalTime = $intervalTime --type = ${type}") - var time = System.currentTimeMillis() + Log.d("UploadHelper", "shareItemSum = $shareItemSum --- intervalTime = $intervalTime --type = $type") + val time = System.currentTimeMillis() Log.d("UploadHelper", "time = $time ") if (intervalTime == 0.toLong()) { SharedPrefsMgr.getInstance(context).putLong(KEY_CLICK_SHARE_ITEM_TIME, time) @@ -92,8 +91,7 @@ object UploadHelper { private fun getTypeName(type: String): String? { - var typeName = "" - typeName = when (type) { + return when (type) { MarkerPoiTypeEnum.TRAFFIC_CHECK -> "交通检查" MarkerPoiTypeEnum.ROAD_CLOSED -> "封路" MarkerPoiTypeEnum.FOURS_ROAD_WORK -> "施工" @@ -105,7 +103,6 @@ object UploadHelper { MarkerPoiTypeEnum.FOURS_LIVING -> "实时路况" else -> "实时路况" } - return typeName } } \ No newline at end of file diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/ShareApiService.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/ShareApiService.kt index 1485f30d96..347ff0de3d 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/ShareApiService.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/net/ShareApiService.kt @@ -42,6 +42,6 @@ interface ShareApiService { */ @FormUrlEncoded @POST("/yycp-launcherSnapshot/launcherSnapshot/searchRoadEventsSync") - fun queryRoadInfos(@FieldMap params: Map): Observable> + fun queryRoadInfos(@FieldMap params: Map): Observable> } \ No newline at end of file diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt index eb0c2dc0d9..c8a97b5f37 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt @@ -159,7 +159,7 @@ class BlockStrategy(private val context: Context, private val apis: IMogoService val params = ArrayMap() params["speed"] = average.toInt() val body = RequestBody.create(MediaType.parse("Content-type:application/json;charset=UTF-8"), GsonUtil.jsonFromObject(params)) - val disposable = apis.networkApi.create(ShareApiService::class.java, HttpConstant.getNetHost()).sendAverageSpeedForBlockStrategy(body, Utils.getSn()).subscribeOn(Schedulers.io()).subscribe(object : SubscribeImpl(RequestOptions.create(context)) { + apis.networkApi.create(ShareApiService::class.java, HttpConstant.getNetHost()).sendAverageSpeedForBlockStrategy(body, Utils.getSn()).subscribeOn(Schedulers.io()).subscribe(object : SubscribeImpl(RequestOptions.create(context)) { override fun onSuccess(response: AverateSpeedResponse?) { super.onSuccess(response) response?.let { diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XEventPanelFragment.kt b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XEventPanelFragment.kt index d68cb92a12..1af736ad0d 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XEventPanelFragment.kt +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XEventPanelFragment.kt @@ -71,7 +71,7 @@ class V2XEventPanelFragment : MvpFragment + private val mCheckHistoryEventCb = V2XVoiceCallbackListener { _: String?, _: Intent? -> try { mRbScenarioHistory?.isChecked = true } catch (e: java.lang.Exception) { @@ -80,7 +80,7 @@ class V2XEventPanelFragment : MvpFragment + private val mCheckSurroundingCb = V2XVoiceCallbackListener { _: String?, _: Intent? -> try { mRbSurroundingEvent?.isChecked = true } catch (e: java.lang.Exception) { @@ -89,7 +89,7 @@ class V2XEventPanelFragment : MvpFragment + private val mCheckShearEventCb = V2XVoiceCallbackListener { _: String?, _: Intent? -> try { mRbShareEvents?.isChecked = true } catch (e: java.lang.Exception) { @@ -98,7 +98,7 @@ class V2XEventPanelFragment : MvpFragment + private val mCloeEventCb = V2XVoiceCallbackListener { _: String?, _: Intent? -> try { TrackUtils.trackV2xHistoryEvent(5) hidePanel() @@ -132,7 +132,7 @@ class V2XEventPanelFragment : MvpFragment + mRgTabSelect?.setOnCheckedChangeListener { _, checkedId -> when (checkedId) { R.id.rbScenarioHistory -> { // 更改选中是否加粗 diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/SimpleCoverVideoPlayer.kt b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/SimpleCoverVideoPlayer.kt index be83a6236d..018657a861 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/SimpleCoverVideoPlayer.kt +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/SimpleCoverVideoPlayer.kt @@ -149,6 +149,7 @@ class SimpleCoverVideoPlayer : StandardGSYVideoPlayer { mFullPauseBitmap = null if (mAudioManager != null) { try { + @Suppress("DEPRECATION") mAudioManager.abandonAudioFocus(onAudioFocusChangeListener) } catch (e: Exception) { Logger.e(TAG, e, "onDetachedFromWindow - abandonAudioFocus") @@ -158,7 +159,7 @@ class SimpleCoverVideoPlayer : StandardGSYVideoPlayer { override fun onClick(v: View?) { super.onClick(v) - Log.d("kl", "onClick160" + mCurrentState) + Log.d("kl", "onClick160 : $mCurrentState") if (mCurrentState == CURRENT_STATE_PAUSE) { onVideoResume() } else if (mCurrentState == CURRENT_STATE_PLAYING) {