地图模块代码更新3.0.0
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package com.zhidaoauto.map.sdk.inner
|
||||
|
||||
import com.zhidaoauto.map.sdk.inner.common.MapHelper
|
||||
|
||||
object CompileConfig {
|
||||
var DEBUG = MapHelper.debug
|
||||
|
||||
fun setDebug(debug: Boolean){
|
||||
DEBUG = debug
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.zhidaoauto.map.sdk.inner.abs
|
||||
|
||||
interface CancelableCallback {
|
||||
fun onFinish()
|
||||
fun onCancel()
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.zhidaoauto.map.sdk.inner.abs
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.view.MotionEvent
|
||||
import com.autonavi.nge.map.OnMapScreenShotListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.MapStatusListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnCameraChangeListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapChangeListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapClickListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapLoadedListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapStyleListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapTouchListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapViewVisualAngleChangeListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnRenderListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnRoadInfoListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnRoamStatusListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnScrollListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.log.ILog
|
||||
import com.zhidaoauto.map.sdk.open.camera.CameraPosition
|
||||
import com.zhidaoauto.map.sdk.open.location.MogoLocation
|
||||
import com.zhidaoauto.map.sdk.open.marker.Marker
|
||||
import com.zhidaoauto.map.sdk.open.marker.OnMarkClickListener
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint
|
||||
import com.zhidaoauto.map.sdk.open.road.RoadCross
|
||||
import com.zhidaoauto.map.sdk.open.road.StopLine
|
||||
|
||||
interface IEventController {
|
||||
|
||||
fun exit()
|
||||
fun addHdDataDownListener(id: Int, onHdDataDownByCityListener: OnHdDataDownByCityListener)
|
||||
fun removeHdDataDownListener(id: Int)
|
||||
fun dispatchHdDataDownListener(id: Int, progress: Double)
|
||||
fun dispatchHdDataDownStateListener(id: Int, state: Int)
|
||||
fun addCameraChangeListener(cameraChangeListener: OnCameraChangeListener)
|
||||
fun removeCameraChangeListener(cameraChangeListener: OnCameraChangeListener)
|
||||
fun dispatchCameraChangeListener(type: Int, value: Int)
|
||||
fun dispatchCameraChangeFinishListener(position: CameraPosition?)
|
||||
fun addMapTouchListener(mapTouchListener: OnMapTouchListener)
|
||||
fun removeMapTouchListener(mapTouchListener: OnMapTouchListener)
|
||||
fun dispatchMapTouchListener(event: MotionEvent?): Boolean
|
||||
fun isMapTouchListenerListEmpty(): Boolean
|
||||
fun addMapClickListener(mapClickListener: OnMapClickListener)
|
||||
fun removeMapClickListener(mapClickListener: OnMapClickListener)
|
||||
fun dispatchMapClickListener(lonLatPoint: LonLatPoint)
|
||||
fun addMapLoadedListener(mapLoadedListener: OnMapLoadedListener)
|
||||
fun removeMapLoadedListener(mapLoadedListener: OnMapLoadedListener)
|
||||
fun dispatchMapLoadedInitListener()
|
||||
fun dispatchMapLoadedListener()
|
||||
fun dispatchRoadLoadedListener(roadInfo: String?)
|
||||
fun addMapViewVisualAngleChangeListener(mapViewVisualAngleChangeListener: OnMapViewVisualAngleChangeListener)
|
||||
fun removeMapViewVisualAngleChangeListener(mapViewVisualAngleChangeListener: OnMapViewVisualAngleChangeListener)
|
||||
fun dispatchMapViewVisualAngleChangeListener(type: Int)
|
||||
fun addScrollListener(scrollListener: OnScrollListener)
|
||||
fun removeScrollListener(scrollListener: OnScrollListener)
|
||||
fun dispatchScrollListener(x: Double, y: Double)
|
||||
fun addMapStyleListener(mapStyleListener: OnMapStyleListener)
|
||||
fun removeMapStyleListener(mapStyleListener: OnMapStyleListener)
|
||||
fun dispatchMapStyleListener(type: Int)
|
||||
fun addScreenShotListener(screenShotListener: OnMapScreenShotListener)
|
||||
fun removeScreenShotListener(screenShotListener: OnMapScreenShotListener)
|
||||
fun dispatchScreenShotListener(bitmap: Bitmap?)
|
||||
fun addMapChangeListener(mapChangeListener: OnMapChangeListener)
|
||||
fun removeMapChangeListener(mapChangeListener: OnMapChangeListener)
|
||||
fun dispatchMapChangeListener(mogoLocation: MogoLocation)
|
||||
fun addMarkClickListener(markClickListener: OnMarkClickListener)
|
||||
fun removeMarkClickListener(markClickListener: OnMarkClickListener)
|
||||
fun dispatchMarkClickListener(marker: Marker)
|
||||
fun isMarkClickListenerListEmpty():Boolean
|
||||
fun addMapStatusListener(mapStatusListener: MapStatusListener, type: Int)
|
||||
fun removeMapStatusListener(mapStatusListener: MapStatusListener, type: Int)
|
||||
fun dispatchMapStatusListener(type:Int, value: Int)
|
||||
fun addRenderListener(renderListener : OnRenderListener)
|
||||
fun removeRenderListener(renderListener : OnRenderListener)
|
||||
fun dispatchRenderListener(duration:Int)
|
||||
fun addRoadInfoListener(roadInfoListener: OnRoadInfoListener)
|
||||
fun removeRoadInfoListener(roadInfoListener : OnRoadInfoListener)
|
||||
fun dispatchStopLineInfo(stopLine: StopLine?)
|
||||
fun dispatchRoadIdInfo(roadId: String?, laneId: String?)
|
||||
fun dispatchRoadCrossInfo(roadCross: RoadCross?)
|
||||
fun addLogListener(listener: ILog)
|
||||
fun removeLogListener(listener : ILog)
|
||||
fun dispatchLog(path: String)
|
||||
|
||||
fun addRoamStatusListener(onRoamStatusListener: OnRoamStatusListener)
|
||||
|
||||
fun removeRoamStatusListener(onRoamStatusListener: OnRoamStatusListener)
|
||||
|
||||
fun dispatchRoamStatusListener(status: Int, msg: String)
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.zhidaoauto.map.sdk.inner.abs
|
||||
|
||||
import com.zhidaoauto.map.sdk.open.location.MyLocationStyle
|
||||
|
||||
interface ILocationView {
|
||||
|
||||
|
||||
fun setMyLocationEnabled(myLocationEnabled: Boolean)
|
||||
fun getMyLocationEnabled(): Boolean
|
||||
fun setMyLocationStyle(myLocationStyle: MyLocationStyle)
|
||||
fun getMyLocationStyle(): MyLocationStyle?
|
||||
fun switch(style: Int)
|
||||
fun exit()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.zhidaoauto.map.sdk.inner.abs
|
||||
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint
|
||||
|
||||
interface ILockLocation {
|
||||
fun setLockCar(lock: Boolean)
|
||||
fun getLockCar(): Boolean
|
||||
fun getCurrentLonLatPoint(): LonLatPoint
|
||||
fun getLastUpdateTime(): Long
|
||||
fun getAgainLastUpdateTime(): Long
|
||||
fun switchStyle(style : Int)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.zhidaoauto.map.sdk.inner.abs
|
||||
|
||||
import com.autonavi.nge.map.LonLat
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint
|
||||
|
||||
interface ILonLatProxy {
|
||||
open fun switchLonLat(lonLat: LonLat):LonLatPoint
|
||||
open fun switchLonLat(lonLatPoint: LonLatPoint):LonLat
|
||||
}
|
||||
@@ -0,0 +1,466 @@
|
||||
package com.zhidaoauto.map.sdk.inner.abs
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.view.View
|
||||
import com.autonavi.nge.map.LonLat
|
||||
import com.autonavi.nge.map.OnMapScreenShotListener
|
||||
import com.autonavi.nge.map.Pixels
|
||||
import com.zhidaoauto.map.sdk.inner.element.MapCoordinate
|
||||
import com.zhidaoauto.map.sdk.inner.use.Clerk
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.view.IMapStyleParams
|
||||
import com.zhidaoauto.map.sdk.open.circle.CircleController
|
||||
import com.zhidaoauto.map.sdk.open.circle.CircleOptions
|
||||
import com.zhidaoauto.map.sdk.open.deadzone.DeadZone
|
||||
import com.zhidaoauto.map.sdk.open.deadzone.DeadZoneOptions
|
||||
import com.zhidaoauto.map.sdk.open.poyline.Polyline
|
||||
import com.zhidaoauto.map.sdk.open.poyline.PolylineOptions
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint
|
||||
import com.zhidaoauto.map.sdk.open.weather.WeatherResult
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
interface IMapController {
|
||||
|
||||
//init相关
|
||||
fun getContext():Context?
|
||||
fun setMarkerCall(markerCall:IMarkerCall)
|
||||
fun setLocalView(localView: ILocationView?)
|
||||
fun getMarkerCall():IMarkerCall?
|
||||
fun getMapStyleParams(): IMapStyleParams
|
||||
fun getClerk():Clerk?
|
||||
|
||||
fun setMarkerController(markerController:IMarkerController?)
|
||||
fun getMarkerController():IMarkerController?
|
||||
|
||||
//The controller of event
|
||||
fun getEventController():IEventController?
|
||||
|
||||
fun isSurfaceCreated():Boolean
|
||||
|
||||
//search相关
|
||||
fun clearSearchResult()
|
||||
|
||||
// MapView相关
|
||||
fun lookUpDown()
|
||||
fun setDAngle(r: Float)
|
||||
fun getCarPosition(pos: MapCoordinate?): Int
|
||||
fun rotate(rotateAngle: Float)
|
||||
fun updateCar(lon: Long, lat: Long, z: Int, r: Int, carResId: Int)
|
||||
fun updateCar(lon: Long, lat: Long, z: Int, r: Int, bitmap: Bitmap)
|
||||
fun updateCar(lon: Long, lat: Long, z: Short, angle: Short)
|
||||
fun getFollowCarMode(): Boolean
|
||||
fun setCenter(lon: Double, lat: Double)
|
||||
fun animateTo(lon: Double, lat: Double, alt: Float, rotateAngle: Float, mDuration: Int)
|
||||
fun dispatchFocusChanged()
|
||||
fun dispatchZoomChanged()
|
||||
fun dispatchRotationAngleChanged(rotateAngle: Float)
|
||||
fun dispatchDAngleChanged()
|
||||
fun getMapScreenShot(var1: OnMapScreenShotListener)
|
||||
|
||||
//NaviController相关
|
||||
fun isMapNorth(): Boolean
|
||||
|
||||
fun setMapViewRotation(rotation: Float)
|
||||
fun setMapStyle(stylemode: Int)
|
||||
fun getMapStyle(): Int
|
||||
fun setFollowCarMode(followCarMode: Boolean)
|
||||
fun setMapNorth(mapNorth: Boolean)
|
||||
fun clearRoute()
|
||||
fun setNaviModeZoom()
|
||||
fun setMapViewPerspective(mapPerspective: Int)
|
||||
fun setShowAllRouteLine(isShowAllRouteLine: Boolean)
|
||||
|
||||
// RouteBookAdapter
|
||||
fun drawNavArrow()
|
||||
|
||||
// POISearchThread
|
||||
fun getCenter(): MapCoordinate?
|
||||
|
||||
|
||||
fun getDAngle(): Float
|
||||
|
||||
fun getMapViewRotation(): Float
|
||||
|
||||
fun getMapViewPerspective(): Float
|
||||
|
||||
fun zoomIn()
|
||||
|
||||
fun zoomOut()
|
||||
|
||||
fun setZoom(zoom: Int)
|
||||
|
||||
fun getZoom(): Int
|
||||
|
||||
fun getRulerInfo(): Float
|
||||
|
||||
|
||||
fun removePel(names: String)
|
||||
fun drawLine(polylineOptions: PolylineOptions): Polyline?
|
||||
fun drawThickLine(polylineOptions: PolylineOptions): Polyline?
|
||||
fun drawDeadZone(deadZoneOptions: DeadZoneOptions): DeadZone?
|
||||
fun drawCircle(circleOptions: CircleOptions?): CircleController
|
||||
fun drawEllipse(polylineOptions: PolylineOptions): Polyline?
|
||||
fun drawRect(polylineOptions: PolylineOptions): Polyline?
|
||||
fun drawPolygon(polylineOptions: PolylineOptions): Polyline?
|
||||
fun clearPel(): Boolean
|
||||
|
||||
//设置同步
|
||||
fun setRenderFrequency(enableSync: Boolean, renderTimePer: Int)
|
||||
fun setMapViewVisualAngle(type: Int)
|
||||
fun resetChangeAngleTime()
|
||||
fun setNearViewAnglePosition(lonLat: LonLat)
|
||||
fun setRoamStyle(isUseTrace: Int, dis: Float, speed: Float)
|
||||
fun setRoamTrajectory(travel: String)
|
||||
fun getIsRoam(): Boolean
|
||||
|
||||
fun testMapViewAngle(type: Int)
|
||||
|
||||
fun interpolation(eyeHeight: Float, angle: Float, zoomVal: Float, mode: Int, duration: Int)
|
||||
fun setStartFrame(zoomVal: Float, lookAngle: Float, eyeHeight: Float)
|
||||
|
||||
fun setScreenToOriginDis(screenToOriginDis: Float)
|
||||
fun setEyeToOriginDis(eyeToOriginDis: Float)
|
||||
fun getCenter(point: DoubleArray)
|
||||
fun setOffset(lon: Int, lat: Int)
|
||||
fun setRotateAngle(angle: Float)
|
||||
fun set3DBuildingVisible(isVisibel: Boolean)
|
||||
fun getResulation(): Float
|
||||
fun getSuitableZoom(minLon: Double, minLat: Double, maxLon: Double, maxLat: Double): Int
|
||||
fun drawTraffic(trafficJson: String)
|
||||
fun addImage(imageKey: String, imageData: ByteArray, width: Int, height: Int): Int
|
||||
fun clearAllTmcLines()
|
||||
fun isTrafficOn(): Boolean
|
||||
fun setTraffic(stat: Int)
|
||||
fun setZoomValue(zoomValue: Float)
|
||||
fun getEyeHeight(): Float
|
||||
fun setEyeHeight(eyeHeight: Float)
|
||||
fun setVerticalViewFieldAngle(angle: Float)
|
||||
fun getVerticalViewFieldAngle(): Float
|
||||
fun getRotateAngle(): Float
|
||||
fun updatePointCloudData(
|
||||
dataStr: String,
|
||||
isTrasformer: Boolean,
|
||||
isResidual: Boolean,
|
||||
isReset: Boolean
|
||||
): Boolean
|
||||
|
||||
fun updatePointCloudDataByPb(
|
||||
dataArray: ByteArray,
|
||||
isTrasformer: Boolean,
|
||||
isResidual: Boolean,
|
||||
isReset: Boolean
|
||||
): Boolean
|
||||
|
||||
fun setIsDrawPointCloud(isDrawPointCloud: Boolean)
|
||||
fun setPointCloudDisplayFllowAnim(isDisplayFllowAnim: Boolean, totalAnimTime: Int)
|
||||
fun setPointCloudSize(pointCloudSize: Float)
|
||||
fun setPointCloudColor(color: String)
|
||||
fun shakeSceneManual()
|
||||
fun shakeMapManual()
|
||||
fun setRouteProp(prop: Int, lon: Int, lat: Int)
|
||||
fun drawRoute()
|
||||
fun removeImage(imageKey: String)
|
||||
fun lonlatToPixels(lon: Double, lat: Double): Pixels?
|
||||
fun pixelsToLonlat(x: Float, y: Float): LonLat?
|
||||
fun setTmcData(tmcData: ByteArray?)
|
||||
fun draw3DPolygon(
|
||||
id: String,
|
||||
lonlatArr: DoubleArray,
|
||||
height: Float,
|
||||
width: Float,
|
||||
count: Int,
|
||||
color: FloatArray
|
||||
)
|
||||
|
||||
fun setGeodesic(id: String, bGeodesic: Boolean)
|
||||
fun setDottedLineType(id: String, type: Int)
|
||||
fun setVisiable(id: String, bVisiable: Boolean)
|
||||
fun setWidth(id: String, width: Float)
|
||||
fun setTransparency(id: String, transparency: Float)
|
||||
fun setColor(id: String, color: Int)
|
||||
fun setZIndex(id: String, zIndex: Float)
|
||||
fun useGradient(id: String, bUseGradient: Boolean)
|
||||
fun setOption(id: String, strJsonOption: String)
|
||||
fun clearAllPrimitives(): Boolean
|
||||
fun drawDeadZone(strJsonOption: String)
|
||||
fun setDeadZoneVisible(b: Boolean)
|
||||
fun cacheHDDataByCity(id: Int, listener: OnHdDataDownByCityListener)
|
||||
fun cacheHDDataByCityLonLat(lon: Double, lat: Double, listener: OnHdDataDownByCityListener)
|
||||
fun cancelCacheHDData()
|
||||
|
||||
/**
|
||||
* 锚点 更新锚点属性
|
||||
*/
|
||||
fun updateAnchorByJson(
|
||||
anchorId: String,
|
||||
json: String,
|
||||
infobitmap: ByteArray?,
|
||||
infoWidth: Int,
|
||||
infoHeight: Int
|
||||
): Boolean
|
||||
|
||||
/**
|
||||
* 锚点 设置层级
|
||||
*/
|
||||
fun setSomeAnchorZIndex(anchorId: String, zIndex: Int)
|
||||
|
||||
fun drawAnchor(nameId: String, lon: Double, lat: Double, imagePath: String)
|
||||
|
||||
/**
|
||||
* 清除指定marker
|
||||
*
|
||||
*/
|
||||
fun removeAnchor(anchorId: String)
|
||||
|
||||
|
||||
fun getRecycleId():String
|
||||
/**
|
||||
* 点击事件
|
||||
*
|
||||
* @param x x坐标
|
||||
* @param y y坐标
|
||||
* @return 底层返回的信息
|
||||
*/
|
||||
fun findAnchorAtScreen(x: Int, y: Int): String
|
||||
|
||||
/**
|
||||
* 锚点开始动画
|
||||
*/
|
||||
fun startAnimation(anchorId: String)
|
||||
|
||||
/**
|
||||
* 锚点结束动画
|
||||
*/
|
||||
fun endAnimation(anchorId: String)
|
||||
|
||||
//动态平移
|
||||
fun addDynamicAnchorPostion(
|
||||
anchorId: String,
|
||||
points: DoubleArray,
|
||||
angle: Float,
|
||||
current: Long,
|
||||
duration: Int
|
||||
)
|
||||
|
||||
//平移
|
||||
fun addTranslateAnimationToAnchor(anchorId: String, points: DoubleArray, duration: Int)
|
||||
|
||||
//缩放
|
||||
fun addScaleAnimationToAnchor(anchorId: String, min: Float, max: Float, duration: Int)
|
||||
|
||||
fun addFlashAnimationToAnchor(anchorId: String, imageJson: String, duration: Int)
|
||||
|
||||
//旋转
|
||||
fun addRotateAnimationToAnchor(
|
||||
anchorId: String,
|
||||
startAngle: Float,
|
||||
endAngle: Float,
|
||||
duration: Int
|
||||
)
|
||||
|
||||
//锚点 设置是否可点击
|
||||
fun setSomeAnchorCanClickable(anchorId: String, canClickable: Boolean)
|
||||
|
||||
/**
|
||||
* 锚点 设置锚点不置顶
|
||||
*/
|
||||
fun setSomeAnchorUnTop(anchorId: String)
|
||||
|
||||
/**
|
||||
* 锚点 设置锚点置顶
|
||||
*/
|
||||
fun setSomeAnchorTop(anchorId: String)
|
||||
|
||||
/**
|
||||
* 锚点 infowindow的偏移量
|
||||
*/
|
||||
fun setSomeAnchorInfowindowOffset(anchorId: String, disx: Int, disy: Int)
|
||||
|
||||
// 设置是否是平贴
|
||||
fun setSomeAnchorFlat(anchorId: String, isFlat: Boolean)
|
||||
|
||||
// 设置拖拽
|
||||
fun setSomeAnchorDrawModel(anchorId: String, dragModel: Boolean)
|
||||
|
||||
// 设置拖拽位置
|
||||
fun setSomeDrawModelPointScreenPosition(screenx: Int, screeny: Int): Boolean
|
||||
|
||||
fun addManyAnchors(json: String, count: Int)
|
||||
|
||||
// 添加海量点
|
||||
fun addManyAnchorByJson(json: String, count: Int)
|
||||
|
||||
// 删除海量点
|
||||
fun removeClusterByClusterid(clusterId: String)
|
||||
|
||||
fun removeManyAnchor(allAnchorJson: String, count: Int)
|
||||
|
||||
fun clearAllCluster()
|
||||
|
||||
/**
|
||||
* 锚点 创建自车锚点
|
||||
*/
|
||||
fun createConstAnchor(
|
||||
attribute: String,
|
||||
infoBitmap: ByteArray?,
|
||||
infoWidth: Int,
|
||||
infoHeight: Int
|
||||
): Boolean
|
||||
|
||||
fun addAnchorAsync(json: String)
|
||||
|
||||
fun executeAnchorAdd()
|
||||
|
||||
//锚点更新位置标记
|
||||
fun setConstAnchorPositionFlag(isUpdate: Boolean)
|
||||
|
||||
fun addAnchor(json: String, infoBitmap: ByteArray?, infoWidth: Int, infoHeight: Int): Boolean
|
||||
|
||||
/**
|
||||
* 返回anchor的对象属性值
|
||||
*
|
||||
* @param id anchor的id
|
||||
* @param propertyName 属性名字
|
||||
* @return 属性值
|
||||
*/
|
||||
fun getAnchorProperty(id: String, propertyName: String): String
|
||||
|
||||
/**
|
||||
* 更新anchor的属性
|
||||
*
|
||||
* @param id anchor的id
|
||||
* @param propertyName 要更新的anchor的属性名
|
||||
* @param propertyValue 要更新的属性值
|
||||
* @return
|
||||
*/
|
||||
fun updateAnchorProperty(id: String, propertyName: String, propertyValue: String): Boolean
|
||||
|
||||
/**
|
||||
* 更新infowindow内容
|
||||
*
|
||||
* @param id infowindow的id
|
||||
* @param imageData 更新的图片byte数组数据
|
||||
* @param width 图片宽度
|
||||
* @param height 图片高度
|
||||
* @return true 更新成功 false 更新失败
|
||||
*/
|
||||
fun updateInfoWindowWithBitMap(
|
||||
id: String,
|
||||
imageData: ByteArray,
|
||||
width: Int,
|
||||
height: Int
|
||||
): Boolean
|
||||
|
||||
/**
|
||||
* 更新anchor
|
||||
*
|
||||
* @param id anchor的id
|
||||
* @return true 更新成功 false 更新失败
|
||||
*/
|
||||
fun updateAnchorWithBitmap(id: String, imageKey: String): Boolean
|
||||
|
||||
/**
|
||||
* 清除所有anchor
|
||||
*
|
||||
* @return true 删除成功 false 删除失败
|
||||
*/
|
||||
fun clearAllAnchors(): Boolean
|
||||
|
||||
/**
|
||||
* 显示infowindow
|
||||
*
|
||||
* @param id Anchor的id
|
||||
*/
|
||||
fun showInfoWindow(id: String)
|
||||
|
||||
/**
|
||||
* 隐藏infoWindow
|
||||
*
|
||||
* @param id Anchor的id
|
||||
*/
|
||||
fun hideInfoWindow(id: String)
|
||||
|
||||
//设置锚点缩放比例
|
||||
fun setAnchorRate(rate: Float)
|
||||
|
||||
//For Test 四个顶点设置锚点变形 左宽 右宽 上高 下高
|
||||
fun setAnchorScale(wideLeft: Float, wideRight: Float, highUp: Float, hightDown: Float)
|
||||
|
||||
//nMode 1:按Tile存储 2:按文件存储 nRecordCnt 单个文件存储的记录个数
|
||||
fun setNameMode(mode: Int, recordCnt: Int)
|
||||
|
||||
/**
|
||||
* 设置地图中心点的旋转方式
|
||||
* 3 正北向上 4 车头向上
|
||||
*
|
||||
* @param mode
|
||||
*/
|
||||
fun setSelfLocaionControl(mode: Int)
|
||||
|
||||
/**
|
||||
* 设置是否锁车
|
||||
*/
|
||||
fun setLockSelfCar(enable: Boolean)
|
||||
|
||||
//锚点是否在动态移动中
|
||||
fun isAnchorDynamicMoving(anchorID: String): Boolean
|
||||
|
||||
//批量更新
|
||||
fun updateBatchAnchorPositon(dataStr: String): Boolean
|
||||
|
||||
fun setAnchorFlash(id: String, colorType: Int, color: String, time: Float, angle: Float)
|
||||
|
||||
fun setAnchorGradientColor(
|
||||
startColor: String,
|
||||
endColor: String,
|
||||
startDistance: Float,
|
||||
endDistance: Float
|
||||
)
|
||||
|
||||
fun setTailLightsType(type: Int, time: Int)
|
||||
fun exit()
|
||||
fun isCollision(data: String): String
|
||||
fun switchData(x: Double, y: Double, isWgs84: Boolean): DoubleArray?
|
||||
|
||||
|
||||
//mapView中迁移出来的部分方法
|
||||
fun setTouchPoiEnable(enable: Boolean)
|
||||
fun getTouchPoiEnable(): Boolean
|
||||
fun isTouching(): Boolean
|
||||
fun setCanZoom(boolean: Boolean)
|
||||
fun isCanZoom(): Boolean
|
||||
fun setOnTouchListener(listener: View.OnTouchListener)
|
||||
fun setScroll(boolean: Boolean)
|
||||
fun setFling(boolean: Boolean)
|
||||
fun setRotate(boolean: Boolean)
|
||||
fun isScroll(): Boolean
|
||||
fun isFling(): Boolean
|
||||
fun isRotate(): Boolean
|
||||
fun toScreen()
|
||||
fun tilt(tilt: Float)
|
||||
fun getTilt(): Float
|
||||
fun renderP()
|
||||
//设置刷新帧率
|
||||
fun setRenderFps(fps: Int)
|
||||
//设置刷新帧率
|
||||
fun getRenderFps(): Int
|
||||
fun setVrMode(isVr: Boolean)
|
||||
fun setWaitTime(time: Long)
|
||||
fun setIsAutoLockCar(isLockCar: Boolean)
|
||||
|
||||
//协程
|
||||
fun getScope(): CoroutineScope?
|
||||
//耗时协程
|
||||
fun getDemaningScope():CoroutineScope?
|
||||
|
||||
fun setWeatherType(type: String)
|
||||
fun getWeatherInfo(lon: Double, lat: Double, call: WeatherResult)
|
||||
fun setSkyBoxMode()
|
||||
|
||||
fun getLastKnownMogoLocation(): LonLatPoint
|
||||
|
||||
fun setFogMode(isEnable: Boolean)
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.zhidaoauto.map.sdk.inner.abs
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import com.autonavi.nge.map.MapEngine
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
interface IMapView {
|
||||
|
||||
//init
|
||||
fun getmContext(): Context?
|
||||
fun getMapEngine(): MapEngine
|
||||
fun setMarkerCall(markerCall: IMarkerCall)
|
||||
//The controller of event
|
||||
fun setEventController(eventController: IEventController?)
|
||||
|
||||
|
||||
fun isSurfaceCreated(): Boolean
|
||||
fun isLoaded(): Boolean
|
||||
fun isTouching(): Boolean
|
||||
fun getWidth(): Int
|
||||
fun getHeight(): Int
|
||||
|
||||
fun getTilt(): Float
|
||||
|
||||
fun loadP(dir: String): Boolean
|
||||
|
||||
fun unloadP()
|
||||
|
||||
fun resizeP(w: Int, h: Int)
|
||||
|
||||
fun renderP()
|
||||
|
||||
// fun renderLocationP(lon: Float, lat: Float, providerType: Int): Int
|
||||
|
||||
fun scrollByP(dx: Float, dy: Float)
|
||||
|
||||
fun addAntCoorP(sessionId: Int, lon: Int, lat: Int, time: Int)
|
||||
|
||||
fun rotateByP(r: Float)
|
||||
|
||||
fun setCanZoom(boolean: Boolean)
|
||||
fun setScroll(boolean: Boolean)
|
||||
fun setFling(boolean: Boolean)
|
||||
fun setRotate(boolean: Boolean)
|
||||
fun isCanZoom(): Boolean
|
||||
fun isScroll(): Boolean
|
||||
fun isFling(): Boolean
|
||||
fun isRotate(): Boolean
|
||||
fun setOnTouchListener(listener: View.OnTouchListener)
|
||||
fun setDoubles(doubleArray: DoubleArray)
|
||||
fun destory()
|
||||
|
||||
//设置刷新帧率
|
||||
fun setRenderFps(fps: Int)
|
||||
|
||||
//设置刷新帧率
|
||||
fun getRenderFps(): Int
|
||||
|
||||
fun setTouchPoiEnable(enable: Boolean)
|
||||
fun getTouchPoiEnable(): Boolean
|
||||
|
||||
//自定义样式路径
|
||||
fun setCustomStyleDir(path: String)
|
||||
|
||||
//设置同频渲染相关参数
|
||||
fun setSyncRenderFrequency(enable: Boolean, renderTimePer: Int)
|
||||
|
||||
fun toScreen()
|
||||
|
||||
fun setVrMode(isVr: Boolean)
|
||||
|
||||
fun tilt(tilt: Float)
|
||||
|
||||
fun removeTouch()
|
||||
|
||||
fun setWaitTime(time: Long)
|
||||
|
||||
fun setIsAutoLockCar(isLockCar: Boolean)
|
||||
|
||||
//协程
|
||||
fun getScope(): CoroutineScope?
|
||||
//耗时协程
|
||||
fun getDemaningScope():CoroutineScope?
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// fun setIsFarViewAngel(isFar: Boolean)
|
||||
//
|
||||
// fun setUpdateCount(updateCount: Int)
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.zhidaoauto.map.sdk.inner.abs
|
||||
|
||||
import android.graphics.Rect
|
||||
import com.zhidaoauto.map.sdk.inner.marker.IInfoViewClick
|
||||
import com.zhidaoauto.map.sdk.open.abs.marker.OnMarkerDragListener
|
||||
import com.zhidaoauto.map.sdk.open.marker.OnAnimationListener
|
||||
import com.zhidaoauto.map.sdk.open.marker.OnInfoWindowClickListener
|
||||
import com.zhidaoauto.map.sdk.open.marker.OnMarkClickListener
|
||||
|
||||
interface IMarkerCall {
|
||||
|
||||
fun exit()
|
||||
/**
|
||||
* 更新marker资源
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
fun updateMarkerResource(dataStr:String?)
|
||||
|
||||
fun getMarkDragListener(markerID: String): OnMarkerDragListener?
|
||||
|
||||
fun getAnimationListener(markerID: String): OnAnimationListener?
|
||||
|
||||
fun addAnimationListener(markerID: String, onAnimationListener: OnAnimationListener?)
|
||||
|
||||
fun getMarkClickListener(markerID: String): OnMarkClickListener?
|
||||
|
||||
fun getInfoWindowClickListener(markerID: String): OnInfoWindowClickListener?
|
||||
|
||||
fun addInfoWindowClickListener(markerID: String, onInfoWindowClickListener: OnInfoWindowClickListener?)
|
||||
|
||||
fun addMarkDragListener(markerID: String, onMarkerDragListener: OnMarkerDragListener?)
|
||||
|
||||
fun addMarkClickListener(markerID: String, onMarkClickListener: OnMarkClickListener?)
|
||||
|
||||
fun containMarkerIcon(icon:String?):Boolean
|
||||
|
||||
fun removeMarkerIcon(icon:String?):Boolean
|
||||
|
||||
fun addMarkerIcon(icon:String):Boolean
|
||||
|
||||
fun containMarkerIconCache(id:Int):Boolean
|
||||
|
||||
fun removeMarkerIconCache(id:Int)
|
||||
|
||||
fun addMarkerIconCache(id:Int,icon:String)
|
||||
|
||||
fun getMarkerIconCache(id:Int):String?
|
||||
|
||||
fun addInfoViewClick(markerId: String, rect: Rect, iInfoViewClick: IInfoViewClick)
|
||||
|
||||
fun getInfoViewClick(markerId: String): HashMap<Rect, IInfoViewClick>?
|
||||
|
||||
fun removeInfoViewClick(markerId: String)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.zhidaoauto.map.sdk.inner.abs
|
||||
|
||||
import com.zhidaoauto.map.sdk.open.abs.marker.InfoWindowAdapter
|
||||
import com.zhidaoauto.map.sdk.open.marker.BatchMarkerOptions
|
||||
import com.zhidaoauto.map.sdk.open.marker.CarInfo
|
||||
import com.zhidaoauto.map.sdk.open.marker.Marker
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions
|
||||
import com.zhidaoauto.map.sdk.open.marker.MultiPointController
|
||||
import com.zhidaoauto.map.sdk.open.marker.MultiPointOverlayOptions
|
||||
|
||||
interface IMarkerController {
|
||||
|
||||
//设置infowindow适配器
|
||||
fun setInfoWindow(infoWindowAdapter: InfoWindowAdapter)
|
||||
//获取infowindow适配器
|
||||
fun getInfoWindow(): InfoWindowAdapter?
|
||||
//添加锚点
|
||||
fun addMarker(markerOptions: MarkerOptions): Marker?
|
||||
//添加自车锚点
|
||||
fun addSelfCar(markerOptions: MarkerOptions): Marker?
|
||||
//添加多个锚点
|
||||
fun addMarkers(multiPointOverlayOptions: MultiPointOverlayOptions): MultiPointController
|
||||
//回收
|
||||
fun destory()
|
||||
//删除锚点
|
||||
fun removeMarker(id:String)
|
||||
/**
|
||||
* 批量更新他车
|
||||
*/
|
||||
fun updateBatchMarkerPositon(batchMarkerOptions: BatchMarkerOptions)
|
||||
//根据车辆类型预添加车辆模型
|
||||
fun addPreVehicleModel(type:Int,modelRes:Int):String?
|
||||
//添加普通模型
|
||||
fun addPreModel(modelRes:Int):String?
|
||||
/**
|
||||
* 更新车辆的大小
|
||||
* @param type 车辆类型
|
||||
* @param width 车辆宽度
|
||||
* @param length 车辆长度
|
||||
*/
|
||||
fun updateCarSize(type:Int,width:Double,length:Double)
|
||||
/**
|
||||
* 检查车辆是否叠加
|
||||
* @param list 他车数据列表
|
||||
* @return 返回车辆叠加数据
|
||||
*/
|
||||
fun checkCollision(list:ArrayList<CarInfo>):Map<Long,ArrayList<CarInfo>>
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.zhidaoauto.map.sdk.inner.abs
|
||||
|
||||
import com.zhidaoauto.map.sdk.open.nav.NavPoi
|
||||
import com.zhidaoauto.map.sdk.open.nav.abs.NaviListener
|
||||
import com.zhidaoauto.map.sdk.open.nav.model.NaviPath
|
||||
import com.zhidaoauto.map.sdk.open.nav.model.NaviSetting
|
||||
|
||||
interface INaviController {
|
||||
|
||||
//设置导航策略
|
||||
fun setNaviStrategy(strategy: Int)
|
||||
|
||||
//设置导航语音是否播报
|
||||
fun setSpeakStatus(status:Boolean)
|
||||
//播报输入文案
|
||||
fun playTTS(tts: String, forcePlay: Boolean): Boolean
|
||||
//获取导航类型
|
||||
fun getNaviType(): Int
|
||||
//导航状态
|
||||
fun getNaviStat(): Boolean
|
||||
//重置状态
|
||||
fun reset()
|
||||
//设置出发地点
|
||||
fun setStart(start: NavPoi)
|
||||
// 设置终点
|
||||
fun setDest(dest: NavPoi)
|
||||
//显示详情信息 -- 只设置了终点情况下
|
||||
fun startNaviDetail()
|
||||
// 开始导航(是否模拟)
|
||||
fun startNavi(isSimulator: Boolean):Boolean
|
||||
//停止导航
|
||||
fun stopNavi()
|
||||
//刷新位置
|
||||
fun updatePosition(
|
||||
lon: Double,
|
||||
lat: Double,
|
||||
provider: String?,
|
||||
speed: Float,
|
||||
heading: Float
|
||||
)
|
||||
// 重置导航
|
||||
fun reSetRoute():Boolean
|
||||
//添加沿途点
|
||||
fun addWayPoint(
|
||||
poi: NavPoi,
|
||||
heading: Int,
|
||||
sessionid: Int
|
||||
)
|
||||
|
||||
//添加沿途点
|
||||
fun addWayPoints(
|
||||
wayPoints: ArrayList<NavPoi>
|
||||
)
|
||||
//清除沿途点
|
||||
fun clearWayPoints(sessionid: Int)
|
||||
//重置路线
|
||||
fun resetRouteSetPanel()
|
||||
//是否模拟导航
|
||||
fun setSimNavi(simNavi: Boolean)
|
||||
//是否模拟导航
|
||||
fun isSimNavi(): Boolean
|
||||
//获取起点
|
||||
fun getStartPoi(): NavPoi?
|
||||
//获取终点
|
||||
fun getEndPoi(): NavPoi?
|
||||
//获取沿途点
|
||||
fun getWayPoi(): NavPoi?
|
||||
//设置模拟导航速度
|
||||
fun setSimNaviSpeed(speed: Int)
|
||||
//是否暂停模拟导航
|
||||
fun isSimNaviPaused(): Boolean
|
||||
//设置暂停模拟导航
|
||||
fun setSimNaviPaused(isPaused: Boolean)
|
||||
//是否已设置起点
|
||||
fun isStartSet(): Boolean
|
||||
//是否已设置终点
|
||||
fun isDestSet(): Boolean
|
||||
//是否设置沿途点
|
||||
fun isTuSet(): Boolean
|
||||
|
||||
fun destory()
|
||||
|
||||
//复读
|
||||
fun readCurrentTts():Boolean
|
||||
|
||||
fun setNaviListener(naviListener: NaviListener)
|
||||
|
||||
fun removeNaviListener()
|
||||
|
||||
fun getNavPath(): NaviPath
|
||||
|
||||
fun getNaviSetting(): NaviSetting
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.zhidaoauto.map.sdk.inner.abs
|
||||
|
||||
interface IRoadData {
|
||||
|
||||
fun result(code:Int,result:String?)
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.zhidaoauto.map.sdk.inner.abs
|
||||
|
||||
interface ITraffic {
|
||||
fun onRoadLoaded(tileId: Int, leftTopLon: Double, leftTopLat: Double, leftBottomLon: Double, leftBottomLat: Double,
|
||||
rightTopLon: Double, rightTopLat: Double, rightBottomLon: Double, rightBottomLat: Double,roadInfo:String?)
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.zhidaoauto.map.sdk.inner.aspect
|
||||
|
||||
object KotlinExtern {
|
||||
fun Double.toTenDecimalsStr():String{
|
||||
return String.format("%.10f", this)
|
||||
}
|
||||
|
||||
fun Float.toTenDecimalsStr():String{
|
||||
return String.format("%.10f", this)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.zhidaoauto.map.sdk.inner.aspect;
|
||||
|
||||
|
||||
//@Aspect
|
||||
public class LonLatAspect {
|
||||
// @Pointcut("execution(* com.lqr.androidaopdemo.MainActivity.test(..))")
|
||||
// public void pointcut() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Before("pointcut()")
|
||||
// public void before(JoinPoint point) {
|
||||
// System.out.println("@Before");
|
||||
// }
|
||||
//
|
||||
// @Around("pointcut()")
|
||||
// public void around(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
// System.out.println("@Around");
|
||||
// }
|
||||
//
|
||||
// @After("pointcut()")
|
||||
// public void after(JoinPoint point) {
|
||||
// System.out.println("@After");
|
||||
// }
|
||||
//
|
||||
// @AfterReturning("pointcut()")
|
||||
// public void afterReturning(JoinPoint point, Object returnValue) {
|
||||
// System.out.println("@AfterReturning");
|
||||
// }
|
||||
//
|
||||
// @AfterThrowing(value = "pointcut()", throwing = "ex")
|
||||
// public void afterThrowing(Throwable ex) {
|
||||
// System.out.println("@afterThrowing");
|
||||
// System.out.println("ex = " + ex.getMessage());
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.zhidaoauto.map.sdk.inner.byteh;
|
||||
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
public @interface CodecProprety {
|
||||
/**
|
||||
* 属性顺序
|
||||
* @return
|
||||
*/
|
||||
int order();
|
||||
|
||||
/**
|
||||
* 数据长度。解码时用,除了简单数据类型之外才起作用(如:String)。
|
||||
* @return
|
||||
*/
|
||||
int length() default 0;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.zhidaoauto.map.sdk.inner.byteh;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Codecable {
|
||||
|
||||
public static List<FieldWrapper> resolveFileldWrapperList(Class clazz){
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
List<FieldWrapper> fieldWrapperList = new ArrayList<>();
|
||||
for (Field field : fields) {
|
||||
CodecProprety codecProprety = field.getAnnotation(CodecProprety.class);
|
||||
if (codecProprety == null) {
|
||||
continue;
|
||||
}
|
||||
FieldWrapper fw = new FieldWrapper(field, codecProprety);
|
||||
fieldWrapperList.add(fw);
|
||||
}
|
||||
|
||||
Collections.sort(fieldWrapperList, new Comparator<FieldWrapper>() {
|
||||
@Override
|
||||
public int compare(FieldWrapper o1, FieldWrapper o2) {
|
||||
return o1.getCodecProprety().order() - o2.getCodecProprety().order();
|
||||
}
|
||||
});
|
||||
|
||||
return fieldWrapperList;
|
||||
}
|
||||
|
||||
|
||||
public abstract List<FieldWrapper> getFieldWrapperList();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.zhidaoauto.map.sdk.inner.byteh;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class FieldWrapper {
|
||||
/**
|
||||
* 上下行数据属性
|
||||
*/
|
||||
private Field field;
|
||||
/**
|
||||
* 上下行数据属性上的注解
|
||||
*/
|
||||
private CodecProprety codecProprety;
|
||||
|
||||
public FieldWrapper(Field field, CodecProprety codecProprety) {
|
||||
this.field = field;
|
||||
this.codecProprety = codecProprety;
|
||||
}
|
||||
|
||||
public Field getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setField(Field field) {
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
public CodecProprety getCodecProprety() {
|
||||
return codecProprety;
|
||||
}
|
||||
|
||||
public void setCodecProprety(CodecProprety codecProprety) {
|
||||
this.codecProprety = codecProprety;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.zhidaoauto.map.sdk.inner.byteh;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
public class PayloadDecoder {
|
||||
|
||||
public static <T extends Codecable> T resolve(byte[] src, Class<T> clazz) {
|
||||
T instance = null;
|
||||
try {
|
||||
instance = clazz.newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("实例化类失败", e);
|
||||
}
|
||||
|
||||
List<FieldWrapper> fieldWrapperList = instance.getFieldWrapperList();
|
||||
ByteBuf buffer = Unpooled.buffer().writeBytes(src);
|
||||
for (FieldWrapper fieldWrapper : fieldWrapperList) {
|
||||
fillData(fieldWrapper, instance, buffer);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static void fillData(FieldWrapper fieldWrapper, Object instance, ByteBuf buffer) {
|
||||
Field field = fieldWrapper.getField();
|
||||
field.setAccessible(true);
|
||||
String typeName = field.getType().getName();
|
||||
try {
|
||||
switch (typeName) {
|
||||
case "java.lang.Boolean":
|
||||
case "boolean":
|
||||
boolean b = buffer.readBoolean();
|
||||
field.set(instance, b);
|
||||
break;
|
||||
|
||||
case "java.lang.Character":
|
||||
case "char":
|
||||
CharSequence charSequence = buffer.readCharSequence(fieldWrapper.getCodecProprety().length(), Charset.forName("UTF-8"));
|
||||
field.set(instance, charSequence);
|
||||
break;
|
||||
case "java.lang.Byte":
|
||||
case "byte":
|
||||
byte b1 = buffer.readByte();
|
||||
field.set(instance, b1);
|
||||
break;
|
||||
case "java.lang.Short":
|
||||
case "short":
|
||||
short readShort = buffer.readShort();
|
||||
field.set(instance, readShort);
|
||||
break;
|
||||
case "java.lang.Integer":
|
||||
case "int":
|
||||
int readInt = buffer.readInt();
|
||||
field.set(instance, readInt);
|
||||
break;
|
||||
case "java.lang.Long":
|
||||
case "long":
|
||||
long l = buffer.readLong();
|
||||
field.set(instance, l);
|
||||
break;
|
||||
case "java.lang.Float":
|
||||
case "float":
|
||||
float readFloat = buffer.readFloat();
|
||||
field.set(instance, readFloat);
|
||||
break;
|
||||
case "java.lang.Double":
|
||||
case "double":
|
||||
double readDouble = buffer.readDouble();
|
||||
field.set(instance, readDouble);
|
||||
break;
|
||||
case "java.lang.String":
|
||||
String readString = buffer.readCharSequence(fieldWrapper.getCodecProprety().length(), Charset.forName("UTF-8")).toString();
|
||||
field.set(instance, readString);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException(typeName + "不支持,bug");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(typeName + "读取失败,field:" + field.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.zhidaoauto.map.sdk.inner.byteh;
|
||||
|
||||
import com.autonavi.nge.map.LonLat;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
public class PayloadEncoder {
|
||||
public static <T extends Codecable> byte[] getPayload(T command) {
|
||||
List<FieldWrapper> fieldWrapperList = command.getFieldWrapperList();
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
for(FieldWrapper fieldWrapper :fieldWrapperList){
|
||||
write2ByteBuf(fieldWrapper, command, buffer);
|
||||
}
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据写入到ByteBuf
|
||||
*
|
||||
* @param fieldWrapper
|
||||
* @param instance
|
||||
* @param buffer
|
||||
*/
|
||||
private static void write2ByteBuf(FieldWrapper fieldWrapper, Object instance, ByteBuf buffer) {
|
||||
Field field = fieldWrapper.getField();
|
||||
String typeName = field.getType().getName();
|
||||
field.setAccessible(true);
|
||||
Object value = null;
|
||||
try {
|
||||
value = field.get(instance);
|
||||
} catch (IllegalAccessException e) {
|
||||
new RuntimeException("反射获取值失败,filed:" + field.getName(), e);
|
||||
}
|
||||
switch (typeName) {
|
||||
case "com.autonavi.nge.map.LonLat":
|
||||
LonLat lonLat = (LonLat) value;
|
||||
buffer.writeDouble(lonLat.getLon());
|
||||
buffer.writeDouble(lonLat.getLat());
|
||||
break;
|
||||
case "java.lang.Boolean":
|
||||
case "kotlin.Boolean":
|
||||
case "boolean":
|
||||
buffer.writeBoolean((Boolean) value);
|
||||
break;
|
||||
case "java.lang.Character":
|
||||
case "kotlin.Character":
|
||||
case "char":
|
||||
buffer.writeCharSequence((CharSequence) value, Charset.forName("UTF-8"));
|
||||
break;
|
||||
case "java.lang.Byte":
|
||||
case "kotlin.Byte":
|
||||
case "byte":
|
||||
buffer.writeByte((byte) value);
|
||||
break;
|
||||
case "java.lang.Short":
|
||||
case "kotlin.Short":
|
||||
case "short":
|
||||
buffer.writeShort((short) value);
|
||||
break;
|
||||
case "java.lang.Integer":
|
||||
case "kotlin.Int":
|
||||
case "int":
|
||||
buffer.writeInt((int) value);
|
||||
break;
|
||||
case "java.lang.Long":
|
||||
case "kotlin.Long":
|
||||
case "long":
|
||||
buffer.writeLong((long) value);
|
||||
break;
|
||||
case "java.lang.Float":
|
||||
case "kotlin.Float":
|
||||
case "float":
|
||||
buffer.writeFloat((float) value);
|
||||
break;
|
||||
case "java.lang.Double":
|
||||
case "kotlin.Double":
|
||||
case "double":
|
||||
buffer.writeDouble((double) value);
|
||||
break;
|
||||
case "java.lang.String":
|
||||
case "kotlin.String":
|
||||
buffer.writeCharSequence((CharSequence) value, Charset.forName("UTF-8"));
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException(typeName + "不支持,bug");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.zhidaoauto.map.sdk.inner.common
|
||||
|
||||
import com.autonavi.nge.Common
|
||||
|
||||
class CommonHelper {
|
||||
private var common: Common
|
||||
|
||||
private constructor() {
|
||||
common = Common()
|
||||
|
||||
}
|
||||
|
||||
|
||||
companion object{
|
||||
var sInstance: CommonHelper? = null
|
||||
|
||||
@Synchronized
|
||||
fun getInstance(): CommonHelper? {
|
||||
if (sInstance == null) {
|
||||
sInstance = CommonHelper()
|
||||
}
|
||||
return sInstance
|
||||
}
|
||||
}
|
||||
|
||||
fun setCfgKeyVal(key: String, value: String){
|
||||
common.setCfgKeyVal(key, value)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
package com.zhidaoauto.map.sdk.inner.common
|
||||
|
||||
import android.os.Environment
|
||||
import java.io.File
|
||||
|
||||
object ConstantExt {
|
||||
|
||||
|
||||
//近视角模式
|
||||
const val MAP_STYLE_VR_ANGLE_NEAR = 0
|
||||
//默认视角模式
|
||||
const val MAP_STYLE_VR_ANGLE_MIDDLE = 1
|
||||
//远视角模式
|
||||
const val MAP_STYLE_VR_ANGLE_FAR = 2
|
||||
//300米视角模式
|
||||
const val MAP_STYLE_VR_ANGLE_300 = 3
|
||||
//顶视角模式
|
||||
const val MAP_STYLE_VR_ANGLE_TOP = 4
|
||||
//十字路口视角
|
||||
const val MAP_STYLE_VR_ANGLE_CROSS = 5
|
||||
//小巴默认视角
|
||||
const val MAP_STYLE_VR_ANGLE_MIDDLE_XIAOBA = 6
|
||||
//漫游模式
|
||||
const val MAP_STYLE_VR_ROAM = 7
|
||||
//过渡模式
|
||||
const val MAP_STYLE_VR_TRANS = 8
|
||||
//洱海B2车辆模式
|
||||
const val MAP_STYLE_VR_ERHAI_B2 = 9
|
||||
//天空盒模式
|
||||
const val MAP_STYLE_VR_SKY_BOX = 10
|
||||
|
||||
//漫游距离1公里
|
||||
const val ROAM_DIS_1KM = 1000f
|
||||
//漫游距离3公里
|
||||
const val ROAM_DIS_3KM = 3000f
|
||||
//漫游距离5公里
|
||||
const val ROAM_DIS_5KM = 5000f
|
||||
//漫游距离8公里
|
||||
const val ROAM_DIS_8KM = 8000f
|
||||
|
||||
//漫游速度30m/s
|
||||
const val ROAM_SPEED_30 = 30f
|
||||
//漫游速度40m/s
|
||||
const val ROAM_SPEED_40 = 40f
|
||||
//漫游速度60m/s
|
||||
const val ROAM_SPEED_60 = 60f
|
||||
//漫游速度80m/s
|
||||
const val ROAM_SPEED_80 = 80f
|
||||
|
||||
|
||||
//VR模式下的缩放
|
||||
const val MAP_STYLE_VR_ZOOM: Int = 20
|
||||
|
||||
//VR模式下的远视角 角度
|
||||
const val MAP_STYLE_VR_OVER_LOOK_ANGLE_FAR = 11.5f
|
||||
//VR模式下的远视角 缩放值
|
||||
const val MAP_STYLE_VR_ZOOM_VAL_FAR = 1f
|
||||
//VR模式下的远视角 高度
|
||||
const val MAP_STYLE_VR_EYE_HEIGHT_FAR = 40f
|
||||
|
||||
|
||||
//VR模式下的近视角 角度
|
||||
const val MAP_STYLE_VR_OVER_LOOK_ANGLE_NEAR =13.5f
|
||||
//VR模式下的近视角 缩放值
|
||||
const val MAP_STYLE_VR_ZOOM_VAL_NEAR = 0.35f
|
||||
//VR模式下的近视角 高度
|
||||
const val MAP_STYLE_VR_EYE_HEIGHT_NEAR = 22f
|
||||
|
||||
//VR模式下的中视角默认视角 小车位置
|
||||
const val MAP_STYLE_VR_POSITION_MIDDLE = 2.6f
|
||||
//VR模式下的中视角默认视角 角度
|
||||
const val MAP_STYLE_VR_OVER_LOOK_ANGLE_MIDDLE = 12.5f
|
||||
//VR模式下的中视角 缩放值
|
||||
const val MAP_STYLE_VR_ZOOM_VAL_MIDDLE = 0.8f
|
||||
//VR模式下的中视角 高度
|
||||
const val MAP_STYLE_VR_EYE_HEIGHT_MIDDLE = 15f
|
||||
|
||||
//VR模式下的小巴车默认视角 角度
|
||||
const val MAP_STYLE_VR_OVER_LOOK_ANGLE_MIDDLE_XIAOBA = 15.3f
|
||||
//VR模式下的小巴车默认视角 缩放值
|
||||
const val MAP_STYLE_VR_ZOOM_VAL_MIDDLE_XIAOBA = 0.8f
|
||||
//VR模式下的小巴车默认视角 高度
|
||||
const val MAP_STYLE_VR_EYE_HEIGHT_MIDDLE_XIAOBA = 19f
|
||||
|
||||
|
||||
//VR模式下的洱海默认视角 角度
|
||||
const val MAP_STYLE_VR_OVER_LOOK_ANGLE_ERHAI = 13f
|
||||
//VR模式下的洱海默认视角 缩放值
|
||||
const val MAP_STYLE_VR_ZOOM_VAL_ERHAI = 1f
|
||||
//VR模式下的洱海默认视角 高度
|
||||
const val MAP_STYLE_VR_EYE_HEIGHT_ERHAI = 15f
|
||||
|
||||
|
||||
//后方来车300米视角 高度
|
||||
const val MAP_STYLE_VR_EYE_HEIGHT_300 = 27f
|
||||
//后方来车300米视角 角度
|
||||
const val MAP_STYLE_VR_OVER_LOOK_ANGLE_300 = 16.5f
|
||||
//后方来车300米视角 缩放值
|
||||
const val MAP_STYLE_VR_ZOOM_VAL_300 = 1.24f
|
||||
|
||||
|
||||
//顶视角 高度
|
||||
const val MAP_STYLE_VR_EYE_HEIGHT_TOP = 70f
|
||||
//顶视角 角度
|
||||
const val MAP_STYLE_VR_OVER_LOOK_ANGLE_TOP = 45f
|
||||
//顶视角 缩放值
|
||||
const val MAP_STYLE_VR_ZOOM_VAL_TOP = 1f
|
||||
|
||||
|
||||
//十字路口视角 高度
|
||||
const val MAP_STYLE_VR_EYE_HEIGHT_CROSS = 14f
|
||||
//十字路口视角 角度
|
||||
const val MAP_STYLE_VR_OVER_LOOK_ANGLE_CROSS = 20.7f
|
||||
//十字路口视角 缩放值
|
||||
const val MAP_STYLE_VR_ZOOM_VAL_CROSS = 1f
|
||||
|
||||
|
||||
//漫游模式 角度
|
||||
const val MAP_STYLE_VR_OVER_LOOK_ANGLE_ROAM = 12.5f
|
||||
//漫游模式 缩放值
|
||||
const val MAP_STYLE_VR_ZOOM_VAL_ROAM = 0.8f
|
||||
//漫游模式 高度
|
||||
const val MAP_STYLE_VR_EYE_HEIGHT_ROAM = 23f
|
||||
|
||||
//过渡模式 角度
|
||||
const val MAP_STYLE_VR_OVER_LOOK_ANGLE_TRANS = 12.5f
|
||||
//过渡模式 缩放值
|
||||
const val MAP_STYLE_VR_ZOOM_VAL_TRANS = 0.8f
|
||||
//过渡模式 高度
|
||||
const val MAP_STYLE_VR_EYE_HEIGHT_TRANS = 30f
|
||||
|
||||
//天空盒模式
|
||||
const val MAP_STYLE_VR_OVER_LOOK_ANGLE_SKYBOX = 28f//视角
|
||||
const val MAP_STYLE_VR_ZOOM_VAL_SKYBOX = 0.8f//缩放
|
||||
const val MAP_STYLE_VR_EYE_HEIGHT_SKYBOX = 12f//高度
|
||||
|
||||
//默认尾灯不亮
|
||||
const val SELF_CAR_DEFAULT = 0
|
||||
//尾灯左黄
|
||||
const val SELF_CAR_TURN_LEFT_YELLOW = 1
|
||||
//尾灯右黄
|
||||
const val SELF_CAR_TURN_RIGHT_YELLOW = 2
|
||||
//尾灯双黄
|
||||
const val SELF_CAR_STOP_LIGHT_YELLOW = 3
|
||||
//尾灯双红
|
||||
const val SELF_CAR_STOP_LIGHT_RED = 4
|
||||
|
||||
|
||||
//VR模式下的近视角视域
|
||||
const val MAP_STYLE_VR_VIEW_FIELD_ANGLE_NEAR = 18f
|
||||
//VR模式下的远视角视域
|
||||
const val MAP_STYLE_VR_VIEW_FIELD_ANGLE_FAR = 20f
|
||||
//VR模式下的中视角视域
|
||||
const val MAP_STYLE_VR_VIEW_FIELD_ANGLE_MIDDLE = 20f
|
||||
|
||||
|
||||
//设置天气
|
||||
const val WEATHER = "wheatherType"
|
||||
//没有天气效果
|
||||
const val WEATHER_DEFULT = "0"
|
||||
//雨天
|
||||
const val WEATHER_RAIN = "1"
|
||||
//雪天
|
||||
const val WEATHER_SNOW = "2"
|
||||
|
||||
//设置天空盒
|
||||
const val FOG = "fog"
|
||||
const val SKYBOX = "skybox"
|
||||
|
||||
//地图视角测试
|
||||
//地图测试视角角度
|
||||
const val MAP_TEST_ANGLE = 18.5f
|
||||
//地图测试100米视角 高度
|
||||
const val MAP_100_EYE_HEIGHT = 16f
|
||||
//地图测试80米视角 高度
|
||||
const val MAP_80_EYE_HEIGHT = 12.5f
|
||||
|
||||
const val CAR_CENTER_100 = 1
|
||||
|
||||
const val CAR_QUARTER_100 = 2
|
||||
|
||||
const val CAR_TWO_FIFTHS_100 = 3
|
||||
|
||||
const val CAR_TWO_FIFTHS_80= 4
|
||||
|
||||
const val CAR_AFTER_30_FRONT_80 = 5
|
||||
|
||||
const val CAR_AFTER_30_FRONT_100 = 6
|
||||
|
||||
const val CAR_AFTER_30_FRONT_120 = 7
|
||||
|
||||
const val CAR_AFTER_40_FRONT_80= 8
|
||||
|
||||
const val CAR_AFTER_40_FRONT_100 = 9
|
||||
|
||||
const val CAR_AFTER_40_FRONT_120 = 10
|
||||
|
||||
const val CAR_AFTER_30_FRONT_80_ANGLE = 16.1f
|
||||
const val CAR_AFTER_30_FRONT_80_EYEHEIGHT = 11.2f
|
||||
const val CAR_AFTER_30_FRONT_80_POSITION = -1.8f
|
||||
|
||||
const val CAR_AFTER_30_FRONT_100_ANGLE = 15.2f
|
||||
const val CAR_AFTER_30_FRONT_100_EYEHEIGHT = 11f
|
||||
const val CAR_AFTER_30_FRONT_100_POSITION = -1.4f
|
||||
|
||||
|
||||
const val CAR_AFTER_30_FRONT_120_ANGLE = 14.3f
|
||||
const val CAR_AFTER_30_FRONT_120_EYEHEIGHT = 10.2f
|
||||
const val CAR_AFTER_30_FRONT_120_POSITION = -1.4f
|
||||
|
||||
const val CAR_AFTER_40_FRONT_80_ANGLE = 13.8f
|
||||
const val CAR_AFTER_40_FRONT_80_EYEHEIGHT = 7f
|
||||
const val CAR_AFTER_40_FRONT_80_POSITION = -4.2f
|
||||
|
||||
const val CAR_AFTER_40_FRONT_100_ANGLE = 13.2f
|
||||
const val CAR_AFTER_40_FRONT_100_EYEHEIGHT = 6.7f
|
||||
const val CAR_AFTER_40_FRONT_100_POSITION = -4f
|
||||
|
||||
const val CAR_AFTER_40_FRONT_120_ANGLE = 12.8f
|
||||
const val CAR_AFTER_40_FRONT_120_EYEHEIGHT = 6.6f
|
||||
const val CAR_AFTER_40_FRONT_120_POSITION = -3.8f
|
||||
|
||||
|
||||
// 2D模式下的俯视角
|
||||
const val MAP_STYLE_2D_OVER_LOOK_ANGLE: Float = 90f
|
||||
//2D模式下的缩放
|
||||
const val MAP_STYLE_2D_ZOOM: Int = 16
|
||||
//2D模式下的高度
|
||||
const val MAP_STYLE_2D_EYE_HEIGHT: Float = 149f
|
||||
|
||||
// nav模式下的俯视角
|
||||
const val MAP_STYLE_NAV_OVER_LOOK_ANGLE: Float = 30f
|
||||
// nav模式下的缩放
|
||||
const val MAP_STYLE_NAV_ZOOM: Int = 18
|
||||
|
||||
//动画时长
|
||||
const val MAP_ANIM_DEFAULT_DURATION: Int = 350
|
||||
|
||||
|
||||
const val RULE_ZERO_SIX_INT: Float = 1000000.0f
|
||||
|
||||
// 经纬度转int标注
|
||||
const val RULE_FLOAT_TO_INT: Float = 3.6f
|
||||
|
||||
// 经纬度转int标注
|
||||
const val RULE_INT: Float = 3.6f * RULE_ZERO_SIX_INT
|
||||
|
||||
const val SHARED_KEY_LOCATION: String = "SHARED_KEY_LOCATION"
|
||||
|
||||
const val SHARED_KEY_LONLAT: String = "SHARED_KEY_LONLAT"
|
||||
|
||||
//样式版本
|
||||
const val SHARED_KEY_STYLE_VERSION: String = "SHARED_KEY_STYLE_VERSION"
|
||||
//数据版本
|
||||
const val SHARED_KEY_DATA_VERSION: String = "SHARED_KEY_DATA_VERSION"
|
||||
//高精数据版本
|
||||
const val SHARED_KEY_HDDATA_VERSION: String = "SHARED_KEY_HDDATA_VERSION"
|
||||
|
||||
/**
|
||||
* authority
|
||||
*/
|
||||
val AUTHORITY = ".data"
|
||||
|
||||
//查询
|
||||
val STR_QUERY = "str_query"
|
||||
|
||||
val KEY = "key"
|
||||
val VALUE = "value"
|
||||
|
||||
//查询
|
||||
val CODE_QUERY = 1001
|
||||
|
||||
fun getNDSDataPath(): String {
|
||||
var mNDSDataPath: String = ""
|
||||
val NDSFileName = "/shmdata/"
|
||||
val paths = arrayOf(
|
||||
"/storage/extSdCard$NDSFileName",
|
||||
"/storage/sdcard0$NDSFileName",
|
||||
"/storage/sdcard1$NDSFileName",
|
||||
"/sdcard/sd$NDSFileName",
|
||||
"/sdcard/external_sd$NDSFileName",
|
||||
"/sdcard-ext$NDSFileName",
|
||||
"/sdcard$NDSFileName",
|
||||
"/sdcard/ext_sd$NDSFileName",
|
||||
"/mnt/extsd$NDSFileName"
|
||||
)
|
||||
for (i in paths.indices) {
|
||||
if (File(paths[i]).exists()) {
|
||||
mNDSDataPath = paths[i]
|
||||
break
|
||||
} else {
|
||||
mNDSDataPath =
|
||||
Environment.getExternalStorageDirectory().absolutePath + NDSFileName
|
||||
}
|
||||
}
|
||||
return mNDSDataPath
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.zhidaoauto.map.sdk.inner.common
|
||||
|
||||
import android.util.Log
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.proxy.CommonProxy
|
||||
import com.zhidaoauto.map.sdk.inner.proxy.LonLatProxy
|
||||
import com.zhidaoauto.map.sdk.inner.utils.Recorder
|
||||
import com.zhidaoauto.map.sdk.open.MapParams
|
||||
|
||||
object MapHelper {
|
||||
private val TAG = javaClass.simpleName
|
||||
var debug = true
|
||||
var mMapParams:MapParams = MapParams.init()
|
||||
|
||||
fun init(mapParams: MapParams){
|
||||
if(debug){
|
||||
Log.i(TAG,"initop MapParams")
|
||||
}
|
||||
mMapParams = mapParams
|
||||
debug = mapParams.getDebugMode()
|
||||
setDebugMode(debug)
|
||||
//TODO MATT
|
||||
// Clerk.isWork = mapParams.getRecordLogs()
|
||||
Recorder.isWork = mapParams.getRecordLogs()
|
||||
if(debug){
|
||||
Log.i(TAG,"initop setLonLatProxy")
|
||||
}
|
||||
CommonProxy.getInstance().setLonLatProxy(LonLatProxy())
|
||||
}
|
||||
|
||||
fun setDebugMode(debug: Boolean) {
|
||||
CompileConfig.setDebug(debug)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.zhidaoauto.map.sdk.inner.common
|
||||
|
||||
import com.zhidaoauto.map.sdk.open.NavParams
|
||||
|
||||
object NavHelper {
|
||||
|
||||
var mNavParams:NavParams = NavParams.init()
|
||||
|
||||
fun init(navParams: NavParams){
|
||||
mNavParams = navParams
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.zhidaoauto.map.sdk.inner.controller
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Process
|
||||
import android.util.Log
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.utils.Constant.getWorkingDirectory
|
||||
import com.zhidaoauto.map.sdk.inner.utils.Constant.killProcesses
|
||||
import com.zhidaoauto.map.sdk.inner.utils.Recorder
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.cancel
|
||||
|
||||
/**
|
||||
* @author Matt
|
||||
*/
|
||||
class CommonController private constructor() {
|
||||
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
|
||||
private var mContext:Context? = null
|
||||
var scope: CoroutineScope? = null
|
||||
|
||||
|
||||
//获取工作空间
|
||||
var workingDirectory: String? = null
|
||||
private set
|
||||
|
||||
|
||||
|
||||
//初始化
|
||||
fun init(context: Context?) {
|
||||
if(this.mContext == null){
|
||||
this.mContext = context
|
||||
}
|
||||
if (this.scope == null) {
|
||||
this.scope = MainScope()
|
||||
}
|
||||
|
||||
initInner()
|
||||
// MarkerCacheController.instance.init()
|
||||
}
|
||||
|
||||
fun initInner() {
|
||||
if (workingDirectory == null) {
|
||||
workingDirectory = getWorkingDirectory(mContext!!)
|
||||
}
|
||||
Recorder.mWorkingDirectory = workingDirectory
|
||||
}
|
||||
|
||||
//退出
|
||||
fun exit() {
|
||||
// 回收scope
|
||||
scope?.cancel()
|
||||
scope = null
|
||||
|
||||
mContext = null
|
||||
}
|
||||
|
||||
//杀死进程
|
||||
private fun finilize() {
|
||||
Process.killProcess(0)
|
||||
mContext?.let {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "mapop-finilize-killProcesses")
|
||||
}
|
||||
killProcesses(it, it.packageName)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
//单例
|
||||
@JvmStatic val instance: CommonController by lazy((LazyThreadSafetyMode.SYNCHRONIZED)) {
|
||||
CommonController()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,577 @@
|
||||
package com.zhidaoauto.map.sdk.inner.controller
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.view.MotionEvent
|
||||
import com.autonavi.nge.map.OnMapScreenShotListener
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IEventController
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi
|
||||
import com.zhidaoauto.map.sdk.open.abs.MapStatusListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnCameraChangeListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapChangeListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapClickListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapLoadedListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapStyleListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapTouchListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapViewVisualAngleChangeListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnRenderListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnRoadInfoListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnRoamStatusListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnScrollListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.log.ILog
|
||||
import com.zhidaoauto.map.sdk.open.camera.CameraPosition
|
||||
import com.zhidaoauto.map.sdk.open.location.MogoLocation
|
||||
import com.zhidaoauto.map.sdk.open.marker.Marker
|
||||
import com.zhidaoauto.map.sdk.open.marker.OnMarkClickListener
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint
|
||||
import com.zhidaoauto.map.sdk.open.road.RoadCross
|
||||
import com.zhidaoauto.map.sdk.open.road.StopLine
|
||||
|
||||
class MapEventController(): IEventController {
|
||||
|
||||
private var mCameraChangeListenerList: ArrayList<OnCameraChangeListener>? = null
|
||||
private var mMapTouchListenerList: ArrayList<OnMapTouchListener>? = null
|
||||
private var mMapClickListenerList: ArrayList<OnMapClickListener>? = null
|
||||
private var mMapLoadedListenerList: ArrayList<OnMapLoadedListener>? = null
|
||||
private var mMarkClickListenerList: ArrayList<OnMarkClickListener>? = null
|
||||
private var mScrollListenerList: ArrayList<OnScrollListener>? = null
|
||||
private var mMapStyleListenerList: ArrayList<OnMapStyleListener>? = null
|
||||
private var mScreenListenerList: ArrayList<OnMapScreenShotListener>? = null
|
||||
private var mMapChangeListenerList: ArrayList<OnMapChangeListener>? = null
|
||||
private var mMapViewVisualAngleChangeListenerList: ArrayList<OnMapViewVisualAngleChangeListener>? =null
|
||||
private var mFocusListenerList: ArrayList<MapStatusListener>? = null
|
||||
private var mRotateListenerList: ArrayList<MapStatusListener>? = null
|
||||
private var mZoomListenerList: ArrayList<MapStatusListener>? = null
|
||||
private var mDAngleListenerList: ArrayList<MapStatusListener>? = null
|
||||
private var renderListenerList : ArrayList<OnRenderListener>? = null
|
||||
private var mRoadInfoListenerList : ArrayList<OnRoadInfoListener>? = null
|
||||
private var mLogListenerList : ArrayList<ILog>? = null
|
||||
private var mHdDataDownloadListener: HashMap<Int, OnHdDataDownByCityListener>? = null
|
||||
private var mRoamStatusListenerList: ArrayList<OnRoamStatusListener>? = null
|
||||
|
||||
|
||||
override fun exit(){
|
||||
mCameraChangeListenerList?.clear()
|
||||
mCameraChangeListenerList = null
|
||||
mMapTouchListenerList?.clear()
|
||||
mMapTouchListenerList = null
|
||||
mMapClickListenerList?.clear()
|
||||
mMapClickListenerList = null
|
||||
mMapLoadedListenerList?.clear()
|
||||
mMapLoadedListenerList = null
|
||||
mMarkClickListenerList?.clear()
|
||||
mMarkClickListenerList = null
|
||||
mScrollListenerList?.clear()
|
||||
mScrollListenerList = null
|
||||
mMapStyleListenerList?.clear()
|
||||
mMapStyleListenerList = null
|
||||
mScreenListenerList?.clear()
|
||||
mScreenListenerList = null
|
||||
mMapChangeListenerList?.clear()
|
||||
mMapChangeListenerList = null
|
||||
mMapViewVisualAngleChangeListenerList?.clear()
|
||||
mMapViewVisualAngleChangeListenerList = null
|
||||
mFocusListenerList?.clear()
|
||||
mFocusListenerList = null
|
||||
mRotateListenerList?.clear()
|
||||
mRotateListenerList = null
|
||||
mZoomListenerList?.clear()
|
||||
mZoomListenerList = null
|
||||
mDAngleListenerList?.clear()
|
||||
mDAngleListenerList = null
|
||||
mRoadInfoListenerList?.clear()
|
||||
mRoadInfoListenerList = null
|
||||
renderListenerList?.clear()
|
||||
renderListenerList = null
|
||||
mLogListenerList?.clear()
|
||||
mLogListenerList = null
|
||||
mHdDataDownloadListener?.clear()
|
||||
mHdDataDownloadListener = null
|
||||
mRoamStatusListenerList?.clear()
|
||||
mRoamStatusListenerList = null
|
||||
}
|
||||
|
||||
override fun addHdDataDownListener(id: Int, onHdDataDownByCityListener: OnHdDataDownByCityListener){
|
||||
if(mHdDataDownloadListener == null){
|
||||
mHdDataDownloadListener = HashMap()
|
||||
}
|
||||
if(!mHdDataDownloadListener!!.keys.contains(id)) {
|
||||
mHdDataDownloadListener?.put(id, onHdDataDownByCityListener)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeHdDataDownListener(id: Int){
|
||||
mHdDataDownloadListener?.let {
|
||||
if(it.keys.contains(id)) {
|
||||
it.remove(id)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun dispatchHdDataDownListener(id: Int, progress: Double){
|
||||
mHdDataDownloadListener?.let {
|
||||
for(listener in it.values){
|
||||
listener.onMapHDDataCacheProgressByCity(id,progress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispatchHdDataDownStateListener(id: Int, state: Int){
|
||||
mHdDataDownloadListener?.let {
|
||||
for(listener in it.values){
|
||||
listener.onMapHDDataCacheStateByCity(id,state)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun addCameraChangeListener(cameraChangeListener: OnCameraChangeListener){
|
||||
if(mCameraChangeListenerList == null){
|
||||
mCameraChangeListenerList = ArrayList()
|
||||
}
|
||||
if(!mCameraChangeListenerList!!.contains(cameraChangeListener)) {
|
||||
mCameraChangeListenerList?.add(cameraChangeListener)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeCameraChangeListener(cameraChangeListener: OnCameraChangeListener){
|
||||
mCameraChangeListenerList?.remove(cameraChangeListener)
|
||||
}
|
||||
|
||||
override fun dispatchCameraChangeListener(type: Int, value: Int){
|
||||
mCameraChangeListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onCameraChange(type, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun dispatchCameraChangeFinishListener(position: CameraPosition?){
|
||||
mCameraChangeListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onCameraChangeFinish(position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun addMapTouchListener(mapTouchListener: OnMapTouchListener){
|
||||
if(mMapTouchListenerList == null){
|
||||
mMapTouchListenerList = ArrayList()
|
||||
}
|
||||
if(!mMapTouchListenerList!!.contains(mapTouchListener)) {
|
||||
mMapTouchListenerList?.add(mapTouchListener)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeMapTouchListener(mapTouchListener: OnMapTouchListener){
|
||||
mMapTouchListenerList?.remove(mapTouchListener)
|
||||
}
|
||||
|
||||
|
||||
override fun dispatchMapTouchListener(event: MotionEvent?): Boolean{
|
||||
mMapTouchListenerList?.let {
|
||||
for(listener in it){
|
||||
return listener.onTouch(event)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun isMapTouchListenerListEmpty(): Boolean{
|
||||
return mMapTouchListenerList?.isEmpty()?:true
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun addMapClickListener(mapClickListener: OnMapClickListener){
|
||||
if(mMapClickListenerList == null){
|
||||
mMapClickListenerList = ArrayList()
|
||||
}
|
||||
if(!mMapClickListenerList!!.contains(mapClickListener)) {
|
||||
mMapClickListenerList?.add(mapClickListener)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeMapClickListener(mapClickListener: OnMapClickListener){
|
||||
mMapClickListenerList?.remove(mapClickListener)
|
||||
}
|
||||
|
||||
override fun dispatchMapClickListener(lonLatPoint: LonLatPoint){
|
||||
mMapClickListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onMapClick(lonLatPoint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun addMapLoadedListener(mapLoadedListener: OnMapLoadedListener){
|
||||
if(mMapLoadedListenerList == null){
|
||||
mMapLoadedListenerList = ArrayList()
|
||||
}
|
||||
if(!mMapLoadedListenerList!!.contains(mapLoadedListener)) {
|
||||
mMapLoadedListenerList?.add(mapLoadedListener)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeMapLoadedListener(mapLoadedListener: OnMapLoadedListener){
|
||||
mMapLoadedListenerList?.remove(mapLoadedListener)
|
||||
}
|
||||
|
||||
override fun dispatchMapLoadedInitListener(){
|
||||
mMapLoadedListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onMapInit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispatchMapLoadedListener(){
|
||||
mMapLoadedListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onMapLoaded()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispatchRoadLoadedListener(roadInfo: String?){
|
||||
mMapLoadedListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onRoadLoaded(roadInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun addMapViewVisualAngleChangeListener(mapViewVisualAngleChangeListener: OnMapViewVisualAngleChangeListener){
|
||||
if(mMapViewVisualAngleChangeListenerList == null){
|
||||
mMapViewVisualAngleChangeListenerList = ArrayList()
|
||||
}
|
||||
if(!mMapViewVisualAngleChangeListenerList!!.contains(mapViewVisualAngleChangeListener)) {
|
||||
mMapViewVisualAngleChangeListenerList?.add(mapViewVisualAngleChangeListener)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeMapViewVisualAngleChangeListener(mapViewVisualAngleChangeListener: OnMapViewVisualAngleChangeListener){
|
||||
mMapViewVisualAngleChangeListenerList?.remove(mapViewVisualAngleChangeListener)
|
||||
}
|
||||
|
||||
override fun dispatchMapViewVisualAngleChangeListener(type: Int){
|
||||
mMapViewVisualAngleChangeListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onMapViewVisualAngleChange(type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun addScrollListener(scrollListener: OnScrollListener){
|
||||
if(mScrollListenerList == null){
|
||||
mScrollListenerList = ArrayList()
|
||||
}
|
||||
if(!mScrollListenerList!!.contains(scrollListener)) {
|
||||
mScrollListenerList?.add(scrollListener)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeScrollListener(scrollListener: OnScrollListener){
|
||||
mScrollListenerList?.remove(scrollListener)
|
||||
}
|
||||
|
||||
override fun dispatchScrollListener(x: Double, y: Double){
|
||||
mScrollListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.scrollBy(x,y)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun addMapStyleListener(mapStyleListener: OnMapStyleListener){
|
||||
if(mMapStyleListenerList == null){
|
||||
mMapStyleListenerList = ArrayList()
|
||||
}
|
||||
if(!mMapStyleListenerList!!.contains(mapStyleListener)) {
|
||||
mMapStyleListenerList?.add(mapStyleListener)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeMapStyleListener(mapStyleListener: OnMapStyleListener){
|
||||
mMapStyleListenerList?.remove(mapStyleListener)
|
||||
}
|
||||
|
||||
override fun dispatchMapStyleListener(type: Int){
|
||||
mMapStyleListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onChangeMapStyle(type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun addScreenShotListener(screenShotListener: OnMapScreenShotListener){
|
||||
if(mScreenListenerList == null){
|
||||
mScreenListenerList = ArrayList()
|
||||
}
|
||||
if(!mScreenListenerList!!.contains(screenShotListener)) {
|
||||
mScreenListenerList?.add(screenShotListener)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeScreenShotListener(screenShotListener: OnMapScreenShotListener){
|
||||
mScreenListenerList?.remove(screenShotListener)
|
||||
}
|
||||
|
||||
override fun dispatchScreenShotListener(bitmap: Bitmap?){
|
||||
mScreenListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onMapScreenShot(bitmap)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun addMapChangeListener(mapChangeListener: OnMapChangeListener){
|
||||
if(mMapChangeListenerList == null){
|
||||
mMapChangeListenerList = ArrayList()
|
||||
}
|
||||
if(!mMapChangeListenerList!!.contains(mapChangeListener)) {
|
||||
mMapChangeListenerList?.add(mapChangeListener)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeMapChangeListener(mapChangeListener: OnMapChangeListener){
|
||||
mMapChangeListenerList?.remove(mapChangeListener)
|
||||
}
|
||||
|
||||
override fun dispatchMapChangeListener(mogoLocation: MogoLocation){
|
||||
mMapChangeListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onMapChange(mogoLocation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun addMarkClickListener(markClickListener: OnMarkClickListener){
|
||||
if(mMarkClickListenerList == null){
|
||||
mMarkClickListenerList = ArrayList()
|
||||
}
|
||||
if(!mMarkClickListenerList!!.contains(markClickListener)) {
|
||||
mMarkClickListenerList?.add(markClickListener)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeMarkClickListener(markClickListener: OnMarkClickListener){
|
||||
mMarkClickListenerList?.remove(markClickListener)
|
||||
}
|
||||
|
||||
override fun dispatchMarkClickListener(marker: Marker){
|
||||
mMarkClickListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onMarkClick(marker)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun isMarkClickListenerListEmpty():Boolean{
|
||||
return mMarkClickListenerList?.isEmpty()?:true
|
||||
}
|
||||
|
||||
|
||||
override fun addMapStatusListener(mapStatusListener: MapStatusListener, type: Int){
|
||||
when(type){
|
||||
MapAutoApi.LISTENER_TYPE_FOCUS->{
|
||||
if(mFocusListenerList == null){
|
||||
mFocusListenerList = ArrayList()
|
||||
}
|
||||
if(!mFocusListenerList!!.contains(mapStatusListener)) {
|
||||
mFocusListenerList?.add(mapStatusListener)
|
||||
}
|
||||
|
||||
}
|
||||
MapAutoApi.LISTENER_TYPE_ROTATE->{
|
||||
if(mRotateListenerList == null){
|
||||
mRotateListenerList = ArrayList()
|
||||
}
|
||||
if(!mRotateListenerList!!.contains(mapStatusListener)) {
|
||||
mRotateListenerList?.add(mapStatusListener)
|
||||
}
|
||||
}
|
||||
MapAutoApi.LISTENER_TYPE_ZOOM->{
|
||||
if(mZoomListenerList == null){
|
||||
mZoomListenerList = ArrayList()
|
||||
}
|
||||
if(!mZoomListenerList!!.contains(mapStatusListener)) {
|
||||
mZoomListenerList?.add(mapStatusListener)
|
||||
}
|
||||
|
||||
}
|
||||
MapAutoApi.LISTENER_TYPE_3D ->{
|
||||
if(mDAngleListenerList == null){
|
||||
mDAngleListenerList = ArrayList()
|
||||
}
|
||||
if(!mDAngleListenerList!!.contains(mapStatusListener)) {
|
||||
mDAngleListenerList?.add(mapStatusListener)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeMapStatusListener(mapStatusListener: MapStatusListener, type: Int){
|
||||
when(type){
|
||||
MapAutoApi.LISTENER_TYPE_FOCUS->{
|
||||
mFocusListenerList?.remove(mapStatusListener)
|
||||
|
||||
}
|
||||
MapAutoApi.LISTENER_TYPE_ROTATE->{
|
||||
mRotateListenerList?.remove(mapStatusListener)
|
||||
}
|
||||
MapAutoApi.LISTENER_TYPE_ZOOM->{
|
||||
mZoomListenerList?.remove(mapStatusListener)
|
||||
}
|
||||
MapAutoApi.LISTENER_TYPE_3D->{
|
||||
mDAngleListenerList?.remove(mapStatusListener)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun dispatchMapStatusListener(type:Int, value: Int){
|
||||
when(type){
|
||||
MapAutoApi.LISTENER_TYPE_FOCUS->{
|
||||
mFocusListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onMapStatusChanged(type, value)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
MapAutoApi.LISTENER_TYPE_ROTATE->{
|
||||
mRotateListenerList?.let{
|
||||
for(listener in it){
|
||||
listener.onMapStatusChanged(type, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
MapAutoApi.LISTENER_TYPE_ZOOM->{
|
||||
mZoomListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onMapStatusChanged(type, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
MapAutoApi.LISTENER_TYPE_3D->{
|
||||
mDAngleListenerList?.let{
|
||||
for(listener in it){
|
||||
listener.onMapStatusChanged(type, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun addRenderListener(renderListener : OnRenderListener){
|
||||
if(renderListenerList == null){
|
||||
renderListenerList = ArrayList()
|
||||
}
|
||||
if(!renderListenerList!!.contains(renderListener)) {
|
||||
renderListenerList?.add(renderListener)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeRenderListener(renderListener : OnRenderListener){
|
||||
renderListenerList?.remove(renderListener)
|
||||
}
|
||||
|
||||
override fun dispatchRenderListener(duration:Int){
|
||||
renderListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.renderTime(duration)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun addRoadInfoListener(roadInfoListener: OnRoadInfoListener){
|
||||
if(mRoadInfoListenerList == null){
|
||||
mRoadInfoListenerList = ArrayList()
|
||||
}
|
||||
if(!mRoadInfoListenerList!!.contains(roadInfoListener)) {
|
||||
mRoadInfoListenerList?.add(roadInfoListener)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeRoadInfoListener(roadInfoListener : OnRoadInfoListener){
|
||||
mRoadInfoListenerList?.remove(roadInfoListener)
|
||||
}
|
||||
|
||||
override fun dispatchStopLineInfo(stopLine: StopLine?){
|
||||
mRoadInfoListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onStopLineInfo(stopLine)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispatchRoadIdInfo(roadId: String?, laneId: String?){
|
||||
mRoadInfoListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onRoadIdInfo(roadId, laneId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispatchRoadCrossInfo(roadCross: RoadCross?){
|
||||
mRoadInfoListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onRoadCrossInfo(roadCross)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun addLogListener(listener: ILog){
|
||||
if(mLogListenerList == null){
|
||||
mLogListenerList = ArrayList()
|
||||
}
|
||||
if(!mLogListenerList!!.contains(listener)) {
|
||||
mLogListenerList?.add(listener)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeLogListener(listener : ILog){
|
||||
mLogListenerList?.remove(listener)
|
||||
}
|
||||
|
||||
override fun dispatchLog(path: String){
|
||||
mLogListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.result(path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun addRoamStatusListener(onRoamStatusListener: OnRoamStatusListener){
|
||||
if(mRoamStatusListenerList == null){
|
||||
mRoamStatusListenerList = ArrayList()
|
||||
}
|
||||
if(!mRoamStatusListenerList!!.contains(onRoamStatusListener)) {
|
||||
mRoamStatusListenerList?.add(onRoamStatusListener)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeRoamStatusListener(onRoamStatusListener: OnRoamStatusListener){
|
||||
mRoamStatusListenerList?.let {
|
||||
it.remove(onRoamStatusListener)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun dispatchRoamStatusListener(status: Int, msg: String){
|
||||
mRoamStatusListenerList?.let {
|
||||
for(listener in it){
|
||||
listener.onRoamStatus(status, msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.zhidaoauto.map.sdk.inner.db;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
import com.autonavi.nge.obj.DestObj;
|
||||
import com.autonavi.nge.obj.PoiBase;
|
||||
import com.zhidaoauto.map.sdk.open.nav.NavPoi;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* 存储所有的数据信息
|
||||
* @author
|
||||
*
|
||||
*/
|
||||
public class DataStorageManager {
|
||||
|
||||
private static DataStorageManager mDataStorageManager;
|
||||
|
||||
// private TrafficDatabase mTrafficDatabase;
|
||||
//不同组件之间的poi对象传输
|
||||
private NavPoi mNavPoi;
|
||||
//当前位置
|
||||
private Location mCurLocation;
|
||||
//搜索结果列表
|
||||
private Vector<PoiBase> mResultList;
|
||||
//工作目录
|
||||
private String mWorkingDirectory;
|
||||
|
||||
private List<NavPoi> searchList;
|
||||
private String searchkey;
|
||||
private int poibub;
|
||||
|
||||
private DestObj mCurEditDest;//当前正在编辑的目的地
|
||||
|
||||
|
||||
|
||||
private DataStorageManager(){
|
||||
}
|
||||
|
||||
public static DataStorageManager getInstance(){
|
||||
if(mDataStorageManager == null) {
|
||||
mDataStorageManager = new DataStorageManager();
|
||||
}
|
||||
return mDataStorageManager;
|
||||
}
|
||||
|
||||
// public void init(Context context){
|
||||
// SettingService service = new SettingService(context);
|
||||
// Setting settings = service.getSettings();
|
||||
// MainInfo.GetInstance().setBGMusicStat(settings.isBg_music());
|
||||
// MainInfo.GetInstance().SetBusInfo(settings.getAddrDescribe() == 0?true:false);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 搜索列表
|
||||
*/
|
||||
public void setPoiList(List<NavPoi> searchList)
|
||||
{
|
||||
this.searchList = searchList;
|
||||
}
|
||||
|
||||
public List<NavPoi> getPoiList()
|
||||
{
|
||||
return searchList;
|
||||
|
||||
}
|
||||
/**
|
||||
* 搜索关键字
|
||||
*/
|
||||
|
||||
public void setPoiKey(String searchkey)
|
||||
{
|
||||
this.searchkey = searchkey;
|
||||
}
|
||||
|
||||
public String getPoiKey()
|
||||
{
|
||||
return searchkey;
|
||||
|
||||
}
|
||||
|
||||
public void setNavPoi(NavPoi navpoi) {
|
||||
this.mNavPoi = navpoi;
|
||||
}
|
||||
|
||||
public NavPoi getNavPoi() {
|
||||
return mNavPoi;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前是第几个气泡
|
||||
*/
|
||||
|
||||
public void setPoiBub(int poibub)
|
||||
{
|
||||
this.poibub = poibub;
|
||||
}
|
||||
|
||||
public int getPoiBub()
|
||||
{
|
||||
return poibub;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置正在编辑的目的地
|
||||
* @param mChannel
|
||||
*/
|
||||
public void setCurEditDest(DestObj mChannel) {
|
||||
this.mCurEditDest = mChannel;
|
||||
}
|
||||
|
||||
public DestObj getCurEditDest() {
|
||||
return mCurEditDest;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.zhidaoauto.map.sdk.inner.db;
|
||||
|
||||
public class Setting {
|
||||
public boolean isBg_music() {
|
||||
return bg_music;
|
||||
}
|
||||
public void setBg_music(boolean bg_music) {
|
||||
this.bg_music = bg_music;
|
||||
}
|
||||
public boolean isDisclaimer() {
|
||||
return disclaimer;
|
||||
}
|
||||
public void setDisclaimer(boolean disclaimer) {
|
||||
this.disclaimer = disclaimer;
|
||||
}
|
||||
public boolean isAuto_play() {
|
||||
return auto_play;
|
||||
}
|
||||
public void setAuto_play(boolean auto_play) {
|
||||
this.auto_play = auto_play;
|
||||
}
|
||||
public boolean isAlways() {
|
||||
return always;
|
||||
}
|
||||
public void setAlways(boolean always) {
|
||||
this.always = always;
|
||||
}
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
public String geteMail() {
|
||||
return eMail;
|
||||
}
|
||||
public void seteMail(String eMail) {
|
||||
this.eMail = eMail;
|
||||
}
|
||||
|
||||
public int getAddrDescribe() {
|
||||
return AddrDescribe;
|
||||
}
|
||||
public void setAddrDescribe(int addrDescribe) {
|
||||
AddrDescribe = addrDescribe;
|
||||
}
|
||||
|
||||
public void setRegisted(boolean isRegisted) {
|
||||
this.isRegisted = isRegisted;
|
||||
}
|
||||
|
||||
public boolean isRegisted() {
|
||||
return isRegisted;
|
||||
}
|
||||
|
||||
private boolean bg_music; //背景音乐设置
|
||||
private boolean disclaimer; //启动时显示免责声明
|
||||
private boolean auto_play; //启动时开启路况播报
|
||||
private boolean always; //使用中保持屏幕常亮
|
||||
private int AddrDescribe ; //拥堵地点描述方式 :0- 优先使用地名描述 1-优先使用交叉口描述
|
||||
private String userName; //用户名
|
||||
private String eMail; //用户邮箱
|
||||
private boolean isRegisted = false;//是否注册
|
||||
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
package com.zhidaoauto.map.sdk.inner.db;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.autonavi.nge.routing.RoutingProvider;
|
||||
|
||||
public class SettingService {
|
||||
private SharedPreferences mSharedPreferences;
|
||||
|
||||
private static final String PREFERENCES_ADDR_DESTRIBE = "list_preference";
|
||||
private static final String PREFERENCES_ALWAYS = "always";
|
||||
private static final String PREFERENCES_MAP_MODE = "map_mode";
|
||||
private static final String PREFERENCES_USER_ROUTE = "user_route";
|
||||
private static final String PREFERENCES_AUTO_PLAY = "auto_play";
|
||||
private static final String PREFERENCES_AUTO_GO = "auto_go";
|
||||
private static final String PREFERENCES_PLAY_ROAD = "play_road";
|
||||
private static final String PREFERENCES_BG_MUSIC = "bg_music";
|
||||
private static final String PREFERENCES_SHOW_DISCLAIMER = "disclaimer";
|
||||
private static final String PREFERENCES_EMAIL = "eMail";
|
||||
private static final String PREFERENCES_USER_NAME = "userName";
|
||||
private static final String PREFERENCES_IMSI = "imsi";
|
||||
private static final String PREFERENCES_IS_REGISTED = "isRegisted";
|
||||
private static final String PREFERENCES_IS_DOWNLOAD_MAP_SHOW = "downloadMap";
|
||||
private static final String PREFERENCES_LOCATION_LON = "MapCenterX";
|
||||
private static final String PREFERENCES_LOCATION_LAT = "MapCenterY";
|
||||
private static final String PREFERENCES_MEDIA_BOTTOM = "mediaBottom";
|
||||
private static final String PREFERENCES_MEDIA_AUTO_PLAY = "mediaAutoPlay";
|
||||
private static final String PREFERENCES_BT_ADS = "bluetoothAddress";
|
||||
private static final String PREFERENCES_ROUTING_MODEL = "routingModel";
|
||||
private static final String PREFERENCES_ROUTING_AVOID_HWAY = "routingAvoidHWay";
|
||||
private static final String PREFERENCES_ROUTING_AVOID_TOLL = "routingAvoidToll";
|
||||
private static final String PREFERENCES_SEARCH_UPDATEREGION = "searchUpdateRegion";
|
||||
private static final String PREFERENCES_SEARCH_UPDATEREGION_NAME = "searchUpdateRegionName";
|
||||
private static final String PREFERENCES_ROUTE_SELECT_SHOW = "RouteSelectShow";
|
||||
private static final String PREFERENCES_TRACK = "track";
|
||||
private static final String PREFERENCES_SPEED_HIGHWAY = "highway_speed";
|
||||
private static final String PREFERENCES_SPEED_FAST = "fast_speed";
|
||||
private static final String PREFERENCES_SPEED_GENERAL = "general_speed";
|
||||
private static final String PREFERENCES_SPEED_HIGHWAY_TIP = "highway_speed_tip";
|
||||
private static final String PREFERENCES_SPEED_FAST_TIP = "fast_speed_tip";
|
||||
private static final String PREFERENCES_SPEED_GENERAL_TIP = "general_speed_tip";
|
||||
private static final String PREFERENCES_MAP_STYLE = "map_style";
|
||||
|
||||
public SettingService(Context context){
|
||||
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
|
||||
}
|
||||
|
||||
public Setting getSettings(){
|
||||
Setting mSetting = new Setting();
|
||||
String addrDescrbe = mSharedPreferences.getString(PREFERENCES_ADDR_DESTRIBE, "0");
|
||||
int id = 0;
|
||||
try {
|
||||
id = Integer.parseInt(addrDescrbe);
|
||||
} catch (NumberFormatException e) {
|
||||
id = 0;
|
||||
}
|
||||
mSetting.setAddrDescribe(id);
|
||||
mSetting.setAlways(mSharedPreferences.getBoolean(PREFERENCES_ALWAYS, true));
|
||||
mSetting.setAuto_play(mSharedPreferences.getBoolean(PREFERENCES_AUTO_PLAY, true));
|
||||
mSetting.setBg_music(mSharedPreferences.getBoolean(PREFERENCES_BG_MUSIC, true));
|
||||
mSetting.setDisclaimer(mSharedPreferences.getBoolean(PREFERENCES_SHOW_DISCLAIMER, true));
|
||||
mSetting.seteMail(mSharedPreferences.getString(PREFERENCES_EMAIL, ""));
|
||||
mSetting.setUserName(mSharedPreferences.getString(PREFERENCES_USER_NAME,""));
|
||||
mSetting.setUserName(mSharedPreferences.getString(PREFERENCES_IMSI,""));
|
||||
mSetting.setRegisted(mSharedPreferences.getBoolean(PREFERENCES_IS_REGISTED, false));
|
||||
return mSetting;
|
||||
}
|
||||
|
||||
public boolean isShowBGMusic(){
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_BG_MUSIC, true);
|
||||
}
|
||||
|
||||
public boolean updateShowBGMusic(boolean show){
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_BG_MUSIC, show).commit();
|
||||
}
|
||||
|
||||
public boolean isShowDisclaimer(){
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_SHOW_DISCLAIMER, true);
|
||||
}
|
||||
|
||||
public boolean updateShowDisclaimer(boolean show){
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_SHOW_DISCLAIMER, show).commit();
|
||||
}
|
||||
|
||||
public boolean isShowAutoPlay(){
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_AUTO_PLAY, true);
|
||||
}
|
||||
|
||||
public boolean updateAutoPlay(boolean show){
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_AUTO_PLAY, show).commit();
|
||||
}
|
||||
|
||||
public boolean isShowAllwaysScreenOn(){
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_ALWAYS, true);
|
||||
}
|
||||
|
||||
public boolean updateShowAllwaysScreenOn(boolean show){
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_ALWAYS, show).commit();
|
||||
}
|
||||
|
||||
public String getUserName(){
|
||||
return mSharedPreferences.getString(PREFERENCES_USER_NAME, "");
|
||||
}
|
||||
|
||||
public boolean setUserName(String userName){
|
||||
return mSharedPreferences.edit().putString(PREFERENCES_USER_NAME, userName).commit();
|
||||
}
|
||||
|
||||
public String getEmail(){
|
||||
return mSharedPreferences.getString(PREFERENCES_EMAIL, "");
|
||||
}
|
||||
|
||||
public boolean setEmail(String eMail){
|
||||
return mSharedPreferences.edit().putString(PREFERENCES_EMAIL, eMail).commit();
|
||||
}
|
||||
|
||||
public String getIMSI()
|
||||
{
|
||||
return mSharedPreferences.getString(PREFERENCES_IMSI, "");
|
||||
}
|
||||
|
||||
public boolean setIMSI(String imsi)
|
||||
{
|
||||
return mSharedPreferences.edit().putString(PREFERENCES_IMSI, imsi).commit();
|
||||
}
|
||||
|
||||
|
||||
public int getAddrDescribe(){
|
||||
String addrDescrbe = mSharedPreferences.getString(PREFERENCES_ADDR_DESTRIBE, "0");
|
||||
int id = 0;
|
||||
try {
|
||||
id = Integer.parseInt(addrDescrbe);
|
||||
} catch (NumberFormatException e) {
|
||||
id = 0;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean setAddrDescribe(int describe){
|
||||
return mSharedPreferences.edit().putString(PREFERENCES_ADDR_DESTRIBE, String.valueOf(describe)).commit();
|
||||
}
|
||||
|
||||
public boolean setRegisted(boolean isRegisted){
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_IS_REGISTED, isRegisted).commit();
|
||||
}
|
||||
|
||||
public boolean isRegisted(){
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_IS_REGISTED, false);
|
||||
}
|
||||
|
||||
public boolean isDownloadMapShow(){
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_IS_DOWNLOAD_MAP_SHOW, true);
|
||||
}
|
||||
|
||||
public boolean setDownloadMapShow(boolean DownloadMapShow){
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_IS_DOWNLOAD_MAP_SHOW, DownloadMapShow).commit();
|
||||
}
|
||||
|
||||
public int getLocationLon(){
|
||||
return mSharedPreferences.getInt(PREFERENCES_LOCATION_LON, 419031495);
|
||||
}
|
||||
|
||||
public boolean setLocationLon(int LocLon){
|
||||
return mSharedPreferences.edit().putInt(PREFERENCES_LOCATION_LON, LocLon).commit();
|
||||
}
|
||||
|
||||
public int getLocationLat(){
|
||||
return mSharedPreferences.getInt(PREFERENCES_LOCATION_LAT, 143664145);
|
||||
}
|
||||
|
||||
public boolean setLocationLat(int LocLat){
|
||||
return mSharedPreferences.edit().putInt(PREFERENCES_LOCATION_LAT, LocLat).commit();
|
||||
}
|
||||
|
||||
public boolean isAutoGo() {
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_AUTO_GO, true);
|
||||
}
|
||||
|
||||
public boolean updateAutoGo(boolean b) {
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_AUTO_GO, b).commit();
|
||||
}
|
||||
|
||||
public boolean isDriverMap() {
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_MAP_MODE, false);
|
||||
}
|
||||
|
||||
public boolean updateDriverMap(boolean b) {
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_MAP_MODE, b).commit();
|
||||
}
|
||||
|
||||
public boolean isLastUserRoute() {
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_USER_ROUTE, true);
|
||||
}
|
||||
|
||||
public boolean updateUserRoute(boolean b) {
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_USER_ROUTE, b).commit();
|
||||
}
|
||||
|
||||
public boolean isPlayRoad() {
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_PLAY_ROAD, true);
|
||||
}
|
||||
|
||||
public boolean updatePlayRoad(boolean b) {
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_PLAY_ROAD, b).commit();
|
||||
}
|
||||
|
||||
public int getMediaBottom(){
|
||||
return mSharedPreferences.getInt(PREFERENCES_MEDIA_BOTTOM, 0);
|
||||
}
|
||||
|
||||
public boolean updateMediaBottom(int bottom){
|
||||
return mSharedPreferences.edit().putInt(PREFERENCES_MEDIA_BOTTOM, bottom).commit();
|
||||
}
|
||||
|
||||
public boolean isMediaAutoPlay() {
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_MEDIA_AUTO_PLAY, true);
|
||||
}
|
||||
|
||||
public boolean updateMediaAutoPlay(boolean b) {
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_MEDIA_AUTO_PLAY, b).commit();
|
||||
}
|
||||
|
||||
public String getBtAddr(){
|
||||
return mSharedPreferences.getString(PREFERENCES_BT_ADS, "");
|
||||
}
|
||||
|
||||
public boolean updateBtAddr(String btAddr){
|
||||
return mSharedPreferences.edit().putString(PREFERENCES_BT_ADS, btAddr).commit();
|
||||
}
|
||||
|
||||
public int getRoutingModel(){
|
||||
return mSharedPreferences.getInt(PREFERENCES_ROUTING_MODEL, RoutingProvider.COSTMODEL_FASTEST);
|
||||
}
|
||||
|
||||
public boolean setRoutingModel(int model){
|
||||
return mSharedPreferences.edit().putInt(PREFERENCES_ROUTING_MODEL, model).commit();
|
||||
}
|
||||
|
||||
public boolean isRoutingAvoidHighway(){
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_ROUTING_AVOID_HWAY, false);
|
||||
}
|
||||
|
||||
public boolean setRoutingAvoidHighway(boolean isRoutingAvoidHighway){
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_ROUTING_AVOID_HWAY, isRoutingAvoidHighway).commit();
|
||||
}
|
||||
|
||||
public boolean isRoutingAvoidToll(){
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_ROUTING_AVOID_TOLL, false);
|
||||
}
|
||||
|
||||
public boolean setRoutingAvoidToll(boolean isRoutingAvoidToll){
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_ROUTING_AVOID_TOLL, isRoutingAvoidToll).commit();
|
||||
}
|
||||
|
||||
public int getUpdateRegion(){
|
||||
return mSharedPreferences.getInt(PREFERENCES_SEARCH_UPDATEREGION, 1);
|
||||
}
|
||||
|
||||
public boolean setUpdateRegion(int urId){
|
||||
return mSharedPreferences.edit().putInt(PREFERENCES_SEARCH_UPDATEREGION, urId).commit();
|
||||
}
|
||||
|
||||
public String getUpdataRegionName(){
|
||||
return mSharedPreferences.getString(PREFERENCES_SEARCH_UPDATEREGION_NAME, "北京市");
|
||||
}
|
||||
|
||||
public boolean setUpdataRegionName(String name){
|
||||
return mSharedPreferences.edit().putString(PREFERENCES_SEARCH_UPDATEREGION_NAME, name).commit();
|
||||
}
|
||||
|
||||
public boolean isRouteSelectShow() {
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_ROUTE_SELECT_SHOW, true);
|
||||
}
|
||||
|
||||
public boolean setRouteSelectShow(boolean isRouteSelectShow){
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_ROUTE_SELECT_SHOW, isRouteSelectShow).commit();
|
||||
}
|
||||
|
||||
public boolean isTrack(){
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_TRACK, false);
|
||||
}
|
||||
|
||||
public boolean setTrack(boolean isTrack){
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_TRACK, isTrack).commit();
|
||||
}
|
||||
|
||||
public boolean setSpeedHighWay(int speed){
|
||||
return mSharedPreferences.edit().putInt(PREFERENCES_SPEED_HIGHWAY, speed).commit();
|
||||
}
|
||||
|
||||
public int getSpeedHighWay(){
|
||||
return mSharedPreferences.getInt(PREFERENCES_SPEED_HIGHWAY, 120);
|
||||
}
|
||||
|
||||
public boolean setSpeedFast(int speed){
|
||||
return mSharedPreferences.edit().putInt(PREFERENCES_SPEED_FAST, speed).commit();
|
||||
}
|
||||
|
||||
public int getSpeedFast(){
|
||||
return mSharedPreferences.getInt(PREFERENCES_SPEED_FAST, 90);
|
||||
}
|
||||
|
||||
public boolean setSpeedGeneral(int speed){
|
||||
return mSharedPreferences.edit().putInt(PREFERENCES_SPEED_GENERAL, speed).commit();
|
||||
}
|
||||
|
||||
public int getSpeedGeneral(){
|
||||
return mSharedPreferences.getInt(PREFERENCES_SPEED_GENERAL, 60);
|
||||
}
|
||||
|
||||
public boolean getSpeedHighWayTip(){
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_SPEED_HIGHWAY_TIP, true);
|
||||
}
|
||||
|
||||
public boolean setSpeedHighWayTip(boolean tipOn){
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_SPEED_HIGHWAY_TIP, tipOn).commit();
|
||||
}
|
||||
|
||||
public boolean setSpeedFastTip(boolean tipOn){
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_SPEED_FAST_TIP, tipOn).commit();
|
||||
}
|
||||
|
||||
public boolean getSpeedFastTip(){
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_SPEED_FAST_TIP, true);
|
||||
}
|
||||
|
||||
public boolean setSpeedGeneralTip(boolean tipOn){
|
||||
return mSharedPreferences.edit().putBoolean(PREFERENCES_SPEED_GENERAL_TIP, tipOn).commit();
|
||||
}
|
||||
|
||||
public boolean getSpeedGeneralTip(){
|
||||
return mSharedPreferences.getBoolean(PREFERENCES_SPEED_GENERAL_TIP, true);
|
||||
}
|
||||
|
||||
public boolean setMapStyle(String style){
|
||||
return mSharedPreferences.edit().putString(PREFERENCES_MAP_STYLE, style).commit();
|
||||
}
|
||||
|
||||
public String getMapStyle(){
|
||||
return mSharedPreferences.getString(PREFERENCES_MAP_STYLE, "0");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.zhidaoauto.map.sdk.inner.element;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class M3DCar {
|
||||
private Context context;
|
||||
private int resid;
|
||||
public byte[] totBuffer = null;
|
||||
public int totSize = 0;
|
||||
|
||||
public M3DCar(Context context, int resid) {
|
||||
this.resid = resid;
|
||||
this.context = context;
|
||||
loadData();
|
||||
}
|
||||
|
||||
private void loadData() {
|
||||
if (null != totBuffer)
|
||||
return;
|
||||
DataInputStream dis = new DataInputStream(context.getResources().openRawResource(resid));
|
||||
int curTotSize = 64 * 1024;
|
||||
totBuffer = new byte[curTotSize];
|
||||
byte[] buffer = new byte[1024];
|
||||
int size = 0;
|
||||
try {
|
||||
while ((size = dis.read(buffer)) >= 0) {
|
||||
if (totSize + size > curTotSize) {
|
||||
curTotSize = (totSize + size) * 3 / 2;
|
||||
byte[] newTotBuffer = new byte[curTotSize];
|
||||
System.arraycopy(totBuffer, 0, newTotBuffer, 0, totSize);
|
||||
totBuffer = newTotBuffer;
|
||||
}
|
||||
System.arraycopy(buffer, 0, totBuffer, totSize, size);
|
||||
totSize += size;
|
||||
}
|
||||
dis.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zhidaoauto.map.sdk.inner.element;
|
||||
|
||||
public class MapCoordinate {
|
||||
public int x;
|
||||
public int y;
|
||||
|
||||
public MapCoordinate(){}
|
||||
public MapCoordinate(int x, int y){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
@Override
|
||||
public String toString(){
|
||||
return "x=" + x + " y=" + y;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.zhidaoauto.map.sdk.inner.location
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.BitmapFactory
|
||||
import android.util.Log
|
||||
import com.zhidaoauto.map.sdk.R
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.abs.ILocationView
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMarkerController
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi
|
||||
import com.zhidaoauto.map.sdk.open.location.MyLocationStyle
|
||||
import io.netty.util.internal.StringUtil
|
||||
|
||||
class LocationHelper(private var mContext: Context?, private var mMarkerController: IMarkerController?, private var mMapController: IMapController?):ILocationView {
|
||||
private val TAG = "LocationHelper"
|
||||
|
||||
private var myLocationEnabled: Boolean = false
|
||||
private lateinit var myLocationStyle: MyLocationStyle
|
||||
|
||||
init {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "selfop---markerop-LocationHelper constructor")
|
||||
}
|
||||
myLocationStyle = MyLocationStyle(mContext, mMarkerController, mMapController)
|
||||
val mMapStyle = mMapController?.getMapStyleParams()?.getStyleMode()?:MapAutoApi.MAP_STYLE_NIGHT
|
||||
switch(mMapStyle)
|
||||
|
||||
}
|
||||
|
||||
override fun exit() {
|
||||
myLocationStyle?.exit()
|
||||
}
|
||||
|
||||
override fun switch(style: Int) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "selfop---markerop-carCursorRes switch:${style}")
|
||||
}
|
||||
|
||||
if (style >= MapAutoApi.MAP_STYLE_NIGHT_VR) {
|
||||
myLocationStyle?.let {
|
||||
if (style == MapAutoApi.MAP_STYLE_NIGHT_VR) {
|
||||
it.setAnimMarkerRes(
|
||||
R.raw.guangquan,
|
||||
MyLocationStyle.ANIM_WAIT_FRAME_NIGHT,
|
||||
MyLocationStyle.ANIM_PERIOD_NIGHT
|
||||
)
|
||||
} else {
|
||||
it.setAnimMarkerRes(
|
||||
R.raw.guangquan_day,
|
||||
MyLocationStyle.ANIM_WAIT_FRAME_DAY,
|
||||
MyLocationStyle.ANIM_PERIOD_DAY
|
||||
)
|
||||
}
|
||||
it.myLocationIcon(it.car3DResId, true)
|
||||
}
|
||||
|
||||
} else {
|
||||
myLocationStyle?.let {
|
||||
var bitmap = it.myLocationIcon
|
||||
if (bitmap == null) {
|
||||
it.myLocationIcon(it.carResId)
|
||||
} else {
|
||||
if (!StringUtil.isNullOrEmpty(it.locationPath)) {
|
||||
bitmap = BitmapFactory.decodeFile(it.locationPath)
|
||||
}
|
||||
if (bitmap != null) {
|
||||
if (bitmap.isRecycled) {
|
||||
it.myLocationIcon(it.carResId)
|
||||
return@let
|
||||
}
|
||||
it.myLocationIcon(bitmap)
|
||||
} else {
|
||||
it.myLocationIcon(it.carResId)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun setMyLocationEnabled(myLocationEnabled: Boolean) {
|
||||
this.myLocationEnabled = myLocationEnabled
|
||||
}
|
||||
|
||||
override fun getMyLocationEnabled(): Boolean {
|
||||
return this.myLocationEnabled
|
||||
}
|
||||
|
||||
override fun setMyLocationStyle(myLocationStyle: MyLocationStyle) {
|
||||
this.myLocationStyle = myLocationStyle
|
||||
}
|
||||
|
||||
override fun getMyLocationStyle(): MyLocationStyle? {
|
||||
return myLocationStyle
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.zhidaoauto.map.sdk.inner.map
|
||||
|
||||
import android.util.Log
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController
|
||||
import com.zhidaoauto.map.sdk.inner.common.ConstantExt
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi
|
||||
|
||||
class MapAnimate(private val mMapController: IMapController) {
|
||||
private var TAG = javaClass.simpleName
|
||||
private var startEyeHeight: Float
|
||||
private var startLookAngle: Float
|
||||
private var startZoomVal: Float
|
||||
|
||||
private var endEyeHeight:Float? = null
|
||||
private var endLookAngle:Float? = null
|
||||
private var endZoomVal:Float? = null
|
||||
private var duration = 1000
|
||||
private var startTime = 0L
|
||||
private var isRuning:Boolean = false
|
||||
|
||||
init {
|
||||
if(mMapController.getMapStyleParams().getStyleMode() == MapAutoApi.MAP_STYLE_NIGHT){
|
||||
startEyeHeight = ConstantExt.MAP_STYLE_2D_EYE_HEIGHT
|
||||
startLookAngle = ConstantExt.MAP_STYLE_2D_OVER_LOOK_ANGLE
|
||||
startZoomVal = ConstantExt.MAP_STYLE_2D_ZOOM.toFloat()
|
||||
}else{
|
||||
startEyeHeight = ConstantExt.MAP_STYLE_VR_EYE_HEIGHT_MIDDLE
|
||||
startLookAngle = ConstantExt.MAP_STYLE_VR_OVER_LOOK_ANGLE_MIDDLE
|
||||
startZoomVal = ConstantExt.MAP_STYLE_VR_ZOOM_VAL_MIDDLE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun setStartFrame(zoomVal: Float, lookAngle: Float, eyeHeight: Float){
|
||||
if(zoomVal != -1f){
|
||||
startZoomVal = zoomVal
|
||||
}
|
||||
if(lookAngle != -1f){
|
||||
startLookAngle = lookAngle
|
||||
}
|
||||
if(eyeHeight != -1f){
|
||||
startEyeHeight = eyeHeight
|
||||
}
|
||||
}
|
||||
|
||||
fun executeAnim(zoomVal:Float, eyeHeight:Float, lookAngle:Float, duration: Int){
|
||||
if(zoomVal == -1f){
|
||||
endZoomVal = startZoomVal
|
||||
}else {
|
||||
endZoomVal = zoomVal
|
||||
}
|
||||
if(eyeHeight == -1f){
|
||||
endEyeHeight = startEyeHeight
|
||||
}else {
|
||||
endEyeHeight = eyeHeight
|
||||
}
|
||||
if(lookAngle == -1f){
|
||||
endLookAngle = startLookAngle
|
||||
}else {
|
||||
endLookAngle = lookAngle
|
||||
}
|
||||
if(duration != -1){
|
||||
this.duration = duration
|
||||
}else{
|
||||
this.duration = 1000
|
||||
}
|
||||
startTime= System.currentTimeMillis()
|
||||
isRuning = true
|
||||
}
|
||||
|
||||
fun isAnimationing():Boolean{
|
||||
if(startTime == 0L
|
||||
|| !isRuning
|
||||
|| (System.currentTimeMillis()-startTime)>duration){
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun endAnimation(){
|
||||
startTime = 0L
|
||||
isRuning = false
|
||||
endZoomVal?.let {
|
||||
startZoomVal = it
|
||||
}
|
||||
endLookAngle?.let {
|
||||
startLookAngle = it
|
||||
}
|
||||
endEyeHeight?.let {
|
||||
startEyeHeight = it
|
||||
}
|
||||
}
|
||||
|
||||
fun stepAnimation(): FloatArray{
|
||||
if(!isRuning){
|
||||
return floatArrayOf(startZoomVal,startLookAngle,startEyeHeight)
|
||||
}
|
||||
if(!isAnimationing()){
|
||||
endAnimation()
|
||||
return floatArrayOf(startZoomVal,startLookAngle,startEyeHeight)
|
||||
}
|
||||
|
||||
var eyeHeight = 0f
|
||||
var angle = 0f
|
||||
var zoomVal = 0f
|
||||
var factor = ((System.currentTimeMillis() - startTime) / duration.toFloat())
|
||||
|
||||
if( factor >=1){
|
||||
endAnimation()
|
||||
return floatArrayOf(startZoomVal, startLookAngle,startEyeHeight)
|
||||
}else{
|
||||
eyeHeight = startEyeHeight + factor * (endEyeHeight!! - startEyeHeight)
|
||||
angle = startLookAngle + factor * (endLookAngle!! - startLookAngle)
|
||||
zoomVal = startZoomVal + factor * (endZoomVal!! - startZoomVal)
|
||||
}
|
||||
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.d(TAG, "angle: ${angle}, height: ${eyeHeight}, zoomVal: ${zoomVal}")
|
||||
}
|
||||
return floatArrayOf(zoomVal,angle,eyeHeight)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.zhidaoauto.map.sdk.inner.map
|
||||
|
||||
import android.graphics.Point
|
||||
import com.zhidaoauto.map.sdk.open.camera.CameraPosition
|
||||
import com.zhidaoauto.map.sdk.open.camera.LatLngBounds
|
||||
import com.zhidaoauto.map.sdk.open.camera.MapCameraMessage
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint
|
||||
|
||||
class MapCameraMessageImpl private constructor() : MapCameraMessage() {
|
||||
/* private var a: Float = 0.toFloat()
|
||||
private var b: Float = 0.toFloat()
|
||||
private var c: ae? = null*/
|
||||
|
||||
companion object {
|
||||
|
||||
fun createNewInstance(): MapCameraMessageImpl {
|
||||
return MapCameraMessageImpl()
|
||||
}
|
||||
|
||||
fun createZoomInInstance(): MapCameraMessageImpl {
|
||||
val instance = createNewInstance()
|
||||
instance.nowType = Type.zoomIn
|
||||
return instance
|
||||
}
|
||||
|
||||
fun createZoomOutInstance(): MapCameraMessageImpl {
|
||||
val instance = createNewInstance()
|
||||
instance.nowType = Type.zoomOut
|
||||
return instance
|
||||
}
|
||||
|
||||
fun createNewInstance(xPixel: Float, yPixel: Float): MapCameraMessageImpl {
|
||||
val instance = createNewInstance()
|
||||
instance.nowType = Type.scrollBy
|
||||
instance.xPixel = xPixel
|
||||
instance.yPixel = yPixel
|
||||
return instance
|
||||
}
|
||||
|
||||
fun createNewInstance(zoom: Float): MapCameraMessageImpl {
|
||||
val instance = createNewInstance()
|
||||
instance.nowType = Type.zoomTo
|
||||
instance.zoom = zoom
|
||||
return instance
|
||||
}
|
||||
|
||||
fun createAmountInstance(amount: Float): MapCameraMessageImpl {
|
||||
return createNewInstance(amount, null as Point?)
|
||||
}
|
||||
|
||||
fun createNewInstance(amount: Float, point: Point?): MapCameraMessageImpl {
|
||||
val instance = createNewInstance()
|
||||
instance.nowType = Type.zoomBy
|
||||
instance.amount = amount
|
||||
instance.focus = point
|
||||
return instance
|
||||
}
|
||||
|
||||
fun createNewInstance(cameraPosition: CameraPosition?): MapCameraMessageImpl {
|
||||
val instance = createNewInstance()
|
||||
instance.nowType = Type.newCameraPosition
|
||||
instance.cameraPosition = cameraPosition
|
||||
return instance
|
||||
}
|
||||
|
||||
fun createNewInstance(latLng: LonLatPoint): MapCameraMessageImpl {
|
||||
val instance = createNewInstance()
|
||||
instance.nowType = Type.changeCenter
|
||||
instance.cameraPosition =
|
||||
CameraPosition(
|
||||
latLng,
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f
|
||||
)
|
||||
return instance
|
||||
}
|
||||
|
||||
fun createInstance(latLng: LonLatPoint): MapCameraMessageImpl? {
|
||||
return createNewInstance(CameraPosition.builder().target(latLng).build())
|
||||
}
|
||||
|
||||
fun createNewInstance(latLng: LonLatPoint, zoomLevel: Float): MapCameraMessageImpl {
|
||||
return createNewInstance(CameraPosition.builder().target(latLng).zoom(zoomLevel).build())
|
||||
}
|
||||
|
||||
fun createNewInstance(
|
||||
latLng: LonLatPoint,
|
||||
zoomLevel: Float,
|
||||
bearing: Float,
|
||||
tilt: Float
|
||||
): MapCameraMessageImpl? {
|
||||
return createNewInstance(
|
||||
CameraPosition.builder().target(latLng).zoom(zoomLevel).bearing(
|
||||
bearing
|
||||
).tilt(tilt).build()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
fun createNewInstance(latLngBounds: LatLngBounds, padding: Int): MapCameraMessageImpl {
|
||||
val instance = createNewInstance()
|
||||
instance.nowType = Type.newLatLngBounds
|
||||
instance.bounds = latLngBounds
|
||||
instance.paddingLeft = padding
|
||||
instance.paddingRight = padding
|
||||
instance.paddingTop = padding
|
||||
instance.paddingBottom = padding
|
||||
return instance
|
||||
}
|
||||
|
||||
fun createNewInstance(latLngBounds: LatLngBounds, width: Int, height: Int, padding: Int): MapCameraMessageImpl {
|
||||
val instance = createNewInstance()
|
||||
instance.nowType = Type.newLatLngBoundsWithSize
|
||||
instance.bounds = latLngBounds
|
||||
instance.paddingLeft = padding
|
||||
instance.paddingRight = padding
|
||||
instance.paddingTop = padding
|
||||
instance.paddingBottom = padding
|
||||
instance.width = width
|
||||
instance.height = height
|
||||
return instance
|
||||
}
|
||||
|
||||
fun createNewInstance(latLngBounds: LatLngBounds, paddingLeft: Int, paddingRight: Int, paddingTop: Int, paddingBottom: Int): MapCameraMessage {
|
||||
val instance = createNewInstance()
|
||||
instance.nowType = Type.newLatLngBounds
|
||||
instance.bounds = latLngBounds
|
||||
instance.paddingLeft = paddingLeft
|
||||
instance.paddingRight = paddingRight
|
||||
instance.paddingTop = paddingTop
|
||||
instance.paddingBottom = paddingBottom
|
||||
return instance
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
package com.zhidaoauto.map.sdk.inner.map
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.common.ConstantExt
|
||||
import com.zhidaoauto.map.sdk.inner.controller.CommonController
|
||||
import com.zhidaoauto.map.sdk.inner.utils.FileUtils
|
||||
import com.zhidaoauto.map.sdk.inner.utils.SharedPrefsMgr
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
|
||||
object MapDataHelper {
|
||||
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
|
||||
//更新数据时版本+1
|
||||
val currentDataVersion = 5
|
||||
|
||||
private var deleteJob:Job? = null
|
||||
|
||||
fun updateData(context: Context, dir: String) {
|
||||
val oldVersion = SharedPrefsMgr.getInstance(context).getInt(ConstantExt.SHARED_KEY_DATA_VERSION, 0)
|
||||
if (oldVersion < currentDataVersion) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"dataop--delete old verion ${oldVersion} for update version ${currentDataVersion}")
|
||||
}
|
||||
SharedPrefsMgr.getInstance(context).putInt(ConstantExt.SHARED_KEY_DATA_VERSION, currentDataVersion)
|
||||
deleteDataDir(dir)
|
||||
}
|
||||
}
|
||||
|
||||
private fun deleteDataDir(dir: String) {
|
||||
deleteJob?.cancel()
|
||||
deleteJob = CommonController.instance.scope?.launch(Dispatchers.IO) {
|
||||
val fileOld = File(dir)
|
||||
val fileNew = File("${dir}_temp")
|
||||
try {
|
||||
val result = fileOld.renameTo(fileNew)
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"dataop--rename ${fileOld.absolutePath} delete ${fileNew.absolutePath} ,result:${result}")
|
||||
}
|
||||
}catch (e:Exception){
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.e(TAG,"dataop--exception",e)
|
||||
}
|
||||
}
|
||||
FileUtils.deleteDirectory(fileNew.absolutePath)
|
||||
}
|
||||
}
|
||||
|
||||
fun exit(){
|
||||
deleteJob?.cancel()
|
||||
deleteJob = null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.zhidaoauto.map.sdk.inner.map
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.AssetManager
|
||||
import android.util.Log
|
||||
import com.autonavi.nge.dm.SharedMemoryService
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.common.ConstantExt
|
||||
import com.zhidaoauto.map.sdk.inner.controller.CommonController
|
||||
import com.zhidaoauto.map.sdk.inner.utils.FileUtils
|
||||
import com.zhidaoauto.map.sdk.inner.utils.SharedPrefsMgr
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
object MapHdDataHelper {
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
|
||||
//更新样式时版本+1
|
||||
val currentDataVersion = 61
|
||||
|
||||
private var initJob:Job? = null
|
||||
private var copyJob:Job? = null
|
||||
private var context:Context? = null
|
||||
|
||||
var loadDataOver:AtomicBoolean = AtomicBoolean(false)
|
||||
|
||||
private fun updateData(context: Context, dir: String) {
|
||||
val oldVersion = SharedPrefsMgr.getInstance(context).getInt(ConstantExt.SHARED_KEY_HDDATA_VERSION, 0)
|
||||
if (oldVersion < currentDataVersion) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"hdmapop--delete old verion ${oldVersion} for update version ${currentDataVersion}")
|
||||
}
|
||||
FileUtils.deleteDirectory(dir)
|
||||
}
|
||||
}
|
||||
|
||||
fun copyAssetsToSdcard(context: Context, assetDir: String, dir: String) {
|
||||
val assetManager = context.resources.assets
|
||||
copyJob?.cancel()
|
||||
copyJob = CommonController.instance.scope?.launch(Dispatchers.IO) {
|
||||
updateData(context, dir)
|
||||
val file = File(dir)
|
||||
if (file.isDirectory && file.list() != null && file.list().size > 1) {
|
||||
if(FileUtils.isSameFiles(assetManager, assetDir, dir)) {
|
||||
loadDataOver.set(true)
|
||||
return@launch
|
||||
}else{
|
||||
FileUtils.deleteDirectory(dir)
|
||||
}
|
||||
|
||||
}
|
||||
dealAssetsToSdcard(context, assetManager, assetDir, dir)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun dealAssetsToSdcard(context: Context, assetManager : AssetManager, assetDir: String, dir: String){
|
||||
SharedPrefsMgr.getInstance(context).putInt(ConstantExt.SHARED_KEY_HDDATA_VERSION, currentDataVersion)
|
||||
val start = System.currentTimeMillis()
|
||||
var result = FileUtils.copyDirect(assetManager, assetDir, dir)
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"hdmapop-assetop-copy to ${dir} cost:${System.currentTimeMillis()-start}ms")
|
||||
}
|
||||
if(!result){
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"hdmapop --assetop-copy fail")
|
||||
}
|
||||
FileUtils.deleteDirectory(dir)
|
||||
result = FileUtils.copyDirect(assetManager, assetDir, dir)
|
||||
loadDataOver.set(true)
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"hdmapop --assetop-second-copy result:${result}")
|
||||
}
|
||||
}else{
|
||||
loadDataOver.set(true)
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"hdmapop --assetop-copy success")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun initDataMgr(context: Context){
|
||||
initJob?.cancel()
|
||||
this.context = context
|
||||
initJob = CommonController.instance.scope?.launch(Dispatchers.IO) {
|
||||
SharedMemoryService.getInstance(context)
|
||||
loadDataOver.set(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun exit(){
|
||||
initJob?.cancel()
|
||||
initJob = null
|
||||
copyJob?.cancel()
|
||||
copyJob = null
|
||||
SharedMemoryService.getInstance(context).exit()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.zhidaoauto.map.sdk.inner.map
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.AssetManager
|
||||
import android.util.Log
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.common.ConstantExt
|
||||
import com.zhidaoauto.map.sdk.inner.controller.CommonController
|
||||
import com.zhidaoauto.map.sdk.inner.utils.FileUtils
|
||||
import com.zhidaoauto.map.sdk.inner.utils.SharedPrefsMgr
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
object MapStyleHelper {
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
|
||||
//更新样式时版本+1
|
||||
val currentStyleVersion = 65
|
||||
|
||||
private var copyJob:Job? = null
|
||||
|
||||
var loadStyleOver:AtomicBoolean = AtomicBoolean(false)
|
||||
|
||||
private fun updateStyle(context: Context, dir: String) {
|
||||
val oldVersion = SharedPrefsMgr.getInstance(context).getInt(ConstantExt.SHARED_KEY_STYLE_VERSION, 0)
|
||||
if (oldVersion < currentStyleVersion) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"styleop--delete old verion ${oldVersion} for update version ${currentStyleVersion}")
|
||||
}
|
||||
FileUtils.deleteDirectory(dir)
|
||||
}
|
||||
}
|
||||
|
||||
fun copyAssetsToSdcard(context: Context, assetDir: String, dir: String) {
|
||||
|
||||
val assetManager = context.resources.assets
|
||||
copyJob?.cancel()
|
||||
copyJob = CommonController.instance.scope?.launch(Dispatchers.IO) {
|
||||
updateStyle(context, dir)
|
||||
val file = File(dir)
|
||||
if (file.isDirectory && file.list() != null && file.list().size > 1) {
|
||||
if(FileUtils.isSameFiles(assetManager, assetDir, dir)) {
|
||||
loadStyleOver.set(true)
|
||||
return@launch
|
||||
}else{
|
||||
FileUtils.deleteDirectory(dir)
|
||||
}
|
||||
}
|
||||
dealAssetsToSdcard(context, assetManager, assetDir, dir)
|
||||
}
|
||||
}
|
||||
|
||||
private fun dealAssetsToSdcard(context: Context, assetManager :AssetManager,assetDir: String, dir: String){
|
||||
SharedPrefsMgr.getInstance(context).putInt(ConstantExt.SHARED_KEY_STYLE_VERSION, currentStyleVersion)
|
||||
val start = System.currentTimeMillis()
|
||||
var result = FileUtils.copyDirect(assetManager, assetDir, dir)
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"styleop-assetop-copy to ${dir} cost:${System.currentTimeMillis()-start}ms")
|
||||
}
|
||||
if(!result){
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"styleop --assetop-copy fail")
|
||||
}
|
||||
FileUtils.deleteDirectory(dir)
|
||||
result = FileUtils.copyDirect(assetManager, assetDir, dir)
|
||||
loadStyleOver.set(true)
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"styleop --assetop-second-copy result:${result}")
|
||||
}
|
||||
}else{
|
||||
loadStyleOver.set(true)
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"styleop --assetop-copy success")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun exit(){
|
||||
copyJob?.cancel()
|
||||
copyJob = null
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.zhidaoauto.map.sdk.inner.map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController;
|
||||
import com.zhidaoauto.map.sdk.open.abs.MapStatusListener;
|
||||
|
||||
|
||||
public class MapZoomAdjuster implements MapStatusListener {
|
||||
|
||||
private static final int NAVMODE = 3;
|
||||
private static final int NAVZOOMLEVEL = 19;
|
||||
|
||||
private static final int MSG_ZOOM_CHANGED = 1;
|
||||
|
||||
private IMapController mMapCtrl = null;
|
||||
private int mMapMode = 0;
|
||||
private boolean mFollowCarMode = false;
|
||||
|
||||
public MapZoomAdjuster(Context context, IMapController controller) {
|
||||
mMapCtrl = controller;
|
||||
mMapCtrl.getEventController().addMapStatusListener(this, MapController.LISTENER_TYPE_ZOOM);
|
||||
}
|
||||
|
||||
void setMapStyle(int stylemode) {
|
||||
mMapMode = stylemode;
|
||||
if (mMapMode >= NAVMODE) {
|
||||
cancelAdjustZoomChange();
|
||||
}
|
||||
}
|
||||
|
||||
void setFollowCarMode(boolean followCarMode) {
|
||||
mFollowCarMode = followCarMode;
|
||||
if (true == followCarMode) {
|
||||
adjustZoomChange(mMapCtrl.getZoom(), 5);
|
||||
} else {
|
||||
cancelAdjustZoomChange();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapStatusChanged(int type, int value) {
|
||||
|
||||
if (MapController.LISTENER_TYPE_ZOOM == type) {
|
||||
adjustZoomChange(value, 10);
|
||||
}
|
||||
}
|
||||
|
||||
void adjustZoomChange(int value, int delaysecond) {
|
||||
if (mMapMode >= NAVMODE && true == mFollowCarMode && value != NAVZOOMLEVEL) {
|
||||
cancelAdjustZoomChange();
|
||||
mNaviControllerHandler.sendEmptyMessageDelayed(MSG_ZOOM_CHANGED, 1000*delaysecond); /* delay 10s */
|
||||
}
|
||||
}
|
||||
|
||||
void cancelAdjustZoomChange() {
|
||||
mNaviControllerHandler.removeMessages(MSG_ZOOM_CHANGED);
|
||||
}
|
||||
|
||||
|
||||
private Handler mNaviControllerHandler = new Handler() {
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
|
||||
switch(msg.what) {
|
||||
case MSG_ZOOM_CHANGED:
|
||||
if (null != mMapCtrl) {
|
||||
mMapCtrl.setZoom(NAVZOOMLEVEL);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.zhidaoauto.map.sdk.inner.marker
|
||||
|
||||
interface IInfoViewClick {
|
||||
fun click()
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.zhidaoauto.map.sdk.inner.marker
|
||||
|
||||
import com.zhidaoauto.map.sdk.open.abs.marker.InfoWindowAdapter
|
||||
|
||||
class MarkerAdapterManager {
|
||||
|
||||
var mInfoWindowAdapter:InfoWindowAdapter? = null
|
||||
|
||||
private constructor(){
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
var mInstance: MarkerAdapterManager? = null
|
||||
fun getInstance(): MarkerAdapterManager {
|
||||
if (mInstance == null) {
|
||||
synchronized(MarkerAdapterManager::class.java) {
|
||||
if (mInstance == null) {
|
||||
mInstance = MarkerAdapterManager()
|
||||
}
|
||||
}
|
||||
}
|
||||
return mInstance!!
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.zhidaoauto.map.sdk.inner.marker
|
||||
|
||||
import android.graphics.Rect
|
||||
|
||||
class MarkerInfoViewClickController {
|
||||
private val TAG = javaClass.simpleName
|
||||
|
||||
private constructor() {
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
val instance by lazy { MarkerInfoViewClickController() }
|
||||
}
|
||||
|
||||
private val infoViewClickMap = HashMap<String, HashMap<Rect, IInfoViewClick>>()
|
||||
|
||||
fun add(markerId: String, rect: Rect, iInfoViewClick: IInfoViewClick) {
|
||||
var map: HashMap<Rect, IInfoViewClick>?
|
||||
if (infoViewClickMap.containsKey(markerId)) {
|
||||
map = infoViewClickMap.get(markerId)
|
||||
} else {
|
||||
map = HashMap<Rect, IInfoViewClick>()
|
||||
}
|
||||
map?.let {
|
||||
it.put(rect, iInfoViewClick)
|
||||
infoViewClickMap.put(markerId, it)
|
||||
}
|
||||
}
|
||||
|
||||
fun get(markerId: String): HashMap<Rect, IInfoViewClick>? {
|
||||
return infoViewClickMap.get(markerId)
|
||||
}
|
||||
|
||||
fun remove(markerId: String) {
|
||||
infoViewClickMap.remove(markerId)
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
infoViewClickMap.clear()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,761 @@
|
||||
package com.zhidaoauto.map.sdk.inner.marker
|
||||
|
||||
import android.graphics.Rect
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import com.alibaba.fastjson.JSON
|
||||
import com.autonavi.nge.map.LonLat
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig.DEBUG
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMarkerCall
|
||||
import com.zhidaoauto.map.sdk.open.abs.marker.OnMarkerDragListener
|
||||
import com.zhidaoauto.map.sdk.open.marker.*
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint
|
||||
import com.zhidaoauto.map.sdk.open.tools.MD5Utils
|
||||
import com.zhidaoauto.map.sdk.open.tools.MapTools
|
||||
import io.netty.buffer.Unpooled
|
||||
import java.nio.charset.Charset
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
class MarkerNativeInterface(private val mMapController: IMapController): IMarkerCall {
|
||||
|
||||
private val TAG = "MarkerNativeInterface"
|
||||
|
||||
|
||||
private val markerIconList = ArrayList<String>()
|
||||
private val markClickListenerMap: MutableMap<String, OnMarkClickListener> = HashMap()
|
||||
private val infoWindowClickListenerMap: MutableMap<String, OnInfoWindowClickListener> = HashMap<String, OnInfoWindowClickListener>()
|
||||
private val animationListenerMap: MutableMap<String, OnAnimationListener> = HashMap<String, OnAnimationListener>()
|
||||
private val markDragListenerMap: MutableMap<String, OnMarkerDragListener> = HashMap()
|
||||
private val markerIconCacheMap = HashMap<Int,String>()
|
||||
private val markerInfoCacheMap = ConcurrentHashMap<String,String>()
|
||||
|
||||
//点击infoview区域
|
||||
private val infoViewClickMap = HashMap<String, HashMap<Rect, IInfoViewClick>>()
|
||||
|
||||
override fun exit(){
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--MarkerNativeInterface:exit")
|
||||
}
|
||||
markerIconList.clear()
|
||||
markClickListenerMap.clear()
|
||||
infoWindowClickListenerMap.clear()
|
||||
animationListenerMap.clear()
|
||||
markDragListenerMap.clear()
|
||||
markerIconCacheMap.clear()
|
||||
markerInfoCacheMap.clear()
|
||||
infoViewClickMap.clear()
|
||||
}
|
||||
|
||||
override fun addInfoViewClick(markerId: String, rect: Rect, iInfoViewClick: IInfoViewClick) {
|
||||
var map: HashMap<Rect, IInfoViewClick>?
|
||||
if (infoViewClickMap.containsKey(markerId)) {
|
||||
map = infoViewClickMap.get(markerId)
|
||||
} else {
|
||||
map = HashMap<Rect, IInfoViewClick>()
|
||||
}
|
||||
map?.let {
|
||||
it.put(rect, iInfoViewClick)
|
||||
infoViewClickMap.put(markerId, it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getInfoViewClick(markerId: String): HashMap<Rect, IInfoViewClick>? {
|
||||
return infoViewClickMap.get(markerId)
|
||||
}
|
||||
|
||||
override fun removeInfoViewClick(markerId: String) {
|
||||
infoViewClickMap.remove(markerId)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun addMarkerIcon(icon:String):Boolean{
|
||||
return markerIconList.add(icon)
|
||||
}
|
||||
|
||||
override fun containMarkerIconCache(id: Int): Boolean {
|
||||
return markerIconCacheMap.containsKey(id)
|
||||
}
|
||||
|
||||
override fun removeMarkerIconCache(id: Int) {
|
||||
markerIconCacheMap.remove(id)
|
||||
}
|
||||
|
||||
override fun addMarkerIconCache(id: Int, icon: String) {
|
||||
markerIconCacheMap.put(id,icon)
|
||||
}
|
||||
|
||||
override fun getMarkerIconCache(id:Int):String?{
|
||||
return markerIconCacheMap.get(id)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun removeMarkerIcon(icon:String?):Boolean{
|
||||
return markerIconList.remove(icon)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun containMarkerIcon(icon:String?):Boolean{
|
||||
return markerIconList.contains(icon)
|
||||
}
|
||||
/**
|
||||
* 清除所有marker
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
fun clearAllMarkers(): Boolean? {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--clearAllMarkers:")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
val isSuccess = mMapController.clearAllAnchors()
|
||||
refreshMap()
|
||||
// }
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置infowindow的title值
|
||||
*
|
||||
* @param id
|
||||
* @param title
|
||||
*/
|
||||
fun setTitle(id: String?, title: String?) {
|
||||
|
||||
updateMarkerProperty(id!!, "title", title!!)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取infowindow的标题
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
fun getTitle(id: String?): String {
|
||||
return getMarkerProperty(id!!, "title")?:""
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置infowindow的内容
|
||||
*
|
||||
* @param id
|
||||
* @param snippet
|
||||
*/
|
||||
fun setSnippet(id: String?, snippet: String?) {
|
||||
updateMarkerProperty(id!!, "snippet", snippet!!)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取infowindow属性snippet的值
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
fun getSnippet(id: String?): String {
|
||||
return getMarkerProperty(id!!, "snippet")?:""
|
||||
}
|
||||
|
||||
fun isAnchorDynamicMoving(id: String): Boolean {
|
||||
return mMapController.isAnchorDynamicMoving(id)?:false
|
||||
}
|
||||
|
||||
/**
|
||||
* 更换marker的图片
|
||||
*
|
||||
* @param id
|
||||
* @param bitmapDescriptor
|
||||
*/
|
||||
fun setIcon(id: String?, bitmapDescriptor: BitmapDescriptor) {
|
||||
val markerBytes = bitmapDescriptor.getBytes()
|
||||
if(markerBytes.size == 0){
|
||||
return
|
||||
}
|
||||
MD5Utils.getInstanse()
|
||||
val markerIconName = MD5Utils.getMD5String(markerBytes)
|
||||
//缓存图片
|
||||
if (!containMarkerIcon(markerIconName)) {
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--setIcon--addImagetoImageManager:${markerIconName}")
|
||||
}
|
||||
|
||||
val result = mMapController.addImage(
|
||||
markerIconName,
|
||||
markerBytes,
|
||||
bitmapDescriptor.width,
|
||||
bitmapDescriptor.height
|
||||
) ?:-1
|
||||
if(result ==0 ){
|
||||
addMarkerIcon( markerIconName)
|
||||
}
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
mMapController.updateAnchorWithBitmap(id!!, markerIconName)
|
||||
refreshMap()
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置marker的水平和垂直范围的比例
|
||||
*
|
||||
* @param id
|
||||
* @param anchorU
|
||||
* @param anchorV
|
||||
*/
|
||||
fun setAnchor(id: String?, anchorU: Float, anchorV: Float) {
|
||||
updateMarkerProperty(id!!, "anchorUV", "${anchorU},${anchorV}" )
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置marker的位置(经纬度)
|
||||
*
|
||||
* @param id
|
||||
* @param latitude
|
||||
* @param longitude
|
||||
* @return
|
||||
*/
|
||||
fun setPosition(id: String?, latitude: Double, longitude: Double): Boolean {
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "autoop-markerop--setPosition: ${id},$latitude,$longitude")
|
||||
}
|
||||
val isSuccess = updateMarkerProperty(id!!, "lonLatPoint", "$longitude,$latitude")
|
||||
refreshMap()
|
||||
return isSuccess?:false
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置marker的上诉缩放
|
||||
*
|
||||
* @param id
|
||||
* @param latitude
|
||||
* @param longitude
|
||||
* @return
|
||||
*/
|
||||
fun setScale(id: String?, scale: Float): Boolean {
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "autoop-markerop--setScale: ${id},$scale")
|
||||
}
|
||||
val isSuccess = updateMarkerProperty(id!!, "scale", "$scale")
|
||||
refreshMap()
|
||||
return isSuccess?:false
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取marker的经纬度
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
fun getPosition(id: String?): LonLat? {
|
||||
val lonlstStr = getMarkerProperty(id!!, "lonLatPoint")
|
||||
val lonlat = lonlstStr?.split(",")?.toTypedArray()
|
||||
lonlat?.let{
|
||||
return LonLat(lonlat[0].toDouble(), lonlat[1].toDouble())
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除marker
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
fun removeMarker(id: String?): Boolean {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--removeMarker:${id}")
|
||||
}
|
||||
mMapController.removeAnchor(id!!)
|
||||
refreshMap()
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* infowindow是否显示
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
fun isInfoWindowShown(id: String?): Boolean {
|
||||
val isInfoWindowShown = getMarkerProperty(id!!, "isInfoWindowShown")
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--isInfoWindowShown:${isInfoWindowShown}")
|
||||
}
|
||||
return isInfoWindowShown?.toBoolean()?:false
|
||||
}
|
||||
|
||||
fun setInfoWindowShown(id: String?,flag:Boolean):Boolean{
|
||||
val isSuccess = updateMarkerProperty(id!!, "isInfoWindowShown", "$flag")
|
||||
refreshMap()
|
||||
return isSuccess?:false
|
||||
}
|
||||
|
||||
fun setInfoWindowEnabled(id: String?,flag:Boolean):Boolean{
|
||||
val isSuccess = updateMarkerProperty(id!!, "infoWindowEnabled", "$flag")
|
||||
refreshMap()
|
||||
return isSuccess?:false
|
||||
}
|
||||
|
||||
/**
|
||||
* infowindow是否可以显示
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
fun isInfoWindowEnabled(id: String?): Boolean {
|
||||
val infoWindowEnabled = getMarkerProperty(id!!, "infoWindowEnabled")
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--infoWindowEnabled:${infoWindowEnabled}")
|
||||
}
|
||||
return infoWindowEnabled?.toBoolean()?:false
|
||||
}
|
||||
|
||||
fun setVisible(id: String?, visible: Boolean) {
|
||||
updateMarkerProperty(id!!, "visible",visible.toString())
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
fun isVisible(id: String?): Boolean {
|
||||
return getMarkerProperty(id!!, "visible")?.toBoolean()?:false
|
||||
}
|
||||
|
||||
fun setRotateAngle(id: String?, rotateAngle: Float) {
|
||||
updateMarkerProperty(id!!, "rotateAngle", rotateAngle.toString())
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
fun getRoateAngle(id: String?): Float {
|
||||
val rotateAngle = getMarkerProperty(id!!, "rotateAngle")
|
||||
return java.lang.Float.valueOf(rotateAngle)
|
||||
}
|
||||
|
||||
fun getDraggable(id: String?): Boolean {
|
||||
val draggable = getMarkerProperty(id!!, "draggable")
|
||||
return draggable!!.toBoolean()
|
||||
}
|
||||
|
||||
fun setPeriod(id: String?, period: Int) {
|
||||
updateMarkerProperty(id!!, "period", period.toString())
|
||||
}
|
||||
|
||||
fun getPeriod(id: String?): Int {
|
||||
val period = getMarkerProperty(id!!, "period")
|
||||
return period!!.toInt()
|
||||
}
|
||||
|
||||
fun showInfoWindow(id: String?) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--showInfoWindow:${id}")
|
||||
}
|
||||
mMapController.showInfoWindow(id!!)
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
fun hideInfoWindow(id: String?) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--hideInfoWindow:${id}")
|
||||
}
|
||||
mMapController.hideInfoWindow(id!!)
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
fun setInfoWindowIcon(id: String?, markerInfoName: String) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--setInfoWindowIcon:${id}")
|
||||
}
|
||||
updateMarkerProperty(id!!, "markerInfoName", markerInfoName)
|
||||
// CommonController.instance.mapView?.updateInfoWindowWithBitMap(id!!, bitmapDescriptor.getBytes(), bitmapDescriptor.width, bitmapDescriptor.height)
|
||||
showInfoWindow(id)
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
private fun getMarkerProperty(id:String,propertyName:String):String{
|
||||
return mMapController.getAnchorProperty(id,propertyName)?:""
|
||||
}
|
||||
|
||||
private fun updateMarkerProperty(id:String,propertyName:String,value:String):Boolean{
|
||||
val flag = mMapController.updateAnchorProperty(id,propertyName,value)
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--updateMarkerProperty:${id},${propertyName},${value},result:${flag}")
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun clear(): Boolean {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--clear clearAllAluster --clearAllMarkers:")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
val isSuccess = mMapController.clearAllAnchors()
|
||||
mMapController.clearAllCluster()
|
||||
refreshMap()
|
||||
|
||||
// }
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun getAnimationListener(markerID: String): OnAnimationListener? {
|
||||
if (animationListenerMap == null || animationListenerMap.size == 0) {
|
||||
return null
|
||||
}
|
||||
for (id in animationListenerMap.keys) {
|
||||
if (TextUtils.equals(id, markerID)) {
|
||||
return animationListenerMap[markerID]
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun addAnimationListener(markerID: String, onAnimationListener: OnAnimationListener?) {
|
||||
if(onAnimationListener == null){
|
||||
animationListenerMap.remove(markerID)
|
||||
}else{
|
||||
animationListenerMap[markerID] = onAnimationListener
|
||||
}
|
||||
}
|
||||
|
||||
override fun getInfoWindowClickListener(markerID: String): OnInfoWindowClickListener? {
|
||||
if (infoWindowClickListenerMap == null || infoWindowClickListenerMap.size == 0) {
|
||||
return null
|
||||
}
|
||||
for (id in infoWindowClickListenerMap.keys) {
|
||||
if (TextUtils.equals(id, markerID)) {
|
||||
return infoWindowClickListenerMap[markerID]
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun addInfoWindowClickListener(markerID: String, onInfoWindowClickListener: OnInfoWindowClickListener?) {
|
||||
if(onInfoWindowClickListener == null){
|
||||
infoWindowClickListenerMap.remove(markerID)
|
||||
}else{
|
||||
infoWindowClickListenerMap[markerID] = onInfoWindowClickListener
|
||||
}
|
||||
}
|
||||
|
||||
override fun addMarkClickListener(markerID: String, onMarkClickListener: OnMarkClickListener?) {
|
||||
if(onMarkClickListener == null){
|
||||
markClickListenerMap.remove(markerID)
|
||||
}else{
|
||||
markClickListenerMap[markerID] = onMarkClickListener
|
||||
}
|
||||
}
|
||||
|
||||
override fun addMarkDragListener(markerID: String, onMarkerDragListener: OnMarkerDragListener?) {
|
||||
if(onMarkerDragListener == null){
|
||||
markDragListenerMap.remove(markerID)
|
||||
}else{
|
||||
markDragListenerMap[markerID] = onMarkerDragListener
|
||||
}
|
||||
}
|
||||
|
||||
override fun getMarkDragListener(markerID: String): OnMarkerDragListener?{
|
||||
if (markDragListenerMap == null || markDragListenerMap.size == 0) {
|
||||
return null
|
||||
}
|
||||
for (id in markDragListenerMap.keys) {
|
||||
if (TextUtils.equals(id, markerID)) {
|
||||
return markDragListenerMap[markerID]
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
override fun getMarkClickListener(markerID: String): OnMarkClickListener? {
|
||||
if (markClickListenerMap == null || markClickListenerMap.size == 0) {
|
||||
return null
|
||||
}
|
||||
for (id in markClickListenerMap.keys) {
|
||||
if (TextUtils.equals(id, markerID)) {
|
||||
return markClickListenerMap[markerID]
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun setAlpha(id: String?, alpha: Float) {
|
||||
updateMarkerProperty(id!!, "alpha", java.lang.Float.toString(alpha))
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
fun getAlpha(id: String): Float {
|
||||
return java.lang.Float.valueOf(getMarkerProperty(id, "alpha"))
|
||||
}
|
||||
|
||||
fun setClickable(id: String?, clickable: Boolean) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--setClickable:${id}")
|
||||
}
|
||||
mMapController.setSomeAnchorCanClickable(id!!, clickable)
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
fun addDynamicAnchorPostion(id: String, points: List<LonLatPoint>,angle:Float, isGps:Boolean,current:Long,duration: Int) {
|
||||
val data = MapTools.listToArray(points,!isGps)
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--addDynamicAnchorPostion:${id},${points},isGps:${isGps},duration:${duration}")
|
||||
}
|
||||
mMapController.addDynamicAnchorPostion(id, data,angle,current, duration)
|
||||
}
|
||||
|
||||
fun addTranslateAnimationToAnchor(id: String, points: DoubleArray, duration: Int) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--addTranslateAnimationToAnchor:${id}")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
mMapController.addTranslateAnimationToAnchor(id, points, duration)
|
||||
// }
|
||||
}
|
||||
|
||||
fun addScaleAnimationToAnchor(id: String, startScale: Float, endScale: Float, duration: Int) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--addScaleAnimationToAnchor:${id}")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
mMapController.addScaleAnimationToAnchor(id, startScale, endScale, duration)
|
||||
// }
|
||||
}
|
||||
|
||||
fun addFlashAnimationToAnchorPoint(id: String, images: String, duration: Int){
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--addFlashAnimationToAnchorPoint:${id}")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
mMapController.addFlashAnimationToAnchor(id, images, duration)
|
||||
// }
|
||||
}
|
||||
|
||||
fun addRotateAnimationToAnchorPoint(id: String, startAng: Float, endAng: Float, duration: Int){
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--addRotateAnimationToAnchorPoint:${id}")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
mMapController.addRotateAnimationToAnchor(id, startAng, endAng, duration)
|
||||
// }
|
||||
}
|
||||
fun startAnimation(id: String) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--startAnimation:${id}")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
mMapController.startAnimation(id)
|
||||
// }
|
||||
}
|
||||
|
||||
fun endAnimation(id: String) {
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
mMapController.endAnimation(id)
|
||||
// }
|
||||
}
|
||||
|
||||
fun setToTop(id: String) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--SetSomeAnchorTop:${id}")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
mMapController.setSomeAnchorTop(id)
|
||||
refreshMap()
|
||||
// }
|
||||
}
|
||||
|
||||
fun setZIndex(id: String, zIndex: Int) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--setZIndex:${id},${zIndex}")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
mMapController.setSomeAnchorZIndex(id, zIndex)
|
||||
refreshMap()
|
||||
// }
|
||||
}
|
||||
|
||||
//设置marker是否可以拖拽
|
||||
fun setDraggable(id: String, draggable: Boolean) {
|
||||
updateMarkerProperty(id!!, "draggable", draggable.toString())
|
||||
}
|
||||
|
||||
//设置marker是否需要指定方向
|
||||
fun setControlAngle(id: String, enable: Boolean) {
|
||||
updateMarkerProperty(id, "controlAngle", java.lang.Boolean.toString(enable))
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
//设置marker 模型顔色
|
||||
fun set3DAnchorColor(id: String, color: String) {
|
||||
updateMarkerProperty(id!!, "anchorColor", color)
|
||||
}
|
||||
|
||||
fun vrIcon(id: String, flag: Boolean) {
|
||||
updateMarkerProperty(id, "vrIcon", java.lang.Boolean.toString(flag))
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
//设置marker是否可以平贴
|
||||
fun setFlat(id: String, flat: Boolean) {
|
||||
updateMarkerProperty(id!!, "flat", flat.toString())
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--setFlat:${id},${flat}")
|
||||
}
|
||||
mMapController.setSomeAnchorFlat(id, flat)
|
||||
}
|
||||
|
||||
|
||||
//设置infowindow的偏移量
|
||||
fun setInfoWindowOffset(id: String, offsetX: Int, offsetY: Int) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--setInfoWindowOffset:${id},${offsetX},${offsetY}")
|
||||
}
|
||||
mMapController.setSomeAnchorInfowindowOffset(id, offsetX, offsetY)
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
fun setMarkerOptions(id: String?, markerPtions: MarkerOptions) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"markerop--setMarkerOptions:${id},${markerPtions}")
|
||||
}
|
||||
mMapController.updateAnchorByJson(id!!, JSON.toJSONString(markerPtions), ByteArray(0), 0, 0)
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
fun setUnTop(id: String) {
|
||||
mMapController.setSomeAnchorUnTop(id)
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
private fun refreshMap() {
|
||||
// val isRefresh = CommonController.instance.mapAutoView?.getLockCar()?:false
|
||||
// if(isRefresh){
|
||||
// CommonController.instance.mapView?.shakeSceneManual()
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
fun addImagetoImageManager(markerIconName: String, markerBytes: ByteArray, width: Int, height: Int ){
|
||||
if (!containMarkerIcon(markerIconName)) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--setIcon--addImagetoImageManager:${markerIconName}")
|
||||
}
|
||||
val result = mMapController.addImage(
|
||||
markerIconName,
|
||||
markerBytes,
|
||||
width,
|
||||
height
|
||||
)?:-1
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--setIcon--addImagetoImageManager:${markerIconName},result:${result},threadop:${Thread.currentThread().id}")
|
||||
}
|
||||
if (result == 0) {
|
||||
addMarkerIcon(markerIconName)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 更新marker资源
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
override fun updateMarkerResource(dataStr:String?) {
|
||||
dataStr?.let {
|
||||
val array = it.split(",")
|
||||
if(array.isEmpty()){
|
||||
return@let
|
||||
}
|
||||
val deleteList:ArrayList<String> = ArrayList<String>()
|
||||
for(id in markerInfoCacheMap.keys){
|
||||
if(!array.contains(id)){
|
||||
deleteList.add(id)
|
||||
}
|
||||
}
|
||||
for(id in deleteList){
|
||||
markerInfoCacheMap.remove(id)
|
||||
}
|
||||
deleteList.clear()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置锚点的动画资源
|
||||
*/
|
||||
fun setMarkerAnimResource(id: String?, resName: String) {
|
||||
mMapController.updateAnchorProperty(id!!, "animAnchorResource", resName)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置锚点的动画开关
|
||||
*/
|
||||
fun setMarkerDisplayAnimEnable(id: String?, isDisplayAnim: Boolean) {
|
||||
mMapController.updateAnchorProperty(id!!, "isDisplayAnim", "${isDisplayAnim}")
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置锚点的动画停顿帧数
|
||||
*/
|
||||
fun setMarkerAnimWaitFrame(id: String?, animWaitFrame: Int) {
|
||||
mMapController.updateAnchorProperty(id!!, "animWaitFrame", "${animWaitFrame}")
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置锚点的动画类型
|
||||
*/
|
||||
fun setMarkerAnimType(id: String?, animType: Int) {
|
||||
mMapController.updateAnchorProperty(id!!, "animType", "${animType}")
|
||||
}
|
||||
|
||||
fun setMarkerAnchorType(id: String?, anchorType: Int) {
|
||||
mMapController.updateAnchorProperty(id!!, "anchorType", "${anchorType}")
|
||||
}
|
||||
|
||||
fun setMarkerAnchorShadow(id: String?, anchorShadow: Int) {
|
||||
mMapController.updateAnchorProperty(id!!, "anchorShadow", "${anchorShadow}")
|
||||
}
|
||||
|
||||
fun setMarkerColorType(id: String?, colorType: Int) {
|
||||
mMapController.updateAnchorProperty(id!!, "colorType", "${colorType}")
|
||||
}
|
||||
|
||||
fun setMarkerChangerColorTime(id: String?, changerColorTime: Float) {
|
||||
mMapController.updateAnchorProperty(id!!, "changeColorTime", "${changerColorTime}")
|
||||
}
|
||||
|
||||
fun setMarkerChangeColorAngle(id: String?, changeColorAngle: Float) {
|
||||
mMapController.updateAnchorProperty(id!!, "changeColorAngle", "${changeColorAngle}")
|
||||
}
|
||||
|
||||
fun setMarkerFlash(id: String, colorType: Int, color: String, time: Float, angle: Float){
|
||||
mMapController.setAnchorFlash(id, colorType, color, time, angle)
|
||||
}
|
||||
|
||||
val charset = Charset.forName("UTF-8")
|
||||
|
||||
private fun dealMarker(markerPtions: MarkerOptions):ByteArray?{
|
||||
val buffer = Unpooled.buffer()
|
||||
buffer.writeCharSequence(markerPtions.getId(), charset)
|
||||
buffer.writeDouble(markerPtions.getLonLatPoint()!!.lon)
|
||||
buffer.writeDouble(markerPtions.getLonLatPoint()!!.lat)
|
||||
buffer.writeCharSequence(markerPtions.getTitle(), charset)
|
||||
buffer.writeCharSequence(markerPtions.getSnippet(), charset)
|
||||
buffer.writeFloat(markerPtions.getAnchorU())
|
||||
buffer.writeFloat(markerPtions.getAnchorV())
|
||||
buffer.writeBoolean(markerPtions.isVisible())
|
||||
buffer.writeFloat(markerPtions.getRotateAngle())
|
||||
buffer.writeBoolean(markerPtions.isInfoWindowEnable())
|
||||
buffer.writeBoolean(markerPtions.isInfoWindowShown())
|
||||
buffer.writeFloat(markerPtions.getAlpha())
|
||||
buffer.writeInt(markerPtions.getOffectX())
|
||||
buffer.writeInt(markerPtions.getOffectY())
|
||||
buffer.writeInt(markerPtions.period)
|
||||
buffer.writeBoolean(markerPtions.isClickable())
|
||||
buffer.writeInt(markerPtions.getZIndex())
|
||||
buffer.writeCharSequence(markerPtions.getMarkerIconName(),charset)
|
||||
return buffer.array()
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.zhidaoauto.map.sdk.inner.marker
|
||||
|
||||
import android.util.Log
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
|
||||
class RecycleController {
|
||||
private val TAG = javaClass.simpleName
|
||||
|
||||
public constructor() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private val renderList: HashSet<String> = HashSet<String>()
|
||||
private val recycleList: CopyOnWriteArrayList<String> = CopyOnWriteArrayList<String>()
|
||||
|
||||
private val idStart:AtomicLong = AtomicLong(99999999)
|
||||
|
||||
fun addRecycle(markerId: String) {
|
||||
if(!recycleList.contains(markerId)){
|
||||
recycleList.add(markerId)
|
||||
}
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "RecycleController--addRecycle: ${markerId},total:${recycleList.size}")
|
||||
}
|
||||
}
|
||||
|
||||
fun getRecycle(): String {
|
||||
var id =""
|
||||
if(recycleList.isEmpty()){
|
||||
// id = UUID.randomUUID().toString().replace("-","")
|
||||
id = idStart.addAndGet(1).toString()
|
||||
}else{
|
||||
id = recycleList.removeAt(0)
|
||||
if(id.isEmpty()){
|
||||
// id = UUID.randomUUID().toString().replace("-","")
|
||||
id = idStart.addAndGet(1).toString()
|
||||
}
|
||||
}
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "RecycleController--getRecycle: ${id},total:${recycleList.size}")
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
fun addRender(markerId: String){
|
||||
renderList.add(markerId)
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "RecycleController--addRender: ${markerId},total:${renderList.size}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun removeRender(markerId: String){
|
||||
renderList.remove(markerId)
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "RecycleController--removeRender: ${markerId},total:${renderList.size}")
|
||||
}
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
idStart.set(1)
|
||||
renderList.clear()
|
||||
recycleList.clear()
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,83 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.autonavi.nge.obj.SubCategory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Category implements Parcelable{
|
||||
|
||||
public static final Creator<com.autonavi.nge.obj.Category> CREATOR = new Creator<com.autonavi.nge.obj.Category>() {
|
||||
public com.autonavi.nge.obj.Category createFromParcel(Parcel in) {
|
||||
com.autonavi.nge.obj.Category category = new com.autonavi.nge.obj.Category();
|
||||
category.setCatName(in.readString());
|
||||
category.setKindId(in.readInt());
|
||||
category.setSubCategory(in.readArrayList(SubCategory.class.getClassLoader()));
|
||||
category.setSubNum(in.readInt());
|
||||
return category;
|
||||
}
|
||||
|
||||
public com.autonavi.nge.obj.Category[] newArray(int size) {
|
||||
return new com.autonavi.nge.obj.Category[size];
|
||||
}
|
||||
};
|
||||
|
||||
private String m_sCatName = "";
|
||||
private int m_iKindId = 0;
|
||||
private List<SubCategory> m_oSubCategory = null;
|
||||
private int m_iSubNum = 0;
|
||||
|
||||
public String getCatName() {
|
||||
return m_sCatName;
|
||||
}
|
||||
|
||||
public int getKindId() {
|
||||
return m_iKindId;
|
||||
}
|
||||
|
||||
public List<SubCategory> getSubCategory() {
|
||||
return m_oSubCategory;
|
||||
}
|
||||
|
||||
public int getSubNum() {
|
||||
return m_iSubNum;
|
||||
}
|
||||
|
||||
public void setCatName(String sCatName) {
|
||||
this.m_sCatName = sCatName;
|
||||
}
|
||||
|
||||
public void setKindId(int iKindId) {
|
||||
this.m_iKindId = iKindId;
|
||||
}
|
||||
|
||||
public void setSubCategory(List<SubCategory> subCateList) {
|
||||
this.m_oSubCategory = subCateList;
|
||||
}
|
||||
|
||||
public void setSubNum(int iSubNum) {
|
||||
this.m_iSubNum = iSubNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int arg1) {
|
||||
out.writeString(m_sCatName);
|
||||
out.writeInt(m_iKindId);
|
||||
out.writeList(m_oSubCategory);
|
||||
out.writeInt(m_iSubNum);
|
||||
}
|
||||
|
||||
public void readFromParcel(Parcel in) {
|
||||
m_sCatName = in.readString();
|
||||
m_iKindId = in.readInt();
|
||||
m_oSubCategory = in.readArrayList(SubCategory.class.getClassLoader());
|
||||
m_iSubNum = in.readInt();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj;
|
||||
|
||||
/**
|
||||
* 坐标基类
|
||||
*/
|
||||
public class Coordinate {
|
||||
private double x;
|
||||
private double y;
|
||||
|
||||
public Coordinate(double x, double y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj
|
||||
|
||||
class CustomDriveStep {
|
||||
// private String road;
|
||||
// private String orientation;
|
||||
// private float distance;
|
||||
// private float duration;
|
||||
var customTmcList: List<CustomTMC>? = null
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj
|
||||
|
||||
import com.autonavi.nge.map.LonLat
|
||||
|
||||
class CustomTMC {
|
||||
//长度
|
||||
// private int distance;
|
||||
//状态 0 畅通 1 缓行 2 拥堵 3 严重拥堵
|
||||
var status = 0
|
||||
|
||||
//道路点
|
||||
var polylines: List<LonLat> = ArrayList<LonLat>()
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj;
|
||||
|
||||
import com.autonavi.nge.obj.PoiBase;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Dest
|
||||
* @author
|
||||
*
|
||||
*/
|
||||
public class DestObj implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private PoiBase poi;
|
||||
private long ID;
|
||||
//0:添加的 1:回家 2:上班
|
||||
private int kind = 0;
|
||||
//创建时间
|
||||
private String strCreateDate;
|
||||
|
||||
public DestObj() {
|
||||
|
||||
}
|
||||
/**
|
||||
* 一般用于添加新Dest
|
||||
* @param poi
|
||||
* @param kind
|
||||
*/
|
||||
public DestObj(PoiBase poi) {
|
||||
this.poi = poi;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
|
||||
this.strCreateDate = sdf.format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 一般用于更新Dest
|
||||
* @param id
|
||||
* @param name
|
||||
* @param deslon
|
||||
* @param deslat
|
||||
* @param desname
|
||||
*/
|
||||
public DestObj(long id, String name, int deslon, int deslat, String desname) {
|
||||
PoiBase mPoiBase = new PoiBase(name, desname, deslon, deslat);
|
||||
this.poi = mPoiBase;
|
||||
this.ID = id;
|
||||
}
|
||||
|
||||
public PoiBase getPoi() {
|
||||
if(poi == null) //不应该出现
|
||||
poi = new PoiBase("", "", 0, 0);
|
||||
return poi;
|
||||
}
|
||||
public void setPoi(PoiBase poi) {
|
||||
this.poi = poi;
|
||||
}
|
||||
public long getId() {
|
||||
return ID;
|
||||
}
|
||||
public void setId(long ID) {
|
||||
this.ID = ID;
|
||||
}
|
||||
public int getKind() {
|
||||
return kind;
|
||||
}
|
||||
public void setKind(int kind) {
|
||||
this.kind = kind;
|
||||
}
|
||||
public String getCreateDate() {
|
||||
return strCreateDate;
|
||||
}
|
||||
public void setCreateDate(String strCreateDate) {
|
||||
this.strCreateDate = strCreateDate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj;
|
||||
|
||||
import com.autonavi.nge.obj.PoiBase;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class History implements Serializable {
|
||||
private static final long serialVersionUID = 759861585179477287L;
|
||||
|
||||
private PoiBase poi;
|
||||
private int ID;
|
||||
|
||||
public PoiBase getPoi() {
|
||||
return poi;
|
||||
}
|
||||
public void setPoi(PoiBase poi) {
|
||||
this.poi = poi;
|
||||
}
|
||||
public int getID() {
|
||||
return ID;
|
||||
}
|
||||
public void setID(int ID) {
|
||||
this.ID = ID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj
|
||||
|
||||
import com.zhidaoauto.map.sdk.open.nav.NavInfo
|
||||
|
||||
class NavMsg {
|
||||
var msgType:Int? = null
|
||||
var staus:Int? = null
|
||||
var navInfo:NavInfo? = null
|
||||
|
||||
constructor(msgType: Int?) {
|
||||
this.msgType = msgType
|
||||
}
|
||||
|
||||
constructor(msgType: Int?, staus: Int?, navInfo: NavInfo?) {
|
||||
this.msgType = msgType
|
||||
this.staus = staus
|
||||
this.navInfo = navInfo
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj
|
||||
|
||||
class NdsPoint {
|
||||
var lon:Long = 0L
|
||||
var lat:Long = 0L
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj;
|
||||
|
||||
import android.R;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import com.zhidaoauto.map.sdk.inner.element.MapCoordinate;
|
||||
|
||||
public class OverlayItem
|
||||
{
|
||||
protected final MapCoordinate m_Coordinate;
|
||||
protected final String m_Title;
|
||||
protected final String m_Snippet;
|
||||
protected Drawable m_Marker;
|
||||
|
||||
public static final int ITEM_STATE_FOCUSED_MASK = 4;
|
||||
public static final int ITEM_STATE_SELECTED_MASK = 2;
|
||||
public static final int ITEM_STATE_PRESSED_MASK = 1;
|
||||
private static final int ITEM_STATE_TO_STATE_SET[][] = {
|
||||
{
|
||||
-R.attr.state_focused, -R.attr.state_selected, -R.attr.state_pressed
|
||||
}, {
|
||||
-R.attr.state_focused, -R.attr.state_selected, R.attr.state_pressed
|
||||
}, {
|
||||
-R.attr.state_focused, R.attr.state_selected, -R.attr.state_pressed
|
||||
}, {
|
||||
-R.attr.state_focused, R.attr.state_selected, R.attr.state_pressed
|
||||
}, {
|
||||
R.attr.state_focused, -R.attr.state_selected, -R.attr.state_pressed
|
||||
}, {
|
||||
R.attr.state_focused, -R.attr.state_selected, R.attr.state_pressed
|
||||
}, {
|
||||
R.attr.state_focused, R.attr.state_selected, -R.attr.state_pressed
|
||||
}, {
|
||||
R.attr.state_focused, R.attr.state_selected, R.attr.state_pressed
|
||||
}
|
||||
};
|
||||
|
||||
public OverlayItem(MapCoordinate point, String title, String snippet)
|
||||
{
|
||||
m_Marker = null;
|
||||
m_Coordinate = point;
|
||||
m_Title = title;
|
||||
m_Snippet = snippet;
|
||||
}
|
||||
|
||||
public void setMarker(Drawable marker)
|
||||
{
|
||||
m_Marker = marker;
|
||||
}
|
||||
|
||||
public Drawable getMarker(int stateBitset)
|
||||
{
|
||||
if(m_Marker != null)
|
||||
{
|
||||
setState(m_Marker, stateBitset);
|
||||
}
|
||||
return m_Marker;
|
||||
}
|
||||
|
||||
public static void setState(Drawable drawable, int stateBitset)
|
||||
{
|
||||
drawable.setState(ITEM_STATE_TO_STATE_SET[stateBitset]);
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return m_Title;
|
||||
}
|
||||
|
||||
public String getSnippet()
|
||||
{
|
||||
return m_Snippet;
|
||||
}
|
||||
|
||||
public MapCoordinate getPoint()
|
||||
{
|
||||
return m_Coordinate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.autonavi.nge.obj.OverlayItem;
|
||||
import com.zhidaoauto.map.sdk.inner.element.MapCoordinate;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class PoiBase extends OverlayItem implements Parcelable, Serializable {
|
||||
|
||||
public static final Creator<PoiBase> CREATOR = new Creator<PoiBase>() {
|
||||
@Override
|
||||
public PoiBase createFromParcel(Parcel in) {
|
||||
String name = in.readString();
|
||||
String address = in.readString();
|
||||
String tel = in.readString();
|
||||
int x = in.readInt();
|
||||
int y = in.readInt();
|
||||
int id = in.readInt();
|
||||
return new PoiBase(name, address, tel, x, y, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PoiBase[] newArray(int size) {
|
||||
return new PoiBase[size];
|
||||
}
|
||||
};
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public String name = "";
|
||||
public String address = "";
|
||||
public String tel = "";
|
||||
public String sDeepDetail = "";
|
||||
public int nPicId = 0;
|
||||
public int x = 0;
|
||||
public int y = 0;
|
||||
public int id = 0;
|
||||
|
||||
public PoiBase(String name, String address, int x, int y) {
|
||||
super(new MapCoordinate(x, y), name, null);
|
||||
this.name = name;
|
||||
this.address = address;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public PoiBase(String name, String address, String tel, int x, int y) {
|
||||
super(new MapCoordinate(x, y), name, null);
|
||||
this.name = name;
|
||||
this.address = address;
|
||||
this.tel = tel;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public PoiBase(String name, String address, String tel, int x, int y, int id) {
|
||||
super(new MapCoordinate(x, y), name, null);
|
||||
this.name = name;
|
||||
this.address = address;
|
||||
this.tel = tel;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.id = id;
|
||||
}
|
||||
public PoiBase(String name, String address, String sDeepDetail ,String tel, int picId, int x, int y, int id, Drawable icon) {
|
||||
super(new MapCoordinate(x, y), name, null);
|
||||
this.name = name;
|
||||
this.address = address;
|
||||
this.tel = tel;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.id = id;
|
||||
this.nPicId = picId;
|
||||
this.sDeepDetail = sDeepDetail;
|
||||
if(null != icon) {
|
||||
m_Marker = icon;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getTel() {
|
||||
return tel;
|
||||
}
|
||||
|
||||
public void setTel(String tel) {
|
||||
this.tel = tel;
|
||||
}
|
||||
|
||||
public String getsDeepDetail() {
|
||||
return sDeepDetail;
|
||||
}
|
||||
|
||||
public void setsDeepDetail(String sDeepDetail) {
|
||||
this.sDeepDetail = sDeepDetail;
|
||||
}
|
||||
|
||||
public int getnPicId() {
|
||||
return nPicId;
|
||||
}
|
||||
|
||||
public void setnPicId(int nPicId) {
|
||||
this.nPicId = nPicId;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int arg1) {
|
||||
out.writeString(name);
|
||||
out.writeString(address);
|
||||
out.writeString(tel);
|
||||
out.writeInt(x);
|
||||
out.writeInt(y);
|
||||
out.writeInt(id);
|
||||
}
|
||||
|
||||
public void readFromParcel(Parcel in) {
|
||||
name = in.readString();
|
||||
address = in.readString();
|
||||
tel = in.readString();
|
||||
x = in.readInt();
|
||||
y = in.readInt();
|
||||
id = in.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PoiBase{" +
|
||||
"name='" + name + '\'' +
|
||||
", address='" + address + '\'' +
|
||||
", tel='" + tel + '\'' +
|
||||
", sDeepDetail='" + sDeepDetail + '\'' +
|
||||
", nPicId=" + nPicId +
|
||||
", x=" + x +
|
||||
", y=" + y +
|
||||
", id=" + id +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj
|
||||
|
||||
class Point {
|
||||
var x = 0.0
|
||||
var y = 0.0
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj
|
||||
|
||||
class PointData {
|
||||
var x:Double = 0.0
|
||||
var y:Double = 0.0
|
||||
var z:Double = 0.0
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 数据传输类
|
||||
*/
|
||||
public class ResultData implements Serializable {
|
||||
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
public class SubCategory implements Parcelable{
|
||||
|
||||
public static final Creator<com.autonavi.nge.obj.SubCategory> CREATOR = new Creator<com.autonavi.nge.obj.SubCategory>() {
|
||||
@Override
|
||||
public com.autonavi.nge.obj.SubCategory[] newArray(int size) {
|
||||
return new com.autonavi.nge.obj.SubCategory[size];
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.autonavi.nge.obj.SubCategory createFromParcel(Parcel in) {
|
||||
com.autonavi.nge.obj.SubCategory subCategory = new com.autonavi.nge.obj.SubCategory();
|
||||
subCategory.setKindId(in.readInt());
|
||||
subCategory.setCatName(in.readString());
|
||||
return subCategory;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int m_iKindId = 0;
|
||||
String m_sCatName = "";
|
||||
|
||||
public int getKindId() {
|
||||
return m_iKindId;
|
||||
}
|
||||
|
||||
public String getCatName() {
|
||||
return m_sCatName;
|
||||
}
|
||||
|
||||
public void setKindId(int iKindId) {
|
||||
this.m_iKindId = iKindId;
|
||||
}
|
||||
|
||||
public void setCatName(String sCatName) {
|
||||
this.m_sCatName = sCatName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int arg1) {
|
||||
out.writeInt(m_iKindId);
|
||||
out.writeString(m_sCatName);
|
||||
}
|
||||
|
||||
public void readFromParcel(Parcel in) {
|
||||
m_iKindId = in.readInt();
|
||||
m_sCatName = in.readString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj
|
||||
|
||||
class TrafficResult {
|
||||
var customDriveSteps: List<CustomDriveStep>? = null
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.zhidaoauto.map.sdk.inner.obj;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
public class UpdateRegion implements Parcelable{
|
||||
|
||||
public static final Creator<com.autonavi.nge.obj.UpdateRegion> CREATOR = new Creator<com.autonavi.nge.obj.UpdateRegion>() {
|
||||
|
||||
@Override
|
||||
public com.autonavi.nge.obj.UpdateRegion[] newArray(int size) {
|
||||
|
||||
return new com.autonavi.nge.obj.UpdateRegion[size];
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.autonavi.nge.obj.UpdateRegion createFromParcel(Parcel in) {
|
||||
com.autonavi.nge.obj.UpdateRegion updateRegion = new com.autonavi.nge.obj.UpdateRegion();
|
||||
updateRegion.setUrId(in.readInt());
|
||||
updateRegion.setUrNameId(in.readInt());
|
||||
updateRegion.setUrName(in.readString());
|
||||
return updateRegion;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int m_urId;
|
||||
int m_urNameId;
|
||||
String m_urName;
|
||||
|
||||
public int getUrId() {
|
||||
return m_urId;
|
||||
}
|
||||
|
||||
public void setUrId(int urId) {
|
||||
this.m_urId = urId;
|
||||
}
|
||||
|
||||
public int getUrNameId() {
|
||||
return m_urNameId;
|
||||
}
|
||||
|
||||
public void setUrNameId(int urNameId) {
|
||||
this.m_urNameId = urNameId;
|
||||
}
|
||||
|
||||
public String getUrName() {
|
||||
return m_urName;
|
||||
}
|
||||
|
||||
public void setUrName(String urName) {
|
||||
this.m_urName = urName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int arg1) {
|
||||
out.writeInt(m_urId);
|
||||
out.writeInt(m_urNameId);
|
||||
out.writeString(m_urName);
|
||||
}
|
||||
|
||||
public void readFromParcel(Parcel in) {
|
||||
m_urId = in.readInt();
|
||||
m_urNameId = in.readInt();
|
||||
m_urName = in.readString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.zhidaoauto.map.sdk.inner.panel;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Camera;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.zhidaoauto.map.sdk.R;
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig;
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController;
|
||||
import com.zhidaoauto.map.sdk.inner.map.MapController;
|
||||
import com.zhidaoauto.map.sdk.open.abs.MapStatusListener;
|
||||
|
||||
@SuppressLint("AppCompatCustomView")
|
||||
public class DirectionLayer extends ImageView implements MapStatusListener {
|
||||
|
||||
private static final String TAG = "DirectionLayer";
|
||||
private Drawable icon;
|
||||
private IMapController mMapController;
|
||||
private Matrix matrix = new Matrix();
|
||||
private Camera mCamera = new Camera();
|
||||
|
||||
public DirectionLayer(Context context){
|
||||
super(context);
|
||||
try{
|
||||
icon = context.getResources().getDrawable(R.mipmap.mapdir);
|
||||
}catch(Exception e){
|
||||
icon = null;
|
||||
}
|
||||
if(null == icon) {
|
||||
return;
|
||||
}
|
||||
if(CompileConfig.INSTANCE.getDEBUG()){
|
||||
Log.i(TAG,"autoop--DirectionLayer show");
|
||||
}
|
||||
icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
|
||||
//setBackgroundResource(R.drawable.btn_selecter);
|
||||
final float scale = getResources().getDisplayMetrics().density;
|
||||
int btnSize = getResources().getDimensionPixelSize(R.dimen.btn_size);
|
||||
setLayoutParams(new LayoutParams(btnSize, btnSize));
|
||||
int padding = (int) (5 * scale + 0.5f);
|
||||
setPadding(padding, padding, padding, padding);
|
||||
setImageDrawable(icon);
|
||||
}
|
||||
|
||||
public DirectionLayer(Context context,IMapController mapController){
|
||||
super(context);
|
||||
try{
|
||||
icon = context.getResources().getDrawable(R.mipmap.mapdir);
|
||||
}catch(Exception e){
|
||||
icon = null;
|
||||
}
|
||||
if(null == icon) {
|
||||
return;
|
||||
}
|
||||
if(CompileConfig.INSTANCE.getDEBUG()){
|
||||
Log.i(TAG,"autoop--DirectionLayer show");
|
||||
}
|
||||
icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
|
||||
//setBackgroundResource(R.drawable.btn_selecter);
|
||||
final float scale = getResources().getDisplayMetrics().density;
|
||||
int btnSize = getResources().getDimensionPixelSize(R.dimen.btn_size);
|
||||
setLayoutParams(new LayoutParams(btnSize, btnSize));
|
||||
int padding = (int) (5 * scale + 0.5f);
|
||||
setPadding(padding, padding, padding, padding);
|
||||
setImageDrawable(icon);
|
||||
mMapController = mapController;
|
||||
if(mMapController.getEventController() != null){
|
||||
mMapController.getEventController().addMapStatusListener(this, MapController.LISTENER_TYPE_3D | MapController.LISTENER_TYPE_ROTATE);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onDraw(Canvas canvas){
|
||||
if(null == mMapController) {
|
||||
return;
|
||||
}
|
||||
canvas.save();
|
||||
canvas.translate(getWidth() / 2, getHeight() / 2);
|
||||
// mCamera.save();
|
||||
// mCamera.rotateX(90 - mapController.getDAngle());
|
||||
// mCamera.getMatrix(matrix);
|
||||
// mCamera.restore();
|
||||
canvas.concat(matrix);
|
||||
canvas.rotate(mMapController.getMapViewRotation());
|
||||
canvas.translate(-getWidth() / 2, -getHeight() / 2);
|
||||
super.onDraw(canvas);
|
||||
canvas.restore();
|
||||
postInvalidate();
|
||||
}
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev){
|
||||
if(null == mMapController) {
|
||||
return true;
|
||||
}
|
||||
if(ev.getAction() == MotionEvent.ACTION_UP){
|
||||
// if(!CommonController.getInstance().getNaviController().getNaviStat()){
|
||||
// mapController.setMapViewRotation(0);
|
||||
// }
|
||||
if(mMapController.getMapViewPerspective() == MapController.MAP_PERSPECTIVE_2D){
|
||||
mMapController.setMapViewPerspective(MapController.MAP_PERSPECTIVE_3D);
|
||||
}else if(mMapController.getMapViewPerspective() == MapController.MAP_PERSPECTIVE_3D){
|
||||
mMapController.setMapViewPerspective(MapController.MAP_PERSPECTIVE_2D);
|
||||
}
|
||||
postInvalidate();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void onMapStatusChanged(int type, int value) {
|
||||
postInvalidate();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.zhidaoauto.map.sdk.inner.panel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.zhidaoauto.map.sdk.R;
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController;
|
||||
|
||||
public abstract class Panel extends LinearLayout{
|
||||
protected Context mContext;
|
||||
protected IMapController mMapController;
|
||||
protected FrameLayout.LayoutParams mLayoutParams;
|
||||
protected View mView;
|
||||
|
||||
protected Animation mTopInAnimation;
|
||||
protected Animation mTopOutAnimation;
|
||||
|
||||
protected Animation mLeftInAnimation;
|
||||
protected Animation mLeftOutAnimation;
|
||||
|
||||
protected Animation mRightInAnimation;
|
||||
protected Animation mRightOutAnimation;
|
||||
|
||||
public Panel(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
this.setClickable(true);
|
||||
mTopInAnimation = AnimationUtils.loadAnimation(mContext, R.anim.top_in);
|
||||
mTopOutAnimation = AnimationUtils.loadAnimation(mContext, R.anim.top_out);
|
||||
|
||||
mLeftInAnimation = AnimationUtils.loadAnimation(mContext, R.anim.left_in);
|
||||
mLeftOutAnimation = AnimationUtils.loadAnimation(mContext, R.anim.left_out);
|
||||
|
||||
mRightInAnimation = AnimationUtils.loadAnimation(mContext, R.anim.right_in);
|
||||
mRightOutAnimation = AnimationUtils.loadAnimation(mContext, R.anim.right_out);
|
||||
}
|
||||
|
||||
public Panel(Context context, IMapController mapController) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
this.mMapController = mapController;
|
||||
this.setClickable(true);
|
||||
mTopInAnimation = AnimationUtils.loadAnimation(mContext, R.anim.top_in);
|
||||
mTopOutAnimation = AnimationUtils.loadAnimation(mContext, R.anim.top_out);
|
||||
|
||||
mLeftInAnimation = AnimationUtils.loadAnimation(mContext, R.anim.left_in);
|
||||
mLeftOutAnimation = AnimationUtils.loadAnimation(mContext, R.anim.left_out);
|
||||
|
||||
mRightInAnimation = AnimationUtils.loadAnimation(mContext, R.anim.right_in);
|
||||
mRightOutAnimation = AnimationUtils.loadAnimation(mContext, R.anim.right_out);
|
||||
}
|
||||
|
||||
protected void remove(){
|
||||
ViewParent parent = this.getParent();
|
||||
if(parent != null && parent instanceof ViewGroup){
|
||||
((ViewGroup)parent).removeView(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean dispatchPanelKeyEvent(KeyEvent event){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
|
||||
protected void setContentView(int layoutResID, LayoutParams lauoutParams){
|
||||
if(mView == null){
|
||||
mView = LayoutInflater.from(mContext).inflate(layoutResID, null);
|
||||
addView(mView, lauoutParams);
|
||||
}
|
||||
}
|
||||
|
||||
protected View findVievById(int id){
|
||||
return mView.findViewById(id);
|
||||
}
|
||||
|
||||
protected void setMyGravity(int gravity){
|
||||
if(mLayoutParams == null){
|
||||
mLayoutParams = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
mLayoutParams.gravity = gravity;
|
||||
setLayoutParams(mLayoutParams);
|
||||
}
|
||||
|
||||
protected void setMargin(Integer top, Integer bottom, Integer left, Integer right){
|
||||
if(mLayoutParams == null){
|
||||
mLayoutParams = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
mLayoutParams.topMargin = top;
|
||||
mLayoutParams.bottomMargin = bottom;
|
||||
mLayoutParams.leftMargin = left;
|
||||
mLayoutParams.rightMargin = right;
|
||||
setLayoutParams(mLayoutParams);
|
||||
}
|
||||
|
||||
protected abstract void onShowPanel();
|
||||
protected abstract boolean onHidPanel();
|
||||
protected abstract void onPausePanel();
|
||||
protected abstract void onResumePanel();
|
||||
protected abstract void reset();
|
||||
protected abstract void setPos(Integer top, Integer bottom, Integer left, Integer right);
|
||||
protected abstract boolean onPrepareOptionsMenu(Menu menu);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.zhidaoauto.map.sdk.inner.panel
|
||||
|
||||
import android.content.Context
|
||||
import android.view.Gravity
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import com.zhidaoauto.map.sdk.R
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi
|
||||
import kotlinx.android.synthetic.main.panel_btn_location.view.btn_pos
|
||||
|
||||
class PanelBtnLocation(context: Context?,private val mMapController: IMapController) : Panel(context,mMapController), View.OnClickListener {
|
||||
override fun onClick(v: View) {
|
||||
if (v.id == R.id.btn_pos) {
|
||||
try {
|
||||
var location = mMapController.getLastKnownMogoLocation()
|
||||
if (location != null && location.longitude > 0 && location.latitude > 0) {
|
||||
mMapController!!.setCenter(location.longitude, location.latitude)
|
||||
mMapController.setFollowCarMode(true)
|
||||
} else {
|
||||
Toast.makeText(mContext, "定位中,请稍后", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onShowPanel() {}
|
||||
override fun onHidPanel(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onPausePanel() {}
|
||||
override fun onResumePanel() {}
|
||||
override fun reset() {}
|
||||
override fun setPos(
|
||||
top: Int, bottom: Int, left: Int,
|
||||
right: Int
|
||||
) {
|
||||
setMargin(top, bottom, left, right)
|
||||
}
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
init {
|
||||
setContentView(
|
||||
R.layout.panel_btn_location, LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
)
|
||||
setPos(0, 20, 10, 25)
|
||||
setMyGravity(Gravity.BOTTOM or Gravity.RIGHT)
|
||||
val style = mMapController.getMapStyleParams().getStyleMode()
|
||||
if(style == MapAutoApi.MAP_STYLE_DAY || style == MapAutoApi.MAP_STYLE_DAY_VR){
|
||||
btn_pos.setImageResource(R.mipmap.icon_location_day)
|
||||
}else{
|
||||
btn_pos.setImageResource(R.mipmap.icon_location_night)
|
||||
}
|
||||
isClickable = false
|
||||
btn_pos.setOnClickListener(this)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.zhidaoauto.map.sdk.inner.panel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
|
||||
import com.zhidaoauto.map.sdk.R;
|
||||
|
||||
|
||||
public class PanelBtnLogo extends Panel {
|
||||
public PanelBtnLogo(Context context) {
|
||||
super(context);
|
||||
|
||||
setContentView(R.layout.panel_btn_logo, new LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
||||
setPos(0, 30, 100, 0);
|
||||
setMyGravity(Gravity.LEFT | Gravity.BOTTOM);
|
||||
|
||||
this.setFocusableInTouchMode(false);
|
||||
this.setFocusable(false);
|
||||
this.setClickable(false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onShowPanel() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onHidPanel() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPausePanel() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResumePanel() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reset() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPos(Integer top, Integer bottom, Integer left,
|
||||
Integer right) {
|
||||
setMargin(top, bottom, left, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onPrepareOptionsMenu(Menu menu) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.zhidaoauto.map.sdk.inner.panel;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.zhidaoauto.map.sdk.R;
|
||||
|
||||
public class PanelBtnRightTop extends Panel implements OnClickListener {
|
||||
|
||||
private FrameLayout mBtnGPS;
|
||||
private TextView mTvGpsNun;
|
||||
private SatelliteSkyView mSkyView;
|
||||
private Dialog mDialogGPS;
|
||||
|
||||
// private Button mBtnScale;
|
||||
|
||||
private static final int MSG_RESET = 0;
|
||||
|
||||
private long[] mHits;
|
||||
|
||||
private Handler mResetHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_RESET:
|
||||
mTvGpsNun.setText(String.valueOf(mSkyView.getGPSSatellites()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public PanelBtnRightTop(Context context) {
|
||||
super(context);
|
||||
this.setClickable(false);
|
||||
setContentView(R.layout.layout_panel_btn_top_right, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
||||
setGravity(Gravity.RIGHT | Gravity.TOP);
|
||||
setPadding(0, 10, 10, 0);
|
||||
|
||||
mBtnGPS = (FrameLayout) findVievById(R.id.panel_btn_gps);
|
||||
mBtnGPS.setOnClickListener(this);
|
||||
|
||||
mTvGpsNun = (TextView) findVievById(R.id.panel_text_gps);
|
||||
|
||||
mSkyView = new SatelliteSkyView(context);
|
||||
mSkyView.Resume();
|
||||
mDialogGPS = new Dialog(mContext, R.style.Dialog_Fullscreen);
|
||||
mDialogGPS.setOwnerActivity((Activity) mContext);
|
||||
LinearLayout layout = new LinearLayout(mContext);
|
||||
layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
||||
layout.addView(mSkyView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
||||
mDialogGPS.addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
||||
|
||||
mHits = new long[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.panel_btn_gps) {
|
||||
mDialogGPS.show();
|
||||
// case R.id.panel_btn_scale:
|
||||
// System.arraycopy(mHits, 1, mHits, 0, mHits.length-1);
|
||||
// mHits[mHits.length-1] = SystemClock.uptimeMillis();
|
||||
// if (mHits[0] >= (SystemClock.uptimeMillis()-500)) {
|
||||
// Toast.makeText(mContext, "guidanceView", Toast.LENGTH_SHORT).show();
|
||||
// mApplication.getMapAct().getPanelManager().setPanel(PanelManager.PANEL_WHAT_SET_MODE, PanelManager.PANEL_MODE_GUIDANCE);
|
||||
// }
|
||||
// break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onShowPanel() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onHidPanel() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPausePanel() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResumePanel() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reset() {
|
||||
mResetHandler.sendEmptyMessage(MSG_RESET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPos(Integer top, Integer bottom, Integer left,
|
||||
Integer right) {
|
||||
setMargin(top, bottom, left, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onPrepareOptionsMenu(Menu menu) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
package com.zhidaoauto.map.sdk.inner.panel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.zhidaoauto.map.sdk.R;
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController;
|
||||
import com.zhidaoauto.map.sdk.inner.map.MapController;
|
||||
import com.zhidaoauto.map.sdk.open.abs.MapStatusListener;
|
||||
|
||||
|
||||
public class PanelBtnScale extends Panel implements MapStatusListener {
|
||||
|
||||
private static final int MSG_SETSCALE = 1;
|
||||
int baseLenght;
|
||||
/**
|
||||
* 比例尺
|
||||
*/
|
||||
TextView tv_scale, tv_scale_bg;
|
||||
protected Handler mHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_SETSCALE:
|
||||
if (msg.arg1 < mapscale.length) {
|
||||
tv_scale.setText(mapscale[msg.arg1]);
|
||||
if (msg.arg2 > 0) {
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) tv_scale
|
||||
.getLayoutParams();
|
||||
if (params != null) {
|
||||
params.width = msg.arg2;
|
||||
tv_scale_bg.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(mContext, "传入的地图级别错误", Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 地图级别文字
|
||||
*/
|
||||
String[] mapscale;
|
||||
Resources res;
|
||||
float[] mapdist;
|
||||
|
||||
public PanelBtnScale(Context context,IMapController mapController) {
|
||||
super(context,mapController);
|
||||
|
||||
setContentView(R.layout.panel_btn_scale, new LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
||||
setPos(0, 75, 100, 0);
|
||||
setMyGravity(Gravity.LEFT | Gravity.BOTTOM);
|
||||
|
||||
tv_scale = (TextView) findVievById(R.id.tv_scale);
|
||||
tv_scale_bg = (TextView) findVievById(R.id.tv_scale_bg);
|
||||
res = context.getResources();
|
||||
mapscale = res.getStringArray(R.array.mapscale);
|
||||
baseLenght = (int) res.getDimensionPixelSize(R.dimen.scale);
|
||||
if (res.getDisplayMetrics().widthPixels < 1000) {
|
||||
baseLenght = 5;
|
||||
}
|
||||
String[] distStr = res.getStringArray(R.array.mapdist);
|
||||
mapdist = new float[distStr.length];
|
||||
for (int i = 0; i < distStr.length; i++) {
|
||||
mapdist[i] = Float.parseFloat(distStr[i]);
|
||||
}
|
||||
|
||||
tv_scale.setClickable(false);
|
||||
this.setFocusableInTouchMode(false);
|
||||
this.setFocusable(false);
|
||||
this.setClickable(false);
|
||||
|
||||
if(mMapController.getEventController() != null){
|
||||
mMapController.getEventController().addMapStatusListener(this, MapController.LISTENER_TYPE_ZOOM);
|
||||
}
|
||||
mMapController.dispatchZoomChanged();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置地图级别
|
||||
*
|
||||
* @param level 地图级别
|
||||
* @param scaleLength 比例尺的长度 scaleLength<=0表示使用默认参数 此处传入dp即可,代码里已做转换
|
||||
*/
|
||||
public void setMapScale(int level, int scaleLength) {
|
||||
mHandler.removeMessages(MSG_SETSCALE);// 取消不必要的放大缩小
|
||||
Message msg = new Message();
|
||||
msg.what = MSG_SETSCALE;
|
||||
msg.arg1 = level;
|
||||
// msg.arg2 = DensityChangeUtil.dip2px(mContext,(float)scaleLength);
|
||||
msg.arg2 = scaleLength;
|
||||
mHandler.sendMessageDelayed(msg, 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onShowPanel() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onHidPanel() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPausePanel() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResumePanel() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reset() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPos(Integer top, Integer bottom, Integer left,
|
||||
Integer right) {
|
||||
setMargin(top, bottom, left, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onPrepareOptionsMenu(Menu menu) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapStatusChanged(int type, int value) {
|
||||
if(mMapController ==null){
|
||||
return;
|
||||
}
|
||||
float dist = mMapController.getRulerInfo();
|
||||
|
||||
//南北极
|
||||
if (0.5f >= dist) {
|
||||
dist = 50000.0f;
|
||||
}
|
||||
|
||||
int index = mapdist.length - 1;
|
||||
for (int i = 0; i < mapdist.length; i++) {
|
||||
if (dist <= mapdist[i]) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index > mapscale.length - 1) {
|
||||
index = mapscale.length - 1;
|
||||
}
|
||||
String ltext = mapscale[index];
|
||||
float scale = 0;
|
||||
if (ltext.endsWith("km")) {
|
||||
scale = Float.parseFloat(ltext.substring(0, ltext.length() - 2)) * 1000;
|
||||
} else if (ltext.endsWith("m")) {
|
||||
scale = Float.parseFloat(ltext.substring(0, ltext.length() - 1));
|
||||
}
|
||||
int scaleLength = (int) (100 * scale / dist);
|
||||
setMapScale(index, baseLenght + scaleLength);
|
||||
// setMapScale(index, scaleLength);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
if(mMapController ==null){
|
||||
return;
|
||||
}
|
||||
if(mMapController.getEventController() != null) {
|
||||
mMapController.getEventController().removeMapStatusListener(this, MapController.LISTENER_TYPE_ZOOM);
|
||||
}
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package com.zhidaoauto.map.sdk.inner.panel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.zhidaoauto.map.sdk.R;
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController;
|
||||
|
||||
|
||||
public class PanelBtnZoom extends Panel implements OnClickListener {
|
||||
|
||||
private Button mBtnZoomOut, mBtnZoomIn, mBtnZoomCountry,
|
||||
mBtnZoomProvincial, mBtnZoomCity, mBtnZoomRoad;
|
||||
private LinearLayout mLayoutZoom, mLayoutZoomValue;
|
||||
private boolean isLayoutZoomValueShow = false;
|
||||
private static final int MSG_HID = 0;
|
||||
|
||||
protected Handler mHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_HID:
|
||||
mLayoutZoomValue.setVisibility(View.GONE);
|
||||
isLayoutZoomValueShow = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public PanelBtnZoom(Context context,IMapController mMapController) {
|
||||
super(context,mMapController);
|
||||
|
||||
setContentView(R.layout.panel_btn_zoom_ctrl, new LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
||||
setMyGravity(Gravity.RIGHT | Gravity.CENTER);
|
||||
setPos(0, 0, 0, 10);
|
||||
mBtnZoomOut = (Button) findVievById(R.id.btn_zoom_out);
|
||||
mBtnZoomOut.setOnClickListener(this);
|
||||
mBtnZoomIn = (Button) findVievById(R.id.btn_zoom_in);
|
||||
mBtnZoomIn.setOnClickListener(this);
|
||||
|
||||
mLayoutZoom = (LinearLayout) findVievById(R.id.layout_zoom);
|
||||
mLayoutZoom.setOnClickListener(this);
|
||||
mLayoutZoomValue = (LinearLayout) findVievById(R.id.layout_zoom_value);
|
||||
|
||||
mBtnZoomCountry = (Button) findVievById(R.id.btn_zoom_country);
|
||||
mBtnZoomCountry.setOnClickListener(this);
|
||||
|
||||
mBtnZoomProvincial = (Button) findVievById(R.id.btn_zoom_provincial);
|
||||
mBtnZoomProvincial.setOnClickListener(this);
|
||||
|
||||
mBtnZoomCity = (Button) findVievById(R.id.btn_zoom_city);
|
||||
mBtnZoomCity.setOnClickListener(this);
|
||||
|
||||
mBtnZoomRoad = (Button) findVievById(R.id.btn_zoom_road);
|
||||
mBtnZoomRoad.setOnClickListener(this);
|
||||
|
||||
|
||||
this.setFocusableInTouchMode(false);
|
||||
this.setFocusable(false);
|
||||
this.setClickable(false);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mHandler.removeMessages(MSG_HID);
|
||||
int id = v.getId();
|
||||
if (id == R.id.btn_zoom_out) {
|
||||
mMapController.zoomOut();
|
||||
|
||||
} else if (id == R.id.btn_zoom_in) {
|
||||
mMapController.zoomIn();
|
||||
} else if (id == R.id.layout_zoom) {
|
||||
if (isLayoutZoomValueShow) {
|
||||
mLayoutZoomValue.setVisibility(View.GONE);
|
||||
isLayoutZoomValueShow = false;
|
||||
} else {
|
||||
mLayoutZoomValue.setVisibility(View.VISIBLE);
|
||||
isLayoutZoomValueShow = true;
|
||||
}
|
||||
hidZoomValueLayout();
|
||||
} else if (id == R.id.btn_zoom_country) {
|
||||
Toast.makeText(mContext, "国家", Toast.LENGTH_SHORT).show();
|
||||
hidZoomValueLayout();
|
||||
mMapController.setZoom(8);
|
||||
} else if (id == R.id.btn_zoom_provincial) {
|
||||
Toast.makeText(mContext, "省际", Toast.LENGTH_SHORT).show();
|
||||
hidZoomValueLayout();
|
||||
mMapController.setZoom(8);
|
||||
} else if (id == R.id.btn_zoom_city) {
|
||||
Toast.makeText(mContext, "城市", Toast.LENGTH_SHORT).show();
|
||||
hidZoomValueLayout();
|
||||
mMapController.setZoom(16);
|
||||
} else if (id == R.id.btn_zoom_road) {
|
||||
Toast.makeText(mContext, "街道", Toast.LENGTH_SHORT).show();
|
||||
hidZoomValueLayout();
|
||||
mMapController.setZoom(19);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onShowPanel() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onHidPanel() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPausePanel() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResumePanel() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reset() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPos(Integer top, Integer bottom, Integer left,
|
||||
Integer right) {
|
||||
setMargin(top, bottom, left, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onPrepareOptionsMenu(Menu menu) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void hidZoomValueLayout() {
|
||||
mHandler.removeMessages(MSG_HID);
|
||||
mHandler.sendEmptyMessageDelayed(MSG_HID, 3000);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.zhidaoauto.map.sdk.inner.panel;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
public class PanelConstructor {
|
||||
protected static Panel construct(String className, Context context, IMapController mapController){
|
||||
try {
|
||||
Class<?> clazz = Class.forName(className); //创建一个Class对象,用于描述Person类
|
||||
|
||||
/**
|
||||
* 调用有参的构造方法
|
||||
*/
|
||||
Class<?>[] argTypes = {Context.class}; //指明所要调用的构造方法的形参
|
||||
Constructor<?> constructor = clazz.getConstructor(argTypes);//获取指定参数的构造方法
|
||||
Panel panel = (Panel) constructor.newInstance(context,mapController);
|
||||
return panel;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.zhidaoauto.map.sdk.inner.panel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController;
|
||||
|
||||
public class PanelDirction extends Panel{
|
||||
private DirectionLayer directionLayer;
|
||||
|
||||
public PanelDirction(Context context) {
|
||||
super(context);
|
||||
setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
||||
setGravity(Gravity.LEFT | Gravity.TOP);
|
||||
setPadding(10, 10, 0, 0);
|
||||
directionLayer = new DirectionLayer(mContext);
|
||||
this.addView(directionLayer);
|
||||
}
|
||||
|
||||
public PanelDirction(Context context, IMapController mapController) {
|
||||
super(context,mapController);
|
||||
setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
||||
setGravity(Gravity.LEFT | Gravity.TOP);
|
||||
setPadding(10, 10, 0, 0);
|
||||
directionLayer = new DirectionLayer(mContext);
|
||||
this.addView(directionLayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onShowPanel() {
|
||||
if( View.VISIBLE == getVisibility()) {
|
||||
return;
|
||||
}
|
||||
setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onHidPanel() {
|
||||
if( View.VISIBLE == getVisibility())
|
||||
{
|
||||
setVisibility(View.INVISIBLE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPausePanel() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResumePanel() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reset() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPos(Integer top, Integer bottom, Integer left,
|
||||
Integer right) {
|
||||
setMargin(top, bottom, left, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onPrepareOptionsMenu(Menu menu) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,579 @@
|
||||
//package com.zhidaoauto.map.sdk.inner.panel
|
||||
//
|
||||
//import android.content.Context
|
||||
//import android.graphics.*
|
||||
//import android.graphics.drawable.BitmapDrawable
|
||||
//import android.graphics.drawable.Drawable
|
||||
//import android.util.Log
|
||||
//import android.view.Gravity
|
||||
//import android.view.KeyEvent
|
||||
//import android.view.Menu
|
||||
//import android.view.View
|
||||
//import android.widget.LinearLayout
|
||||
//import android.widget.Toast
|
||||
//import com.autonavi.nge.guidance.LaneMarkTools
|
||||
//import com.autonavi.nge.guidance.NaviDirRes
|
||||
//import com.autonavi.nge.guidance.NaviInfo
|
||||
//import com.zhidaoauto.map.sdk.R
|
||||
//import com.zhidaoauto.map.sdk.inner.CompileConfig.DEBUG
|
||||
//import com.zhidaoauto.map.sdk.inner.controller.CommonController
|
||||
//import com.zhidaoauto.map.sdk.inner.element.MapCoordinate
|
||||
//import com.zhidaoauto.map.sdk.inner.utils.CommonUtils
|
||||
//import com.zhidaoauto.map.sdk.inner.utils.Constant.getDisString
|
||||
//import com.zhidaoauto.map.sdk.inner.utils.Constant.getRoadIsHighRoad
|
||||
//import com.zhidaoauto.map.sdk.inner.utils.Constant.getTimeString
|
||||
//import com.zhidaoauto.map.sdk.inner.utils.PubFunction
|
||||
//import kotlinx.android.synthetic.main.layout_panel_guidance.view.*
|
||||
//
|
||||
//class PanelGuidance(context: Context?) :
|
||||
// Panel(context), View.OnClickListener {
|
||||
//// private val mBtnRouteShowMode: Button
|
||||
// private var isShowAllRoute = false
|
||||
//// private val iv_guidance_next_road: ImageView
|
||||
//// private val iv_guidance_line: ImageView
|
||||
//// private val iv_next_guidance_icon: ImageView
|
||||
//// private val tv_guidance_over_time: TextView
|
||||
//// private val tv_guidance_over_mileage: TextView
|
||||
//// private val iv_guidance_over_mileage: ImageView
|
||||
//// private val tv_guidance_next_road: TextView
|
||||
//// private val iv_guidance_next_road_over_mileage //当前路口距离
|
||||
//// : TextView
|
||||
//// private val iv_guidance_next_turn_over_mileage //下一路口距离
|
||||
//// : TextView
|
||||
//// private val iv_3d_route_BG //看版图背景
|
||||
//// : ImageView
|
||||
//// private val iv_3d_route_Arrow //看版图箭头
|
||||
//// : ImageView
|
||||
//
|
||||
// private var m_BGBitmap: Bitmap? = null
|
||||
// private var m_ArrowBitmap: Bitmap? = null
|
||||
// private var m_SGPBGBitmap: Bitmap? = null
|
||||
// private var m_SGPArrowBitmap: Bitmap? = null
|
||||
// private var m_BGID = 0
|
||||
// private var m_ArrowID = 0
|
||||
// private var m_SGPBGID = 0
|
||||
// private var m_SGPArrowID = 0
|
||||
// private var mSimNaviSpeed = 1
|
||||
//
|
||||
// var layout: LinearLayout
|
||||
// var mLayoutParams_next_road: LinearLayout.LayoutParams
|
||||
//// var mLayoutParams_progress: LinearLayout.LayoutParams
|
||||
// private var isProgressShow = false
|
||||
// private var mMatrix = Matrix()
|
||||
// var m_LaneTools: LaneMarkTools? = null
|
||||
// var mWidth: Int = 0
|
||||
// var mHeight: Int = 0
|
||||
// var progress = 0
|
||||
// override fun onShowPanel() {
|
||||
// if (DEBUG) {
|
||||
// Log.i(TAG, "navop-onShowPanel:")
|
||||
// }
|
||||
// mWidth = this.resources.displayMetrics.widthPixels
|
||||
//
|
||||
// CommonController.instance.panelManager?.setPanelPos(
|
||||
// PanelManager.PANEL_MODE_MAP,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0
|
||||
// )
|
||||
// if (CommonController.instance.naviController!!.isSimNavi()) {
|
||||
// mSimNaviSpeed = 4
|
||||
// }
|
||||
// if (DEBUG) {
|
||||
// Log.i(TAG, "navop-PanelGuidance: onShowPanel")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onHidPanel(): Boolean {
|
||||
// CommonController.instance.panelManager?.setPanelPos(PanelManager.PANEL_MODE_MAP, 0, 0, 0, 0)
|
||||
// if (DEBUG) {
|
||||
// Log.i(TAG, "navop-PanelGuidance: onHidPanel")
|
||||
// }
|
||||
// return true
|
||||
// }
|
||||
//
|
||||
// override fun onPausePanel() {}
|
||||
// override fun onResumePanel() {}
|
||||
// override fun reset() {
|
||||
// if (DEBUG) {
|
||||
// Log.i(
|
||||
// TAG,
|
||||
// "navop-PanelGuidance: reset"
|
||||
// )
|
||||
// }
|
||||
// var naviinfo: NaviInfo? = null
|
||||
// try {
|
||||
// naviinfo = CommonController.instance.iNavigationCore?.Guidance_NaviInfo()
|
||||
// if (naviinfo == null) {
|
||||
// return
|
||||
// }
|
||||
// // 当前中心点
|
||||
// val center =
|
||||
// CommonController.instance
|
||||
// .mapController
|
||||
// ?.getCenter()
|
||||
// // 目的地
|
||||
// val dest =
|
||||
// CommonController.instance
|
||||
// .naviController
|
||||
// ?.getEndPoi()
|
||||
// // 绑定点
|
||||
// val bind =
|
||||
// MapCoordinate(
|
||||
// (naviinfo.m_nBindLon * 3.6).toInt(),
|
||||
// (naviinfo.m_nBindLat * 3.6).toInt()
|
||||
// )
|
||||
// val angle_centerToEnd =
|
||||
// PubFunction.GetLineAngle(
|
||||
// center,
|
||||
// dest
|
||||
// ).toFloat()
|
||||
// val angle_mapView =
|
||||
// CommonController.instance
|
||||
// .mapController
|
||||
// ?.getMapViewRotation() ?: 0f
|
||||
// val angle_bindToEnd = PubFunction
|
||||
// .GetLineAngle(bind, dest).toFloat()
|
||||
// var bitmap1 = (resources.getDrawable(
|
||||
// R.mipmap.ui_navigate
|
||||
// ) as BitmapDrawable).bitmap
|
||||
// // 设
|
||||
// mMatrix.setRotate(angle_centerToEnd + angle_mapView)
|
||||
// // 重新绘制Bitmap
|
||||
// bitmap1 = Bitmap.createBitmap(
|
||||
// bitmap1, 0, 0, bitmap1.width,
|
||||
// bitmap1.height, mMatrix, true
|
||||
// )
|
||||
// iv_guidance_over_mileage.setImageBitmap(bitmap1)
|
||||
// val carPos = MapCoordinate()
|
||||
// val type = CommonController.instance.mapController?.getCarPosition(carPos) ?: 0
|
||||
// if (type > 0) {
|
||||
// val x = carPos.x
|
||||
// val y = carPos.y
|
||||
// var angle = 0
|
||||
// when (type) {
|
||||
// 1 -> angle = 270
|
||||
// 2 -> angle = 0
|
||||
// 3 -> angle = 90
|
||||
// 4 -> angle = 180
|
||||
// }
|
||||
// var bitmap2 = (resources.getDrawable(
|
||||
// R.mipmap.arrow
|
||||
// ) as BitmapDrawable).bitmap // 设
|
||||
// val matrix = Matrix()
|
||||
// matrix.setRotate(angle.toFloat())
|
||||
// bitmap2 = Bitmap.createBitmap(
|
||||
// bitmap2, 0, 0,
|
||||
// bitmap2.width, bitmap2.height, matrix, true
|
||||
// )
|
||||
// iv_guidance_bind_car_arrow.setImageBitmap(bitmap2)
|
||||
// iv_guidance_bind_car_arrow.setPadding(x, y, 0, 0)
|
||||
// iv_guidance_bind_car_arrow.visibility = View.VISIBLE
|
||||
// } else {
|
||||
// iv_guidance_bind_car_arrow.visibility = View.INVISIBLE
|
||||
// }
|
||||
// guidance_tv_speed.text = naviinfo.m_nSpeed.toString() + "km/h"
|
||||
// if (naviinfo.m_EntranceDist == 0 && naviinfo.m_ServerDist == 0 && naviinfo.m_ExitDist == 0
|
||||
// ) {
|
||||
// guidance_layout_server_enter.visibility = View.GONE
|
||||
// }
|
||||
// if (naviinfo.m_EntranceDist > 0) {
|
||||
// guidance_enter_image.visibility = View.VISIBLE
|
||||
// tv_guidance_enter_dis.text = (""
|
||||
// + getDisString(naviinfo.m_EntranceDist))
|
||||
// iv_guidance_enter_icon.text = "入口"
|
||||
// iv_guidance_enter_icon
|
||||
// .setBackgroundDrawable(
|
||||
// getPanelImage(
|
||||
// Color.argb(
|
||||
// 255, 0,
|
||||
// 51, 255
|
||||
// )
|
||||
// )
|
||||
// )
|
||||
// } else {
|
||||
// guidance_enter_image.visibility = View.GONE
|
||||
// }
|
||||
// if (naviinfo.m_ExitDist > 0) {
|
||||
// guidance_exit_image.visibility = View.VISIBLE
|
||||
// tv_guidance_exit_dis.text = (""
|
||||
// + getDisString(naviinfo.m_ExitDist))
|
||||
// iv_guidance_exit_icon.text = "出口"
|
||||
// iv_guidance_exit_icon.setBackgroundDrawable(
|
||||
// getPanelImage(
|
||||
// Color
|
||||
// .argb(255, 0, 51, 255)
|
||||
// )
|
||||
// )
|
||||
// } else {
|
||||
// guidance_exit_image.visibility = View.GONE
|
||||
// }
|
||||
// if (naviinfo.m_ServerDist > 0) {
|
||||
// guidance_server_image.visibility = View.VISIBLE
|
||||
// tv_guidance_server_dis.text = (""
|
||||
// + getDisString(naviinfo.m_ServerDist))
|
||||
// iv_guidance_server_icon.text = "服务区"
|
||||
// iv_guidance_server_icon
|
||||
// .setBackgroundDrawable(
|
||||
// getPanelImage(
|
||||
// Color.argb(
|
||||
// 255,
|
||||
// 36, 36, 219
|
||||
// )
|
||||
// )
|
||||
// )
|
||||
// } else {
|
||||
// guidance_server_image.visibility = View.GONE
|
||||
// }
|
||||
// tv_guidance_over_mileage.text = getDisString(naviinfo.m_nDistanceToDest)
|
||||
// tv_guidance_over_time.text = getTimeString(naviinfo.m_nTimeToDest)
|
||||
// tv_next_road.text = naviinfo.m_pStrNextName
|
||||
// tv_guidance_next_road.text = naviinfo.m_pStrNextName
|
||||
// iv_guidance_next_road.setImageResource(NaviDirRes.getNaviResID(naviinfo.m_nTurnID))
|
||||
// iv_guidance_next_road_over_mileage.text = getDisString(naviinfo.m_nDistanceToTurn)
|
||||
// if(naviinfo.m_nNextTurn == 1) {
|
||||
// lin_next_turn.visibility = VISIBLE
|
||||
// iv_guidance_next_turn.setImageResource(NaviDirRes.getNextNaviResID(naviinfo.m_nNextTurnID))
|
||||
// iv_guidance_next_road_trun_mileage.text = getDisString(naviinfo.m_nDistanceToNextTurn)
|
||||
// }else{
|
||||
// lin_next_turn.visibility = GONE
|
||||
// }
|
||||
//// tv_guidance_progress.text = "" + naviinfo.m_nDistanceToTurn
|
||||
// val name = getRoadIsHighRoad(naviinfo.m_pStrNextName)
|
||||
// if (name != null) {
|
||||
// tv_guidance_next_road_two_name.visibility = View.VISIBLE
|
||||
// tv_guidance_next_road_two_name.text = name
|
||||
// tv_guidance_next_road_two_name.setBackgroundDrawable(
|
||||
// getPanelImage(
|
||||
// Color
|
||||
// .argb(255, 8, 72, 152)
|
||||
// )
|
||||
// )
|
||||
// } else {
|
||||
// tv_guidance_next_road_two_name.visibility = View.GONE
|
||||
// }
|
||||
// if (naviinfo.m_IsExport.toInt() == 1) {
|
||||
// tv_guidance_next_export.visibility = View.VISIBLE
|
||||
// tv_guidance_next_export.text = "出"
|
||||
// tv_guidance_next_export.setBackgroundDrawable(
|
||||
// getPanelImage(
|
||||
// Color.argb(
|
||||
// 255, 204, 204, 33
|
||||
// )
|
||||
// )
|
||||
// )
|
||||
// } else {
|
||||
// tv_guidance_next_export.visibility = View.GONE
|
||||
// }
|
||||
// if (naviinfo.m_nImageType.toInt() == 1 && naviinfo.m_nImageBg > 0 && naviinfo.m_nImageArrow > 0
|
||||
// ) {
|
||||
// iv_guidance_3d_route_bg.visibility = View.VISIBLE
|
||||
// iv_guidance_3d_route_arrow.visibility = View.VISIBLE
|
||||
// iv_guidance_next_road.visibility = View.VISIBLE
|
||||
// guidance_progressBar.visibility = VISIBLE
|
||||
// if(progress == 0) {
|
||||
// guidance_progressBar.setMax(naviinfo.m_nDistanceToTurn)
|
||||
// }
|
||||
// guidance_progressBar.setProgress(naviinfo.m_nDistanceToTurn)
|
||||
// progress = naviinfo.m_nDistanceToTurn
|
||||
// if (m_BGID != naviinfo.m_nImageBg
|
||||
// || m_ArrowID != naviinfo.m_nImageArrow
|
||||
// ) {
|
||||
// val routeimage = CommonController.instance.iNavigationCore?.Guidance_Image(
|
||||
// naviinfo.m_nImageUr,
|
||||
// naviinfo.m_nImageBg,
|
||||
// naviinfo.m_nImageArrow, 0
|
||||
// )
|
||||
// if (m_BGBitmap != null) {
|
||||
// m_BGBitmap!!.recycle()
|
||||
// }
|
||||
// m_BGBitmap = null
|
||||
// if (m_ArrowBitmap != null) {
|
||||
// m_ArrowBitmap!!.recycle()
|
||||
// }
|
||||
// m_ArrowBitmap = null
|
||||
//
|
||||
// // 记录下载历史的展现的图片
|
||||
// m_BGBitmap = BitmapFactory.decodeByteArray(
|
||||
// routeimage?.imageBg, 0, routeimage?.imageBg?.size ?: 0
|
||||
// )
|
||||
// m_ArrowBitmap = BitmapFactory.decodeByteArray(
|
||||
// routeimage?.imageArrow, 0,
|
||||
// routeimage?.imageArrow?.size ?: 0
|
||||
// )
|
||||
// // 记录历史现实的图片,如果相同,在新的展现路口上 不在重新获取。
|
||||
// m_BGID = naviinfo.m_nImageBg
|
||||
// m_ArrowID = naviinfo.m_nImageArrow
|
||||
// }
|
||||
// if (m_BGBitmap != null) {
|
||||
// // iv_guidance_3d_route_bg.setImageBitmap(m_BGBitmap)
|
||||
// }
|
||||
// if (m_ArrowBitmap != null) {
|
||||
// //iv_guidance_3d_route_arrow.setImageBitmap(m_ArrowBitmap)
|
||||
// }
|
||||
//
|
||||
// val img = CommonUtils.combineBitmap(m_BGBitmap, m_ArrowBitmap!!)
|
||||
// iv_guidance_3d_route_bg.setImageBitmap(img)
|
||||
// } else {
|
||||
// iv_guidance_3d_route_bg.visibility = View.GONE
|
||||
// iv_guidance_3d_route_arrow.visibility = View.GONE
|
||||
// guidance_progressBar.visibility = GONE
|
||||
// guidance_progressBar.setProgress(100)
|
||||
// guidance_progressBar.setMax(100)
|
||||
// iv_guidance_next_road.visibility = View.VISIBLE
|
||||
// progress = 0
|
||||
// }
|
||||
// if (naviinfo.m_nSGPImageType.toInt() == 1 && naviinfo.m_nSGPImageBg > 0 && naviinfo.m_nSGPImageArrow > 0
|
||||
// ) {
|
||||
// iv_guidance_board_bg.visibility = View.VISIBLE
|
||||
// iv_guidance_board_arrow.visibility = View.VISIBLE
|
||||
// if (m_SGPBGID != naviinfo.m_nSGPImageBg
|
||||
// || m_SGPArrowID != naviinfo.m_nSGPImageArrow
|
||||
// ) {
|
||||
// val routeimage =
|
||||
// CommonController.instance.iNavigationCore?.Guidance_Image(
|
||||
// naviinfo.m_nSGPImageUr,
|
||||
// naviinfo.m_nSGPImageBg,
|
||||
// naviinfo.m_nSGPImageArrow, 1
|
||||
// )
|
||||
// if (m_SGPBGBitmap != null) {
|
||||
// m_SGPBGBitmap!!.recycle()
|
||||
// }
|
||||
// m_SGPBGBitmap = null
|
||||
// if (m_SGPArrowBitmap != null) {
|
||||
// m_SGPArrowBitmap!!.recycle()
|
||||
// }
|
||||
// m_SGPArrowBitmap = null
|
||||
//
|
||||
// // 记录下载历史的展现的图片
|
||||
// m_SGPBGBitmap = BitmapFactory.decodeByteArray(
|
||||
// routeimage?.imageBg, 0, routeimage?.imageBg?.size ?: 0
|
||||
// )
|
||||
// m_SGPArrowBitmap = BitmapFactory.decodeByteArray(
|
||||
// routeimage?.imageArrow, 0,
|
||||
// routeimage?.imageArrow?.size ?: 0
|
||||
// )
|
||||
// // 记录历史现实的图片,如果相同,在新的展现路口上 不在重新获取。
|
||||
// m_SGPBGID = naviinfo.m_nSGPImageBg
|
||||
// m_SGPArrowID = naviinfo.m_nSGPImageArrow
|
||||
// }
|
||||
// if (m_SGPBGBitmap != null) {
|
||||
// iv_guidance_board_bg.setImageBitmap(m_SGPBGBitmap)
|
||||
// }
|
||||
// if (m_SGPArrowBitmap != null) {
|
||||
// iv_guidance_board_arrow.setImageBitmap(m_SGPArrowBitmap)
|
||||
// }
|
||||
// } else {
|
||||
// iv_guidance_board_bg.visibility = View.GONE
|
||||
// iv_guidance_board_arrow.visibility = View.GONE
|
||||
// }
|
||||
// if (naviinfo.m_LaneType.toInt() == 1) {
|
||||
// val lan = CommonController.instance.iNavigationCore?.Guidance_LaneMask()
|
||||
// val bitmap = m_LaneTools!!.getComposeLaneInfo(lan)
|
||||
// iv_guidance_lane_bg.visibility = View.GONE
|
||||
// iv_guidance_lane_arrow.visibility = View.VISIBLE
|
||||
// if (bitmap != null) {
|
||||
// iv_guidance_lane_arrow.setImageBitmap(bitmap)
|
||||
// }
|
||||
// }
|
||||
// } catch (e: Exception) {
|
||||
// Log.e(
|
||||
// TAG,
|
||||
// e.message
|
||||
// )
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// if (DEBUG) {
|
||||
// Log.i(
|
||||
// TAG,
|
||||
// "navop-PanelGuidance: reset-end"
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun setPos(
|
||||
// top: Int, bottom: Int, left: Int,
|
||||
// right: Int
|
||||
// ) {
|
||||
// }
|
||||
//
|
||||
// override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||
// return false
|
||||
// }
|
||||
//
|
||||
// public override fun dispatchPanelKeyEvent(event: KeyEvent): Boolean {
|
||||
// if (this.visibility == View.VISIBLE
|
||||
// && event.keyCode == KeyEvent.KEYCODE_BACK
|
||||
// && event.action == KeyEvent.ACTION_UP
|
||||
// ) {
|
||||
// Toast.makeText(
|
||||
// CommonController.instance.mapView?.getmContext(), "退出导航", Toast.LENGTH_LONG
|
||||
// ).show()
|
||||
// CommonController.instance.naviController?.stopNavi()
|
||||
// return true
|
||||
// }
|
||||
// return super.dispatchPanelKeyEvent(event)
|
||||
// }
|
||||
//
|
||||
// private fun showProgressView() {
|
||||
// isProgressShow = true
|
||||
// guidance_progressBar.visibility = View.VISIBLE
|
||||
//// tv_guidance_progress.visibility = View.VISIBLE
|
||||
// guidance_layout_next_road_name.visibility = View.GONE
|
||||
//// layout_guidance_next_road.visibility = View.GONE
|
||||
//// iv_guidance_line.visibility = View.GONE
|
||||
// tv_next_road.visibility = View.GONE
|
||||
// mLayoutParams_next_road.rightMargin = 40
|
||||
// iv_guidance_next_road.layoutParams = mLayoutParams_next_road
|
||||
// }
|
||||
//
|
||||
// private fun hidProgressView() {
|
||||
// isProgressShow = false
|
||||
// guidance_progressBar.visibility = View.GONE
|
||||
//// tv_guidance_progress.visibility = View.GONE
|
||||
// //guidance_layout_next_road_name.visibility = View.VISIBLE
|
||||
// //layout_guidance_next_road.visibility = View.VISIBLE
|
||||
//// iv_guidance_line.visibility = View.VISIBLE
|
||||
// tv_next_road.visibility = View.VISIBLE
|
||||
// mLayoutParams_next_road.rightMargin = 0
|
||||
// mLayoutParams_next_road.gravity = Gravity.CENTER
|
||||
// iv_guidance_next_road.layoutParams = mLayoutParams_next_road
|
||||
// }
|
||||
//
|
||||
// fun getPanelImage(colorID: Int): Drawable {
|
||||
// val typemask = 0x88
|
||||
// val m_iLanePanelBorderMargin = 40
|
||||
// val m_iLanePanelBorderRadian = 40
|
||||
// val bitmap =
|
||||
// Bitmap.createBitmap(40, 40, Bitmap.Config.ARGB_8888)
|
||||
// val paint = Paint()
|
||||
// paint.setARGB(0, 0, 0, 0)
|
||||
// val canvas = Canvas(bitmap)
|
||||
// canvas.drawPaint(paint)
|
||||
// paint.color = colorID
|
||||
// paint.style = Paint.Style.FILL
|
||||
// paint.isAntiAlias = true
|
||||
// val rect1 = RectF()
|
||||
// rect1[0f, 0f, 40f] = 40f
|
||||
// canvas.drawRoundRect(rect1, 5f, 5f, paint)
|
||||
// paint.color = Color.WHITE
|
||||
// paint.strokeWidth = 2f
|
||||
// paint.style = Paint.Style.STROKE
|
||||
// paint.isAntiAlias = true
|
||||
// val rect = RectF()
|
||||
// rect[3f, 3f, 37f] = 37f
|
||||
// canvas.drawRoundRect(rect, 5f, 5f, paint)
|
||||
// return BitmapDrawable(
|
||||
// mContext.resources,
|
||||
// bitmap
|
||||
// )
|
||||
// }
|
||||
//
|
||||
// override fun onClick(v: View) {
|
||||
// if (v.id == R.id.iv_guidance_next_road) {
|
||||
// if (isProgressShow) {
|
||||
// hidProgressView()
|
||||
// } else {
|
||||
// showProgressView()
|
||||
// }
|
||||
// } else if (v.id == R.id.sim_navi_start) {
|
||||
// if (CommonController.instance
|
||||
// .naviController!!.isSimNaviPaused()
|
||||
// ) {
|
||||
// sim_navi_start?.setImageResource(R.mipmap.icon_pause_night)
|
||||
// } else {
|
||||
// Toast.makeText(mContext, "暂停", Toast.LENGTH_SHORT)
|
||||
// .show()
|
||||
// sim_navi_start?.setImageResource(R.mipmap.icon_play_night)
|
||||
// }
|
||||
// val isSimNaviPaused = CommonController.instance.naviController!!.isSimNaviPaused()
|
||||
// CommonController.instance.naviController?.setSimNaviPaused(!isSimNaviPaused)
|
||||
// } else if (v.id == R.id.guidance_btn_show_route_mode) {
|
||||
// isShowAllRoute = !isShowAllRoute
|
||||
// CommonController.instance.mapController?.setShowAllRouteLine(isShowAllRoute)
|
||||
// if (isShowAllRoute) {
|
||||
// guidance_btn_show_route_mode.text = "返回"
|
||||
// } else {
|
||||
// guidance_btn_show_route_mode.text = "全貌"
|
||||
// }
|
||||
//// CommonController.instance.naviAutoView?.mNaviViewListener?.onScanViewButtonClick()
|
||||
// } else if (v.id == R.id.guidance_tv_speed) {
|
||||
//// Log.d("ouou", "点击速度"+sim_navi_control.getVisibility());
|
||||
// if (CommonController.instance.naviController!!.isSimNavi()
|
||||
// ) {
|
||||
// mSimNaviSpeed *= 2
|
||||
// if (mSimNaviSpeed > 8)
|
||||
// mSimNaviSpeed = 1
|
||||
//
|
||||
// CommonController.instance.naviController?.setSimNaviSpeed(mSimNaviSpeed * 20)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// companion object {
|
||||
// private const val TAG = "PanelGuidance"
|
||||
// }
|
||||
//
|
||||
// init {
|
||||
// if (DEBUG) {
|
||||
// Log.i(
|
||||
// TAG,
|
||||
// "navop-PanelGuidance: start"
|
||||
// )
|
||||
// }
|
||||
// setContentView(
|
||||
// R.layout.layout_panel_guidance,
|
||||
// LayoutParams(
|
||||
// LayoutParams.MATCH_PARENT,
|
||||
// LayoutParams.MATCH_PARENT
|
||||
// )
|
||||
// )
|
||||
// isClickable = false
|
||||
// mLayoutParams_next_road = LinearLayout.LayoutParams(
|
||||
// LayoutParams.WRAP_CONTENT,
|
||||
// LayoutParams.WRAP_CONTENT
|
||||
// )
|
||||
// mLayoutParams_next_road.rightMargin = 0
|
||||
// mLayoutParams_next_road.gravity = Gravity.CENTER
|
||||
//
|
||||
// iv_guidance_next_road.layoutParams = mLayoutParams_next_road
|
||||
//// iv_guidance_next_road.setOnClickListener(this)
|
||||
//
|
||||
////
|
||||
//
|
||||
//// mLayoutParams_progress = LinearLayout.LayoutParams(
|
||||
//// LayoutParams.WRAP_CONTENT,
|
||||
//// LayoutParams.WRAP_CONTENT
|
||||
//// )
|
||||
//// mLayoutParams_progress.width = (this.resources
|
||||
//// .getDrawable(R.mipmap.navi_s_1).intrinsicHeight + this
|
||||
//// .resources.displayMetrics.density * 10).toInt()
|
||||
//// mLayoutParams_progress.gravity = Gravity.CENTER
|
||||
//// mLayoutParams_progress.leftMargin = (mLayoutParams_progress.width / 2 + this
|
||||
//// .resources.displayMetrics.density * 20).toInt()
|
||||
//// mProgressBar.layoutParams = mLayoutParams_progress
|
||||
////
|
||||
//
|
||||
// guidance_tv_speed.setOnClickListener(this)
|
||||
////
|
||||
// layout =
|
||||
// findVievById(R.id.panel_guidance_right) as LinearLayout
|
||||
// // TODO: 2020/5/12 Matt 设置导航显示
|
||||
//// mApplication.getMapAct().setRequestedOrientation(
|
||||
//// ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
// // m_LaneTools = new LaneMarkTools(400.0f /
|
||||
// // this.getResources().getDisplayMetrics().widthPixels);
|
||||
// m_LaneTools = LaneMarkTools(
|
||||
// 0.5f, this.resources
|
||||
// .displayMetrics.widthPixels, this.resources
|
||||
// .displayMetrics.heightPixels
|
||||
// )
|
||||
// if (CommonController.instance.naviController!!.isSimNavi()) {
|
||||
//
|
||||
// guidance_btn_show_route_mode.setOnClickListener(this)
|
||||
// sim_navi_start.setOnClickListener(this)
|
||||
// hidProgressView()
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,409 @@
|
||||
package com.zhidaoauto.map.sdk.inner.panel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PanelManager {
|
||||
|
||||
private static final int PANEL_WHAT_BASE = 1000;
|
||||
public static final int PANEL_WHAT_SET_MODE = PANEL_WHAT_BASE + 1;
|
||||
public static final int PANEL_WHAT_SHOW = PANEL_WHAT_BASE + 2;
|
||||
public static final int PANEL_WHAT_HID = PANEL_WHAT_BASE + 3;
|
||||
public static final int PANEL_WHAT_RESET = PANEL_WHAT_BASE + 4;
|
||||
public static final int PANEL_WHAT_BACK = PANEL_WHAT_BASE + 5;
|
||||
public static final int PANEL_WHAT_ONPAUSE = PANEL_WHAT_BASE + 6;
|
||||
public static final int PANEL_WHAT_ONRESUME = PANEL_WHAT_BASE + 7;
|
||||
public static final int PANEL_WHAT_INVERSION = PANEL_WHAT_BASE + 8;
|
||||
|
||||
private static final int PANEL_BTN_LEFT = 0x4;
|
||||
private static final int PANEL_BTN_RIGHT = 0x8;
|
||||
public static final int PANEL_BTN_ZOOM = 0x10;
|
||||
public static final int PANEL_BTN_DIRECTION = 0x20;
|
||||
private static final int PANEL_SEARCH_MENU = 0x40;
|
||||
private static final int PANEL_RESULTLIST = 0x80;
|
||||
public static final int PANEL_RIGHT_TOP = 0x100;
|
||||
private static final int PANEL_TEST_TEXT = 0x200;
|
||||
private static final int PANEL_ATTITUDE_SHOW = 0x400;
|
||||
private static final int PANEL_BT_SENSOR = 0x800;
|
||||
private static final int PANEL_MENU = 0x1000;
|
||||
private static final int PANEL_GUIDANCE = 0x2000;
|
||||
private static final int PANEL_MAP = 0x4000;
|
||||
private static final int PANEL_ROUTING_SELECT = 0x8000;
|
||||
private static final int PANEL_FRAME_COUNTER = 0x10000;
|
||||
private static final int PANEL_HIS_LIST = 0x20000;
|
||||
private static final int PANEL_MENU_COMMON = 0x40000;
|
||||
private static final int PANEL_ROUTE_SET = 0x80000;
|
||||
private static final int PANEL_CATEGORY_LIST = 0x100000;
|
||||
private static final int PANEL_MAC_SHOW = 0x200000;
|
||||
private static final int PANEL_STATE_SHOW = 0x400000;
|
||||
private static final int PANEL_RTINFO_SHOW = 0x800000;
|
||||
public static final int PANEL_BTN_LOCATION = 0x1000000;
|
||||
public static final int PANEL_BTN_SCALE = 0x2000000;
|
||||
public static final int PANEL_BTN_LOGO = 0x4000000;
|
||||
public static final int PANEL_BTN_CAR = 0x8000000;
|
||||
|
||||
public static final int PANEL_POLYGON = 0x40000000;
|
||||
public static final int PANEL_BTN_CARS = 0x20000000;
|
||||
|
||||
public static final int PANEL_TRAFFIC_SIGN = 0x10000000;
|
||||
|
||||
public static final int PANEL_MODE_NONE = 0;
|
||||
public static final int PANEL_MODE_RESULTLIST = PANEL_RESULTLIST;
|
||||
public static final int PANEL_MODE_SDK_MAIN = PANEL_MAP ;//| PANEL_TRAFFIC_SIGN
|
||||
public static final int PANEL_MODE_VIEW_MAIN = PANEL_BTN_DIRECTION | PANEL_BTN_ZOOM | PANEL_BTN_LOCATION | PANEL_BTN_SCALE | PANEL_BTN_LOGO | PANEL_BTN_CAR | PANEL_POLYGON | PANEL_BTN_CARS;
|
||||
public static final int PANEL_MODE_MAIN = PANEL_MAP | PANEL_BTN_LEFT | PANEL_BTN_RIGHT | PANEL_BTN_ZOOM | PANEL_RIGHT_TOP | PANEL_BTN_DIRECTION | PANEL_FRAME_COUNTER;
|
||||
public static final int PANEL_MODE_RIGHT_TOP = PANEL_RIGHT_TOP;
|
||||
public static final int PANEL_MODE_SEARCH = PANEL_SEARCH_MENU;
|
||||
public static final int PANEL_MODE_PANEL_BTN_LEFT = PANEL_BTN_LEFT;
|
||||
public static final int PANEL_MODE_PANEL_TEST_TEXT = PANEL_TEST_TEXT;
|
||||
public static final int PANEL_MODE_PANEL_ATTITUDE_SHOW = PANEL_ATTITUDE_SHOW;
|
||||
public static final int PANEL_MODE_PANEL_BT_SENSOR = PANEL_BT_SENSOR;
|
||||
public static final int PANEL_MODE_MENU = PANEL_MENU;
|
||||
public static final int PANEL_MODE_GUIDANCE = PANEL_MAP | PANEL_GUIDANCE | PANEL_BTN_DIRECTION;
|
||||
public static final int PANEL_MODE_MAP = PANEL_MAP;
|
||||
public static final int PANEL_MODE_ROUTING_SELECT = PANEL_ROUTING_SELECT;
|
||||
public static final int PANEL_MODE_COUNTER = PANEL_FRAME_COUNTER;
|
||||
public static final int PANEL_MODE_HIS_LIST = PANEL_HIS_LIST;
|
||||
public static final int PANEL_MODE_MENU_COMMON = PANEL_MENU_COMMON;
|
||||
public static final int PANEL_MODE_ROUTE_SET = PANEL_ROUTE_SET;
|
||||
public static final int PANEL_MODE_CATEGORY_LIST = PANEL_CATEGORY_LIST;
|
||||
public static final int PANEL_MODE_PANEL_MAC_SHOW = PANEL_MAC_SHOW;
|
||||
public static final int PANEL_MODE_PANEL_STATE_SHOW = PANEL_STATE_SHOW;
|
||||
public static final int PANEL_MODE_RTINFO_SHOW = PANEL_RTINFO_SHOW;
|
||||
public static final int PANEL_MODE_GUIDANCE_SHOW = PANEL_GUIDANCE | PANEL_BTN_DIRECTION;
|
||||
|
||||
|
||||
private Context mContext;
|
||||
private FrameLayout mContainer;
|
||||
//store all panel's class name, used to construct the class
|
||||
private String[] classNames;
|
||||
//store all panels
|
||||
private Panel[] panels;
|
||||
//store all modes corresponding to the panel
|
||||
private int[] mPanelModes;
|
||||
private int childCountAlreaday = 0;
|
||||
private List<Integer> mChildAlreadyList = null;
|
||||
|
||||
private List<Integer> mHistoryModeSetList = null;
|
||||
|
||||
private int m_iCurModes = 0;
|
||||
|
||||
private IMapController mMapController;
|
||||
|
||||
|
||||
public PanelManager(FrameLayout container, Context context, IMapController mapController) {
|
||||
mContext = context;
|
||||
mMapController = mapController;
|
||||
classNames = new String[]{
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelMap",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelDirction",
|
||||
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelFrameCounter",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelTestText",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelBtnLeft",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelBtnRight",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelZoom",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelBtnRightTop",
|
||||
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelSelectRoute",
|
||||
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelHisList",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelMenuCommon",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelRouteSet",
|
||||
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelMenu",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelSearchMenu",
|
||||
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelAttitudeShow",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelBTSensor",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelGuidance",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelCategoryList",
|
||||
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelResultList",
|
||||
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelMac",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelCarstateShow",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelStaticShow",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelBtnLocation",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelBtnScale",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelBtnLogo",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelCar",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelBtnLogo",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelPolyGon",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelCars",
|
||||
"com.zhidaoauto.map.sdk.inner.panel.PanelTrafficSign"
|
||||
|
||||
};
|
||||
mPanelModes = new int[]{
|
||||
PANEL_MAP,
|
||||
PANEL_BTN_DIRECTION,
|
||||
// PANEL_ROUTING_SELECT,
|
||||
PANEL_FRAME_COUNTER,
|
||||
PANEL_MODE_PANEL_TEST_TEXT,
|
||||
PANEL_BTN_LEFT,
|
||||
PANEL_BTN_RIGHT,
|
||||
PANEL_BTN_ZOOM,
|
||||
PANEL_RIGHT_TOP,
|
||||
|
||||
PANEL_ROUTING_SELECT,
|
||||
|
||||
PANEL_MODE_HIS_LIST,
|
||||
PANEL_MODE_MENU_COMMON,
|
||||
PANEL_ROUTE_SET,
|
||||
|
||||
|
||||
PANEL_MENU,
|
||||
PANEL_SEARCH_MENU,
|
||||
|
||||
PANEL_ATTITUDE_SHOW,
|
||||
PANEL_BT_SENSOR,
|
||||
PANEL_GUIDANCE,
|
||||
PANEL_CATEGORY_LIST,
|
||||
|
||||
PANEL_RESULTLIST,
|
||||
|
||||
PANEL_MAC_SHOW,
|
||||
PANEL_STATE_SHOW,
|
||||
PANEL_RTINFO_SHOW,
|
||||
|
||||
PANEL_BTN_LOCATION,
|
||||
PANEL_BTN_SCALE,
|
||||
PANEL_BTN_LOGO,
|
||||
PANEL_BTN_CAR,
|
||||
PANEL_BTN_LOGO,
|
||||
PANEL_POLYGON,
|
||||
PANEL_BTN_CARS,
|
||||
PANEL_TRAFFIC_SIGN
|
||||
|
||||
|
||||
};
|
||||
panels = new Panel[classNames.length];
|
||||
mContainer = container;
|
||||
childCountAlreaday = mContainer.getChildCount();
|
||||
|
||||
mHistoryModeSetList = new ArrayList<Integer>();
|
||||
m_iCurModes = PANEL_MODE_SDK_MAIN;
|
||||
mChildAlreadyList = new ArrayList<Integer>();
|
||||
}
|
||||
|
||||
private int getPanelIndexInAdd(int index) {
|
||||
int size = mChildAlreadyList.size();
|
||||
if (size == 0) {
|
||||
mChildAlreadyList.add(index);
|
||||
return 0;
|
||||
}
|
||||
int i = size > index ? index : size - 1;
|
||||
for (; i >= 0; i--) {
|
||||
if (index == mChildAlreadyList.get(i)) {
|
||||
return ++i;
|
||||
}
|
||||
if (index > mChildAlreadyList.get(i)) {
|
||||
mChildAlreadyList.add(++i, index);
|
||||
return i;
|
||||
}
|
||||
if (i == 0) {
|
||||
mChildAlreadyList.add(0, index);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void showPanel(int index) {
|
||||
if (index >= panels.length || index < 0) {
|
||||
throw new IndexOutOfBoundsException("index = " + index + " count = " + panels.length);
|
||||
}
|
||||
Panel panel = panels[index];
|
||||
if (panel == null) {
|
||||
panel = panels[index] = PanelConstructor.construct(classNames[index], mContext,mMapController);
|
||||
|
||||
if (panel == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
//not contained in the container
|
||||
if (panel.getParent() == null) {
|
||||
int mIndex = getPanelIndexInAdd(index);
|
||||
if (mIndex == -1) {
|
||||
mContainer.addView(panel);
|
||||
} else {
|
||||
//the container may already have child views beside panel
|
||||
mContainer.addView(panel, mIndex + childCountAlreaday);
|
||||
}
|
||||
}
|
||||
if (panel.getVisibility() != View.VISIBLE) {
|
||||
panel.setVisibility(View.VISIBLE);
|
||||
}
|
||||
panel.onShowPanel();
|
||||
}
|
||||
|
||||
private void HidePannel(int index) {
|
||||
if (index >= panels.length || index < 0) {
|
||||
throw new IndexOutOfBoundsException("index = " + index + " count = " + panels.length);
|
||||
}
|
||||
Panel panel = panels[index];
|
||||
if (panel != null) {
|
||||
if (panel.onHidPanel()) {
|
||||
//make sure the panel has already been removed
|
||||
if (panel.getParent() != null) {
|
||||
panel.setVisibility(View.INVISIBLE);
|
||||
panel.remove();
|
||||
}
|
||||
int size = mChildAlreadyList.size();
|
||||
int i = size > index ? index : size - 1;
|
||||
for (; i >= 0; i--) {
|
||||
if (index == mChildAlreadyList.get(i)) {
|
||||
mChildAlreadyList.remove(i);
|
||||
}
|
||||
}
|
||||
//release the panel
|
||||
panels[index] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void resetPanel(int mode) {
|
||||
for (int index = 0; index < mPanelModes.length; index++) {
|
||||
if ((mode & mPanelModes[index]) > 0 && panels[index] != null) {
|
||||
panels[index].reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void switchToMode(int mode) {
|
||||
for (int index = 0; index < mPanelModes.length; index++) {
|
||||
if ((mode & mPanelModes[index]) > 0) {
|
||||
showPanel(index);
|
||||
} else {
|
||||
HidePannel(index);
|
||||
}
|
||||
}
|
||||
m_iCurModes = mode;
|
||||
}
|
||||
|
||||
private void inverseMode(int mode) {
|
||||
if ((m_iCurModes & mode) == 0) {
|
||||
switchToMode(m_iCurModes | mode);
|
||||
} else {
|
||||
switchToMode(m_iCurModes & ~mode);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setPanel(int what, int panemMode) {
|
||||
switch (what) {
|
||||
case PANEL_WHAT_SET_MODE:
|
||||
// 保存上一次设置的状态
|
||||
if (panemMode == PANEL_MODE_SDK_MAIN) {
|
||||
mHistoryModeSetList.clear();
|
||||
mHistoryModeSetList.add(panemMode);
|
||||
} else if (m_iCurModes != panemMode && (mHistoryModeSetList.size() == 0 || m_iCurModes != mHistoryModeSetList.get(mHistoryModeSetList.size() - 1))) {
|
||||
mHistoryModeSetList.add(m_iCurModes);
|
||||
}
|
||||
switchToMode(panemMode);
|
||||
return true;
|
||||
case PANEL_WHAT_SHOW:
|
||||
// 保存上一次设置的状态
|
||||
if (m_iCurModes != panemMode && (mHistoryModeSetList.size() == 0 || m_iCurModes != mHistoryModeSetList.get(mHistoryModeSetList.size() - 1))) {
|
||||
mHistoryModeSetList.add(m_iCurModes);
|
||||
}
|
||||
if ((m_iCurModes & panemMode) == 0) {
|
||||
switchToMode(m_iCurModes | panemMode);
|
||||
}
|
||||
return true;
|
||||
case PANEL_WHAT_HID:
|
||||
// 保存上一次设置的状态
|
||||
if (m_iCurModes != panemMode && (mHistoryModeSetList.size() == 0 || m_iCurModes != mHistoryModeSetList.get(mHistoryModeSetList.size() - 1))) {
|
||||
mHistoryModeSetList.add(m_iCurModes);
|
||||
}
|
||||
if ((m_iCurModes & panemMode) > 0) {
|
||||
switchToMode(m_iCurModes & ~panemMode);
|
||||
}
|
||||
return true;
|
||||
case PANEL_WHAT_INVERSION:
|
||||
// 保存上一次设置的状态for menu, not need
|
||||
// if (m_iCurModes != mode && (mHistoryModeSetList.size() ==0 || m_iCurModes != mHistoryModeSetList.get(mHistoryModeSetList.size() -1))) {
|
||||
// mHistoryModeSetList.add(m_iCurModes);
|
||||
// }
|
||||
inverseMode(panemMode);
|
||||
return true;
|
||||
case PANEL_WHAT_RESET:
|
||||
resetPanel(panemMode);
|
||||
return true;
|
||||
case PANEL_WHAT_BACK:
|
||||
int size = mHistoryModeSetList.size();
|
||||
if (size > 0) {
|
||||
// 上一个状态
|
||||
panemMode = mHistoryModeSetList.get(size - 1);
|
||||
// 删除上一个状态
|
||||
mHistoryModeSetList.remove(size - 1);
|
||||
}
|
||||
switchToMode(panemMode);
|
||||
return true;
|
||||
case PANEL_WHAT_ONPAUSE:
|
||||
for (Panel panel : panels) {
|
||||
if (panel != null) {
|
||||
panel.onPausePanel();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case PANEL_WHAT_ONRESUME:
|
||||
for (Panel panel : panels) {
|
||||
if (panel != null) {
|
||||
panel.onResumePanel();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setPanelPos(int panelMode, int top, int bottom, int left, int right) {
|
||||
for (int index = 0; index < mPanelModes.length; index++) {
|
||||
if ((panelMode & mPanelModes[index]) > 0 && panels[index] != null) {
|
||||
panels[index].setPos(top, bottom, left, right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
for (int i = panels.length - 1; i >= 0; i--) {
|
||||
Panel panel = panels[i];
|
||||
if (panel != null && panel.dispatchPanelKeyEvent(event)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
for (int i = panels.length - 1; i >= 0; i--) {
|
||||
Panel panel = panels[i];
|
||||
if (panel != null && panel.onPrepareOptionsMenu(menu)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setPanelPos(int panelMode, int gravity, int top, int bottom, int left, int right) {
|
||||
for (int index = 0; index < mPanelModes.length; index++) {
|
||||
if ((panelMode & mPanelModes[index]) > 0 && panels[index] != null) {
|
||||
panels[index].setMyGravity(gravity);
|
||||
panels[index].setPos(top, bottom, left, right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void destory() {
|
||||
mContainer.removeAllViews();
|
||||
mContainer = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.zhidaoauto.map.sdk.inner.panel;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig;
|
||||
|
||||
public class PanelMap extends Panel{
|
||||
|
||||
private static final String TAG = "PanelMap";
|
||||
|
||||
public PanelMap(Context context) {
|
||||
super(context);
|
||||
if (CompileConfig.INSTANCE.getDEBUG()) {
|
||||
Log.i(TAG, "autoop-mapop-PanelMap:init");
|
||||
}
|
||||
// addView((MapView) CommonController.getInstance().getMapView());
|
||||
setMargin(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onShowPanel() {
|
||||
if (CompileConfig.INSTANCE.getDEBUG()) {
|
||||
Log.i(TAG, "autoop-mapop-PanelMap:onShowPanel");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onHidPanel() {
|
||||
if (CompileConfig.INSTANCE.getDEBUG()) {
|
||||
Log.i(TAG, "autoop-mapop-PanelMap:onHidPanel");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPausePanel() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResumePanel() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reset() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPos(Integer top, Integer bottom, Integer left, Integer right) {
|
||||
setMargin(top, bottom, left, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onPrepareOptionsMenu(Menu menu) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
//package com.zhidaoauto.map.sdk.inner.panel
|
||||
//
|
||||
//import android.content.Context
|
||||
//import android.content.res.Configuration
|
||||
//import android.graphics.Color
|
||||
//import android.os.RemoteException
|
||||
//import android.view.KeyEvent
|
||||
//import android.view.Menu
|
||||
//import android.view.View
|
||||
//import android.widget.Button
|
||||
//import android.widget.LinearLayout
|
||||
//import com.zhidaoauto.map.sdk.R
|
||||
//import com.zhidaoauto.map.sdk.inner.common.ConstantExt
|
||||
//import com.zhidaoauto.map.sdk.inner.controller.CommonController
|
||||
//import com.zhidaoauto.map.sdk.inner.db.DataStorageManager
|
||||
//import com.zhidaoauto.map.sdk.inner.proxy.CommonProxy
|
||||
//import com.zhidaoauto.map.sdk.inner.utils.Constant.initRouteSetting
|
||||
//import com.zhidaoauto.map.sdk.open.nav.NavPoi
|
||||
//import com.zhidaoauto.map.sdk.open.query.LonLatPoint
|
||||
//
|
||||
//class PanelRouteSet(context: Context?) :
|
||||
// Panel(context), View.OnClickListener {
|
||||
// private val mBtnSetStart: Button
|
||||
// private val mBtnSetWayPoi: Button
|
||||
// private val mBtnSetEnd: Button
|
||||
// private val mBtnOk: Button
|
||||
// private var mRouteSetStat = 0
|
||||
// private var mPoiStart: NavPoi? = null
|
||||
// private var mPoiWay: NavPoi? = null
|
||||
// private var mPoiEnd: NavPoi? = null
|
||||
// override fun onClick(v: View) {
|
||||
// mRouteSetStat = v.id
|
||||
// when (v.id) {
|
||||
// R.id.route_set_start, R.id.route_set_waypoi, R.id.route_set_end -> CommonController.instance
|
||||
// .panelManager?.setPanel(
|
||||
// PanelManager.PANEL_WHAT_SHOW,
|
||||
// PanelManager.PANEL_MODE_SEARCH
|
||||
// )
|
||||
// R.id.route_set_ok -> {
|
||||
// mPoiStart?.let {
|
||||
// CommonController.instance.naviController?.setStart(it)
|
||||
// }
|
||||
// mPoiWay?.let {
|
||||
// CommonController.instance
|
||||
// .naviController?.addWayPoint(it, 0, 0)
|
||||
// }
|
||||
// mPoiEnd?.let {
|
||||
// CommonController.instance.naviController?.setDest(it)
|
||||
// }
|
||||
// if (mPoiStart == null && mPoiEnd == null) {
|
||||
// CommonController.instance.naviController?.reSetRoute()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public override fun dispatchPanelKeyEvent(event: KeyEvent): Boolean {
|
||||
// if (this.visibility == View.VISIBLE && event.keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_UP) {
|
||||
// CommonController.instance.panelManager?.setPanel(
|
||||
// PanelManager.PANEL_WHAT_HID,
|
||||
// PanelManager.PANEL_MODE_ROUTE_SET
|
||||
// )
|
||||
// mPoiStart = null
|
||||
// mPoiWay = null
|
||||
// mPoiEnd = null
|
||||
// return true
|
||||
// }
|
||||
// return super.dispatchPanelKeyEvent(event)
|
||||
// }
|
||||
//
|
||||
// override fun onConfigurationChanged(newConfig: Configuration) {}
|
||||
// override fun onPausePanel() {}
|
||||
// override fun onResumePanel() {}
|
||||
// override fun onShowPanel() {}
|
||||
// override fun onHidPanel(): Boolean {
|
||||
// this.visibility = View.GONE
|
||||
// return true
|
||||
// }
|
||||
//
|
||||
// override fun reset() {
|
||||
// setRoute()
|
||||
// if (DataStorageManager.getInstance().navPoi == null)
|
||||
// return;
|
||||
// when (mRouteSetStat) {
|
||||
// R.id.route_set_start -> {
|
||||
// mBtnSetStart.setText(mPoiStart?.name);
|
||||
// }
|
||||
// R.id.route_set_waypoi -> {
|
||||
// mPoiWay = DataStorageManager.getInstance().navPoi;
|
||||
// mBtnSetWayPoi.setText(mPoiWay?.name);
|
||||
// }
|
||||
// R.id.route_set_end -> {
|
||||
// mPoiEnd = DataStorageManager.getInstance().navPoi;
|
||||
// mBtnSetEnd.setText(mPoiEnd?.name);
|
||||
// }
|
||||
// }
|
||||
// if (mPoiEnd != null || (CommonController.instance.naviController!!.isDestSet() && CommonController.instance.naviController!!.getEndPoi() != null)) {
|
||||
// mBtnOk.setClickable(true);
|
||||
// mBtnOk.setTextColor(mContext.getResources().getColor(R.color.text_btn_color));
|
||||
// mBtnOk.setBackgroundResource(R.drawable.btn_selecter);
|
||||
// } else {
|
||||
// mBtnOk.setClickable(false);
|
||||
// mBtnOk.setBackgroundResource(R.drawable.btn);
|
||||
// mBtnOk.setTextColor(Color.GRAY);
|
||||
// }
|
||||
// DataStorageManager.getInstance().setNavPoi(null);
|
||||
// CommonController.instance.mapController?.clearSearchPoi();
|
||||
// }
|
||||
//
|
||||
// override fun setPos(
|
||||
// top: Int, bottom: Int, left: Int,
|
||||
// right: Int
|
||||
// ) {
|
||||
// }
|
||||
//
|
||||
// override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||
// return false
|
||||
// }
|
||||
//
|
||||
// private fun setRoute() {
|
||||
// if (CommonController.instance.naviController!!.isStartSet()
|
||||
// && CommonController.instance.naviController?.getStartPoi() != null
|
||||
// ) {
|
||||
// mBtnSetStart.text = CommonController.instance
|
||||
// .naviController?.getStartPoi().toString()
|
||||
// } else {
|
||||
// try {
|
||||
// val location = CommonController.instance.lastKnownMogoLocation
|
||||
// location?.let {
|
||||
// val lonLat = CommonProxy.getInstance().getLonLatProxy()
|
||||
// .switchLonLat(LonLatPoint(it.lon, it.lat))
|
||||
// val lon = lonLat.lon * ConstantExt.RULE_INT
|
||||
// val lat = lonLat.lat * ConstantExt.RULE_INT
|
||||
//
|
||||
// if (lon > 0 && lat > 0) {
|
||||
// mBtnSetStart.text = "我的位置"
|
||||
// } else {
|
||||
// mBtnSetStart.text = "未设置"
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } catch (e: RemoteException) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }
|
||||
// if (CommonController.instance.naviController!!.isDestSet()
|
||||
// && CommonController.instance.naviController?.getEndPoi() != null
|
||||
// ) {
|
||||
// mBtnSetEnd.text = CommonController.instance
|
||||
// .naviController?.getEndPoi().toString()
|
||||
// mBtnOk.isClickable = true
|
||||
// mBtnOk.setTextColor(
|
||||
// mContext.resources.getColor(R.color.text_btn_color)
|
||||
// )
|
||||
// mBtnOk.setBackgroundResource(R.drawable.btn_selecter)
|
||||
// } else {
|
||||
// mBtnSetEnd.text = "未设置"
|
||||
// mBtnOk.isClickable = false
|
||||
// mBtnOk.setBackgroundResource(R.drawable.btn)
|
||||
// mBtnOk.setTextColor(Color.GRAY)
|
||||
// }
|
||||
// if (CommonController.instance.naviController!!.isTuSet()
|
||||
// && CommonController.instance.naviController?.getWayPoi() != null
|
||||
// ) {
|
||||
// mBtnSetWayPoi.text = CommonController.instance
|
||||
// .naviController?.getWayPoi().toString()
|
||||
// } else {
|
||||
// mBtnSetWayPoi.text = "未设置"
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// init {
|
||||
// setContentView(
|
||||
// R.layout.panel_route_set,
|
||||
// LayoutParams(
|
||||
// LayoutParams.FILL_PARENT,
|
||||
// LayoutParams.FILL_PARENT
|
||||
// )
|
||||
// )
|
||||
// mBtnSetStart =
|
||||
// findVievById(R.id.route_set_start) as Button
|
||||
// mBtnSetStart.setOnClickListener(this)
|
||||
// mBtnSetWayPoi =
|
||||
// findVievById(R.id.route_set_waypoi) as Button
|
||||
// mBtnSetWayPoi.setOnClickListener(this)
|
||||
// mBtnSetEnd =
|
||||
// findVievById(R.id.route_set_end) as Button
|
||||
// mBtnSetEnd.setOnClickListener(this)
|
||||
// val mLayoutRouteSet =
|
||||
// findVievById(R.id.route_set_layout) as LinearLayout
|
||||
// initRouteSetting(mContext, mLayoutRouteSet)
|
||||
// mBtnOk =
|
||||
// mLayoutRouteSet.findViewById(R.id.route_set_ok) as Button
|
||||
// mBtnOk.setOnClickListener(this)
|
||||
// setRoute()
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,324 @@
|
||||
//package com.zhidaoauto.map.sdk.inner.panel
|
||||
//
|
||||
//import android.content.Context
|
||||
//import android.os.RemoteException
|
||||
//import android.text.TextUtils
|
||||
//import android.util.Log
|
||||
//import android.view.Gravity
|
||||
//import android.view.KeyEvent
|
||||
//import android.view.Menu
|
||||
//import android.view.View
|
||||
//import android.widget.LinearLayout
|
||||
//import android.widget.RadioButton
|
||||
//import android.widget.RadioGroup
|
||||
//import android.widget.TextView
|
||||
//import androidx.recyclerview.widget.LinearLayoutManager
|
||||
//import androidx.recyclerview.widget.RecyclerView
|
||||
//import com.autonavi.nge.guidance.RouteBook
|
||||
//import com.autonavi.nge.guidance.RouteBookAdapter
|
||||
//import com.autonavi.nge.guidance.RouteBookItem
|
||||
//import com.autonavi.nge.routing.RoutingProvider
|
||||
//import com.zhidaoauto.map.sdk.R
|
||||
//import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
//import com.zhidaoauto.map.sdk.inner.common.NavHelper.mNavParams
|
||||
//import com.zhidaoauto.map.sdk.inner.controller.CommonController
|
||||
//import com.zhidaoauto.map.sdk.inner.utils.Constant.getDisString
|
||||
//import com.zhidaoauto.map.sdk.inner.utils.Constant.getTimeString
|
||||
//import com.zhidaoauto.map.sdk.open.nav.model.NaviPath
|
||||
//import kotlinx.android.synthetic.main.panel_route_select.view.*
|
||||
//import kotlinx.coroutines.Dispatchers
|
||||
//import kotlinx.coroutines.launch
|
||||
//import kotlinx.coroutines.withContext
|
||||
//
|
||||
//class PanelSelectRoute(context: Context?) : Panel(context), View.OnClickListener {
|
||||
//
|
||||
// private val TAG = javaClass.simpleName
|
||||
// private var mLayoutSelectSetting: LinearLayout? = null
|
||||
// private val mLayoutStart: LinearLayout
|
||||
// private var mRbSelect: RadioButton? = null
|
||||
// private val isShow: Boolean
|
||||
// private var isLoadMore: Boolean = false
|
||||
// private var mTvSelect: TextView? = null
|
||||
// private val routeBookAdapter = RouteBookAdapter()
|
||||
//
|
||||
// private fun initRouteSetting(layoutRouteSet: LinearLayout) {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "navop-initRouteSetting")
|
||||
// }
|
||||
// val rg_routing_model = layoutRouteSet.findViewById(R.id.rg_routing_set) as RadioGroup
|
||||
// when (mNavParams.getRoutingModel()) {
|
||||
// RoutingProvider.COSTMODEL_DEFAULT -> rg_routing_model.check(R.id.routing_set_default)
|
||||
// RoutingProvider.COSTMODEL_FASTEST -> {
|
||||
// rg_routing_model.check(R.id.routing_set_fast)
|
||||
// mRbSelect = rg_routing_model.getChildAt(2) as RadioButton
|
||||
// refreshRouteTime()
|
||||
// }
|
||||
// RoutingProvider.COSTMODEL_SHORTEST -> {
|
||||
// rg_routing_model.check(R.id.routing_set_short)
|
||||
// mRbSelect = rg_routing_model.getChildAt(4) as RadioButton
|
||||
// refreshRouteTime()
|
||||
// }
|
||||
// RoutingProvider.COSTMODEL_SUGGEST -> {
|
||||
// rg_routing_model.check(R.id.routing_set_avoidhwy)
|
||||
// mRbSelect = rg_routing_model.getChildAt(6) as RadioButton
|
||||
// refreshRouteTime()
|
||||
// }
|
||||
// RoutingProvider.COSTMODEL_ECO -> {
|
||||
// rg_routing_model.check(R.id.routing_set_avoidtoll)
|
||||
// mRbSelect = rg_routing_model.getChildAt(8) as RadioButton
|
||||
// refreshRouteTime()
|
||||
// }
|
||||
// }
|
||||
// rg_routing_model.setOnCheckedChangeListener { group, checkedId ->
|
||||
// when (checkedId) {
|
||||
// R.id.routing_set_default -> {
|
||||
// mNavParams.setRoutingModel(RoutingProvider.COSTMODEL_DEFAULT)
|
||||
// CommonController.instance.iNavigationCore?.RoutingSetCostModel(RoutingProvider.COSTMODEL_DEFAULT, 0)
|
||||
// }
|
||||
// R.id.routing_set_fast -> {
|
||||
// mNavParams.setRoutingModel(RoutingProvider.COSTMODEL_FASTEST)
|
||||
// CommonController.instance.iNavigationCore?.RoutingSetCostModel(RoutingProvider.COSTMODEL_FASTEST, 0)
|
||||
// CommonController.instance.iNavigationCore?.RoutingSetAvoidHighway(false, 0)
|
||||
// CommonController.instance.iNavigationCore?.RoutingSetAvoidToll(false, 0)
|
||||
// CommonController.instance.naviController?.reSetRoute()
|
||||
// }
|
||||
// R.id.routing_set_short -> {
|
||||
// mNavParams.setRoutingModel(RoutingProvider.COSTMODEL_SHORTEST)
|
||||
// CommonController.instance.iNavigationCore?.RoutingSetCostModel(RoutingProvider.COSTMODEL_SHORTEST, 0)
|
||||
// CommonController.instance.iNavigationCore?.RoutingSetAvoidHighway(false, 0)
|
||||
// CommonController.instance.iNavigationCore?.RoutingSetAvoidToll(false, 0)
|
||||
// CommonController.instance.naviController?.reSetRoute()
|
||||
// }
|
||||
// R.id.routing_set_avoidhwy -> {
|
||||
// mNavParams.setRoutingModel(RoutingProvider.COSTMODEL_SUGGEST)
|
||||
// CommonController.instance.iNavigationCore?.RoutingSetCostModel(RoutingProvider.COSTMODEL_FASTEST, 0)
|
||||
// CommonController.instance.iNavigationCore?.RoutingSetAvoidHighway(true, 0)
|
||||
// CommonController.instance.iNavigationCore?.RoutingSetAvoidToll(false, 0)
|
||||
// CommonController.instance.naviController?.reSetRoute()
|
||||
// }
|
||||
// R.id.routing_set_avoidtoll -> {
|
||||
// mNavParams.setRoutingModel(RoutingProvider.COSTMODEL_ECO)
|
||||
// CommonController.instance.iNavigationCore?.RoutingSetCostModel(RoutingProvider.COSTMODEL_FASTEST, 0)
|
||||
// CommonController.instance.iNavigationCore?.RoutingSetAvoidHighway(false, 0)
|
||||
// CommonController.instance.iNavigationCore?.RoutingSetAvoidToll(true, 0)
|
||||
// CommonController.instance.naviController?.reSetRoute()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "navop-initRouteSetting-over")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onClick(v: View) {
|
||||
// when (v.id) {
|
||||
// R.id.route_select_start_navi -> {
|
||||
// CommonController.instance.naviController?.startNavi(false)
|
||||
// }
|
||||
// R.id.route_select_sim_navi -> {
|
||||
// CommonController.instance.naviController?.startNavi(true)
|
||||
// }
|
||||
// R.id.route_select_ok -> {
|
||||
// showStartView()
|
||||
// }
|
||||
// R.id.iv_back -> {
|
||||
// route_select_start.visibility = GONE
|
||||
// route_select_setting.visibility = VISIBLE
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onShowPanel() {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "navop-onShowPanel")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onHidPanel(): Boolean {
|
||||
// CommonController.instance.panelManager?.setPanelPos(PanelManager.PANEL_MODE_MAP, 0, 0, 0, 0)
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "navop-onHidPanel")
|
||||
// }
|
||||
// return true
|
||||
// }
|
||||
//
|
||||
// override fun onPausePanel() {}
|
||||
// override fun onResumePanel() {
|
||||
// refreshRouteTime()
|
||||
// }
|
||||
//
|
||||
// override fun reset() {
|
||||
// showStartView()
|
||||
// }
|
||||
//
|
||||
// override fun setPos(top: Int, bottom: Int, left: Int, right: Int) {
|
||||
// }
|
||||
//
|
||||
// override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||
// return false
|
||||
// }
|
||||
//
|
||||
// public override fun dispatchPanelKeyEvent(event: KeyEvent): Boolean {
|
||||
// if (this.visibility == View.VISIBLE && event.keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_UP) {
|
||||
// if (mLayoutSelectSetting != null && mLayoutSelectSetting!!.visibility == View.GONE && isShow) {
|
||||
// showRouteSettingView()
|
||||
// } else {
|
||||
// CommonController.instance.panelManager?.setPanel(PanelManager.PANEL_WHAT_SET_MODE, PanelManager.PANEL_MODE_MAIN)
|
||||
// CommonController.instance.panelManager?.setPanelPos(PanelManager.PANEL_MODE_MAP, 0, 0, 0, 0)
|
||||
// }
|
||||
// return true
|
||||
// }
|
||||
// return super.dispatchPanelKeyEvent(event)
|
||||
// }
|
||||
//
|
||||
// private fun showRouteSettingView() {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "navop-showRouteSettingView")
|
||||
// }
|
||||
// if (mLayoutSelectSetting == null) {
|
||||
// mLayoutSelectSetting = findVievById(R.id.route_select_setting) as LinearLayout
|
||||
// }
|
||||
// mLayoutSelectSetting?.isClickable = true
|
||||
// mLayoutSelectSetting?.visibility = View.VISIBLE
|
||||
// mLayoutStart.visibility = View.GONE
|
||||
// initRouteSetting(this)
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "navop-showRouteSettingView-over")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private fun showStartView() {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "navop-showStartView")
|
||||
// }
|
||||
// if (mLayoutSelectSetting == null) {
|
||||
// mLayoutSelectSetting = findVievById(R.id.route_select_setting) as LinearLayout
|
||||
// }
|
||||
// mLayoutSelectSetting?.visibility = View.GONE
|
||||
// mLayoutStart.visibility = View.VISIBLE
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "navop-showStartView-over")
|
||||
// }
|
||||
// refreshRouteBook()
|
||||
// }
|
||||
//
|
||||
// var list: List<RouteBookItem>? = null
|
||||
// private fun refreshRouteBook() {
|
||||
// CommonController.instance.scope?.launch(Dispatchers.IO) {
|
||||
// var routebook: RouteBook? = null
|
||||
// if(isLoadMore){
|
||||
// var start = list!!.size
|
||||
// routebook = CommonController.instance.iNavigationCore?.Guidance_RouteBook(0, start, start?.plus(50))
|
||||
// }else {
|
||||
// routebook = CommonController.instance.iNavigationCore?.Guidance_RouteBook(0, 0, Int.MAX_VALUE)
|
||||
// }
|
||||
// list = routebook?.bookdata
|
||||
// Log.i(TAG, "navop--refreshRouteBook:${list?.size}")
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "navop--refreshRouteBook:${routebook?.itemSize}")
|
||||
// }
|
||||
//
|
||||
//
|
||||
// withContext(Dispatchers.Main) {
|
||||
// if (lv_info.adapter == null) {
|
||||
// lv_info.adapter = routeBookAdapter
|
||||
// }
|
||||
// if (routeBookAdapter.itemCount == 0) {
|
||||
// routeBookAdapter.setNewInstance(routebook?.bookdata)
|
||||
// } else {
|
||||
// routeBookAdapter.setList(routebook?.bookdata)
|
||||
// routeBookAdapter.notifyDataSetChanged()
|
||||
// }
|
||||
// tv_dis.text = "距离:${getDisString(routebook?.totalLength ?: 0)}\n时间:${getTimeString(routebook?.totalTime ?: 0)}"
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private fun refreshRouteTime() {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "navop-setRouteTime")
|
||||
// }
|
||||
// try {
|
||||
// val sTime = CommonController.instance.iNavigationCore?.RoutingGetSTime(0, 0) ?: 0
|
||||
// val dTime = CommonController.instance.iNavigationCore?.RoutingGetDTime(0, 0) ?: 0
|
||||
// val distance = CommonController.instance.iNavigationCore?.RoutingGetLength(0, 0) ?: 0
|
||||
// if(CompileConfig.DEBUG){
|
||||
// Log.i(TAG,"navop--refreshRouteTime:${sTime},${dTime},${distance}")
|
||||
// }
|
||||
// val length = getDisString(distance)
|
||||
// val text = "耗时:${getTimeString(sTime)}\n距离:${length}"
|
||||
// if (mTvSelect == null) {
|
||||
// mTvSelect = findVievById(R.id.route_select_time) as TextView
|
||||
// }
|
||||
// mTvSelect?.text = text
|
||||
// } catch (e: RemoteException) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "navop-setRouteTime-over")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// init {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "navop-init")
|
||||
// }
|
||||
// val width = if (this.resources.displayMetrics.widthPixels > this.resources.displayMetrics.heightPixels) {
|
||||
// this.resources.displayMetrics.widthPixels
|
||||
// } else {
|
||||
// this.resources.displayMetrics.heightPixels
|
||||
// }
|
||||
// val layoutW = (width / 3.5f).toInt()
|
||||
// setContentView(R.layout.panel_route_select, LayoutParams(layoutW, LayoutParams.MATCH_PARENT))
|
||||
// CommonController.instance.panelManager?.setPanelPos(PanelManager.PANEL_MODE_MAP, 0, 0, 0, 0)
|
||||
// setGravity(Gravity.LEFT)
|
||||
// isClickable = false
|
||||
// mLayoutStart = findVievById(R.id.route_select_start) as LinearLayout
|
||||
// isShow = mNavParams.getRouteSelectShow()
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "navop-init--getRouteSelectShow:$isShow")
|
||||
// }
|
||||
// if (!isShow) {
|
||||
// showStartView()
|
||||
// } else {
|
||||
// showRouteSettingView()
|
||||
// }
|
||||
// val lv_info = findVievById(R.id.lv_info) as RecyclerView
|
||||
// lv_info.setLayoutManager(LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
|
||||
// lv_info.adapter = routeBookAdapter
|
||||
//// routeBookAdapter.setOnItemClickListener { adapter, view, position ->
|
||||
//// if (position == routeBookAdapter.itemCount - 1
|
||||
//// && !TextUtils.equals("目的地", routeBookAdapter.getItem(position - 1).routeName)
|
||||
//// ) {
|
||||
//// refreshRouteBook()
|
||||
//// }
|
||||
//// }
|
||||
// lv_info.setOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
// override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||
// super.onScrollStateChanged(recyclerView, newState)
|
||||
// val manager = recyclerView.layoutManager as LinearLayoutManager
|
||||
// if (newState === RecyclerView.SCROLL_STATE_IDLE) {
|
||||
// val lastVisibleItem = manager.findLastCompletelyVisibleItemPosition()
|
||||
// val totalItemCount = manager.itemCount
|
||||
// if (lastVisibleItem == totalItemCount - 1
|
||||
// && !TextUtils.equals("目的地", routeBookAdapter.getItem(lastVisibleItem).routeName)
|
||||
// ) {
|
||||
// isLoadMore = true
|
||||
// refreshRouteBook()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
//
|
||||
// iv_back.setOnClickListener(this)
|
||||
// route_select_start_navi.setOnClickListener(this)
|
||||
// route_select_sim_navi.setOnClickListener(this)
|
||||
// route_select_ok.setOnClickListener(this)
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "navop-init-over")
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,287 @@
|
||||
package com.zhidaoauto.map.sdk.inner.panel
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import android.view.Gravity
|
||||
import android.view.Menu
|
||||
import com.zhidaoauto.map.sdk.R
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController
|
||||
import com.zhidaoauto.map.sdk.inner.road.RoadHelper
|
||||
import com.zhidaoauto.map.sdk.inner.utils.MathUtils
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapChangeListener
|
||||
import com.zhidaoauto.map.sdk.open.location.MogoLocation
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint
|
||||
import com.zhidaoauto.map.sdk.open.road.Lane
|
||||
import com.zhidaoauto.map.sdk.open.road.RoadSign
|
||||
import kotlinx.android.synthetic.main.panel_traffic_sign.view.iv_traffic
|
||||
import kotlin.math.abs
|
||||
|
||||
class PanelTrafficSign(context: Context,private val mMapController: IMapController) : Panel(context,mMapController), OnMapChangeListener {
|
||||
private val TAG = javaClass.simpleName
|
||||
|
||||
private var lastLonLatPoint: LonLatPoint? = null
|
||||
private var lastTitleId: Long = 0L
|
||||
private var roadSigns: ArrayList<RoadSign>? = ArrayList()
|
||||
private var mRoadSign: RoadSign? = null
|
||||
private var lanes: ArrayList<Lane>? = ArrayList()
|
||||
private val roadSignDisMap: MutableMap<Int, Double> = HashMap()
|
||||
private val roadSignAngleMap: MutableMap<Int, Double> = HashMap()
|
||||
|
||||
|
||||
init{
|
||||
setContentView(R.layout.panel_traffic_sign, LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT))
|
||||
setPos(context.getResources().getDimensionPixelSize(R.dimen.road_sign_top), 0, 0, context.getResources().getDimensionPixelSize(R.dimen.road_sign_right))
|
||||
setMyGravity(Gravity.TOP or Gravity.RIGHT)
|
||||
mMapController.getEventController()?.addMapChangeListener(this)
|
||||
|
||||
}
|
||||
override fun onShowPanel() {
|
||||
|
||||
}
|
||||
|
||||
override fun onHidPanel(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onPausePanel() {
|
||||
|
||||
}
|
||||
|
||||
override fun onResumePanel() {
|
||||
|
||||
}
|
||||
|
||||
override fun reset() {
|
||||
}
|
||||
|
||||
override fun setPos(top: Int?, bottom: Int?, left: Int?, right: Int?) {
|
||||
setMargin(top, bottom, left, right)
|
||||
}
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
|
||||
override fun onMapChange(mogoLocation: MogoLocation) {
|
||||
// val flag = !(CommonController.instance.mapView?.isSurfaceCreated()?:false)
|
||||
// if(flag){
|
||||
// return
|
||||
// }
|
||||
if(mMapController.getMapStyleParams().getStyleMode() < MapAutoApi.MAP_STYLE_NIGHT_VR){
|
||||
return
|
||||
}
|
||||
val lonlatPoint = LonLatPoint(mogoLocation.lon, mogoLocation.lat,mogoLocation.heading)
|
||||
if(lastLonLatPoint == null){
|
||||
lastLonLatPoint = lonlatPoint
|
||||
}
|
||||
|
||||
var dis = 0.0
|
||||
lastLonLatPoint?.let {
|
||||
dis = MathUtils.distance(it.longitude, it.latitude, lonlatPoint.longitude, lonlatPoint.latitude)
|
||||
}
|
||||
if (dis > 20) {
|
||||
lastLonLatPoint = lonlatPoint
|
||||
var tileId = MapAutoApi.getTileID(lonlatPoint.longitude, lonlatPoint.latitude, 13)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "tileId: ${tileId}")
|
||||
}
|
||||
if (lastTitleId != tileId) {
|
||||
roadSigns = RoadHelper.getInstance()?.getRoadSign(tileId)
|
||||
}
|
||||
var distance = 0.0
|
||||
mRoadSign = null
|
||||
roadSigns?.let { roadSigns ->
|
||||
if (roadSigns.size > 0) {
|
||||
for (roadSign in roadSigns) {
|
||||
if(roadSign.content == 0) {
|
||||
continue
|
||||
}
|
||||
roadSign.position?.let {
|
||||
var lon = 0.0
|
||||
var lat = 0.0
|
||||
|
||||
for (i in 0..3) {
|
||||
lon += it[i].lon
|
||||
lat += it[i].lat
|
||||
}
|
||||
lon /= 4
|
||||
lat /= 4
|
||||
distance = MathUtils.distance(lon, lat, lonlatPoint.longitude, lonlatPoint.latitude)
|
||||
|
||||
if (lastTitleId != tileId) {
|
||||
// lanes = MapDataApi.getLaneInfo(tileId, roadSign.roadId)
|
||||
// lanes?.let { lanes ->
|
||||
// if (lanes.size > 0) {
|
||||
// val lane = lanes[0]
|
||||
// if (lane.laneLatLonPoints != null && lane.laneLatLonPoints.size > 1) {
|
||||
// val angle = GisGeomTool.getAngleToNorth(lane.laneLatLonPoints[1].longitude - lane.laneLatLonPoints[0].longitude, lane.laneLatLonPoints[1].latitude - lane.laneLatLonPoints[0].latitude)
|
||||
// roadSignAngleMap.put(roadSign.id, angle)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// val angle = GisGeomTool.getAngleToNorth(it[1].lon - it[0].lon, it[1].lat - it[0].lat)
|
||||
// roadSignAngleMap.put(roadSign.id, angle)
|
||||
}
|
||||
|
||||
var disAngle = 0.0
|
||||
roadSignAngleMap[roadSign.id]?.let {
|
||||
disAngle = abs(lonlatPoint.angle - it)
|
||||
if(disAngle > 300){
|
||||
disAngle = 360 - disAngle
|
||||
}
|
||||
}
|
||||
roadSignDisMap[roadSign.id]?.let {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "id: ${roadSign.id},content: ${roadSign.content}, distance: ${distance}, lastDis: ${it}, carangle: ${lonlatPoint.angle}, angle:${roadSignAngleMap[roadSign.id]}, disAngle: ${disAngle}")
|
||||
}
|
||||
if (distance <= 50 && it > distance && disAngle < 90) {
|
||||
mRoadSign = roadSign
|
||||
}
|
||||
}
|
||||
roadSignDisMap.put(roadSign.id, distance)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (mRoadSign != null) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "mRoadSign--id: ${mRoadSign!!.id},content: ${mRoadSign!!.content}")
|
||||
}
|
||||
var resID = 0
|
||||
mRoadSign?.let {
|
||||
when (it.content) {
|
||||
1 -> {
|
||||
resID = R.mipmap.traffic_sign_1
|
||||
}
|
||||
2 -> {
|
||||
resID = R.mipmap.traffic_sign_2
|
||||
}
|
||||
3 -> {
|
||||
resID = R.mipmap.traffic_sign_3
|
||||
}
|
||||
4 -> {
|
||||
resID = R.mipmap.traffic_sign_4
|
||||
}
|
||||
5 -> {
|
||||
resID = R.mipmap.traffic_sign_5
|
||||
}
|
||||
6 -> {
|
||||
resID = R.mipmap.traffic_sign_6
|
||||
}
|
||||
7 -> {
|
||||
resID = R.mipmap.traffic_sign_7
|
||||
}
|
||||
8 -> {
|
||||
resID = R.mipmap.traffic_sign_8
|
||||
}
|
||||
// 9 -> {
|
||||
// resID = R.mipmap.traffic_sign_9
|
||||
// }
|
||||
10 -> {
|
||||
resID = R.mipmap.traffic_sign_10
|
||||
}
|
||||
11 -> {
|
||||
resID = R.mipmap.traffic_sign_11
|
||||
}
|
||||
12 -> {
|
||||
resID = R.mipmap.traffic_sign_12
|
||||
}
|
||||
13 -> {
|
||||
resID = R.mipmap.traffic_sign_13
|
||||
}
|
||||
20 -> {
|
||||
resID = R.mipmap.traffic_sign_20
|
||||
}
|
||||
22 -> {
|
||||
resID = R.mipmap.traffic_sign_22
|
||||
}
|
||||
23 -> {
|
||||
resID = R.mipmap.traffic_sign_23
|
||||
}
|
||||
24 -> {
|
||||
resID = R.mipmap.traffic_sign_24
|
||||
}
|
||||
25 -> {
|
||||
resID = R.mipmap.traffic_sign_25
|
||||
}
|
||||
26 -> {
|
||||
resID = R.mipmap.traffic_sign_26
|
||||
}
|
||||
27 -> {
|
||||
resID = R.mipmap.traffic_sign_27
|
||||
}
|
||||
28 -> {
|
||||
resID = R.mipmap.traffic_sign_28
|
||||
}
|
||||
31 -> {
|
||||
resID = R.mipmap.traffic_sign_31
|
||||
}
|
||||
32 -> {
|
||||
resID = R.mipmap.traffic_sign_32
|
||||
}
|
||||
33 -> {
|
||||
resID = R.mipmap.traffic_sign_33
|
||||
}
|
||||
34 -> {
|
||||
resID = R.mipmap.traffic_sign_34
|
||||
}
|
||||
35 -> {
|
||||
resID = R.mipmap.traffic_sign_35
|
||||
}
|
||||
36 -> {
|
||||
resID = R.mipmap.traffic_sign_36
|
||||
}
|
||||
37 -> {
|
||||
resID = R.mipmap.traffic_sign_37
|
||||
}
|
||||
38 -> {
|
||||
resID = R.mipmap.traffic_sign_38
|
||||
}
|
||||
39 -> {
|
||||
resID = R.mipmap.traffic_sign_39
|
||||
}
|
||||
40 -> {
|
||||
resID = R.mipmap.traffic_sign_40
|
||||
}
|
||||
41 -> {
|
||||
resID = R.mipmap.traffic_sign_41
|
||||
}
|
||||
42 -> {
|
||||
resID = R.mipmap.traffic_sign_42
|
||||
}
|
||||
43 -> {
|
||||
resID = R.mipmap.traffic_sign_43
|
||||
}
|
||||
44 -> {
|
||||
resID = R.mipmap.traffic_sign_44
|
||||
}
|
||||
45 -> {
|
||||
resID = R.mipmap.traffic_sign_45
|
||||
}
|
||||
}
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "mRoadSign--resID: ${resID}")
|
||||
}
|
||||
if(resID != 0) {
|
||||
iv_traffic.visibility = VISIBLE
|
||||
iv_traffic.setImageResource(resID)
|
||||
}else{
|
||||
iv_traffic.visibility = GONE
|
||||
}
|
||||
}
|
||||
} else {
|
||||
iv_traffic.visibility = GONE
|
||||
}
|
||||
}
|
||||
lastTitleId = tileId
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.zhidaoauto.map.sdk.inner.panel
|
||||
|
||||
import android.content.Context
|
||||
import android.view.Gravity
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
import com.zhidaoauto.map.sdk.R
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi
|
||||
import kotlinx.android.synthetic.main.panel_btn_zoom.view.img_zoom_in
|
||||
import kotlinx.android.synthetic.main.panel_btn_zoom.view.img_zoom_out
|
||||
|
||||
class PanelZoom(context: Context?,private val mMapController:IMapController) : Panel(context,mMapController), View.OnClickListener {
|
||||
|
||||
|
||||
|
||||
override fun onClick(v: View) {
|
||||
when(v.id){
|
||||
R.id.img_zoom_in->{
|
||||
mMapController?.zoomIn()
|
||||
}
|
||||
R.id.img_zoom_out->{
|
||||
mMapController?.zoomOut()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onShowPanel() {}
|
||||
override fun onHidPanel(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onPausePanel() {}
|
||||
override fun onResumePanel() {}
|
||||
override fun reset() {}
|
||||
override fun setPos(
|
||||
top: Int, bottom: Int, left: Int,
|
||||
right: Int
|
||||
) {
|
||||
setMargin(top, bottom, left, right)
|
||||
}
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
init {
|
||||
setContentView(R.layout.panel_btn_zoom, LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT))
|
||||
setMyGravity(Gravity.RIGHT or Gravity.BOTTOM)
|
||||
setPos(0, 165, 0, 25)
|
||||
val style = mMapController.getMapStyleParams().getStyleMode()
|
||||
if(style == MapAutoApi.MAP_STYLE_DAY || style == MapAutoApi.MAP_STYLE_DAY_VR){
|
||||
img_zoom_in.setImageResource(R.mipmap.icon_zoom_in_day)
|
||||
img_zoom_out.setImageResource(R.mipmap.icon_zoom_out_day)
|
||||
}else{
|
||||
img_zoom_in.setImageResource(R.mipmap.icon_zoom_in_night)
|
||||
img_zoom_out.setImageResource(R.mipmap.icon_zoom_out_night)
|
||||
}
|
||||
img_zoom_in.setOnClickListener(this)
|
||||
img_zoom_out.setOnClickListener(this)
|
||||
this.isFocusableInTouchMode = false
|
||||
this.isFocusable = false
|
||||
this.isClickable = false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package com.zhidaoauto.map.sdk.inner.panel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Point;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import com.zhidaoauto.map.sdk.open.abs.MapStatusListener;
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 绘制线面的自定义view
|
||||
*/
|
||||
public class PolyLineView extends View implements MapStatusListener {
|
||||
public static int TYPE_LINE = 0x00000;
|
||||
public static int TYPE_CIRCLE = 0x00001;
|
||||
public static int TYPE_RECT = 0x00002;
|
||||
public static int TYPE_OVIL = 0x00003;
|
||||
public static int TYPE_POLYGON = 0x00004;
|
||||
private List<Point> data;
|
||||
private Context context;
|
||||
private int type;
|
||||
private float radius;
|
||||
private int paintWidth;
|
||||
private int paintColor;
|
||||
private final int LISTENER_TYPE_LINE = 0x111;
|
||||
public List<Point> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<Point> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
//CommonController.getInstance().getMapController().registerStatusListener(this,LISTENER_TYPE_LINE);
|
||||
|
||||
}
|
||||
|
||||
public float getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
public void setRadius(float radius) {
|
||||
this.radius = radius;
|
||||
if (radius <= 5) {
|
||||
this.radius = 5;
|
||||
}
|
||||
}
|
||||
|
||||
public PolyLineView(Context context) {
|
||||
super(context);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public PolyLineView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public PolyLineView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
|
||||
public int getPaintWidth() {
|
||||
return paintWidth;
|
||||
}
|
||||
|
||||
public void setPaintWidth(int paintWidth) {
|
||||
this.paintWidth = paintWidth;
|
||||
if (paintWidth <= 5) {
|
||||
this.paintWidth = 5;
|
||||
}
|
||||
}
|
||||
|
||||
public int getPaintColor() {
|
||||
return paintColor;
|
||||
}
|
||||
|
||||
public void setPaintColor(int paintColor) {
|
||||
this.paintColor = paintColor;
|
||||
if (paintColor == 0) {
|
||||
this.paintColor = Color.GRAY;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
// Paint paint = new Paint();
|
||||
// paint.setAntiAlias(true);
|
||||
// paint.setDither(true);
|
||||
// paint.setColor(paintColor);
|
||||
// //设置画笔宽度
|
||||
// paint.setStrokeWidth(paintWidth);
|
||||
// if (type == TYPE_LINE) {
|
||||
// //设置空心
|
||||
// paint.setStyle(Paint.Style.STROKE);
|
||||
// } else {
|
||||
// paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
// paint.setAlpha(200);
|
||||
// }
|
||||
//
|
||||
// if (type == TYPE_LINE) {
|
||||
// // 画直线
|
||||
// Path path = new Path();
|
||||
// if (lonLatPoints != null && lonLatPoints.size() > 0) {
|
||||
// Point point = MapTools.INSTANCE.toScreenLocation(lonLatPoints.get(0));
|
||||
// path.moveTo(point.x, point.y);
|
||||
// for (int i = 0; i < lonLatPoints.size(); i++) {
|
||||
// Point point1 = MapTools.INSTANCE.toScreenLocation(lonLatPoints.get(i));
|
||||
// path.lineTo(point1.x, point1.y);
|
||||
// }
|
||||
// }
|
||||
// canvas.drawPath(path, paint);
|
||||
//
|
||||
// } else if (type == TYPE_CIRCLE) {
|
||||
// Point point = MapTools.INSTANCE.toScreenLocation(lonLatPoint);
|
||||
// //绘制圆
|
||||
// canvas.drawCircle(point.x, point.y, radius, paint);
|
||||
// } else if (type == TYPE_RECT) {
|
||||
// List<Point> points = MapTools.INSTANCE.toScreenLocations(lonLatPoints);
|
||||
// //矩形
|
||||
// Rect rect = new Rect(points.get(0).x, points.get(0).y, points.get(3).x, points.get(3).y);
|
||||
// canvas.drawRect(rect, paint);
|
||||
// } else if (type == TYPE_OVIL) {
|
||||
// List<Point> points = MapTools.INSTANCE.toScreenLocations(lonLatPoints);
|
||||
// //定义一个矩形区域
|
||||
// RectF oval = new RectF(points.get(0).x, points.get(0).y, points.get(3).x, points.get(3).y);
|
||||
// //矩形区域内切椭圆
|
||||
// canvas.drawOval(oval, paint);// drawOval 绘制椭圆
|
||||
// } else if (type == TYPE_POLYGON) {
|
||||
// Path mPathRect = new Path();
|
||||
// if (lonLatPoints != null && lonLatPoints.size() > 0) {
|
||||
// Point point = MapTools.INSTANCE.toScreenLocation(lonLatPoints.get(0));
|
||||
// mPathRect.moveTo(point.x, point.y);
|
||||
// for (int i = 0; i < lonLatPoints.size(); i++) {
|
||||
// Point point1 = MapTools.INSTANCE.toScreenLocation(lonLatPoints.get(i));
|
||||
// mPathRect.lineTo(point1.x, point1.y);
|
||||
// }
|
||||
// }
|
||||
// paint.setStyle(Paint.Style.STROKE);
|
||||
// mPathRect.close();//效果和mPath.lineTo(200,200);//将最后到达的点和第一个点连接起来
|
||||
// canvas.drawPath(mPathRect, paint);//画出路径
|
||||
//
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
// CommonController.getInstance().getMapController().unRegisterStatusListener(this,LISTENER_TYPE_LINE);
|
||||
}
|
||||
|
||||
private List<LonLatPoint> lonLatPoints;
|
||||
private LonLatPoint lonLatPoint;
|
||||
|
||||
public void setLonlatPoints(List<LonLatPoint> lonLatPoints) {
|
||||
this.lonLatPoints = lonLatPoints;
|
||||
}
|
||||
|
||||
public void setLonLatPoint(LonLatPoint lonLatPoint) {
|
||||
this.lonLatPoint = lonLatPoint;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onMapStatusChanged(int type, int value) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,879 @@
|
||||
package com.zhidaoauto.map.sdk.inner.panel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Align;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.location.GpsSatellite;
|
||||
import android.location.GpsStatus;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.zhidaoauto.map.sdk.R;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class SatelliteSkyView extends View {
|
||||
|
||||
private int text1_x = 66;
|
||||
private int text2_x = 165;
|
||||
private int text3_x = 340;
|
||||
private int text4_x = 46;
|
||||
private int text5_x = 210;
|
||||
private int text6_x = 377;
|
||||
private int text1_y = 57;
|
||||
private int text2_y = 57;
|
||||
private int text3_y = 57;
|
||||
private int text4_y = 133;
|
||||
private int text5_y = 133;
|
||||
private int text6_y = 133;
|
||||
private int radius = 130;// 星球半径
|
||||
private int centerX = 240;// 星球中心点x值
|
||||
private int centerY = 425;// 星球中心点y值
|
||||
private int ballR = 35; // 小球半径
|
||||
private int redR = 175;
|
||||
private int settingX=460;
|
||||
private int settingY=670;
|
||||
|
||||
private Paint mGridPaint;
|
||||
private Paint mTextPaint;
|
||||
private Paint mBackground;
|
||||
|
||||
private Bitmap mbg;
|
||||
private Bitmap[] number = new Bitmap[10];
|
||||
private Bitmap[] lNumber = new Bitmap[10];
|
||||
private Bitmap water;
|
||||
private Bitmap arrow;
|
||||
private Bitmap sector;
|
||||
private Bitmap dot;
|
||||
private Bitmap greenDot;
|
||||
private Bitmap grayDot;
|
||||
private Bitmap yellowDot;
|
||||
|
||||
private int signalBottom;
|
||||
private int signalTop;
|
||||
private int[] signalX = new int[12];
|
||||
private int signalWidth;
|
||||
private float degree = 0;
|
||||
private float acc = 0;
|
||||
private float dirX = 0;
|
||||
private float dirY = 0;
|
||||
private float m_sensorDir = 0;
|
||||
private float[] lastA = new float[3];
|
||||
private float[] initA = new float[3];
|
||||
private boolean start = false;
|
||||
private int count = 0;
|
||||
private int m_nScreenWidth = 0;
|
||||
private int m_nScreenHeight = 0;
|
||||
int nDispH = this.getHeight();
|
||||
|
||||
private float x; //水珠坐标
|
||||
private float y;
|
||||
private float nx;//水珠重力坐标
|
||||
private float ny;
|
||||
private float sx = -80; //雷达坐标
|
||||
private float sy = -165;
|
||||
private double dx;//三角变换
|
||||
private double dy;
|
||||
private int delayCount = 0;
|
||||
private float m_AccX;
|
||||
private float m_AccY;
|
||||
private int lastDir = 0;
|
||||
private float v = 2;
|
||||
private GradientDrawable mDrawable;
|
||||
private Paint blackPaint;
|
||||
|
||||
private float mBitmapAdjustment;
|
||||
|
||||
public final static int MAX_SATS = 12;
|
||||
|
||||
private int mSatellites;
|
||||
private int[] mPrns = null;
|
||||
private float[] mElevation = null;
|
||||
private float[] mAzimuth = null;
|
||||
private float[] mSnrs = null;
|
||||
private float[] mX = null;
|
||||
private float[] mY = null;
|
||||
private int mUsedInFixMask = 0;
|
||||
private double lon = 0;
|
||||
private double lat = 0;
|
||||
|
||||
// 画信号强度
|
||||
private Paint mLinePaint;
|
||||
private Paint mBarPaintUsed;
|
||||
private Paint mBarPaintUnused;
|
||||
private Paint mBarPaintNoFix;
|
||||
private Paint mBarOutlinePaint;
|
||||
|
||||
private double mAlt = 0;
|
||||
private long mTime = -1;
|
||||
private int mSpeed = 0;
|
||||
// 横竖屏模式
|
||||
private boolean m_bW = false;
|
||||
private int m_nDensity = 240;
|
||||
private boolean flagDir = false;
|
||||
private boolean flagBall = false;
|
||||
private SensorManager sensorManager;
|
||||
|
||||
private float fltScale = 0f;
|
||||
|
||||
private Bitmap bitmap;
|
||||
|
||||
private Bitmap setting;
|
||||
|
||||
private GpsStatus gsv = null;;
|
||||
|
||||
public void setExtraInfo(double a, long t, int s) {
|
||||
this.mAlt = a;
|
||||
this.mTime = t;
|
||||
this.mSpeed = s;
|
||||
}
|
||||
|
||||
private void computeXY() {
|
||||
for (int i = 0; i < mSatellites; ++i) {
|
||||
double theta = -(mAzimuth[i] - 90);
|
||||
double rad = theta * Math.PI / 180.0;
|
||||
mX[i] = (float) Math.cos(rad);
|
||||
mY[i] = -(float) Math.sin(rad);
|
||||
mElevation[i] = 90 - mElevation[i];
|
||||
}
|
||||
}
|
||||
|
||||
private float[] gacc = new float[3];
|
||||
private float[] dir = new float[3];
|
||||
private float[] lacc = new float[3];
|
||||
private long curTime = 0;
|
||||
|
||||
private final SensorEventListener sensorEventListener = new SensorEventListener() {
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
if (event.sensor.getType() == Sensor.TYPE_LINEAR_ACCELERATION) {
|
||||
lacc[0] = event.values[0];
|
||||
lacc[1] = event.values[1];
|
||||
lacc[2] = event.values[2];
|
||||
}else if(event.sensor.getType() == Sensor.TYPE_ORIENTATION){
|
||||
dir[0] = event.values[0];
|
||||
dir[1] = event.values[1];
|
||||
dir[2] = event.values[2];
|
||||
}else if(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER){
|
||||
gacc[0] = event.values[0];
|
||||
gacc[1] = event.values[1];
|
||||
gacc[2] = event.values[2];
|
||||
}
|
||||
if(curTime == 0) {
|
||||
curTime = System.currentTimeMillis();
|
||||
} else if(System.currentTimeMillis() - curTime > 50){
|
||||
curTime = System.currentTimeMillis();
|
||||
update(gacc, dir, lacc);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor arg0, int arg1) {
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
private Context mContext;
|
||||
|
||||
public void Resume() {
|
||||
sensorManager.registerListener(
|
||||
sensorEventListener,
|
||||
sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION),
|
||||
SensorManager.SENSOR_DELAY_FASTEST
|
||||
);
|
||||
sensorManager.registerListener(
|
||||
sensorEventListener,
|
||||
sensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION),
|
||||
SensorManager.SENSOR_DELAY_FASTEST
|
||||
);
|
||||
sensorManager.registerListener(
|
||||
sensorEventListener,
|
||||
sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
|
||||
SensorManager.SENSOR_DELAY_FASTEST
|
||||
);
|
||||
}
|
||||
|
||||
public void Destroy() {
|
||||
sensorManager.unregisterListener(sensorEventListener);
|
||||
}
|
||||
|
||||
public SatelliteSkyView(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||
curTime = 0;
|
||||
int nbgID = R.mipmap.navi_gpssv;
|
||||
{
|
||||
// 竖屏
|
||||
x = centerX;
|
||||
y = centerY;
|
||||
|
||||
//信号显示位置设置
|
||||
signalTop = 719;
|
||||
signalBottom = 782;
|
||||
signalWidth = 13;
|
||||
signalX[0] =31;
|
||||
for(int i=1 ; i<12; i++){
|
||||
signalX[i] = signalX[i-1]+37;
|
||||
if(i>=3 && i<=6){
|
||||
signalX[i]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
mDrawable = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
|
||||
new int[] { 0xff7bd497, 0x557bd497 });//13d346
|
||||
blackPaint = new Paint();
|
||||
blackPaint.setStrokeWidth(13);
|
||||
blackPaint.setAlpha(255);
|
||||
blackPaint.setARGB(255, 7, 7, 7);
|
||||
|
||||
try {
|
||||
mbg = decodeResource(this.getResources(), nbgID);
|
||||
setting = decodeResource(this.getResources(), R.mipmap.navi_gps_set);
|
||||
number[0] = decodeResource(this.getResources(), R.mipmap.n0);
|
||||
number[1] = decodeResource(this.getResources(), R.mipmap.n1);
|
||||
number[2] = decodeResource(this.getResources(), R.mipmap.n2);
|
||||
number[3] = decodeResource(this.getResources(), R.mipmap.n3);
|
||||
number[4] = decodeResource(this.getResources(), R.mipmap.n4);
|
||||
number[5] = decodeResource(this.getResources(), R.mipmap.n5);
|
||||
number[6] = decodeResource(this.getResources(), R.mipmap.n6);
|
||||
number[7] = decodeResource(this.getResources(), R.mipmap.n7);
|
||||
number[8] = decodeResource(this.getResources(), R.mipmap.n8);
|
||||
number[9] = decodeResource(this.getResources(), R.mipmap.n9);
|
||||
|
||||
lNumber[0] = decodeResource(this.getResources(), R.mipmap.l0);
|
||||
lNumber[1] = decodeResource(this.getResources(), R.mipmap.l1);
|
||||
lNumber[2] = decodeResource(this.getResources(), R.mipmap.l2);
|
||||
lNumber[3] = decodeResource(this.getResources(), R.mipmap.l3);
|
||||
lNumber[4] = decodeResource(this.getResources(), R.mipmap.l4);
|
||||
lNumber[5] = decodeResource(this.getResources(), R.mipmap.l5);
|
||||
lNumber[6] = decodeResource(this.getResources(), R.mipmap.l6);
|
||||
lNumber[7] = decodeResource(this.getResources(), R.mipmap.l7);
|
||||
lNumber[8] = decodeResource(this.getResources(), R.mipmap.l8);
|
||||
lNumber[9] = decodeResource(this.getResources(), R.mipmap.l9);
|
||||
|
||||
water = decodeResource(this.getResources(), R.mipmap.water);
|
||||
arrow = decodeResource(this.getResources(), R.mipmap.arrow);
|
||||
sector = decodeResource(this.getResources(), R.mipmap.sector);
|
||||
dot = decodeResource(this.getResources(), R.mipmap.dot);
|
||||
|
||||
greenDot = decodeResource(this.getResources(), R.mipmap.green_dot);
|
||||
grayDot = decodeResource(this.getResources(), R.mipmap.gray_dot);
|
||||
yellowDot = decodeResource(this.getResources(), R.mipmap.yellow_dot);
|
||||
|
||||
float fltWScale = 1.0f * this.getWidth() / mbg.getWidth();
|
||||
float fltHScale = 1.0f * this.getHeight() / mbg.getHeight();
|
||||
|
||||
if(fltWScale > fltHScale){
|
||||
fltScale = fltHScale;
|
||||
}
|
||||
else{
|
||||
fltScale = fltWScale;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
mGridPaint = new Paint();
|
||||
mGridPaint.setColor(0xFFDDDDDD);
|
||||
mGridPaint.setAntiAlias(true);
|
||||
mGridPaint.setStyle(Style.STROKE);
|
||||
mGridPaint.setStrokeWidth(1.0f);
|
||||
|
||||
mBackground = new Paint();
|
||||
mBackground.setColor(0xFF4444DD);
|
||||
|
||||
mTextPaint = new Paint();
|
||||
mTextPaint.setAntiAlias(true);
|
||||
mTextPaint.setColor(0xFFFFFFFF);
|
||||
|
||||
mTextPaint.setTextSize(16);
|
||||
mTextPaint.setTextAlign(Align.CENTER);
|
||||
|
||||
mBitmapAdjustment = 10;
|
||||
|
||||
mLinePaint = new Paint();
|
||||
mLinePaint.setColor(0xFFDDDDDD);
|
||||
mLinePaint.setAntiAlias(true);
|
||||
mLinePaint.setStyle(Style.STROKE);
|
||||
mLinePaint.setStrokeWidth(1.0f);
|
||||
|
||||
mBarPaintUsed = new Paint();
|
||||
mBarPaintUsed.setColor(0xFF00BB00);
|
||||
mBarPaintUsed.setAntiAlias(true);
|
||||
mBarPaintUsed.setStyle(Style.FILL);
|
||||
mBarPaintUsed.setStrokeWidth(1.0f);
|
||||
|
||||
mBarPaintUnused = new Paint(mBarPaintUsed);
|
||||
mBarPaintUnused.setColor(0xFFFFCC33);
|
||||
|
||||
mBarPaintNoFix = new Paint(mBarPaintUsed);
|
||||
mBarPaintNoFix.setStyle(Style.STROKE);
|
||||
|
||||
mBarOutlinePaint = new Paint();
|
||||
mBarOutlinePaint.setColor(0xFFFFFFFF);
|
||||
mBarOutlinePaint.setAntiAlias(true);
|
||||
mBarOutlinePaint.setStyle(Style.STROKE);
|
||||
mBarOutlinePaint.setStrokeWidth(1.0f);
|
||||
}
|
||||
|
||||
public void setLonLat(double lon, double lat) {
|
||||
this.lon = lon;
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
|
||||
boolean bReset = false;
|
||||
int nbgID = R.mipmap.navi_gpssv;
|
||||
mbg = decodeResource(this.getResources(), nbgID);
|
||||
|
||||
float fltWScale = 1.0f * w / mbg.getWidth();
|
||||
float fltHScale = 1.0f * h / mbg.getHeight();
|
||||
|
||||
if(fltWScale > fltHScale){
|
||||
fltScale = fltHScale;
|
||||
}
|
||||
else{
|
||||
fltScale = fltWScale;
|
||||
}
|
||||
if (this.getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
if (!m_bW) {
|
||||
return;
|
||||
}
|
||||
|
||||
bReset = true;
|
||||
// 竖屏
|
||||
text1_x = 111;
|
||||
text2_x = 280;
|
||||
text3_x = 540;
|
||||
text4_x = 94;
|
||||
text5_x = 334;
|
||||
text6_x = 565;
|
||||
text1_y = 95;
|
||||
text2_y = 95;
|
||||
text3_y = 95;
|
||||
text4_y = 208;
|
||||
text5_y = 208;
|
||||
text6_y = 208;
|
||||
|
||||
settingX=460;
|
||||
settingY=670;
|
||||
|
||||
radius = 186;
|
||||
centerX = 360;
|
||||
centerY = 638;
|
||||
x = centerX;
|
||||
y = centerY;
|
||||
redR = 295;
|
||||
sx = -185;
|
||||
sy = -195;
|
||||
//信号显示位置设置
|
||||
signalTop = 1074;
|
||||
signalBottom = 1171;
|
||||
signalWidth = 20;
|
||||
signalX[0] =48;
|
||||
for(int i=1 ; i<12; i++){
|
||||
signalX[i] = signalX[i-1]+55;
|
||||
if(i>=3 && i<=6){
|
||||
signalX[i]++;
|
||||
}
|
||||
}
|
||||
sector = decodeResource(this.getResources(), R.mipmap.sector);
|
||||
m_bW = false;
|
||||
} else {
|
||||
if (m_bW) {
|
||||
return;
|
||||
}
|
||||
|
||||
bReset = true;
|
||||
// 横屏
|
||||
text1_x = 135;
|
||||
text2_x = 60;
|
||||
text3_x = 85;
|
||||
text4_x = 120;
|
||||
text5_x = 120;
|
||||
text6_x = 135;
|
||||
text1_y = 85;
|
||||
text2_y = 600;
|
||||
text3_y = 290;
|
||||
text4_y = 500;
|
||||
text5_y = 400;
|
||||
text6_y = 190;
|
||||
|
||||
radius = 172;
|
||||
centerX = 645;
|
||||
centerY = 335;
|
||||
x = centerX;
|
||||
y = centerY;
|
||||
sx = -184;
|
||||
sy = -186;
|
||||
redR = 275;
|
||||
//信号显示位置设置
|
||||
signalTop = 1193;
|
||||
signalBottom = 1089;
|
||||
signalWidth = 20;
|
||||
signalX[0] =57;
|
||||
for(int i=1 ; i<12; i++){
|
||||
signalX[i] = signalX[i-1]+50;
|
||||
if(i>=3 && i<=6){
|
||||
signalX[i]++;
|
||||
}
|
||||
}
|
||||
m_nScreenWidth = this.getWidth();
|
||||
m_nScreenHeight = this.getHeight();
|
||||
//nbgID = R.mipmap.navi_gpssv_h;
|
||||
//sector = decodeResource(this.getResources(), R.mipmap.sector1);
|
||||
m_bW = true;
|
||||
}
|
||||
|
||||
if (bReset) {
|
||||
try {
|
||||
mbg = decodeResource(this.getResources(), nbgID);
|
||||
if(bitmap != null){
|
||||
bitmap.recycle();
|
||||
bitmap = null;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
|
||||
super.onDraw(canvas);
|
||||
int nDispW = this.getWidth();
|
||||
int nDispH = this.getHeight();
|
||||
int nBgWidth = mbg.getWidth();
|
||||
int nBgHeight = mbg.getHeight();
|
||||
|
||||
m_nScreenWidth = nDispW;
|
||||
m_nScreenHeight = nDispH;
|
||||
|
||||
if(bitmap == null){
|
||||
bitmap = Bitmap.createBitmap(mbg.getWidth(), mbg.getHeight(), Bitmap.Config.RGB_565);
|
||||
}
|
||||
|
||||
canvas.setDensity(m_nDensity);
|
||||
bitmap.setDensity(m_nDensity);
|
||||
Canvas tmpCanvas = new Canvas(bitmap);
|
||||
drawView(tmpCanvas);
|
||||
|
||||
int nBgW = (int)(fltScale * nBgWidth);
|
||||
int nBgH = (int)(fltScale * nBgHeight);
|
||||
Rect src = new Rect(0, 0, nBgWidth, nBgHeight);
|
||||
Rect dst = new Rect((nDispW-nBgW)/2, (nDispH-nBgH)/2, (nDispW+nBgW)/2, (nDispH+nBgH)/2);
|
||||
canvas.drawBitmap(bitmap, src, dst, null);
|
||||
}
|
||||
|
||||
private void drawView(Canvas canvas){
|
||||
if(null == canvas){
|
||||
return;
|
||||
}
|
||||
canvas.drawBitmap(mbg, 0, 0, null);
|
||||
canvas.drawBitmap(setting, settingX-setting.getWidth(), settingY-setting.getHeight(), null);
|
||||
//气泡
|
||||
if(!m_bW) {
|
||||
canvas.drawBitmap(water, x-ballR, y-ballR, null);
|
||||
} else{
|
||||
if(m_AccX > 3){
|
||||
canvas.drawBitmap(water, centerX + (y - centerY) - ballR, centerY - (x - centerX) - ballR, null);
|
||||
flagBall = true;
|
||||
}else if(m_AccX < -3){
|
||||
canvas.drawBitmap(water, centerX - (y - centerY) - ballR, centerY + (x - centerX) - ballR, null);
|
||||
flagBall = false;
|
||||
}else{
|
||||
if(flagBall) {
|
||||
canvas.drawBitmap(water, centerX + (y - centerY) - ballR, centerY - (x - centerX) - ballR, null);
|
||||
} else {
|
||||
canvas.drawBitmap(water, centerX - (y - centerY) - ballR, centerY + (x - centerX) - ballR, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//罗盘箭头
|
||||
float dirTmp = m_sensorDir;
|
||||
if(m_bW){
|
||||
if(m_AccX > 3){
|
||||
m_sensorDir = (m_sensorDir + 90) % 360;
|
||||
flagDir = true;
|
||||
}else if(m_AccX < -3){
|
||||
m_sensorDir = (m_sensorDir - 90 + 360) % 360;
|
||||
flagDir = false;
|
||||
}else{
|
||||
if(flagDir) {
|
||||
m_sensorDir = (m_sensorDir + 90) % 360;
|
||||
} else {
|
||||
m_sensorDir = (m_sensorDir - 90 + 360) % 360;
|
||||
}
|
||||
}
|
||||
}
|
||||
canvas.save();
|
||||
canvas.translate(centerX, centerY);
|
||||
int ndir = (int)m_sensorDir;
|
||||
m_sensorDir = dirTmp;
|
||||
int delta = ((360 - ndir) - lastDir + 360) % 360;
|
||||
if(delta > 2){
|
||||
if(delta < 180){
|
||||
lastDir = (lastDir + 1 + delta / 3) % 360;
|
||||
}else{
|
||||
lastDir = (lastDir - 1 - (360-delta) / 3+ 360) % 360;
|
||||
}
|
||||
}
|
||||
canvas.rotate(lastDir);
|
||||
canvas.drawBitmap(arrow, (float)-15, (float)(-redR-45), null);
|
||||
canvas.restore();
|
||||
|
||||
//扫描扇形进行旋转
|
||||
canvas.save();
|
||||
canvas.translate(centerX, centerY);
|
||||
canvas.rotate((degree += 3)%360);
|
||||
canvas.drawBitmap(sector, sx, sy, null);
|
||||
canvas.restore();
|
||||
|
||||
// GpsStatus gsv = MainInfo.GetInstance().getNaviControler().GetCurGSV();
|
||||
|
||||
if(gsv == null){
|
||||
// gsv = CommonController.getInstance().getLocationMgr(mContext).getGpsStatus(gsv);
|
||||
}
|
||||
|
||||
if (gsv != null) {
|
||||
Iterable<GpsSatellite> sats = gsv.getSatellites();
|
||||
Iterator<GpsSatellite> iter = sats.iterator();
|
||||
|
||||
int nMaxNum = gsv.getMaxSatellites();
|
||||
if( nMaxNum <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
mPrns = new int[nMaxNum];
|
||||
mElevation = new float[nMaxNum];
|
||||
mAzimuth = new float[nMaxNum];
|
||||
mSnrs = new float[nMaxNum];
|
||||
mX = new float[nMaxNum];
|
||||
mY = new float[nMaxNum];
|
||||
|
||||
int count = 0;
|
||||
mUsedInFixMask = 0;
|
||||
|
||||
while (iter.hasNext()) {
|
||||
GpsSatellite sat = (GpsSatellite) iter.next();
|
||||
|
||||
int mPrn = sat.getPrn();
|
||||
float mSnr = sat.getSnr();
|
||||
float mElev = sat.getElevation();
|
||||
float mAzi = sat.getAzimuth();
|
||||
|
||||
if (mElev >= 90 || mAzi< 0 || mPrn <= 0 || mSnr < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mPrns[count] = mPrn;
|
||||
mSnrs[count] = mSnr;
|
||||
mElevation[count] = mElev;
|
||||
mAzimuth[count] = mAzi;
|
||||
|
||||
if (sat.usedInFix()) {
|
||||
mUsedInFixMask += 1;
|
||||
}
|
||||
|
||||
mUsedInFixMask <<= 1;
|
||||
count++;
|
||||
}
|
||||
|
||||
mSatellites = count;
|
||||
computeXY();
|
||||
}
|
||||
|
||||
final Paint gridPaint = mGridPaint;
|
||||
final Paint textPaint = mTextPaint;
|
||||
|
||||
double scale = radius / 90.0;
|
||||
|
||||
for (int i = 0; i < mSatellites; ++i) {
|
||||
//屏蔽无效星历
|
||||
if (mElevation[i] >= 90 || mAzimuth[i] <= 0) {
|
||||
continue;
|
||||
}
|
||||
double a = mElevation[i] * scale;
|
||||
|
||||
int x = (int) Math.round(centerX + (mX[i] * a) - mBitmapAdjustment);
|
||||
int y = (int) Math.round(centerY + (mY[i] * a) - mBitmapAdjustment);
|
||||
|
||||
if (0 == mUsedInFixMask || mSnrs[i] <= 0) {
|
||||
//gridPaint.setColor(Color.GRAY);
|
||||
// 地图上的卫星符号
|
||||
canvas.drawBitmap(grayDot, x, y,null);
|
||||
} else if (0 != (mUsedInFixMask & (1 << (mSatellites - i)))) {
|
||||
// 可用
|
||||
gridPaint.setColor(Color.GREEN);
|
||||
canvas.drawBitmap(greenDot, x, y,null);
|
||||
} else {
|
||||
gridPaint.setColor(Color.YELLOW);
|
||||
canvas.drawBitmap(yellowDot, x, y,null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * GPS状态: 搜索中 已连接 速度 高程 方向 卫星颗数(有效的) 时间
|
||||
final int fill = 18;
|
||||
float slotWidth = 36;
|
||||
float barWidth = slotWidth - fill;
|
||||
|
||||
// 宽13 11 间隔 11
|
||||
if (gsv != null) {
|
||||
for (int i = 0; i < mSatellites; ++i) {
|
||||
if (mSnrs[i] < 0) {
|
||||
mSnrs[i] = 0;
|
||||
// MainInfo.GetInstance().LogAdd("GPS: i=" + i + "<0");
|
||||
}else if(mSnrs[i] >= 70){
|
||||
mSnrs[i] = 70;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int mSatellitesInUsed = 0;
|
||||
|
||||
for (int i = 0; i < mSatellites; ++i) {
|
||||
if (mPrns[i] <= 0 || mSnrs[i] < 0) {
|
||||
continue;
|
||||
}
|
||||
if(mSatellitesInUsed >= MAX_SATS){
|
||||
break;
|
||||
}
|
||||
if(!m_bW){//竖屏
|
||||
mDrawable.setBounds(new Rect(signalX[i],signalTop,signalX[i] + signalWidth,signalBottom));
|
||||
mDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
|
||||
|
||||
|
||||
if (0 == mUsedInFixMask) {
|
||||
mDrawable.setColor(0xff858585);
|
||||
} else if (0 != (mUsedInFixMask & (1 << (mSatellites - i)))) {
|
||||
mDrawable.setColor(0xff7bd497);
|
||||
} else {
|
||||
mDrawable.setColor(0xffffa300);
|
||||
}
|
||||
mDrawable.draw(canvas);
|
||||
canvas.drawLine(signalX[i] + signalWidth/2, signalTop, signalX[i] + signalWidth/2, signalBottom - mSnrs[i], blackPaint);
|
||||
int n = mPrns[i]%100/10;
|
||||
if(n > 0){
|
||||
canvas.drawBitmap(lNumber[n], signalX[i]-12, signalBottom -5,null);
|
||||
canvas.drawBitmap(lNumber[mPrns[i]%10], signalX[i]-1, signalBottom -5 ,null);
|
||||
}else{
|
||||
canvas.drawBitmap(lNumber[mPrns[i]%10], signalX[i]-8, signalBottom -5 ,null);
|
||||
}
|
||||
} else {
|
||||
mDrawable.setBounds(new Rect(signalBottom,signalX[i],signalTop,signalX[i] + signalWidth));
|
||||
mDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
|
||||
mDrawable.draw(canvas);
|
||||
|
||||
canvas.drawLine(signalTop, signalX[i] + signalWidth/2, signalBottom + mSnrs[i],signalX[i] + signalWidth/2, blackPaint);
|
||||
canvas.drawBitmap(lNumber[mPrns[i]%100/10], signalBottom -38,signalX[i]-10, null);
|
||||
canvas.drawBitmap(lNumber[mPrns[i]%10], signalBottom-25,signalX[i]-10, null);
|
||||
}
|
||||
mSatellitesInUsed++;
|
||||
|
||||
}
|
||||
|
||||
//卫星颗数
|
||||
if(mSatellites < 10){
|
||||
//canvas.drawBitmap(number[0], text1_x, text1_y,null);
|
||||
canvas.drawBitmap(number[mSatellites], text1_x, text1_y,null);
|
||||
}
|
||||
else{
|
||||
canvas.drawBitmap(number[mSatellites%100/10], text1_x, text1_y,null);
|
||||
canvas.drawBitmap(number[mSatellites%10], text1_x+25, text1_y,null);
|
||||
}
|
||||
//时间
|
||||
Date date = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
||||
String s = sdf.format(date);
|
||||
//System.out.println(s);
|
||||
canvas.drawBitmap(number[(int)(s.charAt(0)-'0')], text2_x, text2_y,null);
|
||||
canvas.drawBitmap(number[(int)(s.charAt(1)-'0')], text2_x+20, text2_y,null);
|
||||
canvas.drawBitmap(dot, text2_x+40, text2_y-2,null);
|
||||
canvas.drawBitmap(dot, text2_x+40, text2_y+10,null);
|
||||
canvas.drawBitmap(number[(int)(s.charAt(3)-'0')], text2_x+55, text2_y,null);
|
||||
canvas.drawBitmap(number[(int)(s.charAt(4)-'0')], text2_x+75, text2_y,null);
|
||||
canvas.drawBitmap(dot, text2_x+95, text2_y-2,null);
|
||||
canvas.drawBitmap(dot, text2_x+95, text2_y+10,null);
|
||||
canvas.drawBitmap(number[(int)(s.charAt(6)-'0')], text2_x+110, text2_y,null);
|
||||
canvas.drawBitmap(number[(int)(s.charAt(7)-'0')], text2_x+130, text2_y,null);
|
||||
//方向角
|
||||
dirX = ((dirX % 360) + 360) % 360;
|
||||
s = String.valueOf(dirX);
|
||||
int startLocation = text3_x;
|
||||
for(int i = 0 ; i < s.length() ; i++){
|
||||
if(s.charAt(i) == '.'){
|
||||
canvas.drawBitmap(dot, startLocation, text3_y+12,null);
|
||||
startLocation +=15 ;
|
||||
canvas.drawBitmap(number[s.charAt(i+1)-'0'], startLocation, text3_y,null);
|
||||
break;
|
||||
}
|
||||
canvas.drawBitmap(number[s.charAt(i)-'0'], startLocation, text3_y,null);
|
||||
startLocation +=20 ;
|
||||
}
|
||||
//俯仰角
|
||||
s = String.valueOf(dirY);
|
||||
startLocation = text4_x;
|
||||
for(int i = 0 ; i < s.length() ; i++){
|
||||
if(s.charAt(i) == '.'){
|
||||
canvas.drawBitmap(dot, startLocation, text4_y+12,null);
|
||||
startLocation +=15 ;
|
||||
canvas.drawBitmap(number[s.charAt(i+1)-'0'], startLocation, text4_y,null);
|
||||
break;
|
||||
}
|
||||
canvas.drawBitmap(number[s.charAt(i)-'0'], startLocation, text4_y,null);
|
||||
startLocation +=20 ;
|
||||
}
|
||||
//加速度
|
||||
s= String.valueOf(acc);
|
||||
startLocation = text5_x;
|
||||
for(int i = 0; i < s.length(); i++ ){
|
||||
if(s.charAt(i) == '.'){
|
||||
canvas.drawBitmap(dot, startLocation, text5_y+12,null);
|
||||
startLocation +=15 ;
|
||||
canvas.drawBitmap(number[s.charAt(i+1)-'0'], startLocation, text5_y,null);
|
||||
break;
|
||||
}
|
||||
canvas.drawBitmap(number[s.charAt(i)-'0'], startLocation, text5_y,null);
|
||||
startLocation += 20;
|
||||
}
|
||||
|
||||
//速度
|
||||
s= String.valueOf(mSpeed);
|
||||
startLocation = text6_x - (s.length()-1) * 10;
|
||||
for(int i = 0; i < s.length() ; i++ ){
|
||||
if(s.charAt(i) == '.') {
|
||||
canvas.drawBitmap(dot, startLocation, text6_y+12,null);
|
||||
} else {
|
||||
canvas.drawBitmap(number[s.charAt(i)-'0'], startLocation, text6_y,null);
|
||||
}
|
||||
startLocation += 20;
|
||||
}
|
||||
}
|
||||
|
||||
private Bitmap decodeResource(Resources resources, int id) {
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.inTargetDensity = m_nDensity;
|
||||
return BitmapFactory.decodeResource(resources, id, opts);
|
||||
}
|
||||
|
||||
public void update(float[] a, float dir[], float[] la) {
|
||||
m_AccX = a[0];
|
||||
m_AccY = a[1];
|
||||
m_sensorDir = dir[0];
|
||||
if(delayCount % 20 == 0){
|
||||
acc = (float) Math.sqrt(la[0]*la[0] + la[1]*la[1] + la[2]*la[2]);
|
||||
dirX = dir[0];
|
||||
dirY = (-dir[1] + 360) % 360;
|
||||
delayCount = 0;
|
||||
}
|
||||
delayCount++;
|
||||
if(!start){
|
||||
if(count == 0){
|
||||
initA[0] = a[0];
|
||||
initA[1] = a[1];
|
||||
count++;
|
||||
return;
|
||||
}else if(count < 10){
|
||||
initA[0] = (float) (initA[0] * 0.8 + a[0] * 0.2);
|
||||
initA[1] = (float) (initA[1] * 0.8 + a[1] * 0.2);
|
||||
count++;
|
||||
return;
|
||||
}else{
|
||||
start = true;
|
||||
lastA[0] = initA[0];
|
||||
lastA[1] = initA[1];
|
||||
}
|
||||
}
|
||||
float mod = (a[0] - lastA[0]) * (a[0] - lastA[0]) + (a[1] - lastA[1]) * (a[1] - lastA[1]);
|
||||
if(mod > 0.1){
|
||||
nx = centerX + (a[0] - initA[0]) * 70;
|
||||
ny = centerY - (a[1] - initA[1]) * 70;
|
||||
double d = Math.sqrt((nx - x) * (nx - x) + (ny - y) * (ny - y));
|
||||
dx = (nx - x) / d;
|
||||
dy = (ny - y) / d;
|
||||
lastA[0] = a[0]- initA[0];
|
||||
lastA[1] = a[1]- initA[1];
|
||||
|
||||
}
|
||||
float dist = (float) Math.sqrt((x-nx)*(x-nx) + (y-ny)*(y-ny));
|
||||
if(dist > 15){
|
||||
x += dx * v;
|
||||
y += dy * v;
|
||||
}
|
||||
float temp = (float) Math.sqrt((x-centerX)*(x-centerX) + (y-centerY)*(y-centerY));
|
||||
|
||||
if(temp > radius){
|
||||
x = radius * (x-centerX) / temp;
|
||||
y = radius * (y-centerY) / temp;
|
||||
x += centerX;
|
||||
y += centerY;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
|
||||
switch( ev.getAction() )
|
||||
{
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
int m_nX = (int)ev.getX();
|
||||
int m_nY = (int)ev.getY();
|
||||
int nDisToCenter =(int) Math.sqrt((m_nScreenWidth/2 - m_nX) * (m_nScreenWidth/2 - m_nX) + (m_nScreenHeight/2 - m_nY) * (m_nScreenHeight/2 - m_nY));
|
||||
if(nDisToCenter < radius){
|
||||
x = centerX;
|
||||
y = centerY;
|
||||
initA[0] = m_AccX;
|
||||
initA[1] = m_AccY;
|
||||
}
|
||||
int nBgW = (int)(fltScale * mbg.getWidth());
|
||||
int nBgH = (int)(fltScale * mbg.getHeight());
|
||||
float x = (m_nX) / fltScale - (this.getWidth() - nBgW)/2;
|
||||
float y = (m_nY ) / fltScale -(this.getHeight() - nBgH)/2;
|
||||
if( x<settingX && x>settingX - setting.getWidth() && y<settingY && y>settingY-setting.getHeight()){
|
||||
this.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
||||
// MainInfo.GetInstance().getNaviControler().removeDialog(DialogManager.DIALOG_GPS_TEST_MAIN);
|
||||
// MainInfo.GetInstance().getNaviControler().showDialog(DialogManager.DIALOG_GPS_TEST_MAIN);
|
||||
// MainInfo.GetInstance().getAppInfo().addActionInfo("NaviControler", "gpstest", null);
|
||||
}
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_UP:
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getGPSSatellites() {
|
||||
return mSatellites;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.zhidaoauto.map.sdk.inner.provider
|
||||
|
||||
import com.alibaba.fastjson.JSON
|
||||
import com.zhidaoauto.map.sdk.inner.obj.ResultData
|
||||
import com.zhidaoauto.map.sdk.open.routeinfo.SPRouteLine
|
||||
|
||||
|
||||
class MapDataHelper private constructor() {
|
||||
val TAG = javaClass.simpleName
|
||||
|
||||
companion object {
|
||||
val instance: MapDataHelper by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
MapDataHelper() }
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun dealValue(key: String,value:String): String {
|
||||
val result = ResultData()
|
||||
result.setKey(key)
|
||||
result.setValue(value)
|
||||
return JSON.toJSONString(result)
|
||||
}
|
||||
|
||||
|
||||
fun dealValue(key: String, value:ArrayList<SPRouteLine>): String {
|
||||
val result = ResultData()
|
||||
result.setKey(key)
|
||||
result.setValue(JSON.toJSONString(value))
|
||||
return JSON.toJSONString(result)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.zhidaoauto.map.sdk.inner.provider
|
||||
|
||||
import android.content.ContentProvider
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.content.UriMatcher
|
||||
import android.database.Cursor
|
||||
import android.database.MatrixCursor
|
||||
import android.net.Uri
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import androidx.annotation.NonNull
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.common.ConstantExt
|
||||
import com.zhidaoauto.map.sdk.inner.road.RoadHelper
|
||||
import com.zhidaoauto.map.sdk.open.data.MapDataApi
|
||||
import org.jetbrains.annotations.Nullable
|
||||
|
||||
class MapDataProvider : ContentProvider() {
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
private var mContext: Context? = null
|
||||
|
||||
override fun onCreate(): Boolean {
|
||||
mContext = context
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "queryop MapDataProvider onCreate")
|
||||
}
|
||||
mMatcher.addURI(context.packageName+ConstantExt.AUTHORITY, ConstantExt.STR_QUERY, ConstantExt.CODE_QUERY)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun update(
|
||||
uri: Uri,
|
||||
values: ContentValues?,
|
||||
selection: String?,
|
||||
selectionArgs: Array<String>?
|
||||
): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun delete(uri: Uri, selection: String?, selectionArgs: Array<String>?): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun insert(uri: Uri, values: ContentValues?): Uri? {
|
||||
return uri
|
||||
}
|
||||
|
||||
override fun query(
|
||||
@NonNull uri: Uri, projection: Array<String>?, @Nullable key: String?,
|
||||
@Nullable selectionArgs: Array<String>?, @Nullable sortOrder: String?
|
||||
): Cursor? {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "queryop = key:${key}")
|
||||
}
|
||||
var cursor: MatrixCursor = MatrixCursor(arrayOf("value"))
|
||||
if (TextUtils.isEmpty(key)) {
|
||||
return cursor
|
||||
}
|
||||
var result: String? = null
|
||||
|
||||
when (mMatcher.match(uri)) {
|
||||
ConstantExt.CODE_QUERY -> {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "queryop key= ${key}")
|
||||
}
|
||||
var array = key!!.split(",")
|
||||
if (array.size < 2) {
|
||||
return cursor
|
||||
}
|
||||
var coor = 0
|
||||
if(array.size >2){
|
||||
coor = array[2].toInt()
|
||||
}
|
||||
var roadType = 5
|
||||
if(array.size >3){
|
||||
roadType = array[3].toInt()
|
||||
}
|
||||
MapDataApi.startZeus(context)
|
||||
Log.i(TAG,"roadop-queryop-start:query:getRouteInfo")
|
||||
val start = System.currentTimeMillis()
|
||||
var value = RoadHelper.getInstance()?.getRoadInfo(array[0].toFloat(),array[1].toFloat(),coor,roadType)
|
||||
Log.i(TAG,"roadop-queryop-coor:${coor}-end:${(System.currentTimeMillis()-start)}ms")
|
||||
if(value == null || value.isEmpty()){
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "queryop result= null")
|
||||
}
|
||||
return cursor
|
||||
}
|
||||
result = MapDataHelper.instance.dealValue(key!!, value!!)
|
||||
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "queryop result= ${result}")
|
||||
}
|
||||
cursor.addRow(arrayOf<Any>(result))
|
||||
}
|
||||
}
|
||||
return cursor
|
||||
}
|
||||
|
||||
override fun getType(@NonNull uri: Uri): String? {
|
||||
return null
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private val mMatcher: UriMatcher
|
||||
|
||||
init {
|
||||
mMatcher = UriMatcher(UriMatcher.NO_MATCH)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.zhidaoauto.map.sdk.inner.proxy
|
||||
|
||||
import android.util.Log
|
||||
import com.zhidaoauto.map.sdk.inner.abs.ILonLatProxy
|
||||
import com.zhidaoauto.map.sdk.inner.common.MapHelper
|
||||
import com.zhidaoauto.map.sdk.open.exception.MapException
|
||||
|
||||
class CommonProxy {
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
companion object {
|
||||
var mInstance: CommonProxy? = null
|
||||
fun getInstance(): CommonProxy {
|
||||
if (mInstance == null) {
|
||||
synchronized(CommonProxy.javaClass) {
|
||||
if (mInstance == null) {
|
||||
mInstance = CommonProxy()
|
||||
}
|
||||
}
|
||||
}
|
||||
return mInstance!!
|
||||
}
|
||||
}
|
||||
|
||||
private var mLonLatProxy: ILonLatProxy? = null
|
||||
|
||||
fun setLonLatProxy(lonLatProxy: ILonLatProxy) {
|
||||
if(MapHelper.debug){
|
||||
Log.i(TAG,"initop setLonLatProxy")
|
||||
}
|
||||
mLonLatProxy = lonLatProxy
|
||||
}
|
||||
|
||||
fun getLonLatProxy(): ILonLatProxy {
|
||||
if(mLonLatProxy == null){
|
||||
mLonLatProxy = LonLatProxy()
|
||||
}
|
||||
mLonLatProxy?.let{
|
||||
return it
|
||||
}
|
||||
throw MapException(MapException.AUTO_INIT_ERROR_LONLATPROXY)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.zhidaoauto.map.sdk.inner.proxy
|
||||
|
||||
import android.util.Log
|
||||
import com.autonavi.nge.map.LonLat
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.abs.ILonLatProxy
|
||||
import com.zhidaoauto.map.sdk.inner.common.MapHelper
|
||||
import com.zhidaoauto.map.sdk.inner.utils.TransformUtils
|
||||
import com.zhidaoauto.map.sdk.open.MapParams
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint
|
||||
|
||||
class LonLatProxy : ILonLatProxy {
|
||||
|
||||
val TAG = javaClass.simpleName
|
||||
/**
|
||||
* 转换为外部使用坐标
|
||||
*/
|
||||
override fun switchLonLat(lonLat: LonLat): LonLatPoint {
|
||||
var array: DoubleArray? = null;
|
||||
when (MapHelper.mMapParams.getCoordinateType()) {
|
||||
MapParams.COORDINATETYPE_GCJ02 -> {
|
||||
array = TransformUtils.transformWgsToGcj(lonLat.lat, lonLat.lon)
|
||||
|
||||
}
|
||||
MapParams.COORDINATETYPE_BD09 -> {
|
||||
array = TransformUtils.transformWgs84ToGcj02(lonLat.lat, lonLat.lon)
|
||||
array = TransformUtils.transformGcj02ToBd09(array[1], array[0])
|
||||
}
|
||||
else -> {
|
||||
array = null
|
||||
}
|
||||
}
|
||||
|
||||
var lonLatPoint = LonLatPoint(lonLat.lon, lonLat.lat)
|
||||
array?.let {
|
||||
lonLatPoint = LonLatPoint(it[0], it[1])
|
||||
}
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "lonlatop--toOuter-before:${lonLat},after:${lonLatPoint}")
|
||||
}
|
||||
return lonLatPoint
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为内部使用坐标
|
||||
*/
|
||||
override fun switchLonLat(lonLatPoint: LonLatPoint): LonLat {
|
||||
var array: DoubleArray? = null
|
||||
|
||||
when (MapHelper.mMapParams.getCoordinateType()) {
|
||||
MapParams.COORDINATETYPE_GCJ02 -> {
|
||||
array = TransformUtils.transformGcj02toWgs84(
|
||||
lonLatPoint.latitude,
|
||||
lonLatPoint.longitude
|
||||
)
|
||||
}
|
||||
MapParams.COORDINATETYPE_BD09 -> {
|
||||
array = TransformUtils.transformBd09ToGcj02(lonLatPoint.latitude, lonLatPoint.longitude)
|
||||
array = TransformUtils.transformGcj02toWgs84(array[1], array[0])
|
||||
}
|
||||
else -> {
|
||||
array = null
|
||||
}
|
||||
}
|
||||
var lonLat = LonLat(lonLatPoint.longitude, lonLatPoint.latitude)
|
||||
array?.let {
|
||||
lonLat = LonLat(it[0], it[1])
|
||||
}
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "lonlatop--toInner-before:${lonLatPoint},after:${lonLat}")
|
||||
}
|
||||
return lonLat
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,68 @@
|
||||
package com.zhidaoauto.map.sdk.inner.road
|
||||
|
||||
import android.util.Log
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IRoadData
|
||||
import com.zhidaoauto.map.sdk.inner.controller.CommonController
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
class RoadResultController {
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
|
||||
private var mRoadResultList: ConcurrentHashMap<String,IRoadData> = ConcurrentHashMap()
|
||||
|
||||
|
||||
|
||||
fun addRoadResultListener(key:String,listener:IRoadData){
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "roadop--addRoadResultListener:$key ")
|
||||
}
|
||||
mRoadResultList.put(key,listener)
|
||||
}
|
||||
|
||||
fun removeRoadResultListenerByTag(tag:String){
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "roadop--removeRoadResultListenerByTag:$tag ")
|
||||
}
|
||||
val keysToRemove = mutableListOf<String>()
|
||||
mRoadResultList.forEach { (key, value) ->
|
||||
if (key.contains(tag)) {
|
||||
keysToRemove.add(key)
|
||||
}
|
||||
}
|
||||
keysToRemove.forEach { key ->
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "roadop--removeRoadResultListenerByTag::$tag--remove:$key ")
|
||||
}
|
||||
mRoadResultList.remove(key)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun dispatchRoadResult(code:Int,key:String,result:String){
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "roadop--dispatchRoadResult:$key,result:$result ")
|
||||
}
|
||||
val call = mRoadResultList.get(key)
|
||||
call?.let {
|
||||
CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
it.result(code,result)
|
||||
}
|
||||
mRoadResultList.remove(key)
|
||||
}
|
||||
}
|
||||
|
||||
fun exit(){
|
||||
mRoadResultList.clear()
|
||||
}
|
||||
|
||||
companion object {
|
||||
//单例
|
||||
@JvmStatic val instance: RoadResultController by lazy((LazyThreadSafetyMode.SYNCHRONIZED)) {
|
||||
RoadResultController()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//package com.zhidaoauto.map.sdk.inner.search
|
||||
//
|
||||
//import com.autonavi.nge.search.SearchAutoApi
|
||||
//import com.zhidaoauto.map.sdk.inner.controller.CommonController
|
||||
//
|
||||
//open class BaseSearchHelper {
|
||||
// constructor(){
|
||||
// if(CommonController.instance.iNavigationCore == null){
|
||||
// SearchAutoApi.init()
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,227 @@
|
||||
//package com.zhidaoauto.map.sdk.inner.search
|
||||
//
|
||||
//import android.content.Context
|
||||
//import android.util.Log
|
||||
//import com.autonavi.nge.map.LonLat
|
||||
//import com.autonavi.nge.search.SPLatLonPoint
|
||||
//import com.autonavi.nge.search.SPQuery
|
||||
//import com.autonavi.nge.search.SPSearchBound
|
||||
//import com.autonavi.nge.search.SPSearchResult
|
||||
//import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
//import com.zhidaoauto.map.sdk.inner.controller.CommonController
|
||||
//import com.zhidaoauto.map.sdk.inner.proxy.CommonProxy
|
||||
//import com.zhidaoauto.map.sdk.open.abs.search.IGeocodeSearch
|
||||
//import com.zhidaoauto.map.sdk.open.query.*
|
||||
//import kotlinx.coroutines.Dispatchers
|
||||
//import kotlinx.coroutines.launch
|
||||
//import kotlinx.coroutines.withContext
|
||||
//
|
||||
//class GeocoderSearchHelper : BaseSearchHelper, IGeocodeSearch {
|
||||
// val TAG = javaClass.simpleName
|
||||
//
|
||||
// private var mContext: Context
|
||||
// private var mOnGeocodeSearchListener: OnGeocodeSearchListener? = null
|
||||
//
|
||||
// constructor(context: Context):super() {
|
||||
// mContext = context
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private fun search(geocodeQuery: GeocodeQuery?): List<SPSearchResult>? {
|
||||
//
|
||||
// val result = CommonController.instance.iNavigationCore?.getPoiItemList(dealSpQuery(geocodeQuery!!))
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop-${result}")
|
||||
// }
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop- center point is null")
|
||||
// }
|
||||
// return result
|
||||
// }
|
||||
//
|
||||
// private fun search(regeocodeQuery: RegeocodeQuery?): List<SPSearchResult>? {
|
||||
//
|
||||
// val result = CommonController.instance.iNavigationCore?.getPoiItemList(dealSpQuery(regeocodeQuery!!))
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop-${result}")
|
||||
// }
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop- center point is null")
|
||||
// }
|
||||
// return result
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private fun dealgeocodeResult(list: List<SPSearchResult>?): GeocodeResult? {
|
||||
// if (list == null) {
|
||||
// return null
|
||||
// }
|
||||
// val results = ArrayList<GeocodeAddress>()
|
||||
// for (poiBase in list) {
|
||||
// results.add(dealGeocodeAddress(poiBase))
|
||||
// }
|
||||
//
|
||||
// val regeocodeResult = GeocodeResult(results)
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop - result:${regeocodeResult}")
|
||||
// }
|
||||
// return regeocodeResult
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private fun dealRegeocodeResult(list: List<SPSearchResult>?): RegeocodeResult? {
|
||||
// if (list == null) {
|
||||
// return null
|
||||
// }
|
||||
// var regeocodeAddress: RegeocodeAddress? = null
|
||||
// var poiItems = ArrayList<PoiItem>()
|
||||
// for ((i,poiBase) in list.withIndex()) {
|
||||
// if (i == 0) {
|
||||
// regeocodeAddress = dealRegeocodeAddress(poiBase)
|
||||
// } else {
|
||||
// poiItems.add(dealPoiItem(poiBase))
|
||||
// }
|
||||
// }
|
||||
// regeocodeAddress?.poiList = poiItems
|
||||
//
|
||||
// val results = RegeocodeResult(regeocodeAddress!!)
|
||||
//
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop - result:${results}")
|
||||
// }
|
||||
// return results
|
||||
// }
|
||||
//
|
||||
// private fun dealPoiItem(result: SPSearchResult): PoiItem {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop--${result}")
|
||||
// }
|
||||
// val poiBase = result.poi
|
||||
// var poiItem = PoiItem()
|
||||
//// poiItem.adName = poiBase.name
|
||||
// poiItem.typeDes = poiBase.snippet
|
||||
// poiItem.businessArea = poiBase.snippet
|
||||
// poiItem.tel = poiBase.tel
|
||||
// poiItem.title = poiBase.title
|
||||
// poiItem.snippet = poiBase.snippet
|
||||
// poiItem.adCode = "${poiBase.poiId}"
|
||||
// poiItem.typeCode = "${poiBase.kind}"
|
||||
// poiItem.poiId = "${poiBase.poiId}"
|
||||
// poiItem.lonLatPoint =
|
||||
// getLonLatPoint(LonLat(poiBase.location.lon.toDouble(), poiBase.location.lat.toDouble()))
|
||||
//
|
||||
// return poiItem
|
||||
// }
|
||||
//
|
||||
// private fun dealRegeocodeAddress(result: SPSearchResult): RegeocodeAddress {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop--${result}")
|
||||
// }
|
||||
// val poiBase = result.poi
|
||||
// var regeocodeAddress = RegeocodeAddress()
|
||||
//// poiItem.adName = poiBase.name
|
||||
// regeocodeAddress.formatAddress = poiBase.title
|
||||
// regeocodeAddress.district = poiBase.snippet
|
||||
// regeocodeAddress.poiId = "${poiBase.poiId}"
|
||||
// return regeocodeAddress
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private fun dealGeocodeAddress(result: SPSearchResult): GeocodeAddress {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop--${result}")
|
||||
// }
|
||||
// val poiBase = result.poi
|
||||
// var geocodeAddress = GeocodeAddress()
|
||||
//// poiItem.adName = poiBase.name
|
||||
// geocodeAddress.formatAddress = poiBase.title
|
||||
// geocodeAddress.district = poiBase.snippet
|
||||
// geocodeAddress.poiId = "${poiBase.poiId}"
|
||||
// geocodeAddress.lonlat =
|
||||
// getLonLatPoint(LonLat(poiBase.location.lon.toDouble(), poiBase.location.lat.toDouble()))
|
||||
//
|
||||
// return geocodeAddress
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private fun getLonLat(lonLatPoint: LonLatPoint): LonLat {
|
||||
// return CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLatPoint)
|
||||
// }
|
||||
//
|
||||
// private fun getLonLatPoint(lonLat: LonLat): LonLatPoint {
|
||||
// return CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLat)
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private fun dealSpQuery(geocodeQuery: GeocodeQuery?): SPQuery {
|
||||
// var spQuery = SPQuery()
|
||||
// geocodeQuery?.let { query ->
|
||||
// spQuery.searchType = 0
|
||||
// spQuery.categoryId = 0//query.category.toInt()
|
||||
// spQuery.keyword = query.locationName
|
||||
// }
|
||||
// return spQuery
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private fun dealSpQuery(regeocodeQuery: RegeocodeQuery?): SPQuery {
|
||||
// var spQuery = SPQuery()
|
||||
// regeocodeQuery?.let { query ->
|
||||
// spQuery.searchType = 0
|
||||
// spQuery.categoryId = 0//query.category.toInt()
|
||||
// spQuery.keyword = ""
|
||||
// var searchBound: SPSearchBound? = null
|
||||
// searchBound = SPSearchBound(
|
||||
// SPLatLonPoint(
|
||||
// query.lonLatPoint!!.latitude.toFloat(),
|
||||
// query.lonLatPoint!!.longitude.toFloat()
|
||||
// ), query.radius, true
|
||||
// )
|
||||
//
|
||||
// spQuery.bound = searchBound
|
||||
// }
|
||||
// return spQuery
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun getFromLocation(regeocodeQuery: RegeocodeQuery): RegeocodeAddress? {
|
||||
// val result = search(regeocodeQuery)
|
||||
// return dealRegeocodeResult(result)?.regeocodeAddress
|
||||
// }
|
||||
//
|
||||
// override fun getFromLocationName(geocodeQuery: GeocodeQuery?): List<GeocodeAddress?>? {
|
||||
// val result = search(geocodeQuery)
|
||||
// return dealgeocodeResult(result)?.geocodeAddressList
|
||||
// }
|
||||
//
|
||||
// override fun setOnGeocodeSearchListener(listener: OnGeocodeSearchListener?) {
|
||||
// this.mOnGeocodeSearchListener = listener
|
||||
// }
|
||||
//
|
||||
// override fun getFromLocationAsyn(regeocodeQuery: RegeocodeQuery?) {
|
||||
// CommonController.instance.scope?.launch(Dispatchers.IO) {
|
||||
// val result = search(regeocodeQuery)
|
||||
// withContext(Dispatchers.Main) {
|
||||
// mOnGeocodeSearchListener?.let {
|
||||
// it.onRegeocodeSearched(dealRegeocodeResult(result), 0)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun getFromLocationNameAsyn(geocodeQuery: GeocodeQuery?) {
|
||||
// CommonController.instance.scope?.launch(Dispatchers.IO) {
|
||||
// val result = search(geocodeQuery)
|
||||
// withContext(Dispatchers.Main) {
|
||||
// mOnGeocodeSearchListener?.let {
|
||||
// it.onGeocodeSearched(dealgeocodeResult(result), 0)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
@@ -0,0 +1,147 @@
|
||||
//package com.zhidaoauto.map.sdk.inner.search
|
||||
//
|
||||
//import android.content.Context
|
||||
//import android.util.Log
|
||||
//import com.autonavi.nge.map.LonLat
|
||||
//import com.autonavi.nge.search.SPConstants
|
||||
//import com.autonavi.nge.search.SPQuery
|
||||
//import com.autonavi.nge.search.SPSearchResult
|
||||
//import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
//import com.zhidaoauto.map.sdk.inner.controller.CommonController
|
||||
//import com.zhidaoauto.map.sdk.inner.proxy.CommonProxy
|
||||
//import com.zhidaoauto.map.sdk.open.abs.search.IInputtipsSearch
|
||||
//import com.zhidaoauto.map.sdk.open.exception.MapException
|
||||
//import com.zhidaoauto.map.sdk.open.query.InputtipsListener
|
||||
//import com.zhidaoauto.map.sdk.open.query.InputtipsQuery
|
||||
//import com.zhidaoauto.map.sdk.open.query.LonLatPoint
|
||||
//import com.zhidaoauto.map.sdk.open.query.Tip
|
||||
//import kotlinx.coroutines.Dispatchers
|
||||
//import kotlinx.coroutines.launch
|
||||
//import kotlinx.coroutines.withContext
|
||||
//
|
||||
//class InputSearchHelper :BaseSearchHelper, IInputtipsSearch {
|
||||
// val TAG = javaClass.simpleName
|
||||
//
|
||||
// private var mQuery: InputtipsQuery
|
||||
// private var mContext: Context
|
||||
// private var mInputtipsListener: InputtipsListener? = null
|
||||
//
|
||||
// constructor(mContext: Context, mQuery: InputtipsQuery):super() {
|
||||
// this.mContext = mContext
|
||||
// this.mQuery = mQuery
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// override fun getQuery(): InputtipsQuery? {
|
||||
// return mQuery
|
||||
// }
|
||||
//
|
||||
// override fun setQuery(query: InputtipsQuery) {
|
||||
// mQuery = query
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun setInputtipsListener(listener: InputtipsListener?) {
|
||||
// mInputtipsListener = listener
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun requestInputtipsAsyn() {
|
||||
// CommonController.instance.scope?.launch(Dispatchers.IO) {
|
||||
// val result = search()
|
||||
// withContext(Dispatchers.Main) {
|
||||
// mInputtipsListener?.let {
|
||||
// it.onGetInputtips(dealTipResults(result), 0)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Throws(MapException::class)
|
||||
// override fun requestInputtips(): ArrayList<Tip>? {
|
||||
// var list = search() as ArrayList
|
||||
// return dealTipResults(list)
|
||||
// }
|
||||
//
|
||||
// private fun getLonLat(lonLatPoint: LonLatPoint): LonLat {
|
||||
// return CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLatPoint)
|
||||
// }
|
||||
//
|
||||
// private fun getLonLatPoint(lonLat: LonLat): LonLatPoint {
|
||||
// return CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLat)
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private fun dealTipResults(list: List<SPSearchResult>?): ArrayList<Tip>? {
|
||||
// if (list == null) {
|
||||
// return null
|
||||
// }
|
||||
// val results = ArrayList<Tip>()
|
||||
// for (tip in list) {
|
||||
// results.add(dealTipResult(tip))
|
||||
// }
|
||||
//
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop - result:${results}")
|
||||
// }
|
||||
// return results
|
||||
// }
|
||||
//
|
||||
// private fun dealTipResult(result: SPSearchResult): Tip {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop--${result}")
|
||||
// }
|
||||
// val poiBase = result.poi
|
||||
// var tip = Tip()
|
||||
//// poiItem.adName = poiBase.name
|
||||
// tip.tip = poiBase.title
|
||||
// tip.address = poiBase.snippet
|
||||
// tip.name = poiBase.title
|
||||
// tip.district = poiBase.snippet
|
||||
// tip.adcode = "${poiBase.poiId}"
|
||||
// tip.typeCode = "${poiBase.kind}"
|
||||
// tip.poiID = "${poiBase.poiId}"
|
||||
// tip.latPoint =
|
||||
// getLonLatPoint(LonLat(poiBase.location.lon.toDouble(), poiBase.location.lat.toDouble()))
|
||||
// tip.orderId = result.orderId
|
||||
// return tip
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Synchronized
|
||||
// private fun search(): List<SPSearchResult>? {
|
||||
// val query = dealSpQuery()
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop-start:${query}")
|
||||
// }
|
||||
// val result = CommonController.instance.iNavigationCore?.getPoiItemList(query)
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop-${result}")
|
||||
// }
|
||||
// return result
|
||||
// }
|
||||
//
|
||||
// private fun dealSpQuery(): SPQuery {
|
||||
// var spQuery = SPQuery()
|
||||
// mQuery?.let { query ->
|
||||
// spQuery.searchType = SPConstants.SEARCH_TYPE_POI
|
||||
// spQuery.pageSize = query.pageSize
|
||||
// spQuery.pageStart = query.pageStart
|
||||
// spQuery.categoryId = 0
|
||||
// spQuery.keyword = query.keyword
|
||||
//// val mCenter = FloatArray(2)
|
||||
//// CommonController.instance.mapView?.getCenter(mCenter)
|
||||
//// mCenter?.let {
|
||||
//// var lon: Float = mCenter[0]
|
||||
//// var lat: Float = mCenter[1]
|
||||
//// spQuery.bound = SPSearchBound(SPLatLonPoint(lat, lon), 3000f, true)
|
||||
//// }
|
||||
// }
|
||||
// return spQuery
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
@@ -0,0 +1,263 @@
|
||||
//package com.zhidaoauto.map.sdk.inner.search
|
||||
//
|
||||
//import android.content.Context
|
||||
//import android.text.TextUtils
|
||||
//import android.util.Log
|
||||
//import com.autonavi.nge.map.LonLat
|
||||
//import com.autonavi.nge.search.*
|
||||
//import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
//import com.zhidaoauto.map.sdk.inner.controller.CommonController
|
||||
//import com.zhidaoauto.map.sdk.inner.proxy.CommonProxy
|
||||
//import com.zhidaoauto.map.sdk.open.abs.search.IPoiSearch
|
||||
//import com.zhidaoauto.map.sdk.open.query.*
|
||||
//import kotlinx.coroutines.Dispatchers
|
||||
//import kotlinx.coroutines.launch
|
||||
//import kotlinx.coroutines.withContext
|
||||
//
|
||||
//class SearchHelper : BaseSearchHelper,IPoiSearch {
|
||||
// val TAG = javaClass.simpleName
|
||||
//
|
||||
// private var mContext: Context
|
||||
// private var mQuery: Query
|
||||
// private var mPoiID: String? = null
|
||||
// private var mSearchBound: SearchBound? = null
|
||||
// private var mOnPoiSearchListener: OnPoiSearchListener? = null
|
||||
//
|
||||
// constructor(context: Context, query: Query):super() {
|
||||
// mContext = context
|
||||
// mQuery = query
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private fun getAllCateGory(): SPCategories? {
|
||||
// var category = CommonController.instance.iNavigationCore?.getAllPoiCategories(31)
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop-${category}")
|
||||
// }
|
||||
// return category
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private fun search(): List<SPSearchResult>? {
|
||||
// val query = dealSpQuery()
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop-param:${query}")
|
||||
// }
|
||||
// val result = CommonController.instance.iNavigationCore?.getPoiItemList(query)
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop-${result}")
|
||||
// }
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop- center point is null")
|
||||
// }
|
||||
// return result
|
||||
// }
|
||||
//
|
||||
// override fun searchPOIAsyn() {
|
||||
// CommonController.instance.scope?.launch(Dispatchers.IO) {
|
||||
// val result = search()
|
||||
// withContext(Dispatchers.Main) {
|
||||
// mOnPoiSearchListener?.let {
|
||||
// it.onPoiSearched(dealPoiResult(result), 0)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun searchPOIId(id: String?): PoiItem? {
|
||||
// return null
|
||||
// }
|
||||
//
|
||||
// override fun searchPOICateGoryAsyn() {
|
||||
// CommonController.instance.scope?.launch(Dispatchers.IO) {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop-searchPOICateGoryAsyn")
|
||||
// }
|
||||
// val result = getAllCateGory()
|
||||
// withContext(Dispatchers.Main) {
|
||||
// mOnPoiSearchListener?.let {
|
||||
// it.onPoiCategorySearched(dealPoiCategories(result), 0)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun getQuery(): Query {
|
||||
// return mQuery
|
||||
// }
|
||||
//
|
||||
// override fun setOnPoiSearchListener(onPoiSearchListener: OnPoiSearchListener?) {
|
||||
// this.mOnPoiSearchListener = onPoiSearchListener
|
||||
// }
|
||||
//
|
||||
// override fun searchPOI(): PoiSearchResult? {
|
||||
// val result = search()
|
||||
// return dealPoiResult(result)
|
||||
// }
|
||||
//
|
||||
// override fun setQuery(query: Query?) {
|
||||
// mQuery = query!!
|
||||
// }
|
||||
//
|
||||
// override fun getBound(): SearchBound? {
|
||||
// return mSearchBound
|
||||
// }
|
||||
//
|
||||
// override fun searchPOIIdAsyn(id: String?) {
|
||||
// mPoiID = id
|
||||
// searchPoi()
|
||||
// }
|
||||
//
|
||||
// override fun setBound(searchBound: SearchBound?) {
|
||||
// mSearchBound = searchBound
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private fun searchPoi() {
|
||||
// val urId: Int = 0
|
||||
// var productId: Int = 1;
|
||||
// mPoiID?.let {
|
||||
// var sPPoiItem = CommonController.instance.iNavigationCore?.getPoiItemByPoiId(it.toInt())
|
||||
// var poiSearchResult = dealPoiSearchResult(SPSearchResult(sPPoiItem, -1))
|
||||
// mOnPoiSearchListener?.onPoiItemSearched(poiSearchResult.poi, 0)
|
||||
// return
|
||||
// }
|
||||
// mOnPoiSearchListener?.onPoiItemSearched(null, -1)
|
||||
// }
|
||||
//
|
||||
// private fun dealPoiCategories(spCategories: SPCategories?): List<PoiCategory>? {
|
||||
// if (spCategories?.categories == null) {
|
||||
// return null
|
||||
// }
|
||||
// val results = ArrayList<PoiCategory>()
|
||||
// for (poiBase in spCategories.categories) {
|
||||
// var poiCategory = PoiCategory()
|
||||
// poiCategory.id = poiBase.first
|
||||
// poiCategory.category = poiBase.second
|
||||
// results.add(poiCategory)
|
||||
// }
|
||||
// return results
|
||||
// }
|
||||
//
|
||||
// private fun dealPoiResult(list: List<SPSearchResult>?): PoiSearchResult? {
|
||||
// if (list == null) {
|
||||
// return null
|
||||
// }
|
||||
// val results = ArrayList<PoiSearchItem>()
|
||||
// for (poiBase in list) {
|
||||
// results.add(dealPoiSearchResult(poiBase))
|
||||
// }
|
||||
//
|
||||
// val poiResult = PoiSearchResult.createPagedResult(
|
||||
// mQuery,
|
||||
// mSearchBound,
|
||||
// ArrayList<String>(),
|
||||
// ArrayList<SuggestionCity>(),
|
||||
// results
|
||||
// )
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop - result:${poiResult}")
|
||||
// }
|
||||
// return poiResult
|
||||
// }
|
||||
//
|
||||
// private fun dealPoiSearchResult(result: SPSearchResult): PoiSearchItem {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "searchop--${result}")
|
||||
// }
|
||||
// val poiBase = result.poi
|
||||
// var poiItem = PoiItem()
|
||||
//// poiItem.adName = poiBase.name
|
||||
// poiItem.typeDes = poiBase.snippet
|
||||
// poiItem.businessArea = poiBase.snippet
|
||||
// poiItem.tel = poiBase.tel
|
||||
// poiItem.title = poiBase.title
|
||||
// poiItem.snippet = poiBase.snippet
|
||||
// poiItem.adCode = "${poiBase.poiId}"
|
||||
// poiItem.typeCode = "${poiBase.kind}"
|
||||
// poiItem.poiId = "${poiBase.poiId}"
|
||||
// poiItem.lonLatPoint =
|
||||
// getLonLatPoint(LonLat(poiBase.location.lon.toDouble(), poiBase.location.lat.toDouble()))
|
||||
// return PoiSearchItem(poiItem, result.orderId)
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private fun getLonLat(lonLatPoint: LonLatPoint): LonLat {
|
||||
// return CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLatPoint)
|
||||
// }
|
||||
//
|
||||
// private fun getLonLatPoint(lonLat: LonLat): LonLatPoint {
|
||||
// return CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLat)
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private fun dealSpQuery(): SPQuery {
|
||||
// var spQuery = SPQuery();
|
||||
// mQuery?.let { query ->
|
||||
// spQuery.searchType = 0
|
||||
// if (!TextUtils.isEmpty(query.category))
|
||||
// spQuery.categoryId = query.category.toInt()
|
||||
// spQuery.keyword = query.keyword
|
||||
// spQuery.pageSize = query.pageSize
|
||||
// spQuery.pageStart = query.pageNum
|
||||
// spQuery.region = query.region
|
||||
// }
|
||||
// mSearchBound?.let {
|
||||
// var searchBound: SPSearchBound? = null;
|
||||
// when (it.shape) {
|
||||
// "Bound" -> {
|
||||
// searchBound = SPSearchBound(
|
||||
// SPLatLonPoint(
|
||||
// it.center!!.latitude.toFloat(),
|
||||
// it.center!!.longitude.toFloat()
|
||||
// ), it.range.toFloat(), it.isDistanceSort
|
||||
// )
|
||||
// }
|
||||
// "Rectangle" -> {
|
||||
// searchBound = SPSearchBound(
|
||||
// SPLatLonPoint(
|
||||
// it.lowerLeft!!.latitude.toFloat(),
|
||||
// it.lowerLeft!!.longitude.toFloat()
|
||||
// ),
|
||||
// SPLatLonPoint(
|
||||
// it.upperRight!!.latitude.toFloat(),
|
||||
// it.upperRight!!.longitude.toFloat()
|
||||
// )
|
||||
// )
|
||||
// }
|
||||
// "Polygon" -> {
|
||||
//
|
||||
// it.polyGonList?.let { polyGonList ->
|
||||
// val list = ArrayList<SPLatLonPoint>()
|
||||
// for (point in polyGonList) {
|
||||
// list.add(SPLatLonPoint(point.latitude, point.longitude))
|
||||
// }
|
||||
// searchBound = SPSearchBound(list)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// else -> {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// spQuery.bound = searchBound
|
||||
// }
|
||||
// if (spQuery.bound == null && TextUtils.isEmpty(spQuery.region)) {
|
||||
// val mCenter = DoubleArray(2)
|
||||
// CommonController.instance.mapController?.getCenter(mCenter)
|
||||
// mCenter?.let {
|
||||
// var lon: Double = mCenter[0]
|
||||
// var lat: Double = mCenter[1]
|
||||
// spQuery.bound = SPSearchBound(SPLatLonPoint(lat, lon), 3000f, true)
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// return spQuery;
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.zhidaoauto.map.sdk.inner.service
|
||||
|
||||
import android.app.ActivityManager
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
|
||||
object ZeusManager {
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
|
||||
/**
|
||||
* 判断服务是否开启
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
fun isServiceRunning(context: Context, ServiceName: String): Boolean {
|
||||
if (TextUtils.isEmpty(ServiceName)) {
|
||||
return false
|
||||
}
|
||||
val myManager = context
|
||||
.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
||||
val runningServices = myManager
|
||||
.getRunningServices(50) as ArrayList<ActivityManager.RunningServiceInfo>
|
||||
for (info in runningServices) {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "zeusop-start--service:${info.service.className}")
|
||||
// }
|
||||
if (info.service.className.equals(ServiceName)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
// fun adbSwipe() {
|
||||
// val cmd = " input swipe 100 0 100 460 "
|
||||
// execCommand(cmd)
|
||||
// }
|
||||
//
|
||||
// fun execCommand(cmd: String) {
|
||||
// CommandExecution.execCommand(cmd)
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
package com.zhidaoauto.map.sdk.inner.traffic
|
||||
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint
|
||||
|
||||
class TrafficHelper {
|
||||
|
||||
val TAG = javaClass.simpleName
|
||||
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载TMC数据入口
|
||||
*/
|
||||
fun loadTraffic(
|
||||
tileId: Int, leftTopLon: Double, leftTopLat: Double, leftBottomLon: Double, leftBottomLat: Double,
|
||||
rightTopLon: Double, rightTopLat: Double, rightBottomLon: Double, rightBottomLat: Double, roadInfo: String?
|
||||
) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "tmc --tmcop--${roadInfo}")
|
||||
}
|
||||
if (TextUtils.isEmpty(roadInfo) || !roadInfo!!.contains(",")) {
|
||||
return
|
||||
}
|
||||
val roadArray = roadInfo.split(",")
|
||||
if (roadArray.size % 4 != 0) {
|
||||
return
|
||||
}
|
||||
val points = ArrayList<LonLatPoint>()
|
||||
for (index in 0..roadArray.size - 1 step 4) {
|
||||
points.add(
|
||||
LonLatPoint(
|
||||
roadArray[index].toDouble(),
|
||||
roadArray[index + 1].toDouble()
|
||||
)
|
||||
)
|
||||
points.add(
|
||||
LonLatPoint(
|
||||
roadArray[index + 2].toDouble(),
|
||||
roadArray[index + 3].toDouble()
|
||||
)
|
||||
)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "tmcop---${tileId},${index},${points.size}")
|
||||
}
|
||||
}
|
||||
val start = LonLatPoint(leftTopLon, leftTopLat)
|
||||
val end = LonLatPoint(rightBottomLon, rightBottomLat)
|
||||
// getRouteTMC(CommonController.instance.context, tileId, start, end, points)
|
||||
}
|
||||
|
||||
|
||||
//调用接口获取TMC信息
|
||||
// private fun getRouteTMC(
|
||||
// context: Context?,
|
||||
// tileId: Int,
|
||||
// start: LonLatPoint,
|
||||
// end: LonLatPoint,
|
||||
// wayPoints: List<LonLatPoint>?
|
||||
// ) {
|
||||
// Log.i(TAG, "tmcop--getRouteTMC:${start}")
|
||||
// val fromAndTo = RouteSearch.FromAndTo(
|
||||
// LatLonPoint(start.latitude, start.longitude),
|
||||
// LatLonPoint(end.latitude, end.longitude)
|
||||
// )
|
||||
// val ways: MutableList<LatLonPoint> = java.util.ArrayList()
|
||||
//
|
||||
// if (!wayPoints.isNullOrEmpty()) {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// val content = "tmcop--getRouteTMC--wayPoints:${wayPoints.size}"
|
||||
// Log.i(TAG, content)
|
||||
// Recorder.i(content)
|
||||
// }
|
||||
//
|
||||
// for (index in 0..wayPoints.size-1 step 2) {
|
||||
// val wayPoint = wayPoints[index]
|
||||
// ways.add(LatLonPoint(wayPoint.latitude, wayPoint.longitude))
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// val query = RouteSearch.DriveRouteQuery(fromAndTo, 0, ways, null, "")
|
||||
// val routeSearch = RouteSearch(context)
|
||||
// routeSearch.calculateDriveRouteAsyn(query)
|
||||
// routeSearch.setRouteSearchListener(object : RouteSearch.OnRouteSearchListener {
|
||||
// override fun onDriveRouteSearched(driveRouteResult: DriveRouteResult?, code: Int) {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "tmcop--driveRouteResult:${driveRouteResult},code:${code}")
|
||||
// }
|
||||
// CommonController.instance.scope?.launch(Dispatchers.IO) {
|
||||
// val result = dealRouteResult(tileId, driveRouteResult)
|
||||
// result?.let {
|
||||
// CommonController.instance.mapController?.setTmcData(it)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onBusRouteSearched(p0: BusRouteResult?, p1: Int) {
|
||||
// TODO("Not yet implemented")
|
||||
// }
|
||||
//
|
||||
// override fun onRideRouteSearched(p0: RideRouteResult?, p1: Int) {
|
||||
// TODO("Not yet implemented")
|
||||
// }
|
||||
//
|
||||
// override fun onWalkRouteSearched(p0: WalkRouteResult?, p1: Int) {
|
||||
// TODO("Not yet implemented")
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
// //封装返回数据给底层处理
|
||||
// private fun dealDriveRouteResult(driveRouteResult: DriveRouteResult?): List<TrafficResult>? {
|
||||
// driveRouteResult?.let {
|
||||
// val pathList = driveRouteResult.paths
|
||||
// Log.i(TAG, "tmcop--pathList:${pathList.size}")
|
||||
// if (pathList.isNullOrEmpty()) {
|
||||
// return null
|
||||
// }
|
||||
// val trafficResultList = ArrayList<TrafficResult>(pathList.size)
|
||||
// val trafficResult = TrafficResult();
|
||||
// var customSteps = ArrayList<CustomDriveStep>()
|
||||
// var customDriveStep =
|
||||
// CustomDriveStep()
|
||||
// var customTmc = CustomTMC()
|
||||
// var customTmcList = ArrayList<CustomTMC>()
|
||||
// var polylineList: ArrayList<LonLat> = ArrayList()
|
||||
// for (drivePath in pathList) {
|
||||
// customSteps = ArrayList<CustomDriveStep>(pathList.size)
|
||||
// val steps = drivePath.steps;
|
||||
// for (step in steps) {
|
||||
// customDriveStep = CustomDriveStep()
|
||||
//// customDriveStep.distance = step.distance
|
||||
//// customDriveStep.duration = step.duration
|
||||
//// customDriveStep.road = step.road
|
||||
//// customDriveStep.orientation = step.orientation
|
||||
// customTmcList = ArrayList<CustomTMC>()
|
||||
//
|
||||
// val tmcs = step.tmCs;
|
||||
// var status = 0
|
||||
// for (tmc in tmcs) {
|
||||
// if (TextUtils.equals("严重拥堵", tmc.status)) {
|
||||
// status = 3
|
||||
// } else if (TextUtils.equals("拥堵", tmc.status)) {
|
||||
// status = 2
|
||||
// } else if (TextUtils.equals("缓行", tmc.status)) {
|
||||
// status = 1
|
||||
// } else {
|
||||
// status = 0
|
||||
// }
|
||||
// if (status == 0) {
|
||||
// break
|
||||
// }
|
||||
// customTmc = CustomTMC()
|
||||
// customTmc.status = status
|
||||
// polylineList = ArrayList()
|
||||
// for (latlon in tmc.polyline) {
|
||||
// polylineList.add(
|
||||
// CommonProxy.getInstance().getLonLatProxy()
|
||||
// .switchLonLat(LonLatPoint(latlon.longitude, latlon.latitude))
|
||||
// )
|
||||
// }
|
||||
// customTmc.polylines = polylineList
|
||||
// customTmcList.add(customTmc)
|
||||
// }
|
||||
// if (!customTmcList.isEmpty()) {
|
||||
// customDriveStep.customTmcList = customTmcList
|
||||
// customSteps.add(customDriveStep)
|
||||
// }
|
||||
// }
|
||||
// if (!customSteps.isEmpty()) {
|
||||
// trafficResult.customDriveSteps = customSteps
|
||||
// trafficResultList.add(trafficResult)
|
||||
// }
|
||||
// }
|
||||
// return trafficResultList
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
|
||||
// //封装返回数据给底层处理
|
||||
// private fun dealRouteResult(tileId: Int, driveRouteResult: DriveRouteResult?): ByteArray? {
|
||||
// driveRouteResult?.let {
|
||||
// val pathList = driveRouteResult.paths
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "tmcop--dealRouteResult--pathList:${pathList.size}")
|
||||
// }
|
||||
// if (pathList.isNullOrEmpty()) {
|
||||
// return null
|
||||
// }
|
||||
// val bufferDetail = Unpooled.buffer()
|
||||
// var count = 0
|
||||
// for (drivePath in pathList) {
|
||||
// val steps = drivePath.steps;
|
||||
// for (step in steps) {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// val content = "tmcop--dealRouteResult--step:${step.polyline.size},${step.tmCs.size}"
|
||||
// Log.i(TAG, content)
|
||||
//// Recorder.i(content)
|
||||
// }
|
||||
// val tmcs = step.tmCs;
|
||||
// var status = 0
|
||||
// for (tmc in tmcs) {
|
||||
// if (TextUtils.equals("严重拥堵", tmc.status)) {
|
||||
// status = 3
|
||||
// } else if (TextUtils.equals("拥堵", tmc.status)) {
|
||||
// status = 2
|
||||
// } else if (TextUtils.equals("缓行", tmc.status)) {
|
||||
// status = 1
|
||||
// } else {
|
||||
// status = 0
|
||||
// }
|
||||
// if (status == 0) {
|
||||
// break
|
||||
// }
|
||||
// count++
|
||||
// bufferDetail.writeInt(status)
|
||||
// bufferDetail.writeInt(tmc.polyline.size)
|
||||
// var lonLat: LonLat
|
||||
// for (latlon in tmc.polyline) {
|
||||
// lonLat = CommonProxy.getInstance().getLonLatProxy()
|
||||
// .switchLonLat(LonLatPoint(latlon.longitude, latlon.latitude))
|
||||
// bufferDetail.writeDouble(lonLat.lon)
|
||||
// bufferDetail.writeDouble(lonLat.lat)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "tmcop--dealDriveRouteResult--result:${tileId},count:${count}")
|
||||
// }
|
||||
// if (count == 0) {
|
||||
// return null
|
||||
// }
|
||||
// val buffer = Unpooled.buffer()
|
||||
// buffer.writeInt(tileId)
|
||||
// buffer.writeInt(count)
|
||||
// buffer.writeBytes(bufferDetail)
|
||||
// return buffer.array()
|
||||
// }
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "tmcop--dealDriveRouteResult--driveRouteResult:${driveRouteResult}")
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
package com.zhidaoauto.map.sdk.inner.use
|
||||
|
||||
import android.util.Log
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController
|
||||
import com.zhidaoauto.map.sdk.inner.utils.Recorder
|
||||
import io.netty.util.internal.ConcurrentSet
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
class Clerk(private val mMapController: IMapController?) {
|
||||
|
||||
private val TAG = "note"
|
||||
|
||||
private val cacheMap:ConcurrentHashMap<Long,StringBuffer> = ConcurrentHashMap<Long,StringBuffer>()
|
||||
|
||||
private var saveJob: Job? = null
|
||||
private var uploadJob: Job? = null
|
||||
|
||||
|
||||
private val saveJobList = ConcurrentSet<Job?>()
|
||||
|
||||
private var mLastPath:String? = null
|
||||
|
||||
// private val repository by lazy { LogRepository()}
|
||||
|
||||
val places = 3
|
||||
//是否记录操作日志
|
||||
var isWork = true
|
||||
|
||||
fun add(){
|
||||
if(!isWork){
|
||||
return
|
||||
}
|
||||
var className:String = ""
|
||||
var methodName:String = ""
|
||||
try{
|
||||
className = Thread.currentThread().stackTrace[3].className
|
||||
methodName = Thread.currentThread().stackTrace[3].methodName
|
||||
}catch (e:Exception){
|
||||
|
||||
}
|
||||
add(className, methodName, "")
|
||||
}
|
||||
|
||||
fun add(param:String?){
|
||||
if(!isWork){
|
||||
return
|
||||
}
|
||||
var className:String = ""
|
||||
var methodName:String = ""
|
||||
try{
|
||||
className = Thread.currentThread().stackTrace[3].className
|
||||
methodName = Thread.currentThread().stackTrace[3].methodName
|
||||
}catch (e:Exception){
|
||||
|
||||
}
|
||||
add(className, methodName, param)
|
||||
}
|
||||
|
||||
fun add(className:String,methodName:String,param:String?){
|
||||
if(!isWork){
|
||||
return
|
||||
}
|
||||
if (CompileConfig.DEBUG){
|
||||
Log.i(TAG, "add: $className,$methodName,$param")
|
||||
}
|
||||
val key = System.currentTimeMillis().shr(places)
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "add: ${System.currentTimeMillis()}-$key")
|
||||
}
|
||||
var stringBuffer = cacheMap.get(key)
|
||||
if(stringBuffer == null){
|
||||
stringBuffer = StringBuffer()
|
||||
}
|
||||
val content = "${System.currentTimeMillis()},$className,$methodName,$param"
|
||||
if(stringBuffer.length > 0){
|
||||
stringBuffer?.append("\n")
|
||||
}
|
||||
stringBuffer?.append(content)
|
||||
cacheMap.put(key,stringBuffer)
|
||||
if(cacheMap.size > 2){
|
||||
save()
|
||||
}
|
||||
}
|
||||
|
||||
private fun save(){
|
||||
if(!isWork){
|
||||
return
|
||||
}
|
||||
if (CompileConfig.DEBUG){
|
||||
Log.i(TAG, "save:")
|
||||
}
|
||||
val scope = mMapController?.getDemaningScope()
|
||||
if(saveJobList.size>10){
|
||||
val needDeleteSize = saveJobList.size - 5
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "i-cancel: $needDeleteSize")
|
||||
}
|
||||
var deleteIndex = 0
|
||||
val it = saveJobList.iterator()
|
||||
while(it.hasNext() && deleteIndex<needDeleteSize){
|
||||
val job = it.next()
|
||||
job?.cancel()
|
||||
it.remove()
|
||||
deleteIndex += 1
|
||||
}
|
||||
}
|
||||
saveJob = scope?.launch(Dispatchers.IO) {
|
||||
val currentKey = System.currentTimeMillis().shr(places)
|
||||
val deleteList = ArrayList<Long>()
|
||||
for((key,buffer) in cacheMap){
|
||||
if(key == currentKey){
|
||||
continue
|
||||
}
|
||||
if (CompileConfig.DEBUG){
|
||||
Log.i(TAG, "save:$key")
|
||||
}
|
||||
val path = Recorder.write(TAG, "${mMapController.hashCode()}",buffer.toString())
|
||||
//处理回调逻辑
|
||||
mLastPath?.let{
|
||||
if(!it.equals(path)){
|
||||
//TODO MATT
|
||||
// CommonEventController.instance.dispatchLog(it)
|
||||
Recorder.checkLog(TAG)
|
||||
}
|
||||
}
|
||||
mLastPath = path
|
||||
deleteList.add(key)
|
||||
}
|
||||
|
||||
for(key in deleteList){
|
||||
cacheMap.remove(key)
|
||||
}
|
||||
deleteList.clear()
|
||||
}
|
||||
saveJobList.add(saveJob)
|
||||
}
|
||||
|
||||
private fun consume(){
|
||||
if(!isWork){
|
||||
return
|
||||
}
|
||||
val scope = mMapController?.getDemaningScope()
|
||||
uploadJob?.cancel()
|
||||
uploadJob = scope?.launch(Dispatchers.IO) {
|
||||
val path = Recorder.getLogDirectory(TAG)
|
||||
val file = File(path)
|
||||
if(!file.isDirectory){
|
||||
return@launch
|
||||
}
|
||||
val firstlist = file.list()
|
||||
for(p in firstlist){
|
||||
val f = File(p)
|
||||
if(!f.isDirectory){
|
||||
break
|
||||
}
|
||||
val secondlist = f.list()
|
||||
for(child in secondlist){
|
||||
val childFile = File(child)
|
||||
upload(childFile)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun upload(file:File){
|
||||
return
|
||||
val content = file.readText()
|
||||
// repository.uploadLogInfo(content)
|
||||
}
|
||||
|
||||
fun setIsRecordLogs(isRecord: Boolean){
|
||||
isWork = isRecord
|
||||
|
||||
}
|
||||
|
||||
fun exit(){
|
||||
if(saveJobList.size > 0){
|
||||
val it = saveJobList.iterator()
|
||||
while(it.hasNext()){
|
||||
val job = it.next()
|
||||
job?.cancel()
|
||||
it.remove()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.zhidaoauto.map.sdk.inner.use
|
||||
|
||||
import java.io.File
|
||||
import java.util.UUID
|
||||
|
||||
object DeviceHelper {
|
||||
|
||||
private val deviceFilePath = "sdcard/Android/data/map/"
|
||||
private val deviceFileName = "uuid.ini"
|
||||
|
||||
private var file:File? = null
|
||||
|
||||
suspend fun getDeviceId():String{
|
||||
val existDeviceFile = existDeviceFile()
|
||||
if(!existDeviceFile){
|
||||
write()
|
||||
}
|
||||
return read()
|
||||
}
|
||||
|
||||
|
||||
fun existDeviceFile(): Boolean{
|
||||
file = File(deviceFilePath + deviceFileName)
|
||||
return file?.exists()?:false
|
||||
}
|
||||
|
||||
private suspend fun read():String{
|
||||
return file?.readText()?:""
|
||||
}
|
||||
|
||||
private suspend fun write(){
|
||||
val parent = File(deviceFilePath)
|
||||
if(!parent.exists()){
|
||||
parent.mkdirs()
|
||||
}
|
||||
val existFile = file?.exists()?:false
|
||||
if(!existFile){
|
||||
file?.createNewFile()
|
||||
}
|
||||
file?.writeText(UUID.randomUUID().toString())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
//package com.zhidaoauto.map.sdk.inner.use
|
||||
//
|
||||
//import com.zhidao.map.net.api.BaseRepository
|
||||
//import com.zhidao.map.net.api.Result
|
||||
//import com.zhidaoauto.map.sdk.open.net.LogRetrofitClient
|
||||
//
|
||||
//class LogRepository : BaseRepository() {
|
||||
//
|
||||
//
|
||||
// suspend fun uploadLogInfo(content: String): Result<Any> {
|
||||
// return safeApiCall(
|
||||
// call = { executeResponse(LogRetrofitClient.service.uploadLogInfo(content,DeviceHelper.getDeviceId()), {}) },
|
||||
// errorMessage = "获取数据失败!"
|
||||
// )
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.zhidaoauto.map.sdk.inner.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorManager;
|
||||
import android.location.LocationManager;
|
||||
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AMapUtils {
|
||||
public static final int DRIVING_DEFAULT = 0;
|
||||
public static final int DRIVING_SAVE_MONEY = 1;
|
||||
public static final int DRIVING_SHORT_DISTANCE = 2;
|
||||
public static final int DRIVING_NO_HIGHWAY = 3;
|
||||
public static final int DRIVING_AVOID_CONGESTION = 4;
|
||||
public static final int DRIVING_NO_HIGHWAY_AVOID_SHORT_MONEY = 5;
|
||||
public static final int DRIVING_NO_HIGHWAY_AVOID_CONGESTION = 6;
|
||||
public static final int DRIVING_SAVE_MONEY_AVOID_CONGESTION = 7;
|
||||
public static final int DRIVING_NO_HIGHWAY_SAVE_MONEY_AVOID_CONGESTION = 8;
|
||||
public static final int BUS_TIME_FIRST = 0;
|
||||
public static final int BUS_MONEY_LITTLE = 1;
|
||||
public static final int BUS_TRANSFER_LITTLE = 2;
|
||||
public static final int BUS_WALK_LITTLE = 3;
|
||||
public static final int BUS_COMFORT = 4;
|
||||
public static final int BUS_NO_SUBWAY = 5;
|
||||
|
||||
public static float calculateLineDistance(LonLatPoint var0, LonLatPoint var1) {
|
||||
if (var0 != null && var1 != null) {
|
||||
try {
|
||||
double var2 = var0.getLongitude();
|
||||
double var4 = var0.getLatitude();
|
||||
double var6 = var1.getLongitude();
|
||||
double var8 = var1.getLatitude();
|
||||
var2 *= 0.01745329251994329D;
|
||||
var4 *= 0.01745329251994329D;
|
||||
var6 *= 0.01745329251994329D;
|
||||
var8 *= 0.01745329251994329D;
|
||||
double var10 = Math.sin(var2);
|
||||
double var12 = Math.sin(var4);
|
||||
double var14 = Math.cos(var2);
|
||||
double var16 = Math.cos(var4);
|
||||
double var18 = Math.sin(var6);
|
||||
double var20 = Math.sin(var8);
|
||||
double var22 = Math.cos(var6);
|
||||
double var24 = Math.cos(var8);
|
||||
double[] var28 = new double[3];
|
||||
double[] var29 = new double[3];
|
||||
var28[0] = var16 * var14;
|
||||
var28[1] = var16 * var10;
|
||||
var28[2] = var12;
|
||||
var29[0] = var24 * var22;
|
||||
var29[1] = var24 * var18;
|
||||
var29[2] = var20;
|
||||
return (float)(Math.asin(Math.sqrt((var28[0] - var29[0]) * (var28[0] - var29[0]) + (var28[1] - var29[1]) * (var28[1] - var29[1]) + (var28[2] - var29[2]) * (var28[2] - var29[2])) / 2.0D) * 1.27420015798544E7D);
|
||||
} catch (Throwable var26) {
|
||||
var26.printStackTrace();
|
||||
return 0.0F;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
throw new Exception("非法坐标值");
|
||||
} catch (Exception var27) {
|
||||
var27.printStackTrace();
|
||||
return 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断是否存在光传感器来判断是否为模拟器
|
||||
* 部分真机也不存在温度和压力传感器。其余传感器模拟器也存在。
|
||||
*
|
||||
* @return true 为模拟器
|
||||
*/
|
||||
public static Boolean notHasLightSensorManager(Context context) {
|
||||
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||
Sensor sensor8 = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); //光
|
||||
if (null == sensor8) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否有GPS
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasGPSDevice(Context context) {
|
||||
final LocationManager mgr = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
if (mgr == null) {
|
||||
return false;
|
||||
}
|
||||
final List<String> providers = mgr.getAllProviders();
|
||||
if (providers == null) {
|
||||
return false;
|
||||
}
|
||||
return providers.contains(LocationManager.GPS_PROVIDER);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.zhidaoauto.map.sdk.inner.utils
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import com.zhidaoauto.map.sdk.inner.controller.CommonController
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
object BitmapUtils {
|
||||
|
||||
fun bitmapToByteArray(bitmap: Bitmap): ByteArray {
|
||||
val bytes = bitmap.byteCount
|
||||
val buf = ByteBuffer.allocate(bytes)
|
||||
bitmap.copyPixelsToBuffer(buf)
|
||||
bitmap.recycle()
|
||||
return buf.array()
|
||||
}
|
||||
|
||||
fun copyBitmap(bitmap: Bitmap):Bitmap?{
|
||||
if(bitmap.isRecycled){
|
||||
return null;
|
||||
}
|
||||
try{
|
||||
val result = bitmap.copy(bitmap.getConfig(), true);
|
||||
// val canvasBmp2 = Canvas( result );
|
||||
// canvasBmp2.drawBitmap(bitmap,null, Paint())
|
||||
return result
|
||||
}catch (e: Exception){
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
fun saveBitmap(bitmap: Bitmap): String? {
|
||||
val path = CommonController.instance.workingDirectory+"image/"
|
||||
val dir = File(path)
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs()
|
||||
}
|
||||
val img = File(path+"location.png")
|
||||
try {
|
||||
val out = FileOutputStream(img)
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out)
|
||||
out.flush()
|
||||
out.close()
|
||||
return img.path
|
||||
} catch (e: FileNotFoundException) {
|
||||
e.printStackTrace()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.zhidaoauto.map.sdk.inner.utils
|
||||
|
||||
import java.io.UnsupportedEncodingException
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
|
||||
object ByteBufferHelper {
|
||||
|
||||
|
||||
fun dealStr(str: String?): ByteBuffer {
|
||||
return ByteBuffer.wrap(str?.toByteArray(charset("utf-8")))
|
||||
}
|
||||
|
||||
fun buf2Str(buf: ByteBuffer): String? {
|
||||
val l = buf.short.toInt()
|
||||
var ret: String? = null
|
||||
if (l > 0) {
|
||||
val tmp = ByteArray(l)
|
||||
for (idx in 0 until l) {
|
||||
tmp[idx] = buf.get()
|
||||
}
|
||||
try {
|
||||
ret = String(tmp, charset("UTF-8"))
|
||||
} catch (e: UnsupportedEncodingException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
fun bytes2ByteBuffer(data: ByteArray?): ByteBuffer? {
|
||||
// 对数据进行格式化
|
||||
if (data == null || data.size < 1) {
|
||||
return null
|
||||
}
|
||||
val buf = ByteBuffer.wrap(data)
|
||||
buf.order(ByteOrder.LITTLE_ENDIAN)
|
||||
return buf
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.zhidaoauto.map.sdk.inner.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.StatFs;
|
||||
|
||||
import com.zhidaoauto.map.sdk.inner.controller.CommonController;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CheckStorageSpaceTool {
|
||||
|
||||
private final static int MSG_CHKSDCARD = 0;
|
||||
private Context mContext;
|
||||
|
||||
public interface StorageSpaceListener {
|
||||
public void onLackSpace();
|
||||
}
|
||||
|
||||
private StorageSpaceListener mStorageSpaceListener;
|
||||
|
||||
private Handler mHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_CHKSDCARD:
|
||||
checkStorageSpace();
|
||||
mHandler.sendEmptyMessageDelayed(MSG_CHKSDCARD, 1800000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public CheckStorageSpaceTool(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public void stopStorageSpaceListener(){
|
||||
mHandler.removeMessages(MSG_CHKSDCARD);
|
||||
}
|
||||
|
||||
public void setStorageSpaceListener(StorageSpaceListener storageSpaceListener){
|
||||
mStorageSpaceListener = storageSpaceListener;
|
||||
mHandler.removeMessages(MSG_CHKSDCARD);
|
||||
mHandler.sendEmptyMessageDelayed(MSG_CHKSDCARD, 3000);
|
||||
}
|
||||
|
||||
private boolean checkStorageSpace() {
|
||||
long avalible = 0;
|
||||
try {
|
||||
String dir = CommonController.getInstance().getWorkingDirectory();
|
||||
if (new File(dir).exists()) {
|
||||
StatFs fss = new StatFs(dir);
|
||||
avalible = (long) fss.getAvailableBlocks() * fss.getBlockSize();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (avalible < 1048576) {
|
||||
// if (avalible < 1000000000) {
|
||||
mStorageSpaceListener.onLackSpace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.zhidaoauto.map.sdk.inner.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
|
||||
|
||||
object CommonUtils {
|
||||
|
||||
fun getScreenWidth(context: Context): Int {
|
||||
val displayMetrics = context.resources.getDisplayMetrics()
|
||||
return displayMetrics.widthPixels
|
||||
}
|
||||
|
||||
fun getScreenHeight(context: Context): Int {
|
||||
val displayMetrics = context.resources.getDisplayMetrics()
|
||||
return displayMetrics.heightPixels
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并两张bitmap为一张
|
||||
* @param background
|
||||
* @param foreground
|
||||
* @return Bitmap
|
||||
*/
|
||||
fun combineBitmap(background: Bitmap?, foreground: Bitmap): Bitmap? {
|
||||
if (background == null) {
|
||||
return null
|
||||
}
|
||||
val bgWidth = background.width
|
||||
val bgHeight = background.height
|
||||
val fgWidth = foreground.width
|
||||
val fgHeight = foreground.height
|
||||
val newmap = Bitmap.createBitmap(bgWidth, bgHeight, Bitmap.Config.ARGB_8888)
|
||||
val canvas = Canvas(newmap)
|
||||
canvas.drawBitmap(background, 0f, 0f, null)
|
||||
canvas.drawBitmap(
|
||||
foreground, (bgWidth - fgWidth) / 2f,
|
||||
(bgHeight - fgHeight) / 2f, null
|
||||
)
|
||||
canvas.save()
|
||||
canvas.restore()
|
||||
return newmap
|
||||
}
|
||||
|
||||
fun getCachePath(context: Context?): String{
|
||||
var cachePath = ""
|
||||
cachePath = if (context != null) {
|
||||
context.filesDir.absolutePath + "/vr_tiles"
|
||||
} else {
|
||||
"sdcard/vr_tiles"
|
||||
}
|
||||
return cachePath
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.zhidaoauto.map.sdk.inner.utils
|
||||
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock
|
||||
|
||||
class ConcurrentLRUCache<K, V>(private val capacity: Int) {
|
||||
|
||||
private val map = LinkedHashMap<K, V>(capacity, 0.75f, true)
|
||||
private val lock = ReentrantReadWriteLock()
|
||||
|
||||
fun put(key: K, value: V) {
|
||||
lock.writeLock().lock()
|
||||
try {
|
||||
map.put(key, value)
|
||||
if (map.size > capacity) {
|
||||
val eldest = map.entries.iterator().next()
|
||||
map.remove(eldest.key)
|
||||
}
|
||||
} finally {
|
||||
lock.writeLock().unlock()
|
||||
}
|
||||
}
|
||||
|
||||
fun get(key: K): V? {
|
||||
lock.readLock().lock()
|
||||
try {
|
||||
return map.get(key)
|
||||
} finally {
|
||||
lock.readLock().unlock()
|
||||
}
|
||||
}
|
||||
|
||||
fun containsKey(key: K): Boolean {
|
||||
lock.readLock().lock()
|
||||
try {
|
||||
return map.containsKey(key)
|
||||
} finally {
|
||||
lock.readLock().unlock()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user