[3.4.0-map-sdk] code style and add npl catch
This commit is contained in:
@@ -543,7 +543,9 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
smallMapView.onDestroy();
|
||||
if(smallMapView != null){
|
||||
smallMapView.onDestroy();
|
||||
}
|
||||
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().unregisterHostMapListener(TAG);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import com.mogo.map.uicontroller.VisualAngleMode
|
||||
import com.mogo.och.common.module.utils.SoundPoolHelper
|
||||
import kotlinx.android.synthetic.main.charter_base_fragment.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.util.*
|
||||
import kotlin.math.abs
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
@@ -162,7 +162,6 @@ abstract class CharterBaseFragment<V : IView?, P : Presenter<V>?>() :
|
||||
|
||||
mSettingBtn = findViewById(R.id.module_mogo_och_setting_layout)
|
||||
mSettingBtn!!.setOnClickListener { v: View? ->
|
||||
// TODO: 2021/12/9
|
||||
showToolsView()
|
||||
}
|
||||
|
||||
@@ -473,7 +472,7 @@ abstract class CharterBaseFragment<V : IView?, P : Presenter<V>?>() :
|
||||
* @param newSpeed
|
||||
*/
|
||||
open fun updateSpeedView(newSpeed: Float) {
|
||||
val speed = (Math.abs(newSpeed) * 3.6f).toInt() // 倒车时工控机反馈定位信息中speed为负值
|
||||
val speed = (abs(newSpeed) * 3.6f).toInt() // 倒车时工控机反馈定位信息中speed为负值
|
||||
if (mTrafficDataView != null) {
|
||||
mTrafficDataView!!.updateSpeedWithValue(speed)
|
||||
}
|
||||
@@ -481,7 +480,7 @@ abstract class CharterBaseFragment<V : IView?, P : Presenter<V>?>() :
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
smallMapView!!.onDestroy()
|
||||
smallMapView?.onDestroy()
|
||||
mogoMapListenerHandler.unregisterHostMapListener(TAG)
|
||||
}
|
||||
|
||||
|
||||
@@ -560,7 +560,9 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
smallMapView.onDestroy();
|
||||
if(smallMapView != null){
|
||||
smallMapView.onDestroy();
|
||||
}
|
||||
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().unregisterHostMapListener(TAG);
|
||||
}
|
||||
|
||||
|
||||
@@ -320,8 +320,10 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if(smallMapView != null){
|
||||
smallMapView.onDestroy();
|
||||
}
|
||||
super.onDestroy();
|
||||
smallMapView.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,11 +21,12 @@ import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/** Junk drawer of utility methods. */
|
||||
final class Util {
|
||||
static final Charset US_ASCII = Charset.forName("US-ASCII");
|
||||
static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
static final Charset US_ASCII = StandardCharsets.US_ASCII;
|
||||
static final Charset UTF_8 = StandardCharsets.UTF_8;
|
||||
|
||||
private Util() {
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ data class QueryCurrentTaskRespBean(var data: Result?) : BaseData() {
|
||||
/**
|
||||
* with order.orderStatus == OnTheWayToEnd
|
||||
*/
|
||||
fun isOrderOnTheWayToEnd(data: QueryCurrentTaskRespBean.Result?): Boolean {
|
||||
fun isOrderOnTheWayToEnd(data: Result?): Boolean {
|
||||
if (data == null) {
|
||||
return false
|
||||
}
|
||||
@@ -121,7 +121,7 @@ data class QueryCurrentTaskRespBean(var data: Result?) : BaseData() {
|
||||
/**
|
||||
* with order.orderStatus == ArriveAtEnd
|
||||
*/
|
||||
fun isOrderArriveAtEnd(data: QueryCurrentTaskRespBean.Result?): Boolean {
|
||||
fun isOrderArriveAtEnd(data: Result?): Boolean {
|
||||
if (data == null) {
|
||||
return false
|
||||
}
|
||||
@@ -134,7 +134,7 @@ data class QueryCurrentTaskRespBean(var data: Result?) : BaseData() {
|
||||
/**
|
||||
* with order.orderStatus == ArriveAtStart
|
||||
*/
|
||||
fun isOrderArriveAtStart(data: QueryCurrentTaskRespBean.Result?): Boolean {
|
||||
fun isOrderArriveAtStart(data: Result?): Boolean {
|
||||
if (data == null) {
|
||||
return false
|
||||
}
|
||||
@@ -144,7 +144,7 @@ data class QueryCurrentTaskRespBean(var data: Result?) : BaseData() {
|
||||
return data.order!!.orderStatus == TaxiOrderStatusEnum.ArriveAtStart.code
|
||||
}
|
||||
|
||||
fun isUserArriveAtStart(data: QueryCurrentTaskRespBean.Result?): Boolean {
|
||||
fun isUserArriveAtStart(data: Result?): Boolean {
|
||||
if (data == null) {
|
||||
return false
|
||||
}
|
||||
@@ -157,7 +157,7 @@ data class QueryCurrentTaskRespBean(var data: Result?) : BaseData() {
|
||||
/**
|
||||
* with task.currentStatus == StartTask
|
||||
*/
|
||||
fun isStartTaskType(data: QueryCurrentTaskRespBean.Result?): Boolean {
|
||||
fun isStartTaskType(data: Result?): Boolean {
|
||||
if (data == null) {
|
||||
return false
|
||||
}
|
||||
@@ -167,7 +167,7 @@ data class QueryCurrentTaskRespBean(var data: Result?) : BaseData() {
|
||||
/**
|
||||
* with task.currentStatus == CompleteTask
|
||||
*/
|
||||
fun isCompleteTaskType(data: QueryCurrentTaskRespBean.Result?): Boolean {
|
||||
fun isCompleteTaskType(data: Result?): Boolean {
|
||||
if (data == null) {
|
||||
return false
|
||||
}
|
||||
@@ -177,7 +177,7 @@ data class QueryCurrentTaskRespBean(var data: Result?) : BaseData() {
|
||||
/**
|
||||
* with task.currentStatus == GetTask
|
||||
*/
|
||||
fun isGetTaskType(data: QueryCurrentTaskRespBean.Result?): Boolean {
|
||||
fun isGetTaskType(data: Result?): Boolean {
|
||||
if (data == null) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ abstract class BaseTaxiTabFragment<V : IView, P : Presenter<V>> : MvpFragment<V,
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
smallMapView.onDestroy()
|
||||
smallMapView?.onDestroy()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
|
||||
@@ -259,8 +259,6 @@ object TaxiTaskModel {
|
||||
|
||||
private val mMogoAutopilotStatusListener: IMoGoAutopilotStatusListener =
|
||||
object : IMoGoAutopilotStatusListener {
|
||||
override fun onAutopilotDockerInfo(dockerVersion: String) {}
|
||||
override fun onAutopilotRouteLineId(lineId: Long) {}
|
||||
override fun onAutopilotIpcConnectStatusChanged(status: Int, reason: String?) {
|
||||
DebugView.printInfoMsg("[域控连接状态变化] status=$status, reason=${if (TextUtils.isEmpty(reason)) "" else reason}")
|
||||
}
|
||||
@@ -268,7 +266,6 @@ object TaxiTaskModel {
|
||||
TaxiTrajectoryManager.getInstance().onAutopilotGuardian(guardianInfo)
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {}
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
DebugView.printInfoMsg("[自驾状态变化] afterValue=STATUS_AUTOPILOT_RUNNING,meaning=自动驾驶中")
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
<exclude-pattern>.*/gen/.*</exclude-pattern>
|
||||
<exclude-pattern>.*Dagger*.*</exclude-pattern>
|
||||
|
||||
<!-- 最佳实践 -->
|
||||
|
||||
<!-- 用log代替e.PrintStackTrace -->
|
||||
<!-- <rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace" />-->
|
||||
<!-- for/foreach 避免index重新赋值 -->
|
||||
@@ -33,6 +35,18 @@
|
||||
<property name="strictMode" value="true" />
|
||||
</properties>
|
||||
</rule>
|
||||
<!-- 检查赋值字段未使用问题 -->
|
||||
<rule ref="category/java/bestpractices.xml/UnusedAssignment">
|
||||
<properties>
|
||||
<property name="checkUnusedPrefixIncrement" value="true" />
|
||||
<property name="reportUnusedVariables" value="true" />
|
||||
</properties>
|
||||
</rule>
|
||||
<!-- 检查未使用的局部变量 -->
|
||||
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable" />
|
||||
<!-- 检查未使用的private变量 -->
|
||||
<!-- <rule ref="category/java/bestpractices.xml/UnusedPrivateField" />-->
|
||||
<rule ref="category/java/bestpractices.xml/UseStandardCharsets" />
|
||||
|
||||
<!-- 容易出现运行时错误 -->
|
||||
<rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop" />
|
||||
|
||||
@@ -21,11 +21,12 @@ import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/** Junk drawer of utility methods. */
|
||||
final class Util {
|
||||
static final Charset US_ASCII = Charset.forName("US-ASCII");
|
||||
static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
static final Charset US_ASCII = StandardCharsets.US_ASCII;
|
||||
static final Charset UTF_8 = StandardCharsets.UTF_8;
|
||||
|
||||
private Util() {
|
||||
}
|
||||
|
||||
@@ -22,11 +22,12 @@ import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/** Junk drawer of utility methods. */
|
||||
final class CacheUtil {
|
||||
static final Charset US_ASCII = Charset.forName("US-ASCII");
|
||||
static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
static final Charset US_ASCII = StandardCharsets.US_ASCII;
|
||||
static final Charset UTF_8 = StandardCharsets.UTF_8;
|
||||
|
||||
private CacheUtil() {
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.zhidaoauto.map.sdk.inner.byteh;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -40,7 +41,7 @@ public class PayloadDecoder {
|
||||
|
||||
case "java.lang.Character":
|
||||
case "char":
|
||||
CharSequence charSequence = buffer.readCharSequence(fieldWrapper.getCodecProprety().length(), Charset.forName("UTF-8"));
|
||||
CharSequence charSequence = buffer.readCharSequence(fieldWrapper.getCodecProprety().length(), StandardCharsets.UTF_8);
|
||||
field.set(instance, charSequence);
|
||||
break;
|
||||
case "java.lang.Byte":
|
||||
@@ -74,7 +75,7 @@ public class PayloadDecoder {
|
||||
field.set(instance, readDouble);
|
||||
break;
|
||||
case "java.lang.String":
|
||||
String readString = buffer.readCharSequence(fieldWrapper.getCodecProprety().length(), Charset.forName("UTF-8")).toString();
|
||||
String readString = buffer.readCharSequence(fieldWrapper.getCodecProprety().length(), StandardCharsets.UTF_8).toString();
|
||||
field.set(instance, readString);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.autonavi.nge.map.LonLat;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -50,7 +51,7 @@ public class PayloadEncoder {
|
||||
case "java.lang.Character":
|
||||
case "kotlin.Character":
|
||||
case "char":
|
||||
buffer.writeCharSequence((CharSequence) value, Charset.forName("UTF-8"));
|
||||
buffer.writeCharSequence((CharSequence) value, StandardCharsets.UTF_8);
|
||||
break;
|
||||
case "java.lang.Byte":
|
||||
case "kotlin.Byte":
|
||||
@@ -84,7 +85,7 @@ public class PayloadEncoder {
|
||||
break;
|
||||
case "java.lang.String":
|
||||
case "kotlin.String":
|
||||
buffer.writeCharSequence((CharSequence) value, Charset.forName("UTF-8"));
|
||||
buffer.writeCharSequence((CharSequence) value, StandardCharsets.UTF_8);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException(typeName + "不支持,bug");
|
||||
|
||||
@@ -15,6 +15,7 @@ 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.nio.charset.StandardCharsets
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
@@ -82,11 +83,11 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
override fun addMarkerIconCache(id: Int, icon: String) {
|
||||
markerIconResourceCacheMap.put(id,icon)
|
||||
markerIconResourceCacheMap[id] = icon
|
||||
}
|
||||
|
||||
override fun getMarkerIconCache(id:Int):String?{
|
||||
return markerIconResourceCacheMap.get(id)
|
||||
return markerIconResourceCacheMap[id]
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
@@ -103,7 +104,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
fun clearAllMarkers(): Boolean? {
|
||||
fun clearAllMarkers(): Boolean {
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--clearAllMarkers:")
|
||||
}
|
||||
@@ -121,9 +122,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
* @param title
|
||||
*/
|
||||
fun setTitle(id: String?, title: String?) {
|
||||
|
||||
updateMarkerProperty(id!!, "title", title!!)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +132,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
* @return
|
||||
*/
|
||||
fun getTitle(id: String?): String {
|
||||
return getMarkerProperty(id!!, "title")?:""
|
||||
return getMarkerProperty(id!!, "title")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,11 +152,11 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
* @return
|
||||
*/
|
||||
fun getSnippet(id: String?): String {
|
||||
return getMarkerProperty(id!!, "snippet")?:""
|
||||
return getMarkerProperty(id!!, "snippet")
|
||||
}
|
||||
|
||||
fun isAnchorDynamicMoving(id: String): Boolean {
|
||||
return mMapController.isAnchorDynamicMoving(id)?:false
|
||||
return mMapController.isAnchorDynamicMoving(id)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -502,7 +501,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
fun addDynamicAnchorPostion(id: String, points: List<LonLatPoint>,angle:Float, isGps:Boolean,current:Long,duration: Int) {
|
||||
fun addDynamicAnchorPosition(id: String, points: List<LonLatPoint>,angle:Float, isGps:Boolean,current:Long,duration: Int) {
|
||||
val data = MapTools.listToArray(points,!isGps)
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--addDynamicAnchorPostion:${id},${points},isGps:${isGps},duration:${duration}")
|
||||
@@ -611,7 +610,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
|
||||
//设置infowindow的偏移量
|
||||
//设置infoWindow的偏移量
|
||||
fun setInfoWindowOffset(id: String, offsetX: Int, offsetY: Int) {
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--setInfoWindowOffset:${id},${offsetX},${offsetY}")
|
||||
@@ -738,7 +737,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
mMapController.setAnchorFlash(id, colorType, color, time, angle)
|
||||
}
|
||||
|
||||
val charset = Charset.forName("UTF-8")
|
||||
val charset: Charset = StandardCharsets.UTF_8
|
||||
|
||||
private fun dealMarker(markerPtions: MarkerOptions):ByteArray?{
|
||||
val buffer = Unpooled.buffer()
|
||||
|
||||
@@ -211,7 +211,7 @@
|
||||
// Log.i(TAG, "navop-msg-getTts")
|
||||
// }
|
||||
// val datas = msg.obj as ByteArray
|
||||
// currentTts = String(datas, Charset.forName("utf-8"))
|
||||
// currentTts = String(datas, StandardCharsets.UTF_8)
|
||||
// if (DEBUG) {
|
||||
// Log.i(TAG, "navop-msg-getTts:${currentTts}")
|
||||
// }
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.zhidaoauto.map.sdk.open.view.MapAutoView
|
||||
import io.netty.buffer.Unpooled
|
||||
import java.math.BigDecimal
|
||||
import java.nio.charset.Charset
|
||||
import java.nio.charset.StandardCharsets
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.pow
|
||||
|
||||
@@ -520,13 +521,13 @@ object MapAutoApi {
|
||||
val byteBuffer = Unpooled.buffer()
|
||||
val str = "1111112345678sjkfdhdkb"
|
||||
byteBuffer.writeInt(str.length)
|
||||
byteBuffer.writeCharSequence(str, Charset.forName("utf-8"))
|
||||
byteBuffer.writeCharSequence(str, StandardCharsets.UTF_8)
|
||||
byteBuffer.writeBoolean(true)
|
||||
byteBuffer.writeInt(999)
|
||||
byteBuffer.writeInt(12)
|
||||
val length = byteBuffer.readInt()
|
||||
println("$length")
|
||||
println("${byteBuffer.readCharSequence(length, Charset.forName("utf-8"))}")
|
||||
println("${byteBuffer.readCharSequence(length, StandardCharsets.UTF_8)}")
|
||||
println("${byteBuffer.readBoolean()}")
|
||||
println("${byteBuffer.readInt()}")
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.zhidaoauto.map.sdk.inner.utils.Recorder
|
||||
import io.netty.buffer.Unpooled
|
||||
import java.math.BigDecimal
|
||||
import java.nio.charset.Charset
|
||||
import java.nio.charset.StandardCharsets
|
||||
import kotlin.math.pow
|
||||
|
||||
object NavAutoApi {
|
||||
@@ -167,13 +168,13 @@ object NavAutoApi {
|
||||
val byteBuffer = Unpooled.buffer()
|
||||
val str = "1111112345678sjkfdhdkb"
|
||||
byteBuffer.writeInt(str.length)
|
||||
byteBuffer.writeCharSequence(str, Charset.forName("utf-8"))
|
||||
byteBuffer.writeCharSequence(str, StandardCharsets.UTF_8)
|
||||
byteBuffer.writeBoolean(true)
|
||||
byteBuffer.writeInt(999)
|
||||
byteBuffer.writeInt(12)
|
||||
val length = byteBuffer.readInt()
|
||||
println("$length")
|
||||
println("${byteBuffer.readCharSequence(length, Charset.forName("utf-8"))}")
|
||||
println("${byteBuffer.readCharSequence(length, StandardCharsets.UTF_8)}")
|
||||
println("${byteBuffer.readBoolean()}")
|
||||
println("${byteBuffer.readInt()}")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user