[6.2.4] fix sonarbug

This commit is contained in:
zhongchao
2023-12-07 17:07:32 +08:00
parent 02199849e9
commit 96304d6541
8 changed files with 28 additions and 15 deletions

View File

@@ -46,7 +46,7 @@ public class AmapNaviToDestinationModel implements AMapNaviListener {
protected final List<NaviLatLng> eList = new ArrayList<NaviLatLng>();
protected List<NaviLatLng> mWayPointList = new ArrayList<NaviLatLng>();
private volatile ICommonNaviChangedCallback mNaviChangedCallback;
private AtomicInteger errorCount = new AtomicInteger(0);
private final AtomicInteger errorCount = new AtomicInteger(0);
private boolean isPlay;
public static AmapNaviToDestinationModel getInstance(Context context) {

View File

@@ -1,5 +1,7 @@
package com.mogo.och.common.module.wigets.sfv;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_HMI;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -12,6 +14,8 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.util.AttributeSet;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@@ -21,6 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* a SurfaceView which draws bitmaps one after another like frame animation
*/
public class FrameSurfaceView extends BaseSurfaceView {
private static final String TAG = "FrameSurfaceView";
public static final int INVALID_INDEX = Integer.MAX_VALUE;
private final int bufferSize = 3;
public static final String DECODE_THREAD_NAME = "DecodingThread";
@@ -320,6 +325,7 @@ public class FrameSurfaceView extends BaseSurfaceView {
decodedBitmaps.put(linkedBitmap);
} catch (InterruptedException e) {
e.printStackTrace();
CallerLogger.e(M_HMI + TAG, "decodeAndPutBitmap error");
}
}
@@ -338,6 +344,7 @@ public class FrameSurfaceView extends BaseSurfaceView {
bitmap = drawnBitmaps.take();
} catch (InterruptedException e) {
e.printStackTrace();
CallerLogger.e(M_HMI + TAG, "getDrawnBitmap error");
}
return bitmap;
}
@@ -354,6 +361,7 @@ public class FrameSurfaceView extends BaseSurfaceView {
bitmap = decodedBitmaps.take();
} catch (InterruptedException e) {
e.printStackTrace();
CallerLogger.e(M_HMI + TAG, "getDecodedBitmap error");
}
return bitmap;
}

View File

@@ -565,6 +565,9 @@ public class BusPassengerModel {
public synchronized void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp routeList) {
// CallerLogger.d(M_BUS_P + TAG, "onAutopilotRotting = "
// + GsonUtil.jsonFromObject(routeList));
if(routeList == null){
return;
}
List<MessagePad.Location> routePoints = routeList.getWayPointsList();
if(globalPathTruncation!=null&&!globalPathTruncation.isDisposed()){

View File

@@ -36,14 +36,14 @@ public class SweeperProvider implements IMogoOCH {
FragmentManager supportFragmentManager = activity.getSupportFragmentManager();
if (sweeperFragment == null) {
CallerLogger.d(TAG, "准备add fragment======");
Fragment fragmentByTag = supportFragmentManager.findFragmentByTag(sweeperFragment.TAG);
Fragment fragmentByTag = supportFragmentManager.findFragmentByTag(SweeperFragment.TAG);
if (fragmentByTag instanceof SweeperFragment) {
sweeperFragment = (SweeperFragment) fragmentByTag;
} else {
sweeperFragment = new SweeperFragment();
}
if(!sweeperFragment.isAdded()) {
supportFragmentManager.beginTransaction().add(containerId, sweeperFragment, sweeperFragment.TAG).commitAllowingStateLoss();
supportFragmentManager.beginTransaction().add(containerId, sweeperFragment, SweeperFragment.TAG).commitAllowingStateLoss();
}
return;
}

View File

@@ -354,7 +354,7 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
}
public static String format(double value) {
BigDecimal bd = new BigDecimal(value);
BigDecimal bd = BigDecimal.valueOf(value);
bd = bd.setScale(2, RoundingMode.HALF_UP);
return bd.toString();
}

View File

@@ -580,7 +580,7 @@ public class CommonUtils {
}
BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
StringBuffer stringBuffer = new StringBuffer();
String line = null;
String line;
while ((line = in.readLine()) != null) {
stringBuffer.append(line + " ");

View File

@@ -39,8 +39,10 @@ public class PayloadEncoder {
switch (typeName) {
case "com.autonavi.nge.map.LonLat":
LonLat lonLat = (LonLat) value;
buffer.writeDouble(lonLat.getLon());
buffer.writeDouble(lonLat.getLat());
if(lonLat != null){
buffer.writeDouble(lonLat.getLon());
buffer.writeDouble(lonLat.getLat());
}
break;
case "java.lang.Boolean":
case "kotlin.Boolean":

View File

@@ -2,6 +2,7 @@ package com.zhidaoauto.map.sdk.inner.utils;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -33,12 +34,11 @@ public class MainInfo {
if (null == dir) {
return;
}
try {
FileWriter fw = new FileWriter((dir + "log.txt"), true);
try(FileWriter fw = new FileWriter((dir + "log.txt"), true)){
String date = dateFormat.format(new Date());
fw.write(date + " " + log + "\r\n");
fw.close();
} catch (Exception ex) {
} catch (IOException e) {
e.printStackTrace();
}
}
@@ -50,11 +50,11 @@ public class MainInfo {
if (null == dir) {
return;
}
try {
FileWriter fw = new FileWriter((dir + "log.txt"), true);
try(FileWriter fw = new FileWriter((dir + "log.txt"), true)){
e.printStackTrace(new PrintWriter(fw));
fw.close();
} catch (Exception ex) {
} catch (IOException ex) {
ex.printStackTrace();
}
}