迁移探路模块和tanlulib代码至此
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
class BaseRequest<T>(var sn: String, var data: T?) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
import com.zhidao.roadcondition.constant.HttpConstants
|
||||
|
||||
class BaseResponse<out T>(val code: Int, val msg: String, val result: T) {
|
||||
fun isSuccess(baseUrl: String): Boolean {
|
||||
return when (baseUrl) {
|
||||
HttpConstants.getBaseUrl() -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
class CityStrategy {
|
||||
|
||||
var video: Video
|
||||
var pic: Pic
|
||||
|
||||
constructor(video: Video, pic: Pic) {
|
||||
this.video = video
|
||||
this.pic = pic
|
||||
}
|
||||
}
|
||||
|
||||
fun Video.getMaxSpeed(): Int {
|
||||
return if (maxSpeed == 0) {
|
||||
-1
|
||||
} else {
|
||||
maxSpeed
|
||||
}
|
||||
}
|
||||
|
||||
class Video {
|
||||
var strategyId: String //策略ID
|
||||
var reportType: Int //一次性、周期性
|
||||
var reportTimeInterval: Int //上传时间间隔 单位:分钟
|
||||
var infoTimeout: Int //情报失效时间 单位:分钟
|
||||
var minSpeed: Int = -1//最小速度
|
||||
var maxSpeed: Int = -1//最大速度
|
||||
var strategyType: Int //策略类型:城市、热门区域、非上报区域等
|
||||
|
||||
constructor(
|
||||
strategyId: String,
|
||||
reportType: Int,
|
||||
reportTimeInterval: Int,
|
||||
infoTimeout: Int,
|
||||
minSpeed: Int,
|
||||
maxSpeed: Int,
|
||||
strategyType: Int
|
||||
) {
|
||||
this.strategyId = strategyId
|
||||
this.reportType = reportType
|
||||
this.reportTimeInterval = reportTimeInterval
|
||||
this.infoTimeout = infoTimeout
|
||||
this.minSpeed = minSpeed
|
||||
this.maxSpeed = maxSpeed
|
||||
this.strategyType = strategyType
|
||||
}
|
||||
}
|
||||
|
||||
fun Pic.getMaxSpeed(): Int {
|
||||
return if (maxSpeed == 0) {
|
||||
-1
|
||||
} else {
|
||||
maxSpeed
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Pic {
|
||||
var strategyId: String //策略ID
|
||||
var reportType: Int //一次性、周期性
|
||||
var reportTimeInterval: Int //上传时间间隔 单位:分钟
|
||||
var infoTimeout: Int //情报失效时间 单位:分钟
|
||||
var minSpeed: Int = -1 //最小速度
|
||||
var maxSpeed: Int = -1 //最大速度
|
||||
var strategyType: Int //策略类型:城市、热门区域、非上报区域等
|
||||
|
||||
constructor(
|
||||
strategyId: String,
|
||||
reportType: Int,
|
||||
reportTimeInterval: Int,
|
||||
infoTimeout: Int,
|
||||
minSpeed: Int,
|
||||
maxSpeed: Int,
|
||||
strategyType: Int
|
||||
) {
|
||||
this.strategyId = strategyId
|
||||
this.reportType = reportType
|
||||
this.reportTimeInterval = reportTimeInterval
|
||||
this.infoTimeout = infoTimeout
|
||||
this.minSpeed = minSpeed
|
||||
this.maxSpeed = maxSpeed
|
||||
this.strategyType = strategyType
|
||||
}
|
||||
}
|
||||
|
||||
class StrategyRequest {
|
||||
var lon: Double
|
||||
var lat: Double
|
||||
var cityCode: String
|
||||
|
||||
constructor(lon: Double, lat: Double, cityCode: String) {
|
||||
this.lon = lon
|
||||
this.lat = lat
|
||||
this.cityCode = cityCode
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
|
||||
fun CommonConfig.isActiveNonNull():Boolean{
|
||||
return active!=null
|
||||
}
|
||||
|
||||
//fun CommonConfig.isPromotionNonNull():Boolean{
|
||||
// return promotion!=null
|
||||
//}
|
||||
|
||||
class CommonConfig {
|
||||
|
||||
var active:Active //活动配置
|
||||
// var promotion:Promotion //Splash页面图片以及语音推广配置
|
||||
var auth:Auth //授权配置
|
||||
|
||||
constructor(active: Active, auth: Auth) {
|
||||
this.active = active
|
||||
// this.promotion = promotion
|
||||
this.auth = auth
|
||||
}
|
||||
}
|
||||
|
||||
class Active{
|
||||
var imageUrl:String
|
||||
var webUrl:String
|
||||
var status:Int
|
||||
|
||||
constructor(imageUrl: String, webUrl: String, status: Int) {
|
||||
this.imageUrl = imageUrl
|
||||
this.webUrl = webUrl
|
||||
this.status = status
|
||||
}
|
||||
}
|
||||
|
||||
class Promotion{
|
||||
var imageUrl:String
|
||||
var voiceContent:String
|
||||
var status:Int
|
||||
|
||||
constructor(imageUrl: String, voiceContent: String, status: Int) {
|
||||
this.imageUrl = imageUrl
|
||||
this.voiceContent = voiceContent
|
||||
this.status = status
|
||||
}
|
||||
}
|
||||
|
||||
class Auth{
|
||||
var isNeedAuth:Int
|
||||
|
||||
constructor(isNeedAuth: Int) {
|
||||
this.isNeedAuth = isNeedAuth
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
data class InformationBody(
|
||||
val data: String,
|
||||
val addr: String,
|
||||
val areaCode: String,
|
||||
val areaName: String,
|
||||
val cityCode: String,
|
||||
val cityName: String,
|
||||
val generateTime: Long,
|
||||
val lat: Double,
|
||||
val lon: Double,
|
||||
val provinceName: String,
|
||||
val sn: String,
|
||||
val street: String,
|
||||
val type: Int,
|
||||
val uid: Int,
|
||||
val infoType: Int,
|
||||
val infoTimeout:Int,
|
||||
val trafficInfoType:String, // 上报情报类型
|
||||
val isShare: Boolean, // 是否分享给附近车机
|
||||
val direction: Float,
|
||||
val poiType: String //类型分类
|
||||
)
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-11-22
|
||||
*
|
||||
* 一次情报的数据
|
||||
*/
|
||||
class InformationResource {
|
||||
|
||||
var id: Long
|
||||
var isCosResourceReady: Boolean = false
|
||||
var isInformationSelected: Boolean = false
|
||||
|
||||
var sourceType: Int = 0 // 情报载体类型:图片、视频
|
||||
var cosParameter: Map<String, String>? = null // 情报参数
|
||||
var informationType: InformationType? = null //情报类型
|
||||
var isCustomSend: Boolean = false // 自动上传
|
||||
|
||||
var callback: ((customSend: Boolean) -> Unit)? = null
|
||||
|
||||
lateinit var newsType: String // 埋点:情报类型
|
||||
lateinit var operType: String // 埋点:操作类型
|
||||
|
||||
constructor(id: Long) {
|
||||
this.id = id
|
||||
}
|
||||
|
||||
fun isReady() = isCosResourceReady and isInformationSelected
|
||||
|
||||
fun release() {
|
||||
cosParameter = null
|
||||
informationType = null
|
||||
callback = null
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "upload information: sourceType=${sourceType}, informationType={${informationType?.dictLabel}, ${informationType?.dictValue}}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.zhidao.roadcondition.constant.DEF_NEWS_LABEL
|
||||
import com.zhidao.roadcondition.constant.DEF_NEWS_TYPE
|
||||
import com.zhidao.roadcondition.constant.DEF_NEWS_VALUE
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-11-18
|
||||
*
|
||||
* 情报类型
|
||||
*/
|
||||
data class InformationType(var dictLabel: String, var dictValue: String, var remark: String) {
|
||||
companion object {
|
||||
val def = InformationType(DEF_NEWS_LABEL, DEF_NEWS_VALUE, DEF_NEWS_TYPE)
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
when (other) {
|
||||
is InformationType -> return other.dictValue.compareTo(dictValue) == 0
|
||||
}
|
||||
return super.equals(other)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return Gson().toJson(this)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-11-18
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
data class InformationTypeResult(var types: List<InformationType>)
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.amap.api.maps.model.LatLng
|
||||
|
||||
|
||||
fun Informations.toLatLng(): LatLng {
|
||||
return LatLng(lat, lon)
|
||||
}
|
||||
|
||||
class Informations(
|
||||
var type: Int,
|
||||
var lon: Double,
|
||||
var lat: Double,
|
||||
var addr: String?,
|
||||
var generateTime: Long,
|
||||
var cityName: String?,
|
||||
// var items: ArrayList<Items>,
|
||||
var distance: Int,
|
||||
var nickName: String?,
|
||||
var headImgUrl: String?
|
||||
) :
|
||||
Parcelable {
|
||||
|
||||
var position = 0
|
||||
|
||||
constructor(parcel: Parcel) : this(
|
||||
parcel.readInt(),
|
||||
parcel.readDouble(),
|
||||
parcel.readDouble(),
|
||||
parcel.readString(),
|
||||
parcel.readLong(),
|
||||
parcel.readString(),
|
||||
// parcel.readArrayList(Items::class.java.classLoader) as ArrayList<Items>,
|
||||
parcel.readInt(),
|
||||
parcel.readString(),
|
||||
parcel.readString()
|
||||
)
|
||||
|
||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||
parcel.writeInt(type)
|
||||
parcel.writeDouble(lon)
|
||||
parcel.writeDouble(lat)
|
||||
parcel.writeString(addr)
|
||||
parcel.writeLong(generateTime)
|
||||
parcel.writeString(cityName)
|
||||
// parcel.writeList(items)
|
||||
parcel.writeInt(distance)
|
||||
parcel.writeString(nickName)
|
||||
parcel.writeString(headImgUrl)
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
companion object CREATOR : Parcelable.Creator<Informations> {
|
||||
override fun createFromParcel(parcel: Parcel): Informations {
|
||||
return Informations(parcel)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<Informations?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
|
||||
class Items(var url: String?, var thumbnail: String? = null) : Parcelable {
|
||||
constructor(parcel: Parcel) : this(
|
||||
parcel.readString(),
|
||||
parcel.readString()
|
||||
) {
|
||||
}
|
||||
|
||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||
parcel.writeString(url)
|
||||
parcel.writeString(thumbnail)
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
companion object CREATOR : Parcelable.Creator<Items> {
|
||||
override fun createFromParcel(parcel: Parcel): Items {
|
||||
return Items(parcel)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<Items?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.amap.api.services.core.LatLonPoint
|
||||
|
||||
|
||||
fun LocationInfo.toLatLng(): LatLng {
|
||||
return LatLng(latitude,longitude)
|
||||
}
|
||||
|
||||
fun LocationInfo.toLatLngPoint():LatLonPoint{
|
||||
return LatLonPoint(latitude,longitude)
|
||||
}
|
||||
|
||||
class LocationInfo {
|
||||
var provinceName: String = "" //省的名称
|
||||
var cityName: String = "" //城市的名称
|
||||
var cityCode :String = "" //城市编码
|
||||
var areaName :String = "" //区县名称
|
||||
var areaCode :String = "" //区县编码
|
||||
var street :String = "" //街道名称
|
||||
var longitude: Double = 0.0
|
||||
var latitude: Double = 0.0
|
||||
var address: String = ""
|
||||
var time: Long = 0L
|
||||
var direction: Float = 0.0f
|
||||
constructor()
|
||||
|
||||
constructor(longitude: Double, latitude: Double, address: String, time: Long) {
|
||||
this.longitude = longitude
|
||||
this.latitude = latitude
|
||||
this.address = address
|
||||
this.time = time
|
||||
}
|
||||
|
||||
constructor(
|
||||
provinceName: String,
|
||||
cityName: String,
|
||||
cityCode: String,
|
||||
areaName: String,
|
||||
areaCode: String,
|
||||
street: String,
|
||||
longitude: Double,
|
||||
latitude: Double,
|
||||
address: String,
|
||||
time: Long,
|
||||
direction: Float = 0.0f
|
||||
) {
|
||||
this.provinceName = provinceName
|
||||
this.cityName = cityName
|
||||
this.cityCode = cityCode
|
||||
this.areaName = areaName
|
||||
this.areaCode = areaCode
|
||||
this.street = street
|
||||
this.longitude = longitude
|
||||
this.latitude = latitude
|
||||
this.address = address
|
||||
this.time = time
|
||||
this.direction = direction
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
/**
|
||||
* 城市策略实体
|
||||
*/
|
||||
class Results(var cityStrategy: CityStrategy) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
import android.util.Log
|
||||
import com.google.gson.Gson
|
||||
import com.mogo.commons.network.Utils
|
||||
import com.zhidao.roadcondition.base.BaseRepository
|
||||
import com.zhidao.roadcondition.net.HttpClient
|
||||
import com.zhidao.roadcondition.util.LocationUtil
|
||||
|
||||
class StrategyServiceModel : BaseRepository() {
|
||||
|
||||
suspend fun getCityStrategy(): BaseResponse<Results> {
|
||||
return apiCall {
|
||||
var map = hashMapOf<String, String>()
|
||||
map["sn"] = Utils.getSn()
|
||||
val locInfo = LocationUtil.getInstance().getLocationInfo()
|
||||
map["data"] = Gson().toJson(
|
||||
StrategyRequest(
|
||||
locInfo.longitude,
|
||||
locInfo.latitude,
|
||||
locInfo.cityCode
|
||||
)
|
||||
)
|
||||
HttpClient.getInstance().getHttpApi().getCityStrategy(map)
|
||||
}
|
||||
}
|
||||
|
||||
// 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(): BaseResponse<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<Any> {
|
||||
return apiCall {
|
||||
var informationBodyStr = Gson().toJson(informationBody)
|
||||
Log.d("MainServiceController", "uploadInformation informationBody = " + informationBodyStr)
|
||||
HttpClient.getInstance().getHttpApi()
|
||||
.uploadInformation(mapOf("sn" to Utils.getSn(), "data" to informationBodyStr))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
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)
|
||||
annotation class ActiveInfoType
|
||||
|
||||
fun isActiveShow(@ActiveInfoType type: Int): Boolean {
|
||||
return when (type) {
|
||||
INFO_TYPE_GONE -> false
|
||||
INFO_TYPE_SHOW -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
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 //图片
|
||||
const val INFO_TYPE_VIDEO = 1
|
||||
const val INFO_TYPE_VOICE = 2
|
||||
const val INFO_TYPE_WORD = 3
|
||||
|
||||
|
||||
@IntDef(INFO_TYPE_IMG, INFO_TYPE_VIDEO, INFO_TYPE_VOICE, INFO_TYPE_WORD)
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
annotation class InformationsType
|
||||
Reference in New Issue
Block a user