[sonar] merge
This commit is contained in:
@@ -6,13 +6,13 @@ import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class M3DCar {
|
||||
private Context context;
|
||||
private int resid;
|
||||
private final Context context;
|
||||
private final int redis;
|
||||
public byte[] totBuffer = null;
|
||||
public int totSize = 0;
|
||||
|
||||
public M3DCar(Context context, int resid) {
|
||||
this.resid = resid;
|
||||
public M3DCar(Context context, int redis) {
|
||||
this.redis = redis;
|
||||
this.context = context;
|
||||
loadData();
|
||||
}
|
||||
@@ -20,12 +20,12 @@ public class M3DCar {
|
||||
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 {
|
||||
int size;
|
||||
try(DataInputStream dis = new DataInputStream(context.getResources().openRawResource(redis))) {
|
||||
while ((size = dis.read(buffer)) >= 0) {
|
||||
if (totSize + size > curTotSize) {
|
||||
curTotSize = (totSize + size) * 3 / 2;
|
||||
@@ -36,8 +36,8 @@ public class M3DCar {
|
||||
System.arraycopy(buffer, 0, totBuffer, totSize, size);
|
||||
totSize += size;
|
||||
}
|
||||
dis.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ 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();
|
||||
private final Matrix matrix = new Matrix();
|
||||
private final Camera mCamera = new Camera();
|
||||
|
||||
public DirectionLayer(Context context){
|
||||
super(context);
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class MainInfo {
|
||||
private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
||||
private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
||||
private static MainInfo m_hinst = null;
|
||||
private boolean mbUserLog = true;
|
||||
private static boolean mbDebug = false;
|
||||
@@ -33,11 +33,9 @@ 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) {
|
||||
}
|
||||
}
|
||||
@@ -50,10 +48,8 @@ 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) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,9 @@ public class BaseSDCardHelper {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
bos.close();
|
||||
if (bos != null) {
|
||||
bos.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@@ -108,7 +110,9 @@ public class BaseSDCardHelper {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
bos.close();
|
||||
if (bos != null) {
|
||||
bos.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@@ -134,7 +138,9 @@ public class BaseSDCardHelper {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
bos.close();
|
||||
if(bos != null){
|
||||
bos.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@@ -160,7 +166,9 @@ public class BaseSDCardHelper {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
bos.close();
|
||||
if(bos != null){
|
||||
bos.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@@ -177,9 +185,9 @@ public class BaseSDCardHelper {
|
||||
|
||||
try {
|
||||
bis = new BufferedInputStream(
|
||||
new FileInputStream(new File(fileDir)));
|
||||
new FileInputStream(fileDir));
|
||||
byte[] buffer = new byte[8 * 1024];
|
||||
int c = 0;
|
||||
int c;
|
||||
while ((c = bis.read(buffer)) != -1) {
|
||||
baos.write(buffer, 0, c);
|
||||
baos.flush();
|
||||
@@ -237,27 +245,27 @@ public class BaseSDCardHelper {
|
||||
* 删除文件夹
|
||||
* @param path
|
||||
*/
|
||||
public static boolean deleteAllFilesOfDir(File path) {
|
||||
public static boolean deleteAllFilesOfDir(File path) {
|
||||
if (!path.exists()){
|
||||
return false;
|
||||
}
|
||||
if (path.isFile()) {
|
||||
path.delete();
|
||||
return true;
|
||||
return path.delete();
|
||||
}
|
||||
File[] files = path.listFiles();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
deleteAllFilesOfDir(files[i]);
|
||||
if(files != null){
|
||||
for (File file : files) {
|
||||
deleteAllFilesOfDir(file);
|
||||
}
|
||||
}
|
||||
path.delete();
|
||||
System.out.println("删除文件夹成功");
|
||||
return true;
|
||||
return path.delete();
|
||||
}
|
||||
/**
|
||||
* 删除文件夹2
|
||||
* @param path
|
||||
*/
|
||||
public static void deleteAllFilesOfDir2(File path) {
|
||||
public static void deleteAllFilesOfDir2(File path) {
|
||||
if (!path.exists()){
|
||||
return ;
|
||||
}
|
||||
@@ -266,8 +274,10 @@ public class BaseSDCardHelper {
|
||||
return ;
|
||||
}
|
||||
File[] files = path.listFiles();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
deleteAllFilesOfDir(files[i]);
|
||||
if(files != null){
|
||||
for (File file : files) {
|
||||
deleteAllFilesOfDir(file);
|
||||
}
|
||||
}
|
||||
path.delete();
|
||||
System.out.println("删除文件夹成功");
|
||||
|
||||
@@ -36,7 +36,6 @@ public class SubscribeInterface {
|
||||
|
||||
public SubscribeInterface(@NonNull OnSubscribeInterfaceListener listener) {
|
||||
this.listener = listener;
|
||||
if (listener == null) throw new RuntimeException();
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -62,10 +61,8 @@ public class SubscribeInterface {
|
||||
* @param role 角色 详情参见{@link Constants.TERMINAL_ROLE}
|
||||
* @param type 注册类型 详情参见{@link Constants.SUBSCRIBE_TYPE}
|
||||
* @param messageTypes 要操作的接口
|
||||
* @return
|
||||
*/
|
||||
public boolean subscribeInterface(@Define.TerminalRole int role, @Define.SubscribeType int type, @NonNull Set<MessageType> messageTypes) {
|
||||
if (messageTypes == null) return false;
|
||||
MessagePad.SubscribeDataReq.Builder builder = MessagePad.SubscribeDataReq.newBuilder();
|
||||
builder.setRole(role).setReqType(type);
|
||||
Map<MessageType, Integer> temp = new HashMap<>();
|
||||
@@ -89,9 +86,7 @@ public class SubscribeInterface {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
return isSendSucceed;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +98,6 @@ public class SubscribeInterface {
|
||||
* @return 是否加入ws发送队列
|
||||
*/
|
||||
public boolean subscribeInterface(@Define.TerminalRole int role, @Define.SubscribeType int type, @NonNull MessageType messageType) {
|
||||
if (messageType == null) return false;
|
||||
MessagePad.SubscribeDataReq.Builder builder = MessagePad.SubscribeDataReq.newBuilder();
|
||||
builder.setRole(role).setReqType(type).addDataTypes(messageType.typeCode.getNumber());
|
||||
boolean isSendSucceed = listener.onSendSubscribe(builder.build().toByteArray());
|
||||
@@ -120,7 +114,7 @@ public class SubscribeInterface {
|
||||
subscribedInterface.remove(messageType);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return isSendSucceed;
|
||||
}
|
||||
|
||||
//根据参数查询是否已订阅
|
||||
|
||||
Reference in New Issue
Block a user