[sonar] code bug

This commit is contained in:
zhongchao
2023-10-19 16:28:13 +08:00
parent 195f971425
commit 2a3e01f66e
44 changed files with 392 additions and 2756 deletions

View File

@@ -46,7 +46,7 @@ public class BusRoutesResult {
return sites;
}
public void setSite(List<BusStationBean> site) {
public void setSites(List<BusStationBean> sites) {
this.sites = sites;
}

View File

@@ -11,7 +11,6 @@ import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;
import java.util.ArrayList;
import java.util.List;
@@ -28,10 +27,10 @@ public class OpenItemAnimator extends DefaultItemAnimator {
private static TimeInterpolator sDefaultInterpolator;
private ArrayList<RecyclerView.ViewHolder> mPendingRemovals = new ArrayList<>();
private ArrayList<RecyclerView.ViewHolder> mPendingAdditions = new ArrayList<>();
private ArrayList<MoveInfo> mPendingMoves = new ArrayList<>();
private ArrayList<ChangeInfo> mPendingChanges = new ArrayList<>();
private final ArrayList<RecyclerView.ViewHolder> mPendingRemovals = new ArrayList<>();
private final ArrayList<RecyclerView.ViewHolder> mPendingAdditions = new ArrayList<>();
private final ArrayList<MoveInfo> mPendingMoves = new ArrayList<>();
private final ArrayList<ChangeInfo> mPendingChanges = new ArrayList<>();
private ArrayList<ArrayList<RecyclerView.ViewHolder>> mAdditionsList = new ArrayList<>();
private ArrayList<ArrayList<MoveInfo>> mMovesList = new ArrayList<>();
@@ -102,20 +101,16 @@ public class OpenItemAnimator extends DefaultItemAnimator {
mPendingRemovals.clear();
// Next, move stuff
if (movesPending) {
final ArrayList<MoveInfo> moves = new ArrayList<>();
moves.addAll(mPendingMoves);
final ArrayList<MoveInfo> moves = new ArrayList<>(mPendingMoves);
mMovesList.add(moves);
mPendingMoves.clear();
Runnable mover = new Runnable() {
@Override
public void run() {
for (MoveInfo moveInfo : moves) {
animateMoveImpl(moveInfo.holder, moveInfo.fromX, moveInfo.fromY,
moveInfo.toX, moveInfo.toY);
}
moves.clear();
mMovesList.remove(moves);
Runnable mover = () -> {
for (MoveInfo moveInfo : moves) {
animateMoveImpl(moveInfo.holder, moveInfo.fromX, moveInfo.fromY,
moveInfo.toX, moveInfo.toY);
}
moves.clear();
mMovesList.remove(moves);
};
if (removalsPending) {
View view = moves.get(0).holder.itemView;
@@ -126,19 +121,15 @@ public class OpenItemAnimator extends DefaultItemAnimator {
}
// Next, change stuff, to run in parallel with move animations
if (changesPending) {
final ArrayList<ChangeInfo> changes = new ArrayList<>();
changes.addAll(mPendingChanges);
final ArrayList<ChangeInfo> changes = new ArrayList<>(mPendingChanges);
mChangesList.add(changes);
mPendingChanges.clear();
Runnable changer = new Runnable() {
@Override
public void run() {
for (ChangeInfo change : changes) {
animateChangeImpl(change);
}
changes.clear();
mChangesList.remove(changes);
Runnable changer = () -> {
for (ChangeInfo change : changes) {
animateChangeImpl(change);
}
changes.clear();
mChangesList.remove(changes);
};
if (removalsPending) {
RecyclerView.ViewHolder holder = changes.get(0).oldHolder;
@@ -149,19 +140,15 @@ public class OpenItemAnimator extends DefaultItemAnimator {
}
// Next, add stuff
if (additionsPending) {
final ArrayList<RecyclerView.ViewHolder> additions = new ArrayList<>();
additions.addAll(mPendingAdditions);
final ArrayList<RecyclerView.ViewHolder> additions = new ArrayList<>(mPendingAdditions);
mAdditionsList.add(additions);
mPendingAdditions.clear();
Runnable adder = new Runnable() {
@Override
public void run() {
for (RecyclerView.ViewHolder holder : additions) {
animateAddImpl(holder);
}
additions.clear();
mAdditionsList.remove(additions);
Runnable adder = () -> {
for (RecyclerView.ViewHolder holder : additions) {
animateAddImpl(holder);
}
additions.clear();
mAdditionsList.remove(additions);
};
if (removalsPending || movesPending || changesPending) {
long removeDuration = removalsPending ? getRemoveDuration() : 0;
@@ -480,25 +467,25 @@ public class OpenItemAnimator extends DefaultItemAnimator {
}
// animations should be ended by the cancel above.
//noinspection PointlessBooleanExpression,ConstantConditions
//noinspection Pointless BooleanExpression,ConstantConditions
if (mRemoveAnimations.remove(item) && DEBUG) {
throw new IllegalStateException("after animation is cancelled, item should not be in "
+ "mRemoveAnimations list");
}
//noinspection PointlessBooleanExpression,ConstantConditions
//noinspection Pointless BooleanExpression,ConstantConditions
if (mAddAnimations.remove(item) && DEBUG) {
throw new IllegalStateException("after animation is cancelled, item should not be in "
+ "mAddAnimations list");
}
//noinspection PointlessBooleanExpression,ConstantConditions
//noinspection Pointless BooleanExpression,ConstantConditions
if (mChangeAnimations.remove(item) && DEBUG) {
throw new IllegalStateException("after animation is cancelled, item should not be in "
+ "mChangeAnimations list");
}
//noinspection PointlessBooleanExpression,ConstantConditions
//noinspection Pointless BooleanExpression,ConstantConditions
if (mMoveAnimations.remove(item) && DEBUG) {
throw new IllegalStateException("after animation is cancelled, item should not be in "
+ "mMoveAnimations list");

View File

@@ -13,13 +13,17 @@ public class CollectionUtils {
OkHttpClient okHttpClient = OkHttpFactory.Companion.getOkHttpClient();
List<Interceptor> interceptors = okHttpClient.interceptors();
Field pro = getDeclaredField(interceptors, "list");
pro.setAccessible(true);
List<Interceptor> modifyerList = null;
try {
modifyerList = (List<Interceptor>) pro.get(interceptors);
modifyerList.add(new SimpleInterceptor());
} catch (IllegalAccessException e) {
e.printStackTrace();
if(pro != null){
pro.setAccessible(true);
List<Interceptor> modifierList;
try {
modifierList = (List<Interceptor>) pro.get(interceptors);
if(modifierList != null){
modifierList.add(new SimpleInterceptor());
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
/**
@@ -32,7 +36,10 @@ public class CollectionUtils {
* @since2019年2月26日 下午4:06:16
*/
public static Field getDeclaredField(Object object, String fieldName){
Field field = null ;
if(fieldName == null){
return null;
}
Field field;
Class<?> clazz = object.getClass() ;
for(; clazz != Object.class ; clazz = clazz.getSuperclass()) {
try {

View File

@@ -14,7 +14,7 @@ public class NumberFormatUtil {
* @return
*/
public static String formatLong(double d) {
BigDecimal bg = new BigDecimal(d).setScale(1, RoundingMode.HALF_UP);
BigDecimal bg = BigDecimal.valueOf(d).setScale(1, RoundingMode.HALF_UP);
double num = bg.doubleValue();
if (Math.ceil(num) - num == 0) {
return String.valueOf((long) num);

View File

@@ -26,7 +26,7 @@ public class MarqueeTextView extends androidx.appcompat.widget.AppCompatTextView
/**
* 是否使用自定义 gap
*/
private boolean mUseCustomGap;
private final boolean mUseCustomGap;
public MarqueeTextView(Context context) {
this(context, null);
@@ -60,7 +60,6 @@ public class MarqueeTextView extends androidx.appcompat.widget.AppCompatTextView
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
if (hasWindowFocus){}
super.onWindowFocusChanged(true);
}

View File

@@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicInteger;
*/
public class FrameSurfaceView extends BaseSurfaceView {
public static final int INVALID_INDEX = Integer.MAX_VALUE;
private int bufferSize = 3;
private final int bufferSize = 3;
public static final String DECODE_THREAD_NAME = "DecodingThread";
public static final int INFINITE = -1;
//-1 means repeat infinitely
@@ -45,12 +45,12 @@ public class FrameSurfaceView extends BaseSurfaceView {
* decoded bitmaps stores in this queue
* consumer is drawing thread, producer is decoding thread.
*/
private LinkedBlockingQueue decodedBitmaps = new LinkedBlockingQueue(bufferSize);
private final LinkedBlockingQueue decodedBitmaps = new LinkedBlockingQueue(bufferSize);
/**
* bitmaps already drawn by canvas stores in this queue
* consumer is decoding thread, producer is drawing thread.
*/
private LinkedBlockingQueue drawnBitmaps = new LinkedBlockingQueue(bufferSize);
private final LinkedBlockingQueue drawnBitmaps = new LinkedBlockingQueue(bufferSize);
/**
* the thread for decoding bitmaps
*/
@@ -64,9 +64,9 @@ public class FrameSurfaceView extends BaseSurfaceView {
*/
private Handler handler;
private BitmapFactory.Options options;
private Paint paint = new Paint();
private final Paint paint = new Paint();
private Rect srcRect;
private Rect dstRect = new Rect();
private final Rect dstRect = new Rect();
private int defaultWidth;
private int defaultHeight;
@@ -138,7 +138,7 @@ public class FrameSurfaceView extends BaseSurfaceView {
return;
}
this.bitmapIds = bitmapIds;
//by default, take the first bitmap's dimension into consideration
//by default, take the first bitMap's dimension into consideration
getBitmapDimension(bitmapIds.get(bitmapIdIndex));
preloadFrames();
decodeRunnable = new DecodeRunnable(bitmapIdIndex, bitmapIds, options);
@@ -322,8 +322,7 @@ public class FrameSurfaceView extends BaseSurfaceView {
* @param linkedBitmap
*/
private void decodeAndPutBitmap(int resId, BitmapFactory.Options options, LinkedBitmap linkedBitmap) {
Bitmap bitmap = decodeBitmap(resId, options);
linkedBitmap.bitmap = bitmap;
linkedBitmap.bitmap = decodeBitmap(resId, options);
try {
decodedBitmaps.put(linkedBitmap);
} catch (InterruptedException e) {
@@ -377,8 +376,8 @@ public class FrameSurfaceView extends BaseSurfaceView {
private class DecodeRunnable implements Runnable {
private int index;
private List<Integer> bitmapIds;
private BitmapFactory.Options options;
private final List<Integer> bitmapIds;
private final BitmapFactory.Options options;
public DecodeRunnable(int index, List<Integer> bitmapIds, BitmapFactory.Options options) {
this.index = index;

View File

@@ -4,8 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/road_video_bg"
tools:context="com.mogo.eagle.core.function.main.VideoAdAtc">
android:background="@drawable/road_video_bg">
<FrameLayout
android:id="@+id/videoPlayerContainer"

View File

@@ -493,7 +493,6 @@ public class BusPassengerModel {
@Override
public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autopilotStatusInfo) {
if (autopilotStatusInfo == null) return;
int state = autopilotStatusInfo.getState();
if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
//2022.7.20 自动驾驶更换成带档位的

View File

@@ -58,7 +58,7 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
mapBizView = findViewById(R.id.mapBizView);
romaPView = findViewById(R.id.romaPView);
if(DeviceUtils.isLenovoModel() || DeviceUtils.isEB5Model()){
romaPView.setVisibility(View.GONE);
romaPView.setVisibility(View.VISIBLE);
}else{
romaPView.setVisibility(View.GONE);
}

View File

@@ -128,55 +128,52 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
//设置左下角四个按钮监听事件
setBottomBtnListener();
// 模拟 下发启动自驾命令
findViewById(R.id.btnStartAutopilot).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!FunctionBuildConfig.isDemoMode && !OCHAdasAbilityManager.getInstance().getAutopilotAbilityStatus()) {
ToastUtils.showLong(OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason() + ", 请稍候重试");
return;
}
new AutopilotModeConfigManager(new AutopilotModeConfigManager.OnReadAutopilotModeConfigListener() {
@Override
public void onReadFailed(String err) {
ThreadUtils.runOnUiThread(() -> {
ToastUtils.showLong("读取失败=" + err);
});
}
@Override
public void onParseFailed(String err) {
ToastUtils.showLong("解析失败=" + err);
}
@Override
public void onParse(MessagePad.SetAutopilotModeReq bean) {
ToastUtils.showLong("下发命令\n" + TextFormat.printer().escapingNonAscii(false).printToString(bean));
AutopilotControlParameters parameters = new AutopilotControlParameters();
MessagePad.RouteInfo routeInfo = bean.getRouteInfo();
if (routeInfo.getRouteID() > 0) {
parameters.routeID = routeInfo.getRouteID();
}
parameters.routeName = routeInfo.getRouteName();
parameters.startName = routeInfo.getStartName();//拼音
parameters.endName = routeInfo.getEndName();//拼音
parameters.startLatLon = new AutopilotControlParameters
.AutoPilotLonLat(routeInfo.getStartLocation().getLatitude(), routeInfo.getStartLocation().getLongitude());
parameters.endLatLon = new AutopilotControlParameters
.AutoPilotLonLat(routeInfo.getEndLocation().getLatitude(), routeInfo.getEndLocation().getLongitude());
parameters.vehicleType = 10;
MessagePad.Line line = routeInfo.getLine();
parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine(
line.getLineId(), line.getLineName(),
line.getTrajUrl(), line.getTrajMd5(),
line.getStopUrl(), line.getStopMd5(),
line.getTimestamp(), line.getVehicleModel(),
line.getTrajUrlDpqp(), line.getTrajMd5Dpqp(),
line.getStopUrlDpqp(), line.getStopMd5Dpqp(),
line.getTimestampDpqp());
CallerAutoPilotControlManager.INSTANCE.startAutoPilot(parameters);
}
}).read();
findViewById(R.id.btnStartAutopilot).setOnClickListener(v -> {
if (!FunctionBuildConfig.isDemoMode && !OCHAdasAbilityManager.getInstance().getAutopilotAbilityStatus()) {
ToastUtils.showLong(OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason() + ", 请稍候重试");
return;
}
new AutopilotModeConfigManager(new AutopilotModeConfigManager.OnReadAutopilotModeConfigListener() {
@Override
public void onReadFailed(String err) {
ThreadUtils.runOnUiThread(() -> {
ToastUtils.showLong("读取失败=" + err);
});
}
@Override
public void onParseFailed(String err) {
ToastUtils.showLong("解析失败=" + err);
}
@Override
public void onParse(MessagePad.SetAutopilotModeReq bean) {
ToastUtils.showLong("下发命令\n" + TextFormat.printer().escapingNonAscii(false).printToString(bean));
AutopilotControlParameters parameters = new AutopilotControlParameters();
MessagePad.RouteInfo routeInfo = bean.getRouteInfo();
if (routeInfo.getRouteID() > 0) {
parameters.routeID = routeInfo.getRouteID();
}
parameters.routeName = routeInfo.getRouteName();
parameters.startName = routeInfo.getStartName();//拼音
parameters.endName = routeInfo.getEndName();//拼音
parameters.startLatLon = new AutopilotControlParameters
.AutoPilotLonLat(routeInfo.getStartLocation().getLatitude(), routeInfo.getStartLocation().getLongitude());
parameters.endLatLon = new AutopilotControlParameters
.AutoPilotLonLat(routeInfo.getEndLocation().getLatitude(), routeInfo.getEndLocation().getLongitude());
parameters.vehicleType = 10;
MessagePad.Line line = routeInfo.getLine();
parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine(
line.getLineId(), line.getLineName(),
line.getTrajUrl(), line.getTrajMd5(),
line.getStopUrl(), line.getStopMd5(),
line.getTimestamp(), line.getVehicleModel(),
line.getTrajUrlDpqp(), line.getTrajMd5Dpqp(),
line.getStopUrlDpqp(), line.getStopMd5Dpqp(),
line.getTimestampDpqp());
CallerAutoPilotControlManager.INSTANCE.startAutoPilot(parameters);
}
}).read();
});
// 模拟 查询当前任务
findViewById(R.id.btnQueryCurrentTask).setOnClickListener(view ->
@@ -437,7 +434,6 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
}
});
mSettingBtn.setOnClickListener(v -> {
// TODO: 2021/12/9
CallerHmiManager.INSTANCE.showToolsView();
});
if (mCardBtn != null) {
@@ -458,8 +454,8 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
if (isShow) {
mFlWeltMapOverView.setVisibility(View.VISIBLE);
if (mWeltMapOverViewFragment == null) {
mWeltMapOverViewFragment = mWeltMapOverViewFragment.newInstance(
(IWeltMapSwitchToSmallCallback) this,
mWeltMapOverViewFragment = WeltMapOverViewFragment.newInstance(
this,
mCurrentTaskEndStation,
mWeltDataBeanList,
mSubTaskCoordinates,
@@ -565,7 +561,7 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
}
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

@@ -59,7 +59,6 @@ import java.util.List;
import chassis.ChassisStatesOuterClass;
import io.reactivex.exceptions.UndeliverableException;
import io.reactivex.functions.Consumer;
import io.reactivex.plugins.RxJavaPlugins;
import mogo.telematics.pad.MessagePad;
import mogo_msg.MogoReportMsg;
@@ -110,7 +109,7 @@ public class SweeperTaskModel implements IMoGoSweeperFutianCloudTaskListener, IM
private boolean isHasTaskInfo = false;//判断是否有任务数据
//用于对应messageType和reqNo绑定在一起保证请求的reqNo和响应的reqNo一致
private HashMap<Integer, String> msgTypeAndReqNo = new HashMap<>();
private final HashMap<Integer, String> msgTypeAndReqNo = new HashMap<>();
public static SweeperTaskModel getInstance() {
if (sInstance == null) {
@@ -149,38 +148,35 @@ public class SweeperTaskModel implements IMoGoSweeperFutianCloudTaskListener, IM
//2022.1.28
// 调用Disposable.dispose() 时候会出现InterruptedException 导致出现崩溃
// The exception could not be delivered to the consumer because it has already canceled/disposed
// the flow or the excTeption has nowhere to go to begin with
RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
@Override
public void accept(Throwable e) {
if (e instanceof UndeliverableException) {
e = e.getCause();
CallerLogger.d(M_SWEEPER + TAG, "UndeliverableException");
}
if ((e instanceof IOException)) {//
// fine, irrelevant network problem or API that throws on cancellation
CallerLogger.d(M_SWEEPER + TAG, "IOException");
return;
}
if (e instanceof InterruptedException) {
// fine, some blocking code was interrupted by a dispose call
CallerLogger.d(M_SWEEPER + TAG, "InterruptedException");
return;
}
if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) {
// that's likely a bug in the application
CallerLogger.d(M_SWEEPER + TAG, "NullPointerException or IllegalArgumentException");
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
return;
}
if (e instanceof IllegalStateException) {
// that's a bug in RxJava or in a custom operator
CallerLogger.d(M_SWEEPER + TAG, "IllegalStateException");
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
return;
}
CallerLogger.d(M_SWEEPER + TAG, "Undeliverable exception");
// the flow or the exception has nowhere to go to begin with
RxJavaPlugins.setErrorHandler(e -> {
if (e instanceof UndeliverableException) {
e = e.getCause();
CallerLogger.d(M_SWEEPER + TAG, "UndeliverableException");
}
if ((e instanceof IOException)) {//
// fine, irrelevant network problem or API that throws on cancellation
CallerLogger.d(M_SWEEPER + TAG, "IOException");
return;
}
if (e instanceof InterruptedException) {
// fine, some blocking code was interrupted by a dispose call
CallerLogger.d(M_SWEEPER + TAG, "InterruptedException");
return;
}
if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) {
// that's likely a bug in the application
CallerLogger.d(M_SWEEPER + TAG, "NullPointerException or IllegalArgumentException");
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
return;
}
if (e instanceof IllegalStateException) {
// that's a bug in RxJava or in a custom operator
CallerLogger.d(M_SWEEPER + TAG, "IllegalStateException");
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
return;
}
CallerLogger.d(M_SWEEPER + TAG, "Undeliverable exception");
});
}
@@ -279,11 +275,6 @@ public class SweeperTaskModel implements IMoGoSweeperFutianCloudTaskListener, IM
OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(null);
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
private final IMogoStatusChangedListener mMogoStatusChangedListener = new IMogoStatusChangedListener() {
// VR mode变更回调
@Override
@@ -424,9 +415,6 @@ public class SweeperTaskModel implements IMoGoSweeperFutianCloudTaskListener, IM
@Override
public void onSweeperFutianCleanSystemState(@NonNull ChassisStatesOuterClass.SweeperFuTianTaskSystemStates cleanSystemState) {
if (cleanSystemState == null) {
return;
}
long current = System.currentTimeMillis();
if (current - mVehicleStateCurrentTimeMillis <= VEHICLE_STATE_INTERVAL_MILLIS) {
return;
@@ -506,7 +494,7 @@ public class SweeperTaskModel implements IMoGoSweeperFutianCloudTaskListener, IM
}
private 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();
}
@@ -688,18 +676,18 @@ public class SweeperTaskModel implements IMoGoSweeperFutianCloudTaskListener, IM
if (mControllerStatusCallback != null) {
mControllerStatusCallback.onAutopilotState(state);
}
switch (state) {
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE://不可自动驾驶
break;
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE://人工驾驶
break;
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING://自动驾驶中
break;
case IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING://平行驾驶
break;
default:
break;
}
// switch (state) {
// case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE://不可自动驾驶
// break;
// case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE://人工驾驶
// break;
// case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING://自动驾驶中
// break;
// case IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING://平行驾驶
// break;
// default:
// break;
// }
}
@Override

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

@@ -408,8 +408,8 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
if (isShow) {
mFlWeltMapOverView.setVisibility(View.VISIBLE);
if (mWeltMapOverViewFragment == null) {
mWeltMapOverViewFragment = mWeltMapOverViewFragment.newInstance(
(IWeltMapSwitchToSmallCallback) this,
mWeltMapOverViewFragment = WeltMapOverViewFragment.newInstance(
this,
mCurrentTaskEndStation,
mWeltDataBeanList,
mSubTaskCoordinates,

View File

@@ -360,11 +360,11 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
*/
lifecycleScope.launch(Dispatchers.IO) {
mSubMutableList?.let {
var sum: Double = 0.0
var sum = 0.0
for (index in it.indices) {
sum += it[index].mileage
}
var completed: Double = 0.0
var completed = 0.0
for (index in it.indices) {
if (index < mCurrentSubPosition) {
// 已完成的子任务记入完成度,进行中的不计入

View File

@@ -140,38 +140,35 @@ public class SweeperTaskModel {
//2022.1.28
// 调用Disposable.dispose() 时候会出现InterruptedException 导致出现崩溃
// The exception could not be delivered to the consumer because it has already canceled/disposed
// the flow or the excTeption has nowhere to go to begin with
RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
@Override
public void accept(Throwable e) {
if (e instanceof UndeliverableException) {
e = e.getCause();
CallerLogger.d(M_SWEEPER + TAG, "UndeliverableException");
}
if ((e instanceof IOException)) {//
// fine, irrelevant network problem or API that throws on cancellation
CallerLogger.d(M_SWEEPER + TAG, "IOException");
return;
}
if (e instanceof InterruptedException) {
// fine, some blocking code was interrupted by a dispose call
CallerLogger.d(M_SWEEPER + TAG, "InterruptedException");
return;
}
if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) {
// that's likely a bug in the application
CallerLogger.d(M_SWEEPER + TAG, "NullPointerException or IllegalArgumentException");
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
return;
}
if (e instanceof IllegalStateException) {
// that's a bug in RxJava or in a custom operator
CallerLogger.d(M_SWEEPER + TAG, "IllegalStateException");
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
return;
}
CallerLogger.d(M_SWEEPER + TAG, "Undeliverable exception");
// the flow or the exception has nowhere to go to begin with
RxJavaPlugins.setErrorHandler(e -> {
if (e instanceof UndeliverableException) {
e = e.getCause();
CallerLogger.d(M_SWEEPER + TAG, "UndeliverableException");
}
if ((e instanceof IOException)) {
// fine, irrelevant network problem or API that throws on cancellation
CallerLogger.d(M_SWEEPER + TAG, "IOException");
return;
}
if (e instanceof InterruptedException) {
// fine, some blocking code was interrupted by a dispose call
CallerLogger.d(M_SWEEPER + TAG, "InterruptedException");
return;
}
if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) {
// that's likely a bug in the application
CallerLogger.d(M_SWEEPER + TAG, "NullPointerException or IllegalArgumentException");
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
return;
}
if (e instanceof IllegalStateException) {
// that's a bug in RxJava or in a custom operator
CallerLogger.d(M_SWEEPER + TAG, "IllegalStateException");
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
return;
}
CallerLogger.d(M_SWEEPER + TAG, "Undeliverable exception");
});
}
@@ -191,7 +188,7 @@ public class SweeperTaskModel {
@Override
public void onAutopilotRotting(MessagePad.GlobalPathResp routeList) {
if (null != routeList && routeList.getWayPointsList()!=null&&routeList.getWayPointsList().size() > 0) {
if (null != routeList && routeList.getWayPointsList().size() > 0) {
if (mCurrentSubTaskDetail.getLineId() != mLineId) {//判断是否同一条路线
mLineId = mCurrentSubTaskDetail.getLineId();
points.addAll(coordinateConverterWgsToGcjList(mContext, routeList.getWayPointsList()));
@@ -316,7 +313,6 @@ public class SweeperTaskModel {
}
if (SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE.getCode() == mSubTaskType) {//人工驾驶子任务需要手动跳过,不能自动结束
addCoordinates(gnssInfo);
return;
}
//子任务完成的围栏判断 子任务正在执行中,还未到达子任务终点
//20230504 为了避免自车定位提前结束任务导致的溜车问题,这里删除自车自动触发到站
@@ -365,7 +361,6 @@ public class SweeperTaskModel {
isAutopilotSubTaskArriveEndSite = true;
//到达子任务终点 结束子任务
subTaskEnd(mIsFirstSubtask, mIsLastSubtask, mSubTaskId); //无自动驾驶到终点信息传null
return;
}
}
@@ -393,10 +388,6 @@ public class SweeperTaskModel {
firstStartAutopilot++;
triggerStartServiceEvent(isRestart, false);
AutopilotControlParameters parameters = initAutopilotControlParameters();
if (null == parameters) {
CallerLogger.e(M_SWEEPER + TAG, "行程日志-AutopilotControlParameters is empty.");
return;
}
CallerAutoPilotControlManager.INSTANCE.startAutoPilot(parameters);
CallerLogger.d(M_SWEEPER + TAG, "行程日志-开启自动驾驶====" + GsonUtil.jsonFromObject(parameters)
+ " startLatLon=" + parameters.startName + "endLatLon=" + parameters.endName +
@@ -496,10 +487,6 @@ public class SweeperTaskModel {
private void updateAutopilotControlParameters() {
AutopilotControlParameters parameters = initAutopilotControlParameters();
if (null == parameters) {
CallerLogger.e(M_SWEEPER + TAG, "AutopilotControlParameters is empty.");
return;
}
CallerLogger.d(M_SWEEPER + TAG, "AutopilotControlParameters" + GsonUtil.jsonFromObject(parameters));
CallerLogger.d(M_SWEEPER + TAG, "AutopilotControlParameters is update.");
CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(parameters);

View File

@@ -11,7 +11,7 @@ sonarqube {
property "sonar.android.lint.report", false
property "sonar.scm.exclusions.disabled", false
property "sonar.scm.exclusions.file", "**/.gitignore"
property "sonar.exclusions", "**/AndroidManifest.xml, **/src/test/**, **/*.jar, **/*.aar, **/*.war, **/*.ear, **/*.rar, **/*.tgz, **/*.zip, **/src/test/java/**/*.java, **/src/test/java/**/*.kt, **/test/**/*, **/*Test.java, **/*Tests.java, **/*Test.kt, **/*.xml,*.xml, **/target/**, **/src/main/java/proto/**, **/build/**, build, build/**, **/db/dao/*.java, **/build/intermediates/**/*"
property "sonar.exclusions", "**/AndroidManifest.xml, **/src/test/**, mogo/core/utils/**, **/*.jar, **/*.aar, **/*.war, **/*.ear, **/*.rar, **/*.tgz, **/*.zip, **/src/test/java/**/*.java, **/src/test/java/**/*.kt, **/test/**/*, **/*Test.java, **/*Tests.java, **/*Test.kt, **/*.xml,*.xml, **/target/**, **/src/main/java/proto/**, **/build/**, build, build/**, **/db/dao/*.java, **/build/intermediates/**/*"
// property "sonar.java.coveragePlugin", "jacoco"
// property("sonar.coverage.jacoco.xmlReportPaths", "../../build/reports/jacocoTestReport.xml,../build/reports/jacocoTestReport.xml")
}

View File

@@ -96,21 +96,6 @@
</activity>
<!-- <activity-->
<!-- android:name="com.mogo.eagle.core.function.main.VideoAdAtc"-->
<!-- android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize"-->
<!-- android:enabled="true"-->
<!-- android:exported="true"-->
<!-- android:process=":video_ad"-->
<!-- android:resizeableActivity="false"-->
<!-- android:resumeWhilePausing="true"-->
<!-- android:screenOrientation="landscape"-->
<!-- android:stateNotNeeded="true"-->
<!-- android:theme="@style/Main"-->
<!-- android:windowSoftInputMode="adjustPan|stateHidden">-->
<!-- </activity>-->
<activity
android:name="com.mogo.eagle.core.function.main.AppListActivity"
android:exported="true"

View File

@@ -25,7 +25,7 @@ public class LogLine {
"\\): ");
private static final String filterPattern = "ResourceType|memtrack|android.os.Debug|BufferItemConsumer|DPM.*|MDM.*|ChimeraUtils|BatteryExternalStats.*|chatty.*|DisplayPowerController|WidgetHelper|WearableService|DigitalWidget.*|^ANDR-PERF-.*";
private static final String failPattern = "^maxLineHeight.*|Failed to read.*";
private static final String failPattern = "(^maxLineHeight.*)|(Failed to read.*)";
private int logLevel;
private String tag;
private String logOutput;

View File

@@ -1,29 +0,0 @@
package com.mogo.eagle.core.function.main
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.util.BarUtils
import com.mogo.eagle.core.widget.TextureVideoView
/**
* 视频广告 TODO 测试用的,可删除
*/
class VideoAdAtc : AppCompatActivity() {
// private lateinit var svpFrame: TextureVideoView
//
// override fun onCreate(savedInstanceState: Bundle?) {
// super.onCreate(savedInstanceState)
// setContentView(R.layout.activity_video_ad_atc)
//
// svpFrame = findViewById(R.id.svp_frame)
//
// val url = "android.resource://" + packageName + "/" + R.raw.mogo_ad
// svpFrame.videoPath = url
// svpFrame.start()
//
// BarUtils.hideStatusBarAndSticky(this.window)
// }
}

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/road_video_bg"
tools:context="com.mogo.eagle.core.function.main.VideoAdAtc">
<com.mogo.eagle.core.widget.TextureVideoView
android:id="@+id/svp_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,18 +0,0 @@
package com.mogo.eagle.core.network;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
/**
* @author congtaowang
* @since 2019-08-30
* <p>
* 信任所有域名
*/
public class AllAllowedHostnameVerifier implements HostnameVerifier {
@Override
public boolean verify( String hostname, SSLSession session ) {
return true;
}
}

View File

@@ -3,8 +3,6 @@ package com.mogo.eagle.core.network;
import android.app.Application;
import android.content.Context;
import com.mogo.cloud.passport.SpStorage;
import androidx.collection.ArraySet;
import java.security.SecureRandom;
@@ -13,7 +11,6 @@ import java.util.Set;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import okhttp3.Interceptor;
@@ -34,15 +31,10 @@ public final class NetConfig {
private final Set< Interceptor > interceptors = new ArraySet<>();
private final Set< Interceptor > networkInterceptors = new ArraySet<>();
private final HostnameVerifier allowAllHostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify( String hostname, SSLSession session ) {
return true;
}
};
private final HostnameVerifier allowAllHostnameVerifier = (hostname, session) -> true;
private String signaturePrefix = "com.foundation.network";
private HostnameVerifier hostnameVerifier = OkHostnameVerifier.INSTANCE;
private final HostnameVerifier hostnameVerifier = OkHostnameVerifier.INSTANCE;
private Map< String, Object > publicParams;
private boolean isLoggable;
private Context appContext;

View File

@@ -1,5 +1,7 @@
package com.mogo.eagle.core.network;
import android.annotation.SuppressLint;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
@@ -13,11 +15,13 @@ import javax.net.ssl.X509TrustManager;
*/
public class X509TrustManagerImpl implements X509TrustManager {
@SuppressLint("TrustAllX509TrustManager")
@Override
public void checkClientTrusted( X509Certificate[] chain, String authType ) throws CertificateException {
}
@SuppressLint("TrustAllX509TrustManager")
@Override
public void checkServerTrusted( X509Certificate[] chain, String authType ) throws CertificateException {

View File

@@ -43,7 +43,6 @@ import java.util.Map;
* provides various display options such as scaling and tinting.
*/
public class TextureVideoView extends TextureView implements MediaPlayerControl {
private String TAG = "TextureVideoView";
public static final int STATE_ERROR = -1;
public static final int STATE_IDLE = 0;

View File

@@ -38,9 +38,9 @@ public class GlideCircleBitmapTransform extends BitmapTransformation {
int radius = newSize / 2;
Bitmap bitmap = Bitmap.createBitmap( toTransform, x, y, newSize, newSize );
Bitmap result = pool.get( newSize, newSize, toTransform.getConfig() );
if ( result == null ) {
result = Bitmap.createBitmap( newSize, newSize, toTransform.getConfig() );
}
// if ( result == null ) { //get() func always return not null
// result = Bitmap.createBitmap( newSize, newSize, toTransform.getConfig() );
// }
Canvas canvas = new Canvas( result );
if ( mBorderWidth > 0 ) {

View File

@@ -18,11 +18,11 @@ import java.security.MessageDigest;
public class GlideRoundBitmapTransform extends BitmapTransformation {
private int mRadius;
private int mBorderWidth;
private int mBorderColor;
private String mKey;
private Context mContext;
private final int mRadius;
private final int mBorderWidth;
private final int mBorderColor;
private final String mKey;
private final Context mContext;
public GlideRoundBitmapTransform( Context context, String key, int radius, int borderWidth, int borderColor ) {
this.mContext = context;
@@ -41,9 +41,9 @@ public class GlideRoundBitmapTransform extends BitmapTransformation {
int height = toTransform.getHeight();
RectF rectF = new RectF( mBorderWidth, mBorderWidth, width - mBorderWidth, height - mBorderWidth );
Bitmap result = pool.get( width, height, toTransform.getConfig() );
if ( result == null ) {
result = toTransform.copy( toTransform.getConfig(), true );
}
// if ( result == null ) { //get() func always return not null
// result = toTransform.copy( toTransform.getConfig(), true );
// }
Canvas canvas = new Canvas( result );
Paint paint = new Paint();
paint.setShader( new BitmapShader( toTransform, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP ) );

View File

@@ -22,8 +22,8 @@ import androidx.annotation.NonNull;
* @author tongchenfei
*/
public class GlideRoundedCornersTransform extends CenterCrop {
private float mRadius;
private CornerType mCornerType;
private final float mRadius;
private final CornerType mCornerType;
private static final int VERSION = 1;
private static final String ID = BuildConfig.LIBRARY_PACKAGE_NAME + "GlideRoundedCornersTransform." + VERSION;
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
@@ -62,10 +62,10 @@ public class GlideRoundedCornersTransform extends CenterCrop {
int height = source.getHeight();
Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
if (result == null) {
result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config
.ARGB_8888);
}
// if (result == null) { //get() func always return not null
// result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config
// .ARGB_8888);
// }
Canvas canvas = new Canvas(result);
Paint paint = new Paint();
paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader
@@ -102,6 +102,7 @@ public class GlideRoundedCornersTransform extends CenterCrop {
drawPath(rids, canvas, paint, path, width, height);
break;
case TOP:
case TOP_LEFT_TOP_RIGHT:
rids = new float[]{mRadius, mRadius, mRadius, mRadius, 0.0f, 0.0f, 0.0f, 0.0f};
drawPath(rids, canvas, paint, path, width, height);
break;
@@ -133,10 +134,6 @@ public class GlideRoundedCornersTransform extends CenterCrop {
rids = new float[]{0.0f, 0.0f, mRadius, mRadius, mRadius, mRadius, mRadius, mRadius};
drawPath(rids, canvas, paint, path, width, height);
break;
case TOP_LEFT_TOP_RIGHT:
rids = new float[]{mRadius, mRadius, mRadius, mRadius, 0.0f, 0.0f, 0.0f, 0.0f};
drawPath(rids, canvas, paint, path, width, height);
break;
default:
throw new RuntimeException("RoundedCorners type not belong to CornerType");
}

View File

@@ -107,7 +107,7 @@ final class LoggerPrinter implements Printer {
}
}
private static final String xmlHtml = "http://xml.apache.org/xslt";
private static final String xmlHtml = "{http://xml.apache.org/xslt}indent-amount";
public void xml( String tag, String xml) {
if ( TextUtils.isEmpty(xml)) {
@@ -118,7 +118,7 @@ final class LoggerPrinter implements Printer {
StreamResult xmlOutput = new StreamResult(new StringWriter());
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty("indent", "yes");
transformer.setOutputProperty("{" + xmlHtml + "}indent-amount", "2");
transformer.setOutputProperty(xmlHtml, "2");
transformer.transform(e, xmlOutput);
this.d(tag, xmlOutput.getWriter().toString().replaceFirst(">", ">\n"));
} catch ( TransformerException var5) {

View File

@@ -61,9 +61,7 @@ public final class CollectionUtils {
public static <E> ArrayList<E> newArrayList(E... array) {
ArrayList<E> list = new ArrayList<>();
if (array == null || array.length == 0) return list;
for (E e : array) {
list.add(e);
}
list.addAll(Arrays.asList(array));
return list;
}
@@ -82,9 +80,7 @@ public final class CollectionUtils {
public static <E> LinkedList<E> newLinkedList(E... array) {
LinkedList<E> list = new LinkedList<>();
if (array == null || array.length == 0) return list;
for (E e : array) {
list.add(e);
}
list.addAll(Arrays.asList(array));
return list;
}
@@ -103,9 +99,7 @@ public final class CollectionUtils {
public static <E> HashSet<E> newHashSet(E... array) {
HashSet<E> set = new HashSet<>();
if (array == null || array.length == 0) return set;
for (E e : array) {
set.add(e);
}
set.addAll(Arrays.asList(array));
return set;
}
@@ -124,9 +118,7 @@ public final class CollectionUtils {
public static <E> TreeSet<E> newTreeSet(Comparator<E> comparator, E... array) {
TreeSet<E> set = new TreeSet<>(comparator);
if (array == null || array.length == 0) return set;
for (E e : array) {
set.add(e);
}
set.addAll(Arrays.asList(array));
return set;
}

View File

@@ -578,7 +578,12 @@ public final class ConvertUtils {
*/
public static byte[] inputStream2Bytes(final InputStream is) {
if (is == null) return null;
return input2OutputStream(is).toByteArray();
ByteArrayOutputStream byteArrayOutputStream = input2OutputStream(is);
if(byteArrayOutputStream != null){
return byteArrayOutputStream.toByteArray();
}else{
return null;
}
}
/**

View File

@@ -3,6 +3,7 @@ package com.mogo.eagle.core.utilcode.util;
import org.jetbrains.annotations.NotNull;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* @author donghongyu
@@ -10,10 +11,6 @@ import java.math.BigDecimal;
public class CoordinateUtils {
/**
* @param lon1
* @param lat1
* @param lon2
* @param lat2
* @return 两坐标的距离 单位M
*/
public static float calculateLineDistance( double lon1, double lat1, double lon2, double lat2 ) {
@@ -56,11 +53,11 @@ public class CoordinateUtils {
private static final double a = 6378245.0D;
private static final double ee = 0.006693421622965943D;
public static final boolean outOfChina( double lat, double lng ) {
public static boolean outOfChina(double lat, double lng ) {
return lng <= 73.66D || lng >= 135.05D || lat <= 3.86D || lat >= 53.55D;
}
private static final double transformLat( double lng, double lat ) {
private static double transformLat(double lng, double lat ) {
double ret = -100.0D + 2.0D * lng + 3.0D * lat + 0.2D * lat * lat + 0.1D * lng * lat + 0.2D * Math.sqrt( Math.abs( lng ) );
ret += ( 20.0D * Math.sin( 6.0D * lng * 3.141592653589793D ) + 20.0D * Math.sin( 2.0D * lng * 3.141592653589793D ) ) * 2.0D / 3.0D;
ret += ( 20.0D * Math.sin( lat * 3.141592653589793D ) + 40.0D * Math.sin( lat / 3.0D * 3.141592653589793D ) ) * 2.0D / 3.0D;
@@ -68,7 +65,7 @@ public class CoordinateUtils {
return ret;
}
private static final double transformLon( double lng, double lat ) {
private static double transformLon(double lng, double lat ) {
double ret = 300.0D + lng + 2.0D * lat + 0.1D * lng * lng + 0.1D * lng * lat + 0.1D * Math.sqrt( Math.abs( lng ) );
ret += ( 20.0D * Math.sin( 6.0D * lng * 3.141592653589793D ) + 20.0D * Math.sin( 2.0D * lng * 3.141592653589793D ) ) * 2.0D / 3.0D;
ret += ( 20.0D * Math.sin( lng * 3.141592653589793D ) + 40.0D * Math.sin( lng / 3.0D * 3.141592653589793D ) ) * 2.0D / 3.0D;
@@ -78,12 +75,11 @@ public class CoordinateUtils {
@NotNull
// World Geodetic System ==> Mars Geodetic System
public static final double[] transformWgsToGcj( double wgLat, double wgLon ) {
public static double[] transformWgsToGcj(double wgLat, double wgLon ) {
double[] point = new double[2];
if ( outOfChina( wgLat, wgLon ) ) {
point[0] = wgLon;
point[1] = wgLat;
return point;
} else {
double dLat = transformLat( wgLon - 105.0D, wgLat - 35.0D );
double dLon = transformLon( wgLon - 105.0D, wgLat - 35.0D );
@@ -97,12 +93,12 @@ public class CoordinateUtils {
double mgLon = wgLon + dLon;
point[0] = dealRound( mgLon );
point[1] = dealRound( mgLat );
return point;
}
return point;
}
@NotNull
public static final double[] transformGcj02toWgs84( double lat, double lng ) {
public static double[] transformGcj02toWgs84(double lat, double lng ) {
double[] var10000;
if ( outOfChina( lat, lng ) ) {
var10000 = new double[]{lng, lat};
@@ -123,10 +119,9 @@ public class CoordinateUtils {
return var10000;
}
private static final double dealRound( double value ) {
BigDecimal bg = new BigDecimal( value );
double result = bg.setScale( 6, 4 ).doubleValue();
return result;
private static double dealRound(double value ) {
BigDecimal bg = BigDecimal.valueOf( value );
return bg.setScale( 6, RoundingMode.HALF_UP).doubleValue();
}
}

View File

@@ -45,6 +45,9 @@ public class DateTimeUtils {
public static Calendar cleanCalendarTime( Calendar c) {
if(c == null){
return null;
}
c.set( Calendar.HOUR_OF_DAY, 0);
c.set( Calendar.MINUTE, 0);
c.set( Calendar.SECOND, 0);
@@ -54,10 +57,6 @@ public class DateTimeUtils {
/**
* 获得指定日期表示格式转换成Calendar的格式
*
* @param src
* @param fallback 若无法转换,返回一个默认值
* @return
*/
public static <T> Calendar getCalendar( T src, Calendar fallback) {
if (src != null) {
@@ -101,7 +100,7 @@ public class DateTimeUtils {
return getCalendarByPatterns(nSrc, PATTERNS);
} catch ( Exception e) {
try {
calendar.setTimeInMillis( Long.valueOf(nSrc));
calendar.setTimeInMillis( Long.parseLong(nSrc));
} catch ( NumberFormatException e1) {
throw new IllegalArgumentException(e1);
}
@@ -134,11 +133,6 @@ public class DateTimeUtils {
/**
* 匹配pattern获得时间若无法解析抛出异常
*
* @param dateTimeStr
* @param patternStr
* @return
* @throws IllegalArgumentException
*/
public static Calendar getCalendarByPattern( String dateTimeStr, String patternStr) {
try {
@@ -156,11 +150,6 @@ public class DateTimeUtils {
/**
* 匹配pattern数组中的所有pattern解析时间格式若没有可以解析的方式则抛出异常
*
* @param dateTimeStr
* @param patternStr
* @return
* @throws IllegalArgumentException
*/
public static Calendar getCalendarByPatterns( String dateTimeStr, String[] patternStr) {
for ( String string : patternStr) {
@@ -208,8 +197,6 @@ public class DateTimeUtils {
/**
* login时server的日期
*
* @return
*/
public static Calendar getLoginServerDate() {
return getCalendar(tss);
@@ -229,12 +216,8 @@ public class DateTimeUtils {
/**
* 获得时间间隔
*
* @param from
* @param to
* @param unit 时间间隔单位{@link DateTimeUtils#ONE_SECOND},{@link DateTimeUtils#ONE_MINUTE},
* {@link DateTimeUtils#ONE_HOUR}, {@link DateTimeUtils#ONE_DAY}
* @return
*/
public static long getIntervalTimes( Calendar from, Calendar to, long unit) {
if (from == null || to == null) {
@@ -245,12 +228,7 @@ public class DateTimeUtils {
/**
* 获得日期间隔 忽略小时
*
* @param startdate
* @param enddate
* @return
*/
public static int getIntervalDays( String startdate, String enddate, String pattern) {
int betweenDays = 0;
if (startdate == null || enddate == null) {
@@ -264,15 +242,15 @@ public class DateTimeUtils {
}
public static <T> int getIntervalDays(T from, T to) {
Calendar startdate = getCalendar(from);
Calendar enddate = getCalendar(to);
cleanCalendarTime(startdate);
cleanCalendarTime(enddate);
return (int) getIntervalTimes(startdate, enddate, ONE_DAY);
Calendar startDate = getCalendar(from);
Calendar endDate = getCalendar(to);
cleanCalendarTime(startDate);
cleanCalendarTime(endDate);
return (int) getIntervalTimes(startDate, endDate, ONE_DAY);
}
private static String[] weekdays = {"", "周日", "周一", "周二", "周三", "周四", "周五", "周六",};
private static String[] weekdays1 = {"", "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六",};
private static final String[] weekdays = {"", "周日", "周一", "周二", "周三", "周四", "周五", "周六",};
private static final String[] weekdays1 = {"", "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六",};
/**
* calendar --> 周一~周日
@@ -310,12 +288,12 @@ public class DateTimeUtils {
}
// 是否到刷新时间
public static boolean isRefersh(long beforeTime) {
return isRefersh(DATETIME_FIELD_REFERSH * 1000 * 60, beforeTime);
public static boolean isRefresh(long beforeTime) {
return isRefresh(DATETIME_FIELD_REFERSH * 1_000L * 60, beforeTime);
}
// 是否到刷新时间
public static boolean isRefersh(long gap, long beforeTime) {
public static boolean isRefresh(long gap, long beforeTime) {
return new Date().getTime() - beforeTime >= gap;
}
@@ -344,13 +322,7 @@ public class DateTimeUtils {
} else if (c1.get( Calendar.MONTH) < c2.get( Calendar.MONTH)) {
return -1;
} else {
if (c1.get( Calendar.DAY_OF_MONTH) > c2.get( Calendar.DAY_OF_MONTH)) {
return 1;
} else if (c1.get( Calendar.DAY_OF_MONTH) < c2.get( Calendar.DAY_OF_MONTH)) {
return -1;
} else {
return 0;
}
return Integer.compare(c1.get(Calendar.DAY_OF_MONTH), c2.get(Calendar.DAY_OF_MONTH));
}
}
}
@@ -359,14 +331,14 @@ public class DateTimeUtils {
if ( TextUtils.isEmpty(HH_mm) || null == src) {
return;
}
String s[] = HH_mm.split(":");
String[] s = HH_mm.split(":");
if (s.length != 2) {
return;
}
try {
cleanCalendarTime(src);
src.set( Calendar.HOUR_OF_DAY, Integer.valueOf(s[0]));
src.set( Calendar.MINUTE, Integer.valueOf(s[1]));
src.set( Calendar.HOUR_OF_DAY, Integer.parseInt(s[0]));
src.set( Calendar.MINUTE, Integer.parseInt(s[1]));
} catch ( NumberFormatException e) {
}
@@ -394,8 +366,7 @@ public class DateTimeUtils {
Calendar a = Calendar.getInstance();
a.set( Calendar.DATE, 1);
a.roll( Calendar.DATE, -1);
int maxDate = a.get( Calendar.DATE);
return maxDate;
return a.get( Calendar.DATE);
}
public static String convertToChineseWeekNumber( int number) {
@@ -444,22 +415,18 @@ public class DateTimeUtils {
/**
* 获取 06月07 格式的日期
* @param timestamp 时间戳
* @return
*/
public static String getTimeText( long timestamp, String dateFormat) {
SimpleDateFormat format = new SimpleDateFormat(dateFormat, Locale.US);
String strStart = format.format(new Date(timestamp));
return strStart;
return format.format(new Date(timestamp));
}
/**
* 获取 06月07 格式的日期
* @return
*/
public static String getTimeText(String dateFormat) {
SimpleDateFormat format = new SimpleDateFormat(dateFormat, Locale.US);
String strStart = format.format(new Date());
return strStart;
return format.format(new Date());
}
}

View File

@@ -24,7 +24,6 @@ import android.telephony.gsm.GsmCellLocation;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.RequiresApi;
import androidx.annotation.RequiresPermission;
import java.io.BufferedReader;
@@ -75,7 +74,6 @@ public final class DeviceUtils {
*
* @return {@code true}: yes<br>{@code false}: no
*/
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public static boolean isAdbEnabled() {
return Settings.Secure.getInt(
Utils.getApp().getContentResolver(),
@@ -277,7 +275,7 @@ public final class DeviceUtils {
InetAddress inetAddress = addresses.nextElement();
if (!inetAddress.isLoopbackAddress()) {
String hostAddress = inetAddress.getHostAddress();
if (hostAddress.indexOf(':') < 0) return inetAddress;
if (hostAddress != null && hostAddress.indexOf(':') < 0) return inetAddress;
}
}
}
@@ -345,14 +343,7 @@ public final class DeviceUtils {
* @return an ordered list of ABIs supported by this device
*/
public static String[] getABIs() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return Build.SUPPORTED_ABIS;
} else {
if (!TextUtils.isEmpty(Build.CPU_ABI2)) {
return new String[]{Build.CPU_ABI, Build.CPU_ABI2};
}
return new String[]{Build.CPU_ABI};
}
return Build.SUPPORTED_ABIS;
}
/**
@@ -391,20 +382,17 @@ public final class DeviceUtils {
operatorName = name;
}
}
boolean checkOperatorName = operatorName.toLowerCase().equals("android");
boolean checkOperatorName = operatorName.equalsIgnoreCase("android");
if (checkOperatorName) return true;
String url = "tel:" + "123456";
Intent intent = new Intent();
intent.setData(Uri.parse(url));
intent.setAction(Intent.ACTION_DIAL);
boolean checkDial = intent.resolveActivity(Utils.getApp().getPackageManager()) == null;
if (checkDial) return true;
return intent.resolveActivity(Utils.getApp().getPackageManager()) == null;
// boolean checkDebuggerConnected = Debug.isDebuggerConnected();
// if (checkDebuggerConnected) return true;
return false;
}
/**
@@ -412,7 +400,6 @@ public final class DeviceUtils {
*
* @return whether user has enabled development settings.
*/
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public static boolean isDevelopmentSettingsEnabled() {
return Settings.Global.getInt(
Utils.getApp().getContentResolver(),
@@ -497,8 +484,8 @@ public final class DeviceUtils {
if (!TextUtils.isEmpty(androidId)) {
return saveUdid(prefix + 2, androidId);
}
} catch (Exception ignore) {
ignore.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return saveUdid(prefix + 9, "");
}
@@ -565,8 +552,8 @@ public final class DeviceUtils {
// Gsm网络 , 联通移动的网络属于这一套
if (location instanceof GsmCellLocation) {
GsmCellLocation gsmLoc = (GsmCellLocation) location;
int cellid = gsmLoc.getCid();
return String.valueOf(cellid);
int cellId = gsmLoc.getCid();
return String.valueOf(cellId);
// Cdma网络 , 电信网络属于这一种
} else if (location instanceof CdmaCellLocation) {
CdmaCellLocation cdmaLoc = (CdmaCellLocation) location;
@@ -584,18 +571,13 @@ public final class DeviceUtils {
public static boolean isLocationEnabled() {
int locationMode = 0;
String locationProviders;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
try {
locationMode = Settings.Secure.getInt(Utils.getApp().getApplicationContext().getContentResolver(), Settings.Secure.LOCATION_MODE);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
return false;
}
return locationMode != Settings.Secure.LOCATION_MODE_OFF;
} else {
locationProviders = Settings.Secure.getString(Utils.getApp().getApplicationContext().getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
return !TextUtils.isEmpty(locationProviders);
try {
locationMode = Settings.Secure.getInt(Utils.getApp().getApplicationContext().getContentResolver(), Settings.Secure.LOCATION_MODE);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
return false;
}
return locationMode != Settings.Secure.LOCATION_MODE_OFF;
}
@@ -678,8 +660,8 @@ public final class DeviceUtils {
}
private static String getSerialnoNumbers() {
final String serialnoStr = "[ro.boot.serialno]";
private static String getSerialNoNumbers() {
final String serialNoStr = "[ro.boot.serialno]";
try {
Process p = Runtime.getRuntime().exec("getprop");
p.waitFor();
@@ -687,20 +669,20 @@ public final class DeviceUtils {
p.getInputStream()));
String temp = "";
while ((temp = stdInput.readLine()) != null) {
Log.i("getSerialnoNumbers", temp);
if (temp.contains(serialnoStr)) {
temp.replaceAll(" ", "");
int index = temp.indexOf(serialnoStr);
Log.i("getSerialNoNumbers", temp);
if (temp.contains(serialNoStr)) {
temp = temp.replaceAll(" ", "");
int index = temp.indexOf(serialNoStr);
temp = temp.substring(index + 20);
temp = temp.substring(1, temp.length() - 1);
Log.d("getSerialnoNumbers", temp);
Log.d("getSerialNoNumbers", temp);
return temp;
}
}
} catch (IOException | InterruptedException e) {
} catch (InterruptedException | IOException e) {
e.printStackTrace();
}
return serialnoStr;
return serialNoStr;
}
public static final String KEY_DEVICE_ID = "deviceId";

View File

@@ -104,7 +104,7 @@ public class MatcherUtils {
* @return
*/
public static boolean isMatches( String regex, String input) {
return input == null ? false : Pattern.compile(regex).matcher(input).find();
return input != null && Pattern.compile(regex).matcher(input).find();
}
/**
@@ -115,7 +115,7 @@ public class MatcherUtils {
* @return
*/
public static boolean isMatchesIgnoreCase( String regex, String input) {
return input == null ? false : Pattern.compile(regex, Pattern.CASE_INSENSITIVE).matcher(input).find();
return input != null && Pattern.compile(regex, Pattern.CASE_INSENSITIVE).matcher(input).find();
}
/**
@@ -274,15 +274,13 @@ public class MatcherUtils {
*/
public static boolean isCJK(char c) {
Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS // CJK统一汉字 \\u4E00-\\u9fAF
// 半形及全形字符 \\uFF00-\\uFFEF
return ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS // CJK统一汉字 \\u4E00-\\u9fAF
|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A // CJK统一汉字扩展-A \\u3400-\\u4dBF
|| ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS // CJK兼容汉字 \\uF900-\\uFAFF
|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION // CJK符号和标点 \\u3000-\\u303F
|| ub == Character.UnicodeBlock.GENERAL_PUNCTUATION // 广义标点 \\u2000-\\u206F
|| ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) { // 半形及全形字符 \\uFF00-\\uFFEF
return true;
}
return false;
|| ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS;
}
/**
@@ -358,6 +356,9 @@ public class MatcherUtils {
* @return
*/
public static boolean isFetionPassword( String input) {
if(input == null){
return false;
}
// 密码必须含有字母和数字符号可选但是必须符合Punct标准,否则返回false
// 首先判断是否含有无效字符含有则返回false
if (isIncludeInvalidChar(input)) {
@@ -374,11 +375,7 @@ public class MatcherUtils {
if (isMatches("[0-9]{1,15}", input)) {
tmpValue++;
}
if (tmpValue >= 2) {
return true;
} else {
return false;
}
return tmpValue >= 2;
}
/**
@@ -390,9 +387,6 @@ public class MatcherUtils {
public static boolean isNumeric( String str) {
Pattern pattern = Pattern.compile("[0-9]+");
Matcher isNum = pattern.matcher(str);
if (!isNum.matches()) {
return false;
}
return true;
return isNum.matches();
}
}

View File

@@ -20,6 +20,11 @@ public final class NumberUtils {
protected DecimalFormat initialValue() {
return (DecimalFormat) NumberFormat.getInstance();
}
@Override
public void remove() {
super.remove();
}
};
public static DecimalFormat getSafeDecimalFormat() {

View File

@@ -120,7 +120,7 @@ public final class PhoneUtils {
} else {
return getMinOne(tm.getMeid(0), tm.getMeid(1));
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
} else {
String ids = getSystemPropertyByReflect(isImei ? "ril.gsm.imei" : "ril.cdma.meid");
if (!TextUtils.isEmpty(ids)) {
String[] idArr = ids.split(",");
@@ -138,11 +138,7 @@ public final class PhoneUtils {
id1 = (String) method.invoke(tm,
isImei ? TelephonyManager.PHONE_TYPE_GSM
: TelephonyManager.PHONE_TYPE_CDMA);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
if (isImei) {
@@ -161,19 +157,7 @@ public final class PhoneUtils {
}
}
return getMinOne(id0, id1);
} else {
String deviceId = tm.getDeviceId();
if (isImei) {
if (deviceId != null && deviceId.length() >= 15) {
return deviceId;
}
} else {
if (deviceId != null && deviceId.length() == 14) {
return deviceId;
}
}
}
return "";
}
private static String getMinOne(String s0, String s1) {

View File

@@ -158,23 +158,20 @@ public final class ReflectUtils {
}
private void sortConstructors(List<Constructor<?>> list) {
Collections.sort(list, new Comparator<Constructor<?>>() {
@Override
public int compare(Constructor<?> o1, Constructor<?> o2) {
Class<?>[] types1 = o1.getParameterTypes();
Class<?>[] types2 = o2.getParameterTypes();
int len = types1.length;
for (int i = 0; i < len; i++) {
if (!types1[i].equals(types2[i])) {
if (wrapper(types1[i]).isAssignableFrom(wrapper(types2[i]))) {
return 1;
} else {
return -1;
}
Collections.sort(list, (o1, o2) -> {
Class<?>[] types1 = o1.getParameterTypes();
Class<?>[] types2 = o2.getParameterTypes();
int len = types1.length;
for (int i = 0; i < len; i++) {
if (!types1[i].equals(types2[i])) {
if (wrapper(types1[i]).isAssignableFrom(wrapper(types2[i]))) {
return 1;
} else {
return -1;
}
}
return 0;
}
return 0;
});
}
@@ -363,23 +360,20 @@ public final class ReflectUtils {
}
private void sortMethods(final List<Method> methods) {
Collections.sort(methods, new Comparator<Method>() {
@Override
public int compare(Method o1, Method o2) {
Class<?>[] types1 = o1.getParameterTypes();
Class<?>[] types2 = o2.getParameterTypes();
int len = types1.length;
for (int i = 0; i < len; i++) {
if (!types1[i].equals(types2[i])) {
if (wrapper(types1[i]).isAssignableFrom(wrapper(types2[i]))) {
return 1;
} else {
return -1;
}
Collections.sort(methods, (o1, o2) -> {
Class<?>[] types1 = o1.getParameterTypes();
Class<?>[] types2 = o2.getParameterTypes();
int len = types1.length;
for (int i = 0; i < len; i++) {
if (!types1[i].equals(types2[i])) {
if (wrapper(types1[i]).isAssignableFrom(wrapper(types2[i]))) {
return 1;
} else {
return -1;
}
}
return 0;
}
return 0;
});
}
@@ -432,29 +426,25 @@ public final class ReflectUtils {
@SuppressWarnings("unchecked")
public <P> P proxy(final Class<P> proxyType) {
final boolean isMap = (object instanceof Map);
final InvocationHandler handler = new InvocationHandler() {
@Override
@SuppressWarnings("null")
public Object invoke(Object proxy, Method method, Object[] args) {
String name = method.getName();
try {
return reflect(object).method(name, args).get();
} catch (ReflectException e) {
if (isMap) {
Map<String, Object> map = (Map<String, Object>) object;
int length = (args == null ? 0 : args.length);
final InvocationHandler handler = (proxy, method, args) -> {
String name = method.getName();
try {
return reflect(object).method(name, args).get();
} catch (ReflectException e) {
if (isMap) {
Map<String, Object> map = (Map<String, Object>) object;
int length = (args == null ? 0 : args.length);
if (length == 0 && name.startsWith("get")) {
return map.get(property(name.substring(3)));
} else if (length == 0 && name.startsWith("is")) {
return map.get(property(name.substring(2)));
} else if (length == 1 && name.startsWith("set")) {
map.put(property(name.substring(3)), args[0]);
return null;
}
if (length == 0 && name.startsWith("get")) {
return map.get(property(name.substring(3)));
} else if (length == 0 && name.startsWith("is")) {
return map.get(property(name.substring(2)));
} else if (length == 1 && name.startsWith("set")) {
map.put(property(name.substring(3)), args[0]);
return null;
}
throw e;
}
throw e;
}
};
return (P) Proxy.newProxyInstance(proxyType.getClassLoader(),

View File

@@ -139,7 +139,7 @@ public final class SpanUtils {
private int spaceSize;
private int spaceColor;
private SerializableSpannableStringBuilder mBuilder;
private final SerializableSpannableStringBuilder mBuilder;
private boolean isCreated;
private int mType;
@@ -1189,7 +1189,7 @@ public final class SpanUtils {
final boolean first, final Layout l) {
if (((Spanned) text).getSpanStart(this) == start) {
Paint.Style style = p.getStyle();
int oldColor = 0;
int oldColor;
oldColor = p.getColor();
p.setColor(color);
p.setStyle(Paint.Style.FILL);
@@ -1249,9 +1249,6 @@ public final class SpanUtils {
if ((fake & Typeface.ITALIC) != 0) {
paint.setTextSkewX(-0.25f);
}
paint.getShader();
paint.setTypeface(tf);
}
}
@@ -1311,9 +1308,11 @@ public final class SpanUtils {
} else {
try {
drawable = ContextCompat.getDrawable(Utils.getApp(), mResourceId);
drawable.setBounds(
0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()
);
if(drawable != null){
drawable.setBounds(
0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()
);
}
} catch (Exception e) {
Log.e("sms", "Unable to find resource: " + mResourceId);
}
@@ -1358,14 +1357,12 @@ public final class SpanUtils {
int lineHeight = fm.bottom - fm.top;
if (lineHeight < rect.height()) {
if (mVerticalAlignment == ALIGN_TOP) {
fm.top = fm.top;
fm.bottom = rect.height() + fm.top;
} else if (mVerticalAlignment == ALIGN_CENTER) {
fm.top = -rect.height() / 2 - lineHeight / 4;
fm.bottom = rect.height() / 2 - lineHeight / 4;
} else {
fm.top = -rect.height() + fm.bottom;
fm.bottom = fm.bottom;
}
fm.ascent = fm.top;
fm.descent = fm.bottom;
@@ -1433,9 +1430,10 @@ public final class SpanUtils {
}
static class ShadowSpan extends CharacterStyle implements UpdateAppearance {
private float radius;
private float dx, dy;
private int shadowColor;
private final float radius;
private final float dx;
private final float dy;
private final int shadowColor;
private ShadowSpan(final float radius,
final float dx,

View File

@@ -1068,7 +1068,7 @@ public final class ThreadUtils {
private final AtomicInteger mSubmittedCount = new AtomicInteger();
private LinkedBlockingQueue4Util mWorkQueue;
private final LinkedBlockingQueue4Util mWorkQueue;
ThreadPoolExecutor4Util(int corePoolSize, int maximumPoolSize,
long keepAliveTime, TimeUnit unit,
@@ -1376,8 +1376,8 @@ public final class ThreadUtils {
public static class SyncValue<T> {
private CountDownLatch mLatch = new CountDownLatch(1);
private AtomicBoolean mFlag = new AtomicBoolean();
private final CountDownLatch mLatch = new CountDownLatch(1);
private final AtomicBoolean mFlag = new AtomicBoolean();
private T mValue;
public void setValue(T value) {

View File

@@ -36,6 +36,11 @@ public final class TimeUtils {
protected Map<String, SimpleDateFormat> initialValue() {
return new HashMap<>();
}
@Override
public void remove() {
super.remove();
}
};
private static SimpleDateFormat getDefaultFormat() {

View File

@@ -118,23 +118,13 @@ final class UtilsActivityLifecycleImpl implements Application.ActivityLifecycleC
void removeActivityLifecycleCallbacks(final Activity activity) {
if (activity == null) return;
UtilsBridge.runOnUiThread(new Runnable() {
@Override
public void run() {
mActivityLifecycleCallbacksMap.remove(activity);
}
});
UtilsBridge.runOnUiThread(() -> mActivityLifecycleCallbacksMap.remove(activity));
}
void removeActivityLifecycleCallbacks(final Activity activity,
final Utils.ActivityLifecycleCallbacks callbacks) {
if (activity == null || callbacks == null) return;
UtilsBridge.runOnUiThread(new Runnable() {
@Override
public void run() {
removeActivityLifecycleCallbacksInner(activity, callbacks);
}
});
UtilsBridge.runOnUiThread(() -> removeActivityLifecycleCallbacksInner(activity, callbacks));
}
private void removeActivityLifecycleCallbacksInner(final Activity activity,
@@ -182,13 +172,7 @@ final class UtilsActivityLifecycleImpl implements Application.ActivityLifecycleC
return null;
}
return (Application) app;
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
} catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException | ClassNotFoundException e) {
e.printStackTrace();
}
return null;
@@ -323,16 +307,13 @@ final class UtilsActivityLifecycleImpl implements Application.ActivityLifecycleC
} else {
final Object tag = activity.getWindow().getDecorView().getTag(-123);
if (!(tag instanceof Integer)) return;
UtilsBridge.runOnUiThreadDelayed(new Runnable() {
@Override
public void run() {
try {
Window window = activity.getWindow();
if (window != null) {
window.setSoftInputMode(((Integer) tag));
}
} catch (Exception ignore) {
UtilsBridge.runOnUiThreadDelayed(() -> {
try {
Window window = activity.getWindow();
if (window != null) {
window.setSoftInputMode(((Integer) tag));
}
} catch (Exception ignore) {
}
}, 100);
}
@@ -370,6 +351,9 @@ final class UtilsActivityLifecycleImpl implements Application.ActivityLifecycleC
Activity topActivity = null;
try {
Object activityThread = getActivityThread();
if(activityThread == null){
return list;
}
Field mActivitiesField = activityThread.getClass().getDeclaredField("mActivities");
mActivitiesField.setAccessible(true);
Object mActivities = mActivitiesField.get(activityThread);
@@ -448,9 +432,7 @@ final class UtilsActivityLifecycleImpl implements Application.ActivityLifecycleC
sDurationScaleField.set(null, 1f);
Log.i("UtilsActivityLifecycle", "setAnimatorsEnabled: Animators are enabled now!");
}
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}

View File

@@ -3,7 +3,6 @@ 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.nio.charset.StandardCharsets;
import java.util.List;
@@ -14,7 +13,7 @@ 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){
for (FieldWrapper fieldWrapper : fieldWrapperList) {
write2ByteBuf(fieldWrapper, command, buffer);
}
return buffer.array();
@@ -37,6 +36,9 @@ public class PayloadEncoder {
} catch (IllegalAccessException e) {
new RuntimeException("反射获取值失败filed:" + field.getName(), e);
}
if (value == null) {
return;
}
switch (typeName) {
case "com.autonavi.nge.map.LonLat":
LonLat lonLat = (LonLat) value;
@@ -51,6 +53,8 @@ public class PayloadEncoder {
case "java.lang.Character":
case "kotlin.Character":
case "char":
case "java.lang.String":
case "kotlin.String":
buffer.writeCharSequence((CharSequence) value, StandardCharsets.UTF_8);
break;
case "java.lang.Byte":
@@ -83,10 +87,6 @@ public class PayloadEncoder {
case "double":
buffer.writeDouble((double) value);
break;
case "java.lang.String":
case "kotlin.String":
buffer.writeCharSequence((CharSequence) value, StandardCharsets.UTF_8);
break;
default:
throw new RuntimeException(typeName + "不支持bug");
}

View File

@@ -38,8 +38,8 @@ class Clerk(private val mMapController: IMapController?) {
}
job?.cancel()
job = mMapController?.getDemaningScope()?.launch(Dispatchers.IO) {
var className: String = ""
var methodName: String = ""
var className = ""
var methodName = ""
try {
className = Thread.currentThread().stackTrace[3].className
methodName = Thread.currentThread().stackTrace[3].methodName
@@ -56,8 +56,8 @@ class Clerk(private val mMapController: IMapController?) {
}
job?.cancel()
job = mMapController?.getDemaningScope()?.launch(Dispatchers.IO) {
var className: String = ""
var methodName: String = ""
var className = ""
var methodName = ""
try {
className = Thread.currentThread().stackTrace[3].className
methodName = Thread.currentThread().stackTrace[3].methodName
@@ -79,7 +79,7 @@ class Clerk(private val mMapController: IMapController?) {
if(CompileConfig.DEBUG){
Log.i(TAG, "add: ${System.currentTimeMillis()}-$key")
}
var stringBuffer = cacheMap.get(key)
var stringBuffer = cacheMap[key]
if(stringBuffer == null){
stringBuffer = StringBuffer()
}
@@ -155,29 +155,34 @@ class Clerk(private val mMapController: IMapController?) {
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
path?.let {
val file = File(it)
if(!file.isDirectory){
return@launch
}
val secondlist = f.list()
for(child in secondlist){
val childFile = File(child)
upload(childFile)
val firstList = file.list()
firstList?.let {
for(p in firstList){
val f = File(p)
if(!f.isDirectory){
break
}
val secondList = f.list()
secondList?.let {
for(child in secondList){
val childFile = File(child)
upload(childFile)
}
}
}
}
}
}
}
private suspend fun upload(file:File){
return
val content = file.readText()
// return
// val content = file.readText()
// repository.uploadLogInfo(content)
}