code style changed and fix bug of aspectJ
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
Reference in New Issue
Block a user