code style changed and fix bug of aspectJ

This commit is contained in:
unknown
2020-12-22 10:24:21 +08:00
parent e807277736
commit 5b4c5b5af5
35 changed files with 101 additions and 688 deletions

View File

@@ -2,6 +2,7 @@ apply plugin: 'com.android.application'
apply plugin: 'com.alibaba.arouter'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'android-aspectjx'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
@@ -445,6 +446,10 @@ repositories {
}
}
aspectjx {
include "com.mogo.chat"
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

View File

@@ -53,6 +53,7 @@ ext {
glideanno : 'com.github.bumptech.glide:annotations:4.8.0',
glidecompiler : 'com.github.bumptech.glide:compiler:4.8.0',
supportannos : "com.android.support:support-annotations:28.0.0",
okhttpinterceptor :"com.squareup.okhttp3:logging-interceptor:3.12.0",
// fresco
fresco : 'com.facebook.fresco:fresco:1.1.0',
// 公司服务 - 语音
@@ -175,6 +176,7 @@ ext {
mogobaseservicesdk : "com.mogo.base:services-sdk:${MOGO_BASE_SERVICES_SDK_VERSION}",
mogobaseserviceapk : "com.mogo.base:services-apk:${MOGO_BASE_SERVICES_APK_VERSION}",
mogobasewebsocketsdk : "com.mogo.base:websocket-sdk:${MOGO_BASE_WEBSOCKET_SDK_VERSION}",
mogowebsocket : "com.mogo.module.carchatting:module-carchatt-socket:${WEBSOCKET_VERSION}",
// loglib
mogologlib : "com.mogo.module:module-loglib:${LOGLIB_VERSION}",
// monitor

View File

@@ -29,8 +29,7 @@ android {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation rootProject.ext.dependencies.arouter
implementation "com.mogo.module.carchatting:module-carchatt-socket:1.1.2"
implementation rootProject.ext.dependencies.mogowebsocket
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.mogoutils

View File

@@ -138,9 +138,11 @@ HTTPDNS_NOOP_VERSION = 2.0.12
######## 外部依赖引用
# 车聊聊
CARCHATTING_VERSION=2.2.23
CARCHATTING_VERSION=2.2.31
# 车聊聊接口
CARCHATTINGPROVIDER_VERSION=1.1.8
# websocket
WEBSOCKET_VERSION=1.1.2
# loglib
LOGLIB_VERSION = 1.0.4

View File

@@ -2,10 +2,8 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'android-aspectjx'
apply plugin: 'com.alibaba.arouter'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
// buildToolsVersion rootProject.ext.android.buildToolsVersion
@@ -50,7 +48,7 @@ dependencies {
implementation rootProject.ext.dependencies.androidxccorektx
implementation rootProject.ext.dependencies.aiassist
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
implementation rootProject.ext.dependencies.okhttpinterceptor
implementation 'com.zhidaoauto.controller:api:1.0.8'
implementation 'com.zhidao.cosupload:cosuploadsdk:1.1.6', {
exclude group: 'com.zhidao.utils', module: 'utils'
@@ -65,7 +63,6 @@ dependencies {
implementation rootProject.ext.dependencies.gson
implementation rootProject.ext.dependencies.rxjava
implementation rootProject.ext.dependencies.rxandroid
implementation rootProject.ext.dependencies.aspectj
implementation rootProject.ext.dependencies.analytics
implementation rootProject.ext.dependencies.arouter

View File

@@ -1,29 +0,0 @@
package com.zhidao.roadcondition.aspect
import android.util.Log
import com.zhidao.roadcondition.util.CarNet_Alive
import com.zhidao.roadcondition.util.trackNormalEvent
import org.aspectj.lang.annotation.*
@Aspect
class DAUAspectj {
companion object {
const val TAG = "DAUAspectj"
}
@Pointcut("execution(* com.zhidao.roadcondition.splash_module.SplashActivity.initView())")
fun callDAU() {
}
@Pointcut("execution(* com.zhidao.roadcondition.service.RoadInfoService.launchMainActivity(..))")
fun callDAUOther(){
}
@Before("callDAU() || callDAUOther()")
fun trackDAU() {
Log.i(TAG, "trackDAU")
trackNormalEvent(CarNet_Alive, null)
}
}

View File

@@ -1,14 +0,0 @@
package com.zhidao.roadcondition.aspect;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({TYPE, METHOD, CONSTRUCTOR})
@Retention(RUNTIME)
public @interface DebugLog {
}

View File

@@ -1,112 +0,0 @@
package com.zhidao.roadcondition.aspect
import android.os.Looper
import android.os.Trace
import android.util.Log
import com.zhidao.roadcondition.BuildConfig
import org.aspectj.lang.ProceedingJoinPoint
import org.aspectj.lang.annotation.Around
import org.aspectj.lang.annotation.Aspect
import org.aspectj.lang.annotation.Pointcut
import org.aspectj.lang.reflect.CodeSignature
import org.aspectj.lang.reflect.MethodSignature
import java.util.concurrent.TimeUnit
@Aspect
class LogAspectj {
companion object {
@Volatile
private var enable: Boolean = BuildConfig.DEBUG
}
@Pointcut("within(@com.zhidao.roadcondition.aspect.DebugLog *)")
fun withinAnnotatedClass() {}
@Pointcut("execution(!synthetic * *(..))&& withinAnnotatedClass()")
fun methodInsideAnnotatedType() {}
@Pointcut("execution(!synthetic *.new(..))&& withinAnnotatedClass()")
fun constructorInsideAnnotatedType() {}
@Pointcut("execution(@com.zhidao.roadcondition.aspect.DebugLog * *(..))|| methodInsideAnnotatedType()")
fun method() {}
@Pointcut("execution(@com.zhidao.roadcondition.aspect.DebugLog *.new(..))|| constructorInsideAnnotatedType()")
fun constructor() {}
@Around("method() || constructor()")
fun logExecute(joinPoint: ProceedingJoinPoint) {
enterMethod(joinPoint)
var startNanos = System.nanoTime()
var result = joinPoint.proceed()
var stopNanos = System.nanoTime()
var lengthMill = TimeUnit.NANOSECONDS.toMillis(stopNanos - startNanos)
exitMethod(joinPoint, result, lengthMill)
}
private fun enterMethod(joinPoint: ProceedingJoinPoint) {
if (!enable) return
val signature = joinPoint.signature as CodeSignature
val cls = signature.declaringType
val methodName = signature.name
val parameterNames = signature.parameterNames
val parameterValues = joinPoint.args
var builder = StringBuilder("\u21E2 ")
builder.append(methodName).append('(')
parameterValues.forEachIndexed { index, _ ->
if (index > 0) {
builder.append(",")
}
builder.append(parameterNames[index]).append('=')
builder.append(parameterValues[index])
}
builder.append(')')
if (Looper.myLooper() != Looper.getMainLooper()) {
builder.append("[Thread:\"").append(Thread.currentThread().name).append("\"]")
}
Log.i(asTag(cls), builder.toString())
val section = builder.toString().substring(2)
Trace.beginSection(section)
}
private fun exitMethod(joinPoint: ProceedingJoinPoint, result: Any?, lengthMill: Long) {
if (!enable) return
Trace.endSection()
val signature = joinPoint.signature
val cls = signature.declaringType
val methodName = signature.name
var hasReturnType = signature is MethodSignature
&& signature.returnType != Void.TYPE
var builder = StringBuilder("\u21E0 ")
.append(methodName)
.append("[")
.append(lengthMill)
.append("ms]")
if (hasReturnType) {
builder.append(" = ")
builder.append(result.let {
result.toString()
})
}
Log.i(asTag(cls), builder.toString())
}
private fun asTag(cls: Class<*>): String {
// if (cls.isAnonymousClass) {
// return asTag(cls.enclosingClass)
// }
return cls.simpleName
}
}

View File

@@ -1,7 +1,6 @@
package com.zhidao.roadcondition.constant
import com.mogo.commons.debug.DebugConfig
import com.zhidao.roadcondition.BuildConfig
class HttpConstants {

View File

@@ -11,7 +11,7 @@ class StrategyServiceModel : BaseRepository() {
suspend fun getCityStrategy(): BaseResponse<Results> {
return apiCall {
var map = hashMapOf<String, String>()
val map = hashMapOf<String, String>()
map["sn"] = Utils.getSn()
val locInfo = LocationUtil.getInstance().getLocationInfo()
map["data"] = Gson().toJson(
@@ -25,43 +25,10 @@ class StrategyServiceModel : BaseRepository() {
}
}
// suspend fun getAuthorization(): BaseResponse<Any> {
// return apiCall {
// HttpClient.getInstance().getHttpApi().getAuthorization(getSn())
// }
// }
//
// suspend fun getAllConfig(): BaseResponse<CommonConfig> {
// return apiCall {
// var map = hashMapOf<String, String>()
// map["sn"] = getSn()
// HttpClient.getInstance().getHttpApi()
// .getAllCommonConfig(map)
// }
// }
//
// suspend fun getSplashConfig(): BaseR
// esponse<SplashConfig> {
// return apiCall {
// var splashConfigRequest =
// SplashConfigRequest("1", "1")
// var splashBodyStr = Gson().toJson(splashConfigRequest)
//
// HttpClient.getInstance().getHttpApi()
// .getSplashConfig(
// mapOf(
// "sn" to getSn(),
// "data" to splashBodyStr
// )
// )
//
// }
// }
suspend fun uploadInformation(informationBody: InformationBody): BaseResponse<UploadResult> {
return apiCall {
var informationBodyStr = Gson().toJson(informationBody)
Log.d("MainServiceController", "uploadInformation informationBody = " + informationBodyStr)
val informationBodyStr = Gson().toJson(informationBody)
Log.d("MainServiceController", "uploadInformation informationBody = $informationBodyStr")
HttpClient.getInstance().getHttpApi()
.uploadInformation(mapOf("sn" to Utils.getSn(), "data" to informationBodyStr))
}

View File

@@ -1,17 +0,0 @@
package com.zhidao.roadcondition.net
import android.util.Log
import okhttp3.Interceptor
import okhttp3.Response
class CommonInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val oldRequest = chain.request()
val newRequest = oldRequest.newBuilder()
Log.d("CommonInterceptor","addHeader")
newRequest.header("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
return chain.proceed(newRequest.build())
}
}

View File

@@ -19,12 +19,10 @@ class HttpClient private constructor(baseUrl: String) {
const val DEFAULT_WRITE_TIMEOUT = 30L
const val DEFAULT_READ_TIMEOUT = 30L
const val COMMON_PARAM_SN = "sn"
private var baseUrlClientMap = HashMap<String, HttpClient>()
fun getInstance(): HttpClient {
var baseUrl = HttpConstants.getBaseUrl()
val baseUrl = HttpConstants.getBaseUrl()
var httpClient = baseUrlClientMap[baseUrl]
if (httpClient == null) {
synchronized(HttpClient::class.java) {

View File

@@ -1,43 +0,0 @@
package com.zhidao.roadcondition.net
import androidx.annotation.NonNull
import okhttp3.MediaType
import okhttp3.RequestBody
import okhttp3.internal.Util
import okio.BufferedSink
class PostCommonBody : RequestBody {
companion object {
val CONTENT_TYPE = MediaType.parse("application/x-www-form-urlencoded; charset=UTF-8")
val charset = Util.UTF_8
fun create(@NonNull content: String): RequestBody {
return PostCommonBody(content)
}
}
private var content: String
constructor(@NonNull content: String) {
this.content = content
}
fun getContent(): String {
return content
}
override fun contentType(): MediaType? {
return CONTENT_TYPE
}
override fun writeTo(sink: BufferedSink) {
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)
}
}

View File

@@ -1,28 +0,0 @@
package com.zhidao.roadcondition.net
import com.zhidao.roadcondition.constant.HttpConstants
import com.zhidao.roadcondition.exception.ApiException
import com.zhidao.roadcondition.model.BaseResponse
import io.reactivex.functions.Function
class ResponseFunction<T> : Function<BaseResponse<T>, T> {
private var baseUrl: String = ""
constructor() {
this.baseUrl = HttpConstants.getBaseUrl()
}
constructor(baseUrl: String) {
this.baseUrl = baseUrl
}
override fun apply(t: BaseResponse<T>): T {
if (!t.isSuccess(baseUrl)) {
throw ApiException(t.code, t.msg)
}
return t.result
}
}

View File

@@ -11,7 +11,7 @@ class ShareRoadReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
Log.d("MainService", "ShareRoadReceiver ------> intent.action = " + intent.action)
if (intent.action == "com.zhidao.share.roadcondition.action") {
var type = intent.getStringExtra("type")
val type = intent.getStringExtra("type")
Log.e("MainService", "ShareRoadReceiver type ----> $type ----> 此方法已经废弃了,无法调起服务")
// MainService.launchService(context, type)
}

View File

@@ -28,15 +28,15 @@ import kotlin.math.abs
* @since 2019-10-30
*/
object CarCorderController : TakePhotoCallback, TakeVideoCallback {
const val TAG: String = "CarCorderController"
private lateinit var zdCarCoderController: ZdCarCoderController
val TAG: String = this.javaClass.simpleName
var outputVideoPath: String = ""
var mType: String = "" //1 上报拥堵, 2 封路和查车
var mainInfoId: Long = 0
var mFromType: String = ""
private var outputVideoPath: String = ""
private var mType: String = "" //1 上报拥堵, 2 封路和查车
private var mainInfoId: Long = 0
private var mFromType: String = ""
private var mLongitude: Double = 0.0
private var mLatitude: Double = 0.0
var mSpeed: Float = 0f
private var mSpeed: Float = 0f
private var getVideoFailed: (() -> Unit)? = null
private var interceptors: ArrayList<TakePhotoInterceptor> = ArrayList(1)

View File

@@ -1,6 +1,5 @@
package com.zhidao.roadcondition.service
import android.util.Log
import com.zhidao.cosupload.callback.CosStatusCallback
import com.zhidao.cosupload.callback.CosStatusCallbackManager
@@ -11,9 +10,7 @@ import com.zhidao.cosupload.callback.CosStatusCallbackManager
*/
object CosCallbackMapController : CosStatusCallback {
val TAG = "CosCallbackMapController"
val map: MutableMap<String, CosStatusCallback> = mutableMapOf()
private val map: MutableMap<String, CosStatusCallback> = mutableMapOf()
var uploadFailed: (() -> Unit)? = null
@@ -58,9 +55,7 @@ object CosCallbackMapController : CosStatusCallback {
}
override fun uploadCosFailed(cosPath: String?, eventId: String?, localPath: String?) {
map[localPath]?.let {
it.uploadCosFailed(cosPath, eventId, localPath)
}
map[localPath]?.uploadCosFailed(cosPath, eventId, localPath)
}
override fun uploadCosCompleted(
@@ -69,15 +64,11 @@ object CosCallbackMapController : CosStatusCallback {
downloadUrl: String?,
localPath: String?
) {
map[localPath]?.let {
it.uploadCosCompleted(cosPath, eventId, downloadUrl, localPath)
}
map[localPath]?.uploadCosCompleted(cosPath, eventId, downloadUrl, localPath)
}
override fun onProgress(localPath: String?, progress: Float) {
map[localPath]?.let {
it.onProgress(localPath, progress)
}
map[localPath]?.onProgress(localPath, progress)
}
fun release() {

View File

@@ -4,11 +4,9 @@ import android.content.Intent
import android.util.Log
import com.google.gson.Gson
import com.mogo.commons.AbsMogoApplication
import com.mogo.utils.TipToast
import com.zhidao.cosupload.DbPriorityConfig
import com.zhidao.cosupload.callback.CosStatusCallback
import com.zhidao.cosupload.manager.CosUploadManagerImpl
import com.zhidao.roadcondition.constant.*
import com.zhidao.roadcondition.event.GetImageSuccessEvent
import com.zhidao.roadcondition.event.LatLngStickyEventBus
import com.zhidao.roadcondition.model.proxy.INFO_TYPE_IMG
@@ -25,11 +23,15 @@ import com.zhidao.roadcondition.util.trackNormalEvent
* @since 2019-10-30
*/
class CosStatusController : CosStatusCallback {
val TAG: String = this.javaClass.simpleName
companion object{
const val TAG: String = "CosStatusController"
}
//存储单次请求的视频和缩略图url
var videoAndThumbMap: MutableMap<String, String> = mutableMapOf()
private var videoAndThumbMap: MutableMap<String, String> = mutableMapOf()
//图片上传的eventId
lateinit var mPicEventId: String
private lateinit var mPicEventId: String
private var isRetry = false //是否重试上传过图片
private var mainServiceHttpModel = MainServiceController()
@@ -41,7 +43,7 @@ class CosStatusController : CosStatusCallback {
private var mFromType: String = ""
private var mLongitude: Double = 0.0
private var mLatitude: Double = 0.0
var mSpeed: Float = 0f
private var mSpeed: Float = 0f
//上传文件
fun uploadFile(picPath: MutableList<String?>?, entity: TakeEntity, type: String, mainInfoId: Long,
@@ -123,7 +125,7 @@ class CosStatusController : CosStatusCallback {
videoAndThumbMap["thumb"] = downloadUrl!!
Log.i(TAG, "videoAndThumbMap add thumb")
}
Log.d(TAG, "videoAndThumbMap ${videoAndThumbMap}")
Log.d(TAG, "videoAndThumbMap $videoAndThumbMap")
if (videoAndThumbMap.size == 2) {
trackUploadCos(4)
Log.d(TAG, "videoAndThumbMap.size == 2 ")

View File

@@ -10,8 +10,8 @@ import java.util.*
*/
object CustomStatusHandler {
val takePhotoStatusQueue: Queue<Boolean> = ArrayDeque(5)
val takeVideoStatusQueue: Queue<TakeEntity> = ArrayDeque(5)
private val takePhotoStatusQueue: Queue<Boolean> = ArrayDeque(5)
private val takeVideoStatusQueue: Queue<TakeEntity> = ArrayDeque(5)
fun offerPhotoStatus(status: Boolean) {
takePhotoStatusQueue.offer(status)

View File

@@ -6,9 +6,6 @@ import android.content.Intent
import android.os.IBinder
import android.util.Log
import com.zhidao.roadcondition.util.*
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import java.io.File
import java.lang.Exception

View File

@@ -13,7 +13,7 @@ import com.zhidao.roadcondition.util.*
*/
object InformationUploadController {
val TAG : String = this.javaClass.simpleName
private val TAG : String = this.javaClass.simpleName
private var mainServiceHttpModel = MainServiceController()
@@ -110,9 +110,7 @@ object InformationUploadController {
fun release(id: Long) {
val target = informationCache.remove(id)
target?.let {
it.release()
}
target?.release()
}
private fun recordUploadTime() {

View File

@@ -33,7 +33,6 @@ import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.getStrateg
import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.getStrategyType
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import java.util.concurrent.TimeUnit
@@ -61,22 +60,21 @@ class MainService : Service() {
//是否已经获取过策略
var isGetStrategies: Boolean = false
val TAG: String = this.javaClass.simpleName
private val TAG: String = this.javaClass.simpleName
//1是一次性2是周期性
var picType: Int = 0
var videoType: Int = 0
var shareType: String = "type"
var fromType: String = ""
var isCustom: Boolean = false
var speed: Float = 0f
private var picType: Int = 0
private var videoType: Int = 0
private var shareType: String = "type"
private var fromType: String = ""
private var isCustom: Boolean = false
private var speed: Float = 0f
var params: UploadParams? = null
var mainInfoId: Long = 0
private var params: UploadParams? = null
private var mainInfoId: Long = 0
private var mLongitude: Double = 0.0
private var mLatitude: Double = 0.0
lateinit var serviceApis: IMogoServiceApis
private lateinit var serviceApis: IMogoServiceApis
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
//清理多媒体资源和sp策略数据
@@ -86,10 +84,8 @@ class MainService : Service() {
//参数说明appKey: app唯一标识比如包名
CosUploadManagerImpl.getInstance(AbsMogoApplication.getApp().applicationContext)
.init(BuildConfig.APPLICATION_ID, 0)
//初始化语音
VoiceController.initVoice()
serviceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(this) as IMogoServiceApis
speed = serviceApis.getMapServiceApi().getSingletonLocationClient(this).getLastKnowLocation().getSpeed()
speed = serviceApis.mapServiceApi.getSingletonLocationClient(this).lastKnowLocation.speed
Log.d(TAG, "onStartCommand speed = $speed")
if (intent != null) {
params = intent.getParcelableExtra("params")
@@ -115,7 +111,7 @@ class MainService : Service() {
}
//定时任务回调广播
var mAlarmBroadCast: BroadcastReceiver = object : BroadcastReceiver() {
private var mAlarmBroadCast: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(p0: Context?, p1: Intent) {
Log.d(TAG, "receive alarm!!!!!!!!!!AlarmType===${p1.getIntExtra("AlarmType", 1)}")
if (p1.action == alarmBroadAction) {
@@ -178,14 +174,14 @@ class MainService : Service() {
// mainServiceHttpModel.getSplashConfig()
}
var id: Long = System.currentTimeMillis()
private var id: Long = System.currentTimeMillis()
/**
* 获取图片成功
*/
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true, priority = 98)
fun getImageEvent(getImageSuccessEvent: GetImageSuccessEvent) {
var info = LocationUtil.getInstance().getLocationInfo()
val info = LocationUtil.getInstance().getLocationInfo()
Log.d("MainService", "getImageEvent long = ${info.longitude} ----> lat= ${info.latitude}")
Log.d(
"MainService",
@@ -209,7 +205,7 @@ class MainService : Service() {
* 初始化定位监听
*/
private fun initLocationListener() {
var isOpen = SharedPrefsMgr.getInstance(AbsMogoApplication.getApp().applicationContext).getBoolean("KEY_SERVER_REPORTSTRATEGY_SWITCH", false)
val isOpen = SharedPrefsMgr.getInstance(AbsMogoApplication.getApp().applicationContext).getBoolean("KEY_SERVER_REPORTSTRATEGY_SWITCH", false)
Logger.d("EntrancePresenter", " initLocationListener ---- isOpen = $isOpen")
//开始开始监听速度,只要超过一次5公里每小时则即开始获取策略进行本地上报 只有release才加此判断qa环境方便测试
LocationUtil.getInstance().setonSpeedlistenner(object : LocationUtil.SpeedListener {
@@ -277,9 +273,9 @@ class MainService : Service() {
//目前不支持连拍只能定时2秒拍一张 第一期每次只拍一张
Observable.intervalRange(0, 1, 0, 2_000, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
.subscribe {
CarCorderController.takePhoto(1, 1, false, isCustom, TANLU_ROAD_CURRENT, mainInfoId, fromType, mLongitude, mLatitude, speed)
})
}
// }
postPhotoAlarmTask(isInterval)
@@ -310,7 +306,7 @@ class MainService : Service() {
intent.action = alarmBroadAction
intent.putExtra("number", getLong(PIC_NUMBER, PIC_NUMBER_DEFAULT))
intent.putExtra("AlarmType", AlarmTypePic)
var pendingIntent = PendingIntent.getBroadcast(this, AlarmTypePic, intent, 0)
val pendingIntent = PendingIntent.getBroadcast(this, AlarmTypePic, intent, 0)
Log.d(
"MainService",
"postPhotoAlarmTask time =" + getStrategyInterval(
@@ -342,7 +338,7 @@ class MainService : Service() {
"duration", (VIDEO_DURATION_DEFAULT / 1000).toInt()
)
videoIntent.putExtra("AlarmType", AlarmTypeVideo)
var videoPendingIntent =
val videoPendingIntent =
PendingIntent.getBroadcast(this, AlarmTypeVideo, videoIntent, 0)
Log.d(
"MainService",

View File

@@ -18,20 +18,20 @@ import kotlinx.coroutines.runBlocking
class MainServiceController {
companion object {
var TAG = this::class.java.name
const val TAG = "MainServiceController"
}
//逆地理编码是否重试
private var geoRetryed = false
private var geoRetry = false
private var mFromType: String = ""
private var mPoiType: String = ""
private val strategyeModel by lazy { StrategyServiceModel() }
private val strategyModel by lazy { StrategyServiceModel() }
fun initStrategies(initFinish: (() -> Unit)? = null) {
request<BaseResponse<Results>> {
loader {
strategyeModel.getCityStrategy()
strategyModel.getCityStrategy()
}
onSuccess {
it.result.let { strategy ->
@@ -184,7 +184,7 @@ class MainServiceController {
}, {
//转换失败的情况下再重试一次
Log.d(TAG, "geoLocation -------true-->")
geoRetryed = if (!geoRetryed) {
geoRetry = if (!geoRetry) {
geoLocation(type, url, locationInfo, isCustom, trafficInfoType, isShare, customSend, poiType,mainInfoId,speed, longitude,latitude)
true
} else {
@@ -207,7 +207,7 @@ class MainServiceController {
trackUploadServer(3)
request<BaseResponse<UploadResult>> {
loader {
strategyeModel.uploadInformation(informationBody)
strategyModel.uploadInformation(informationBody)
}
onSuccess {
Log.i(TAG, "upload success id = " + it.result.id)
@@ -230,7 +230,7 @@ class MainServiceController {
private fun sendUgcStatusReceiver(id: Long, type: String?, fromType: String?) {
Log.d(TAG, "sendUgcStatusReceiver id = $id ---type = $type --fromType = $fromType ")
var intent = Intent()
val intent = Intent()
intent.action = "com.v2x.ugc.upload.status"
intent.putExtra("id", id)
intent.putExtra("type", type)

View File

@@ -2,7 +2,6 @@ package com.zhidao.roadcondition.service
import android.os.Parcel
import android.os.Parcelable
import com.mogo.map.MogoLatLng
class UploadParams(val eventType: String, val fromType: String, val duration: Int, val parentId: Long, val lat: Double, val lon: Double) : Parcelable {
constructor(parcel: Parcel) : this(

View File

@@ -1,63 +0,0 @@
package com.zhidao.roadcondition.service
import com.mogo.commons.AbsMogoApplication
import com.zhidao.auto.platform.voice.VoiceClient
import java.lang.Exception
/**
* @description 声音控制类
*
* @author lixiaopeng
* @since 2019-11-01
*/
object VoiceController {
private lateinit var voiceClient: VoiceClient
fun initVoice() {
voiceClient = VoiceClient(AbsMogoApplication.getApp().applicationContext)
}
/**
* 设置语音命令回调接口
* @param callBack
*/
fun setCallBack(callBack: VoiceClient.VoiceCmdCallBack) {
voiceClient.setCallBack(callBack)
}
/**
* @param speakText 语音播报内容
*/
fun speakVoice(speakText: String) {
voiceClient.speakDefault(speakText)
}
/**
* 注册免唤醒命令
* @param customType 命令
* @param customWakeupCmd 命令对应的唤醒词集合
*/
fun registerCustomWakeupCmd(customType: String, customWakeupCmd: Array<String>) {
voiceClient.registerCustomWakeupCmd(customType, customWakeupCmd)
}
/**
* 取消免唤醒命令
* @param customType 命令
*/
fun unRegisterCustomWakeupCmd(customType: String) {
try {
voiceClient.unRegisterCustomWakeupCmd(customType)
} catch (e:Exception){
}
}
/**
* 释放资源(界面销毁的时候调用)
*/
fun release() {
voiceClient.release()
}
}

View File

@@ -4,7 +4,6 @@ import android.content.Context
import com.elegant.analytics.Analytics
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.network.Utils
import com.zhidao.roadcondition.aspect.DebugLog
import java.util.HashMap
const val CarNet_Alive:String = "CarNet_Alive"//探路日活DAU埋点
@@ -38,7 +37,6 @@ const val CarNet_Geo:String = "CarNet_Geo_Location" //上传服务端, type=1开
const val CarNet_live_broadcast = "CarNet_live_broadcast" // 地图页面点击直播(在线可直播车机)
//自定义埋点
@DebugLog
fun trackNormalEvent(event: String, _data: MutableMap<String, Any>?, context: Context = AbsMogoApplication.getApp().applicationContext) {
var data = _data
if (data == null) {

View File

@@ -3,35 +3,14 @@
package com.zhidao.roadcondition.util
import android.content.Context
import java.lang.reflect.InvocationTargetException
private const val SN_INFO: String = "gsm.serial"
fun getSn(): String {
var serial = ""
try {
var cls = Class.forName("android.os.SystemProperties")
var method = cls.getMethod("get", String::class.java)
serial = method.invoke(cls, SN_INFO) as String
} catch (var4: ClassNotFoundException) {
var4.printStackTrace()
} catch (var5: NoSuchMethodException) {
var5.printStackTrace()
} catch (var6: InvocationTargetException) {
var6.printStackTrace()
} catch (var7: IllegalAccessException) {
var7.printStackTrace()
}
return serial
}
fun getSystemVersion(context: Context): String {
try {
var cls = context.classLoader
var systemProperties = cls.loadClass("android.os.SystemProperties")
var paramTypes = String::class.java
val cls = context.classLoader
val systemProperties = cls.loadClass("android.os.SystemProperties")
val paramTypes = String::class.java
val get = systemProperties.getMethod("get", paramTypes)
val version = get.invoke(systemProperties, *arrayOf<Any>("ro.fota.version")) as String
val version = get.invoke(systemProperties, "ro.fota.version") as String
return if (!version.trim().isNullOrEmpty()) version.trim() else ""
} catch (e: Exception) {
e.printStackTrace()

View File

@@ -3,7 +3,6 @@ package com.zhidao.roadcondition.util
import android.graphics.Bitmap
import android.media.MediaMetadataRetriever
import android.os.Environment
import android.util.Log
import okhttp3.MediaType
import okhttp3.MultipartBody
import okhttp3.RequestBody
@@ -14,21 +13,21 @@ import java.util.*
//创建文件上传请求体
fun fileToMultiPart(fileUrl: String): MultipartBody.Part? {
var file = File(fileUrl)
val file = File(fileUrl)
if (file.exists()) {
var requestBody = RequestBody.create(MediaType.parse("image/jpg"), file)
val requestBody = RequestBody.create(MediaType.parse("image/jpg"), file)
return MultipartBody.Part.createFormData("file", file.name, requestBody)
}
return null
}
fun deletePicFile(filePath: String?): Boolean {
var file = File(filePath)
val file = File(filePath)
if (file.exists()) {
//如果图片地址包含此路径则是C上面的拍照需要再删除后摄图片
if (filePath!!.contains("usbotg-1-1.1")) {
//将地址替换成后摄图片地址
var backFile =
val backFile =
File(filePath.replace("frontPic", "backPic").replace("PhotoFront", "PhotoBack"))
if (backFile.exists()) {
return backFile.delete()
@@ -64,7 +63,7 @@ fun deleteAllFile(file: File?) { //判断文件不为null或文件目录存在
//根据本地视频文件生成缩略图文件
fun getVideoThumbnail(filePath: String, picPath: String): Boolean {
var b: Bitmap? = null
var retriever = MediaMetadataRetriever()
val retriever = MediaMetadataRetriever()
try {
retriever.setDataSource(filePath)
b = retriever.getFrameAtTime(0)
@@ -92,7 +91,7 @@ fun bitmapToFile(bitmap: Bitmap?, filePath: String): Boolean {
file.delete()
file.createNewFile()
val fos = FileOutputStream(file)
var ins = ByteArrayInputStream(baos.toByteArray())
val ins = ByteArrayInputStream(baos.toByteArray())
var x = 0
val b = ByteArray(1024 * 100)
while ({ x = ins.read(b);x }() != -1) {
@@ -130,50 +129,4 @@ fun getCompressVideoPath(): String {
}
return destPath.absolutePath
}
/**
* 保存图片到本地
*/
fun saveImageToSdcard(bmp: Bitmap): Boolean {
val currentFile: File
var fos: FileOutputStream? = null
val picFile = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
picFile.mkdirs()
val builder = StringBuilder()
builder.append("splash_bg")
val filePrefix = builder.toString()
val fileOut = ".jpg"
currentFile = File(picFile, filePrefix + fileOut)
try {
fos = FileOutputStream(currentFile)
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos)
fos.flush()
} catch (e: FileNotFoundException) {
e.printStackTrace()
return false
} catch (e: IOException) {
e.printStackTrace()
return false
} finally {
try {
fos?.close()
} catch (e: IOException) {
e.printStackTrace()
return false
}
}
return true
}
/**
* 获取本地保存的图片地址
*/
fun getImagePath(): String {
return "/mnt/sdcard/Pictures/splash_bg.jpg"
}
}

View File

@@ -11,7 +11,7 @@ import com.mogo.map.search.geo.query.MogoRegeocodeQuery
import com.mogo.module.common.MogoApisHandler
import com.zhidao.roadcondition.model.LocationInfo
private fun MogoRegeocodeAddress.toLocInfo(
private fun toLocInfo(
address: MogoRegeocodeAddress,
latlngPoint: MogoLatLng
): LocationInfo {
@@ -29,7 +29,7 @@ private fun MogoRegeocodeAddress.toLocInfo(
)
}
private fun MogoLocation.toLocInfo(location: MogoLocation): LocationInfo {
private fun toLocInfo(location: MogoLocation): LocationInfo {
return LocationInfo(
location.province,
location.cityName,
@@ -104,7 +104,7 @@ class LocationUtil private constructor() {
locationInfo!!
} else {
val location = MogoApisHandler.getInstance().apis.mapServiceApi.getSingletonLocationClient(mContext).lastKnowLocation
location.toLocInfo(location)
toLocInfo(location)
}
}
@@ -114,8 +114,8 @@ class LocationUtil private constructor() {
locGeoCode: (((locInfo: LocationInfo) -> Unit)),
onError: ((msg: String) -> Unit)
) {
var geocoderSearch = MogoApisHandler.getInstance().apis.mapServiceApi.getGeoSearch(AbsMogoApplication.getApp().applicationContext)
var regeocodeQuery = MogoRegeocodeQuery()
val geocoderSearch = MogoApisHandler.getInstance().apis.mapServiceApi.getGeoSearch(AbsMogoApplication.getApp().applicationContext)
val regeocodeQuery = MogoRegeocodeQuery()
regeocodeQuery.latlngType = ""
regeocodeQuery.point = latlngPoint
regeocodeQuery.radius = 200
@@ -126,13 +126,13 @@ class LocationUtil private constructor() {
override fun onRegeocodeSearched(regeocodeResult: MogoRegeocodeResult?) {
super.onRegeocodeSearched(regeocodeResult)
if( regeocodeResult == null ){
trackUploadGeo(3);
trackUploadGeo(3)
onError.invoke("geoCode")
} else {
trackUploadGeo(2);
var regeocodeAddress = regeocodeResult?.regeocodeAddress
trackUploadGeo(2)
val regeocodeAddress = regeocodeResult.regeocodeAddress
regeocodeAddress?.let {
var locInfo = regeocodeAddress.toLocInfo(regeocodeAddress, latlngPoint)
val locInfo = toLocInfo(regeocodeAddress, latlngPoint)
locGeoCode.invoke(locInfo)
}
}

View File

@@ -5,7 +5,6 @@ import com.google.gson.JsonArray
import com.google.gson.JsonObject
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.network.Utils
import com.zhidao.roadcondition.constant.TANLU_ROAD_CURRENT
import com.zhidao.roadcondition.model.InformationBody
import com.zhidao.roadcondition.model.LocationInfo
import com.zhidao.roadcondition.model.proxy.INFO_TYPE_IMG
@@ -13,16 +12,6 @@ import com.zhidao.roadcondition.model.proxy.INFO_TYPE_VIDEO
import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.getStrategyType
import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.getStrategyValidity
var array: Array<LocationInfo> = arrayOf(
LocationInfo(116.40320588562773, 39.96661385462713, "测试数据1", 123123213),
LocationInfo(116.41309250805662, 39.970285228355976, "测试数据2", 123123213),
LocationInfo(116.40749205563353, 39.97317943101997, "测试数据3", 12321321321),
LocationInfo(116.39925230953978, 39.97314654304226, "测试数据4", 123123123),
LocationInfo(116.439366, 39.868472, "测试数据5", 123123123),
LocationInfo(116.288164, 39.910547, "测试数据6", 123123123),
LocationInfo(116.330132, 39.989311, "测试数据7", 123123123)
)
fun getInformationBody(
types: Int,
urls: Map<String, String>,
@@ -37,21 +26,21 @@ fun getInformationBody(
speed: Float,
fromType: String
): InformationBody {
var jsonArray = JsonArray()
var type: Int
val jsonArray = JsonArray()
val type: Int
type = if (types == INFO_TYPE_VIDEO) {
var videoObject = JsonObject()
val videoObject = JsonObject()
videoObject.addProperty("thumbnail", urls["thumb"])
videoObject.addProperty("url", urls["video"])
jsonArray.add(videoObject)
INFO_TYPE_VIDEO
} else {
var urlObject = JsonObject()
val urlObject = JsonObject()
urlObject.addProperty("url", urls["pic"])
jsonArray.add(urlObject)
INFO_TYPE_IMG
}
var infoType = if (isCustom) 1 else 0
val infoType = if (isCustom) 1 else 0
Log.d("MainServiceController", "isCustom = $isCustom ---- infoType = $infoType")
return InformationBody(
jsonArray.toString(),

View File

@@ -1,123 +1,17 @@
package com.zhidao.roadcondition.util
import android.content.Context
import android.util.Log
import androidx.core.content.edit
import com.mogo.commons.AbsMogoApplication
import com.zhidao.roadcondition.aspect.DebugLog
const val FILE_NAME = "settings_data"
const val FILE_NAME_NAVI = "settings_navi_data"
const val FILE_NAME_ACTIVE = "settings_active_data"
const val NAVI_INFO = "NAVI_INFO" //沿途导航数据存储
const val NAVI_INFO_STATUS = "NAVI_INFO_STATUS" //沿途导航路线是否存在
const val PARAM_AUTHORIZATION = "PARAM_AUTHORIZATION"
const val PARAM_PROMOTION_CONTENT = "PARAM_PROMOTION_CONTENT"
const val PARAM_ACTIVE_WEB_URL = "PARAM_ACTIVE_WEB_URL"
const val PARAM_ACTIVE_IMG_URL = "PARAM_ACTIVE_IMG_URL"
const val PARAM_ACTIVE_STATUS = "PARAM_ACTIVE_STATUS"
const val LAST_ENTER_TIME = "LAST_ENTER_TIME"
const val PIC_NUMBER = "PIC_NUMBER" //图片拍摄张数
const val VIDEO_DURATION_DEFAULT = 10_000L //视频拍摄时长
const val PIC_NUMBER_DEFAULT = 1L //图片拍摄张数
const val TIME_QUANTUM = "time_quantum" //时间段
const val COUNT_DOWN_TIME = "count_down" //倒计时
const val VOICE_TEXT = "voice_text" //语音播报内容
const val IS_SAVE_SPLASH = "is_save_splash" //是否保存了
//播放开始时间
const val PLAYER_START_TIME = "first_time"
fun clearActiveInfo(context: Context = AbsMogoApplication.getApp().applicationContext) {
var sharedPreferences = context.getSharedPreferences(FILE_NAME_ACTIVE, Context.MODE_PRIVATE)
sharedPreferences.edit {
clear()
val clearActiveInfo = commit()
Log.d(FILE_NAME_NAVI, "clearActiveInfo = $clearActiveInfo")
}
}
fun setActiveWebUrl(content: String, context: Context = AbsMogoApplication.getApp().applicationContext) {
var sharedPreferences = context.getSharedPreferences(FILE_NAME_ACTIVE, Context.MODE_PRIVATE)
sharedPreferences.edit {
putString(PARAM_ACTIVE_WEB_URL, content)
.commit()
}
}
fun setActiveStatus(status: Int, context: Context = AbsMogoApplication.getApp().applicationContext) {
var sharedPreferences = context.getSharedPreferences(FILE_NAME_ACTIVE, Context.MODE_PRIVATE)
sharedPreferences.edit {
putInt(PARAM_ACTIVE_STATUS, status)
.commit()
}
}
fun getActiveStatus(context: Context): Int {
return context.getSharedPreferences(FILE_NAME_ACTIVE, Context.MODE_PRIVATE)
.getInt(PARAM_ACTIVE_STATUS, 0)
}
fun setPromotionContent(content: String, context: Context = AbsMogoApplication.getApp().applicationContext) {
var sharedPreferences = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE)
sharedPreferences.edit {
putString(PARAM_PROMOTION_CONTENT, content)
.commit()
}
}
fun isAuthorization(context: Context): Boolean {
return context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE)
.getBoolean(PARAM_AUTHORIZATION, false)
}
@DebugLog
fun setAuthorization(context: Context, authorization: Boolean) {
var sharedPreferences = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE)
sharedPreferences.edit {
putBoolean(PARAM_AUTHORIZATION, authorization)
.commit()
}
}
@DebugLog
fun setNaviInfo(context: Context, naviInfo: String) {
var sharedPreferences = context.getSharedPreferences(FILE_NAME_NAVI, Context.MODE_PRIVATE)
sharedPreferences.edit {
val naviInfoSave = putString(NAVI_INFO, naviInfo)
.commit()
Log.d(FILE_NAME_NAVI, "naviInfoSave = $naviInfoSave")
}
}
@DebugLog
fun setNaviInfoStatus(context: Context, naviInfoStatus: Boolean) {
var sharedPreferences = context.getSharedPreferences(FILE_NAME_NAVI, Context.MODE_PRIVATE)
sharedPreferences.edit {
val naviInfoSaveStatus = putBoolean(NAVI_INFO_STATUS, naviInfoStatus)
.commit()
Log.d(FILE_NAME_NAVI, "naviInfoSaveStatus = $naviInfoSaveStatus")
}
}
fun clearAllNaviInfo(context: Context) {
var sharedPreferences = context.getSharedPreferences(FILE_NAME_NAVI, Context.MODE_PRIVATE)
sharedPreferences.edit {
clear()
val naviInfoAllClear = commit()
Log.d(FILE_NAME_NAVI, "naviInfoAllClear = $naviInfoAllClear")
}
}
fun putLong(key: String, value: Long) {
var sharedPreferences =
val sharedPreferences =
AbsMogoApplication.getApp().applicationContext.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE)
sharedPreferences.edit {
putLong(key, value).apply()
@@ -129,42 +23,27 @@ fun getLong(key: String, defaultValue: Long): Long {
.getLong(key, defaultValue)
}
fun putInt(key: String, value: Int) {
var sharedPreferences =
val sharedPreferences =
AbsMogoApplication.getApp().applicationContext.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE)
sharedPreferences.edit {
putInt(key, value).apply()
}
}
fun getInt(key: String, defaultValue: Int): Int {
return AbsMogoApplication.getApp().applicationContext.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE)
.getInt(key, defaultValue)
}
fun putCommonString(key: String, value: String) {
var sharedPreferences =
val sharedPreferences =
AbsMogoApplication.getApp().applicationContext.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE)
sharedPreferences.edit {
putString(key, value).apply()
}
}
//fun getCommonString(key: String?, defaultValue: String?): String {
// return AbsMogoApplication.getApp().applicationContext.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE)
// .getString(key, defaultValue)
//}
//
//fun putCommonBoolean(key: String, value: Boolean) {
// var sharedPreferences =
// AbsMogoApplication.getApp().applicationContext.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE)
// sharedPreferences.edit {
// putBoolean(key, value).apply()
// }
//}
fun getCommonBoolean(key: String, defaultValue: Boolean): Boolean {
return AbsMogoApplication.getApp().applicationContext.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE)
.getBoolean(key, defaultValue)

View File

@@ -35,7 +35,7 @@ class StrategyPreferenceUtil {
companion object {
//保存策略类型在AccOff的时候清除数据更新时需要在没有情报上传时操作
fun setStrategyType(context: Context, strategyType: Int, type: String) {
var sharedPreferences =
val sharedPreferences =
context.getSharedPreferences(STRATEGY_TYPE_COPY, Context.MODE_PRIVATE)
sharedPreferences.edit {
putInt(STRATEGY_TYPE + type, strategyType).commit()
@@ -51,7 +51,7 @@ class StrategyPreferenceUtil {
}
fun clearStrategyType(context: Context) {
var sharedPreferences =
val sharedPreferences =
context.getSharedPreferences(STRATEGY_TYPE_COPY, Context.MODE_PRIVATE)
sharedPreferences.edit {
clear()
@@ -66,7 +66,7 @@ class StrategyPreferenceUtil {
infoType: String,
frequency: Int
) {
var sharedPreferences =
val sharedPreferences =
context.getSharedPreferences(STRATEGY_FILE_NAME, Context.MODE_PRIVATE)
sharedPreferences.edit {
putInt(
@@ -98,7 +98,7 @@ class StrategyPreferenceUtil {
infoType: String,
interval: Long
) {
var sharedPreferences =
val sharedPreferences =
context.getSharedPreferences(STRATEGY_FILE_NAME, Context.MODE_PRIVATE)
sharedPreferences.edit {
putLong(
@@ -130,7 +130,7 @@ class StrategyPreferenceUtil {
infoType: String,
validity: Int
) {
var sharedPreferences =
val sharedPreferences =
context.getSharedPreferences(STRATEGY_FILE_NAME, Context.MODE_PRIVATE)
sharedPreferences.edit {
putInt(
@@ -154,7 +154,7 @@ class StrategyPreferenceUtil {
infoType: String,
maxSpeed: Int
) {
var sharedPreferences =
val sharedPreferences =
context.getSharedPreferences(STRATEGY_FILE_NAME, Context.MODE_PRIVATE)
sharedPreferences.edit {
putInt(
@@ -178,7 +178,7 @@ class StrategyPreferenceUtil {
infoType: String,
minSpeed: Int
) {
var sharedPreferences =
val sharedPreferences =
context.getSharedPreferences(STRATEGY_FILE_NAME, Context.MODE_PRIVATE)
sharedPreferences.edit {
putInt(

View File

@@ -1,17 +0,0 @@
package com.zhidao.roadcondition.util
import android.text.format.DateFormat
const val format = "yy/MM/dd kk:mm:ss"
fun formatDate(time: Long): String {
return DateFormat.format(format, time).toString()
}
fun convertVar(param: Any?): Any? {
return if (param is String) {
"\"$param\""
} else {
param
}
}

View File

@@ -1,12 +0,0 @@
package com.zhidao.roadcondition.util
import android.content.Context
import android.content.Intent
fun isReiceverRegist(context: Context, intentAction: String): Boolean {
val intent = Intent()
intent.action = intentAction
val pm = context.packageManager
val resolveInfos = pm.queryBroadcastReceivers(intent, 0)
return resolveInfos != null && resolveInfos.isNotEmpty()
}

View File

@@ -3,7 +3,6 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.alibaba.arouter'
apply plugin: 'kotlin-kapt'
apply plugin: 'android-aspectjx'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
@@ -51,7 +50,6 @@ dependencies {
implementation rootProject.ext.dependencies.androidxviewpager2
implementation rootProject.ext.dependencies.arouter
kapt rootProject.ext.dependencies.aroutercompiler
implementation rootProject.ext.dependencies.aspectj
implementation rootProject.ext.dependencies.indicator
if (Boolean.valueOf(RELEASE)) {