code style opt, reduce build time : 1m30s
This commit is contained in:
@@ -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(",")
|
||||
}
|
||||
|
||||
@@ -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 //活动配置
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -36,7 +36,7 @@ class CoroutineChain {
|
||||
return request(loader, true)
|
||||
}
|
||||
|
||||
fun <T> LifecycleOwner.request(loader: suspend () -> T, needAutoCancel: Boolean = true): Deferred<T> {
|
||||
private fun <T> LifecycleOwner.request(loader: suspend () -> T, needAutoCancel: Boolean = true): Deferred<T> {
|
||||
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 {
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
//失败了,传空地址,发起请求
|
||||
|
||||
@@ -27,11 +27,11 @@ object CosCallbackMapController : CosStatusCallback {
|
||||
this.uploadFailed = uploadFailed
|
||||
}
|
||||
|
||||
fun registerCallback(paths: List<String>, callback: CosStatusCallback) {
|
||||
fun registerCallback(paths: List<String?>?, callback: CosStatusCallback) {
|
||||
paths?.let { list ->
|
||||
list.forEach { path ->
|
||||
path?.let {
|
||||
map[path] = callback
|
||||
map[it] = callback
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class CosStatusController : CosStatusCallback {
|
||||
private var mLatitude: Double = 0.0
|
||||
|
||||
//上传文件
|
||||
fun uploadFile(picPath: MutableList<String>, entity: TakeEntity, type: String, mainInfoId: Long,
|
||||
fun uploadFile(picPath: MutableList<String?>?, 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)
|
||||
}
|
||||
|
||||
@@ -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?) {
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -50,9 +50,8 @@ fun deleteAllFile(file: File?) { //判断文件不为null或文件目录存在
|
||||
val files: Array<File> = file.listFiles()
|
||||
//遍历该目录下的文件对象
|
||||
for (f in files) {
|
||||
val name: String = file.getName()
|
||||
//判断子目录是否存在子目录,如果是文件则删除
|
||||
if (f.isDirectory()) {
|
||||
if (f.isDirectory) {
|
||||
deleteAllFile(f)
|
||||
} else {
|
||||
f.delete()
|
||||
|
||||
Reference in New Issue
Block a user