[sonar] fix sonar plm

This commit is contained in:
zhongchao
2023-10-23 17:01:37 +08:00
parent 0672cbb39c
commit 5b910c2082
41 changed files with 1117 additions and 1279 deletions

View File

@@ -7,7 +7,6 @@ import static com.mogo.och.bus.constant.BusConst.STATION_STATUS_STOPPED;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import androidx.annotation.NonNull;
@@ -81,7 +80,6 @@ import java.util.ArrayList;
import java.util.List;
import io.reactivex.exceptions.UndeliverableException;
import io.reactivex.functions.Consumer;
import io.reactivex.plugins.RxJavaPlugins;
import mogo.telematics.pad.MessagePad;
@@ -98,6 +96,7 @@ public class OrderModel {
private int backgroundCurrentStationIndex = 0;//A->B 此处值是A站点索引
private static volatile OrderModel sInstance;
private static final byte[] obj = new byte[0];
private Context mContext;
private final List<BusStationBean> stationList = new ArrayList<>();
private BusRoutesResult busRoutesResult = null;
@@ -125,20 +124,20 @@ public class OrderModel {
private LoginService loginService;
private final Handler handler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
if (msg.what == MSG_QUERY_BUS_STATION) {
queryBusRoutes();
return true;
}
return false;
private final Handler handler = new Handler(msg -> {
if (msg.what == MSG_QUERY_BUS_STATION) {
queryBusRoutes();
return true;
}
return false;
});
private OrderModel() {
}
public static OrderModel getInstance() {
if (sInstance == null) {
synchronized (OrderModel.class) {
synchronized (obj) {
if (sInstance == null) {
sInstance = new OrderModel();
}
@@ -147,10 +146,6 @@ public class OrderModel {
return sInstance;
}
private OrderModel() {
}
public void init() {
mContext = AbsMogoApplication.getApp();
loginService = (LoginService) ARouter.getInstance().build(OchCommonConst.LOGINSERVICE).navigation();
@@ -171,7 +166,7 @@ public class OrderModel {
OCHSocketMessageManager.INSTANCE.registerSocketMessageListener(//监听核销乘客
OCHSocketMessageManager.msgWriteOffPassengerType,
mWriteOffPassengeOnMessageListener);
mWriteOffPassengerOnMessageListener);
AbnormalFactorsLoopManager.INSTANCE.startLoopAbnormalFactors(mContext);
@@ -180,38 +175,35 @@ public class OrderModel {
//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_BUS + TAG, "UndeliverableException");
}
if ((e instanceof IOException)) {//
// fine, irrelevant network problem or API that throws on cancellation
CallerLogger.d(M_BUS + TAG, "IOException");
return;
}
if (e instanceof InterruptedException) {
// fine, some blocking code was interrupted by a dispose call
CallerLogger.d(M_BUS + TAG, "InterruptedException");
return;
}
if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) {
// that's likely a bug in the application
CallerLogger.d(M_BUS + 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_BUS + TAG, "IllegalStateException");
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
return;
}
CallerLogger.d(M_BUS + 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_BUS + TAG, "UndeliverableException");
}
if ((e instanceof IOException)) {
// fine, irrelevant network problem or API that throws on cancellation
CallerLogger.d(M_BUS + TAG, "IOException");
return;
}
if (e instanceof InterruptedException) {
// fine, some blocking code was interrupted by a dispose call
CallerLogger.d(M_BUS + TAG, "InterruptedException");
return;
}
if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) {
// that's likely a bug in the application
CallerLogger.d(M_BUS + 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_BUS + TAG, "IllegalStateException");
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
return;
}
CallerLogger.d(M_BUS + TAG, "Undeliverable exception");
});
}
@@ -234,7 +226,7 @@ public class OrderModel {
}
};
private final IMogoOnMessageListener<WriteOffPassenger> mWriteOffPassengeOnMessageListener =
private final IMogoOnMessageListener<WriteOffPassenger> mWriteOffPassengerOnMessageListener =
new IMogoOnMessageListener<WriteOffPassenger>() {
@Override
public Class<WriteOffPassenger> target() {
@@ -272,11 +264,8 @@ public class OrderModel {
this.mControllerStatusCallback = callback;
}
private final ITrajectoryListener trajectoryListener = new ITrajectoryListener() {
@Override
public void trajectoryCallback(@NonNull List<MogoLocation> routeArrivied, @NonNull List<MogoLocation> routeArriving, @NonNull MogoLocation location) {
private final ITrajectoryListener trajectoryListener = (routeArrivied, routeArriving, location) -> {
}
};
private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener() {
@@ -361,11 +350,6 @@ public class OrderModel {
TrajectoryAndDistanceManager.INSTANCE.removeListener(TAG);
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
private final IMogoStatusChangedListener mMogoStatusChangedListener = new IMogoStatusChangedListener() {
// VR mode变更回调
@Override
@@ -444,8 +428,6 @@ public class OrderModel {
CallerLogger.d(M_BUS + TAG, "judgeArrivedStation() = 刚过站且在15m内");
onArriveAt(null); //无自动驾驶到站信息传null
}
return;
}
}
@@ -621,10 +603,7 @@ public class OrderModel {
leaveTTSTips(nextStation,nextStationKr);
if (busRoutesResult != null) {
boolean isLastStop = false;
if (leaveIndex + 1 == stationList.size() - 1) {
isLastStop = true;
}
boolean isLastStop = leaveIndex + 1 == stationList.size() - 1;
//给bus外屏发送
BusSendTripInfoManager.INSTANCE.sendBusTripInfo(BusSendTripInfoManager.LEAVE_STATION
, busRoutesResult.getName()
@@ -768,10 +747,7 @@ public class OrderModel {
private void arriveStationSuccess(int arrivedStationIndex, String departureStopName,
String arriveStation, String arriveStationKr) {
if (busRoutesResult != null) {
boolean isLastStop = false;
if (arrivedStationIndex == busRoutesResult.getSites().size() - 1) {
isLastStop = true;
}
boolean isLastStop = arrivedStationIndex == busRoutesResult.getSites().size() - 1;
//给bus外屏发送
BusSendTripInfoManager.INSTANCE.sendBusTripInfo(BusSendTripInfoManager.ARRIVE_STATION
, busRoutesResult.getName()
@@ -845,12 +821,7 @@ public class OrderModel {
//车站10s后播报
private void leaveTTSTips(String nextStation,String nextStationKr) {
UiThreadHandler.postDelayed(new Runnable() {
@Override
public void run() {
VoiceManager.INSTANCE.leaveStationBus(nextStation,nextStationKr);
}
},DELAY_10S);
UiThreadHandler.postDelayed(() -> VoiceManager.INSTANCE.leaveStationBus(nextStation,nextStationKr),DELAY_10S);
}
/**
@@ -981,16 +952,12 @@ public class OrderModel {
}
}
Runnable tip3Runnable = new Runnable() {
@Override
public void run() {
if (backgroundCurrentStationIndex == 0 && stationList.get(0).getDrivingStatus() == STATION_STATUS_STOPPED
&& !stationList.get(0).isLeaving()){
tipStartTask("3");
}else {
removeTipRunnables();
}
Runnable tip3Runnable = () -> {
if (backgroundCurrentStationIndex == 0 && stationList.get(0).getDrivingStatus() == STATION_STATUS_STOPPED
&& !stationList.get(0).isLeaving()){
tipStartTask("3");
}else {
removeTipRunnables();
}
};
@@ -1005,16 +972,11 @@ public class OrderModel {
VoiceNotice.showNotice(tips);
}
Runnable tip1Runnable = new Runnable() {
@Override
public void run() {
if (backgroundCurrentStationIndex == 0 && stationList != null &&
stationList.get(0).getDrivingStatus() == STATION_STATUS_STOPPED
&& !stationList.get(0).isLeaving()){
tipStartTask("1");
}else {
removeTipRunnables();
}
Runnable tip1Runnable = () -> {
if (backgroundCurrentStationIndex == 0 && stationList.get(0).getDrivingStatus() == STATION_STATUS_STOPPED && !stationList.get(0).isLeaving()){
tipStartTask("1");
}else {
removeTipRunnables();
}
};
@@ -1205,7 +1167,7 @@ public class OrderModel {
}
public void triggerStartServiceEvent(boolean isRestart, boolean send) {
if (stationList == null || backgroundCurrentStationIndex >= stationList.size() - 1) {
if (backgroundCurrentStationIndex >= stationList.size() - 1) {
return;
}
BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex);
@@ -1215,7 +1177,7 @@ public class OrderModel {
}
public void triggerUnableStartAPReasonEvent() {
if (stationList == null || backgroundCurrentStationIndex >= stationList.size() - 1) {
if (backgroundCurrentStationIndex >= stationList.size() - 1) {
return;
}
BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex);
@@ -1253,8 +1215,8 @@ public class OrderModel {
}
private AutopilotControlParameters initAutopilotControlParameters(int leaveIndex) {
BusStationBean currentStation = null;
BusStationBean nextStation = null;
BusStationBean currentStation;
BusStationBean nextStation;
if (leaveIndex < 0) {
if (backgroundCurrentStationIndex + 1 > stationList.size() - 1 || !isGoingToNextStation) {

View File

@@ -1,7 +1,6 @@
package com.mogo.och.bus.model;
import android.content.Context;
import android.util.Log;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
@@ -24,9 +23,13 @@ public class BusLineModel {
private static volatile BusLineModel sInstance;
private Context mContext;
private IBusLinesCallback mBusLinesCallback;
private static final byte[] obj = new byte[0];
private BusLineModel() {
}
public static BusLineModel getInstance() {
if ( sInstance == null ) {
synchronized ( BusLineModel.class ) {
synchronized ( obj ) {
if ( sInstance == null ) {
sInstance = new BusLineModel();
}
@@ -34,9 +37,7 @@ public class BusLineModel {
}
return sInstance;
}
private BusLineModel() {
}
public void init() {
mContext = AbsMogoApplication.getApp();
}
@@ -79,7 +80,7 @@ public class BusLineModel {
/**
* 通过线路id 查询线路排班表
* @param lineId
* @param lineId 线路id
* @param position 位置
*/
public void queryBusLineTasksById(int lineId, int position,boolean autoRefresh){

View File

@@ -32,14 +32,14 @@ public class OpenItemAnimator extends DefaultItemAnimator {
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<>();
private ArrayList<ArrayList<ChangeInfo>> mChangesList = new ArrayList<>();
private final ArrayList<ArrayList<RecyclerView.ViewHolder>> mAdditionsList = new ArrayList<>();
private final ArrayList<ArrayList<MoveInfo>> mMovesList = new ArrayList<>();
private final ArrayList<ArrayList<ChangeInfo>> mChangesList = new ArrayList<>();
private ArrayList<RecyclerView.ViewHolder> mAddAnimations = new ArrayList<>();
private ArrayList<RecyclerView.ViewHolder> mMoveAnimations = new ArrayList<>();
private ArrayList<RecyclerView.ViewHolder> mRemoveAnimations = new ArrayList<>();
private ArrayList<RecyclerView.ViewHolder> mChangeAnimations = new ArrayList<>();
private final ArrayList<RecyclerView.ViewHolder> mAddAnimations = new ArrayList<>();
private final ArrayList<RecyclerView.ViewHolder> mMoveAnimations = new ArrayList<>();
private final ArrayList<RecyclerView.ViewHolder> mRemoveAnimations = new ArrayList<>();
private final ArrayList<RecyclerView.ViewHolder> mChangeAnimations = new ArrayList<>();
private static class MoveInfo {
public RecyclerView.ViewHolder holder;
@@ -328,8 +328,8 @@ public class OpenItemAnimator extends DefaultItemAnimator {
final ViewPropertyAnimator oldViewAnim = view.animate().setDuration(
getChangeDuration());
mChangeAnimations.add(changeInfo.oldHolder);
oldViewAnim.translationX(changeInfo.toX - changeInfo.fromX);
oldViewAnim.translationY(changeInfo.toY - changeInfo.fromY);
oldViewAnim.translationX((float) (changeInfo.toX - changeInfo.fromX));
oldViewAnim.translationY((float) (changeInfo.toY - changeInfo.fromY));
oldViewAnim.alpha(0).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {

View File

@@ -24,13 +24,13 @@ import com.mogo.och.bus.R;
public class BusArcView extends View {
//中心的文字描述
private String mDes = "KM/H";
private final String mDes = "KM/H";
//根据数据显示的圆弧Paint
private Paint mArcPaint;
//圆弧颜色
private int mArcColor;
//圆弧的画笔的宽度
private float mStrokeWith = getResources().getDimension(R.dimen.bus_ext_arcView_stroke_with);
private final float mStrokeWith = getResources().getDimension(R.dimen.bus_ext_arcView_stroke_with);
//文字描述的paint
private Paint mTextPaint;
@@ -39,9 +39,9 @@ public class BusArcView extends View {
//当前数据
private int currentValue;
//最大数据
private int maxValue = 240;
private final int maxValue = 240;
//圆弧背景的开始和结束间的夹角大小
private float mAngle = 270;
private final float mAngle = 270;
//上次绘制圆弧夹角
private float lastAngle = 0;
@@ -75,13 +75,13 @@ public class BusArcView extends View {
mTextPaint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
//绘制中心的数值
mTextPaint.getTextBounds(mValue, 0, mValue.length(), mRect);
canvas.drawText(mValue, getWidth() / 2, getHeight() / 2 + mRect.height() / 2 - 10, mTextPaint);
canvas.drawText(mValue, getWidth() / 2.0f, getHeight() / 2.0f + mRect.height() / 2.0f - 10, mTextPaint);
mTextPaint.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
//绘制中心文字描述
mTextPaint.setTextSize(getResources().getDimension(R.dimen.bus_ext_arcView_des_text_size));
mTextPaint.getTextBounds(mDes, 0, mDes.length(), mRect);
canvas.drawText(mDes, getWidth() / 2, getHeight() * 17 / 20 + mRect.height() / 2, mTextPaint);
canvas.drawText(mDes, getWidth() / 2.0f, getHeight() * 17.0f / 20.0f + mRect.height() / 2.0f, mTextPaint);
}
private void drawArc(Canvas canvas) {
@@ -135,13 +135,10 @@ public class BusArcView extends View {
ValueAnimator progressAnimator = ValueAnimator.ofFloat(startAngle, currentAngle);
progressAnimator.setDuration(time);
progressAnimator.setTarget(mIncludedAngle);
progressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mIncludedAngle = (float) animation.getAnimatedValue();
//重新绘制,不然不会出现效果
postInvalidate();
}
progressAnimator.addUpdateListener(animation -> {
mIncludedAngle = (float) animation.getAnimatedValue();
//重新绘制,不然不会出现效果
postInvalidate();
});
//开始执行动画
progressAnimator.start();

View File

@@ -22,7 +22,6 @@ import android.view.animation.DecelerateInterpolator;
import androidx.annotation.Nullable;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.eagle.core.utilcode.util.BitmapHelper;
import com.mogo.och.bus.R;
import me.jessyan.autosize.AutoSizeConfig;
@@ -93,7 +92,7 @@ public class SlidePanelView extends View {
private ObjectAnimator matrixAnim;
private String blockText = STRING_SLIDE_TO_RIGHT;
private Paint.FontMetrics blockTextMetrics = new Paint.FontMetrics();
private final Paint.FontMetrics blockTextMetrics = new Paint.FontMetrics();
private static final int GRADIENT_OFFSET = 200;
@@ -250,7 +249,7 @@ public class SlidePanelView extends View {
private void startBlockBackAnim() {
ObjectAnimator blockBackanimator = ObjectAnimator.ofInt(this, "blockOffset", blockOffset, 0);
blockBackanimator.setInterpolator(new DecelerateInterpolator());
blockBackanimator.setDuration(1000 * blockOffset / getWidth());
blockBackanimator.setDuration(1000L * blockOffset / getWidth());
blockBackanimator.start();
lastX = 0;
}
@@ -259,15 +258,15 @@ public class SlidePanelView extends View {
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// 画背景
canvas.drawRoundRect(bgRectF, (float) getHeight() / 2, (float) getHeight() / 2, bgPaint);
canvas.drawRoundRect(bgRectF, (float) getHeight() / 2.0f, (float) getHeight() / 2.0f, bgPaint);
// 画文字
gradientMatrix.setTranslate(matrixTranslate, 0);
textGradient.setLocalMatrix(gradientMatrix);
canvas.save();
canvas.drawText(blockText, blockWidth + BLOCK_START_X + textMarginLeft, textOffset, textPaint);
canvas.drawText(blockText, (float) (blockWidth + BLOCK_START_X + textMarginLeft), textOffset, textPaint);
canvas.restore();
// 画滑块
canvas.drawBitmap(bmBlock, BLOCK_START_X + blockOffset, BLOCK_START_Y, blockPaint);
canvas.drawBitmap(bmBlock, (float) (BLOCK_START_X + blockOffset), (float) BLOCK_START_Y, blockPaint);
}
public interface OnSlidePanelMoveToEndListener {

View File

@@ -47,7 +47,7 @@ public class MogoOCHBusPassenger implements IMogoOCH {
this.mContainerId = containerId;
showFragment();
if (AppIdentityModeUtils.isJL(FunctionBuildConfig.appIdentityMode)) {
if (AppIdentityModeUtils.isJL(FunctionBuildConfig.appIdentityMode) && activity != null) {
MultiDisplayUtils.INSTANCE.startActWithSecond(activity, VideoPlayerActivity.class);
}

View File

@@ -44,8 +44,8 @@ class MogoOCHBusPassenger : IMoGoFunctionProvider {
val supportFragmentManager: FragmentManager? = mActivity?.supportFragmentManager
if (mPassengerFragment == null) {
d(SceneConstant.M_TAXI_P + com.mogo.och.charter.passenger.MogoOCHBusPassenger.Companion.TAG, "准备add fragment======")
var fragmentByTag: Fragment? = supportFragmentManager?.findFragmentByTag(MainFragment.TAG)
d(SceneConstant.M_TAXI_P + TAG, "准备add fragment======")
val fragmentByTag: Fragment? = supportFragmentManager?.findFragmentByTag(MainFragment.TAG)
mPassengerFragment = if (fragmentByTag is MainFragment){
fragmentByTag
}else{
@@ -58,7 +58,7 @@ class MogoOCHBusPassenger : IMoGoFunctionProvider {
}
return
}
d(SceneConstant.M_TAXI_P + com.mogo.och.charter.passenger.MogoOCHBusPassenger.Companion.TAG, "准备show fragment")
d(SceneConstant.M_TAXI_P + TAG, "准备show fragment")
supportFragmentManager?.beginTransaction()?.show(mPassengerFragment!!)
?.commitAllowingStateLoss()
}
@@ -71,6 +71,6 @@ class MogoOCHBusPassenger : IMoGoFunctionProvider {
}
companion object {
private val TAG = com.mogo.och.charter.passenger.MogoOCHBusPassenger::class.java.simpleName
private val TAG = MogoOCHBusPassenger::class.java.simpleName
}
}

View File

@@ -7,11 +7,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* @author: wangmingjun
* @date: 2022/7/19
*/
public class OCHThreadPoolManager<T> {
/**
@@ -42,10 +37,11 @@ public class OCHThreadPoolManager<T> {
}
private volatile static OCHThreadPoolManager INSTANCE;
private static final byte[] obj = new byte[0];
public static OCHThreadPoolManager getsInstance() {
if (INSTANCE == null) {
synchronized (OCHThreadPoolManager.class) {
synchronized (obj) {
if (INSTANCE == null) {
INSTANCE = new OCHThreadPoolManager();
}
@@ -57,12 +53,10 @@ public class OCHThreadPoolManager<T> {
/**
* 开启一个无返回结果的线程
*
* @param r
*/
public void execute(Runnable r) {
if (executor == null) {
/**
/*
* corePoolSize:核心线程数
* maximumPoolSize线程池所容纳最大线程数(workQueue队列满了之后才开启)
* keepAliveTime非核心线程闲置时间超时时长
@@ -73,7 +67,7 @@ public class OCHThreadPoolManager<T> {
*
*/
executor = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE,
KEEP_ALIVE, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(200),
KEEP_ALIVE, TimeUnit.SECONDS, new ArrayBlockingQueue<>(200),
Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
}
// 把一个任务丢到了线程池中
@@ -87,13 +81,10 @@ public class OCHThreadPoolManager<T> {
/**
* 开启一个有返回结果的线程
*
* @param r
* @return
*/
public Future<T> submit(Callable<T> r) {
if (executor == null) {
/**
/*
* corePoolSize:核心线程数
* maximumPoolSize线程池所容纳最大线程数(workQueue队列满了之后才开启)
* keepAliveTime非核心线程闲置时间超时时长
@@ -104,7 +95,7 @@ public class OCHThreadPoolManager<T> {
*
*/
executor = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE,
KEEP_ALIVE, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(20),
KEEP_ALIVE, TimeUnit.SECONDS, new ArrayBlockingQueue<>(20),
Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
}
// 把一个任务丢到了线程池中
@@ -113,12 +104,10 @@ public class OCHThreadPoolManager<T> {
/**
* 开启一个无返回结果的线程
*
* @param r
*/
public Future submit(Runnable r) {
if (executor == null) {
/**
/*
* corePoolSize:核心线程数
* maximumPoolSize线程池所容纳最大线程数(workQueue队列满了之后才开启)
* keepAliveTime非核心线程闲置时间超时时长
@@ -129,7 +118,7 @@ public class OCHThreadPoolManager<T> {
*
*/
executor = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE,
KEEP_ALIVE, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(200),
KEEP_ALIVE, TimeUnit.SECONDS, new ArrayBlockingQueue<>(200),
Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
}
return executor.submit(r);
@@ -138,8 +127,6 @@ public class OCHThreadPoolManager<T> {
/**
* 把任务移除等待队列
*
* @param r
*/
public void cancel(Runnable r) {
if (r != null) {

View File

@@ -1,15 +1,10 @@
package com.mogo.och.common.module.utils;
import android.annotation.SuppressLint;
import android.media.*;
import android.content.*;
import android.os.*;
import android.app.*;
/**
* @author: wangmingjun
* @date: 2022/9/23
*
*/
public class SoundPoolHelper {
private SoundPool mSoundPool;
private AudioManager mAudioManager;
@@ -22,20 +17,16 @@ public class SoundPoolHelper {
private int resId;
private Context mContext;
private volatile static SoundPoolHelper INSTANCE;
private SoundPoolHelper(){}
public static SoundPoolHelper getSoundPoolHelper(){
if (INSTANCE == null){
synchronized (SoundPoolHelper.class){
if (INSTANCE == null){
INSTANCE = new SoundPoolHelper();
}
}
}
return INSTANCE;
return Holder.INSTANCE;
}
public SoundPoolHelper(){}
private static final class Holder{
@SuppressLint("StaticFieldLeak")
private static final SoundPoolHelper INSTANCE = new SoundPoolHelper();
}
//播放资源文件
public void playSoundWithRedId(Context context,int resId){
@@ -64,30 +55,19 @@ public class SoundPoolHelper {
if (mSoundPool == null){
// For Android SDK >= 21
if (Build.VERSION.SDK_INT >= 21 ) {
AudioAttributes audioAttrib = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_GAME)
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.build();
AudioAttributes audioAttrib = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_GAME)
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.build();
SoundPool.Builder builder= new SoundPool.Builder();
builder.setAudioAttributes(audioAttrib).setMaxStreams(MAX_STREAMS);
SoundPool.Builder builder= new SoundPool.Builder();
builder.setAudioAttributes(audioAttrib).setMaxStreams(MAX_STREAMS);
this.mSoundPool = builder.build();
} else {// for Android SDK < 21
// SoundPool(int maxStreams, int streamType, int srcQuality)
this.mSoundPool = new SoundPool(MAX_STREAMS, AudioManager.STREAM_MUSIC, 0);
}
this.mSoundPool = builder.build();
}
// When Sound Pool load complete.
this.mSoundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
playSound();
}
});
this.mSoundPool.setOnLoadCompleteListener((soundPool, sampleId, status) -> playSound());
//load res
this.mSoundId =this.mSoundPool.load(this.mContext,this.resId,1);
@@ -105,14 +85,12 @@ public class SoundPoolHelper {
}
}
//play the sound res
private void playSound(){
float leftVolumn = volume;
float rightVolumn = volume;
float leftVolume = volume;
float rightVolume = volume;
// Play sound of gunfire. Returns the ID of the new stream.
int streamId = this.mSoundPool.play(this.mSoundId,leftVolumn, rightVolumn, 1, 0, 1f);
int streamId = this.mSoundPool.play(this.mSoundId,leftVolume, rightVolume, 1, 0, 1f);
}
}

View File

@@ -21,7 +21,7 @@ public class OCHGradientTextView extends AppCompatTextView {
private Paint mPaint;
private int mViewWidth = 0;//文字的宽度
private int mViewHeight = 0;//文字的高度
private Rect mTextBound = new Rect();
private final Rect mTextBound = new Rect();
private int[] mColorList;//存放颜色的数组
private boolean isVertrial;//默认是横向
@@ -60,7 +60,7 @@ public class OCHGradientTextView extends AppCompatTextView {
mPaint.setShadowLayer(mRadius, mdx, mdy, mColor);
//画出文字
canvas.drawText(mTipText, getMeasuredWidth() / 2 - mTextBound.width() / 2, getMeasuredHeight() / 2 + mTextBound.height() / 2, mPaint);
canvas.drawText(mTipText, getMeasuredWidth() / 2.0f - mTextBound.width() / 2.0f, getMeasuredHeight() / 2.0f + mTextBound.height() / 2.0f, mPaint);
}
/**

View File

@@ -22,18 +22,18 @@ import com.mogo.och.common.module.R;
public class OCHShapeBlurView extends OCHStockBlurView {
Paint mPaint;
RectF mRectF;
private float mRadius;
private int mTopColor; // default #aaffffff
private int mBottomColor; // default #aaffffff
private final float mRadius;
private final int mTopColor; // default #aaffffff
private final int mBottomColor; // default #aaffffff
public OCHShapeBlurView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.OCHRShapeBlurView);
mRadius = a.getDimension(R.styleable.OCHRShapeBlurView_och_realtime_radius,
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.OCHShapeBlurView);
mRadius = a.getDimension(R.styleable.OCHShapeBlurView_och_realtime_radius,
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0, context.getResources().getDisplayMetrics()));
mTopColor = a.getColor(R.styleable.OCHRShapeBlurView_och_realtime_start_color, 0xAAFFFFFF);
mBottomColor = a.getColor(R.styleable.OCHRShapeBlurView_och_realtime_end_color, 0xAAFFFFFF);
mTopColor = a.getColor(R.styleable.OCHShapeBlurView_och_realtime_start_color, 0xAAFFFFFF);
mBottomColor = a.getColor(R.styleable.OCHShapeBlurView_och_realtime_end_color, 0xAAFFFFFF);
a.recycle();
mPaint = new Paint();
mRectF = new RectF();
@@ -60,7 +60,7 @@ public class OCHShapeBlurView extends OCHStockBlurView {
mPaint.reset();
mPaint.setAntiAlias(true);
/* 设置渐变色 这个正方形的颜色是改变的 */
Shader mShader = new LinearGradient(getWidth()/2, 0, getWidth()/2, getHeight(),
Shader mShader = new LinearGradient(getWidth()/2.0f, 0, getWidth()/2.0f, getHeight(),
new int[] {mTopColor,mBottomColor}, null, Shader.TileMode.CLAMP); // 一个材质,打造出一个线性梯度沿著一条线。
mPaint.setShader(mShader);//0xBFE0E8FF,0xBF6AA2D7
canvas.drawRoundRect(mRectF, mRadius,mRadius,mPaint);

View File

@@ -203,8 +203,6 @@ public class FrameSurfaceView extends BaseSurfaceView {
/**
* draw a single frame which is a bitmap
*
* @param canvas
*/
private void drawOneFrame(Canvas canvas) {
LinkedBitmap linkedBitmap = getDecodedBitmap();
@@ -214,12 +212,7 @@ public class FrameSurfaceView extends BaseSurfaceView {
putDrawnBitmap(linkedBitmap);
frameIndex.incrementAndGet();
if(isFinish()&&frameFinishCallback!=null){
runOnUIThread(new Runnable() {
@Override
public void run() {
frameFinishCallback.onFinishCallback();
}
});
runOnUIThread(() -> frameFinishCallback.onFinishCallback());
}
}
@@ -271,8 +264,8 @@ public class FrameSurfaceView extends BaseSurfaceView {
}
if (decodeRunnable != null) {
decodeRunnable.setIndex(0);
handler.post(decodeRunnable);
}
handler.post(decodeRunnable);
}
@@ -290,8 +283,8 @@ public class FrameSurfaceView extends BaseSurfaceView {
* decode bitmap by BitmapFactory.decodeStream(), it is about twice faster than BitmapFactory.decodeResource()
*
* @param resId the bitmap resource
* @param options
* @return
* @param options options
* @return Bitmap
*/
private Bitmap decodeBitmap(int resId, BitmapFactory.Options options) {
options.inScaled = false;

View File

@@ -47,7 +47,7 @@
<attr name="och_realtime_overlay_color" format="color" />
<attr name="och_realtime_onece" format="boolean" />
</declare-styleable>
<declare-styleable name="OCHRShapeBlurView">
<declare-styleable name="OCHShapeBlurView">
<attr name="och_realtime_start_color" format="color" />
<attr name="och_realtime_end_color" format="color" />
<attr name="och_realtime_radius" format="dimension" />

View File

@@ -28,10 +28,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<>();
ArrayList<ArrayList<RecyclerView.ViewHolder>> mAdditionsList = new ArrayList<>();
ArrayList<ArrayList<MoveInfo>> mMovesList = new ArrayList<>();
@@ -102,20 +102,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 +122,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 +141,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;
@@ -341,8 +329,8 @@ public class OpenItemAnimator extends DefaultItemAnimator {
final ViewPropertyAnimator oldViewAnim = view.animate().setDuration(
getChangeDuration());
mChangeAnimations.add(changeInfo.oldHolder);
oldViewAnim.translationX(changeInfo.toX - changeInfo.fromX);
oldViewAnim.translationY(changeInfo.toY - changeInfo.fromY);
oldViewAnim.translationX((float)(changeInfo.toX - changeInfo.fromX));
oldViewAnim.translationY((float)(changeInfo.toY - changeInfo.fromY));
oldViewAnim.alpha(0).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {

View File

@@ -75,13 +75,13 @@ public class BusArcView extends View {
mTextPaint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
//绘制中心的数值
mTextPaint.getTextBounds(mValue, 0, mValue.length(), mRect);
canvas.drawText(mValue, getWidth() / 2, getHeight() / 2 + mRect.height() / 2 - 10, mTextPaint);
canvas.drawText(mValue, getWidth() / 2.0f, getHeight() / 2.0f + mRect.height() / 2.0f - 10, mTextPaint);
mTextPaint.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
//绘制中心文字描述
mTextPaint.setTextSize(getResources().getDimension(R.dimen.bus_ext_arcView_des_text_size));
mTextPaint.getTextBounds(mDes, 0, mDes.length(), mRect);
canvas.drawText(mDes, getWidth() / 2, getHeight() * 17 / 20 + mRect.height() / 2, mTextPaint);
canvas.drawText(mDes, getWidth() / 2.0f, getHeight() * 17.0f / 20.0f + mRect.height() / 2.0f, mTextPaint);
}
private void drawArc(Canvas canvas) {
@@ -135,13 +135,10 @@ public class BusArcView extends View {
ValueAnimator progressAnimator = ValueAnimator.ofFloat(startAngle, currentAngle);
progressAnimator.setDuration(time);
progressAnimator.setTarget(mIncludedAngle);
progressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mIncludedAngle = (float) animation.getAnimatedValue();
//重新绘制,不然不会出现效果
postInvalidate();
}
progressAnimator.addUpdateListener(animation -> {
mIncludedAngle = (float) animation.getAnimatedValue();
//重新绘制,不然不会出现效果
postInvalidate();
});
//开始执行动画
progressAnimator.start();

View File

@@ -22,7 +22,6 @@ import android.view.animation.DecelerateInterpolator;
import androidx.annotation.Nullable;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.eagle.core.utilcode.util.BitmapHelper;
import com.mogo.och.bus.R;
import me.jessyan.autosize.AutoSizeConfig;
@@ -92,7 +91,7 @@ public class SlidePanelView extends View {
private ObjectAnimator matrixAnim;
private String blockText = STRING_SLIDE_TO_RIGHT;
private Paint.FontMetrics blockTextMetrics = new Paint.FontMetrics();
private final Paint.FontMetrics blockTextMetrics = new Paint.FontMetrics();
private static final int GRADIENT_OFFSET = 200;
@@ -263,10 +262,10 @@ public class SlidePanelView extends View {
gradientMatrix.setTranslate(matrixTranslate, 0);
textGradient.setLocalMatrix(gradientMatrix);
canvas.save();
canvas.drawText(blockText, blockWidth + BLOCK_START_X + textMarginLeft, textOffset, textPaint);
canvas.drawText(blockText, (float) (blockWidth + BLOCK_START_X + textMarginLeft), (float) textOffset, textPaint);
canvas.restore();
// 画滑块
canvas.drawBitmap(bmBlock, BLOCK_START_X + blockOffset, BLOCK_START_Y, blockPaint);
canvas.drawBitmap(bmBlock, (float) (BLOCK_START_X + blockOffset), (float) BLOCK_START_Y, blockPaint);
}
public interface OnSlidePanelMoveToEndListener {

View File

@@ -30,7 +30,7 @@ public class BusArcView extends View {
//圆弧颜色
private int mArcColor;
//圆弧的画笔的宽度
private float mStrokeWith = getResources().getDimension(R.dimen.sweeper_ext_arcView_stroke_with);
private final float mStrokeWith = getResources().getDimension(R.dimen.sweeper_ext_arcView_stroke_with);
//文字描述的paint
private Paint mTextPaint;
@@ -39,9 +39,9 @@ public class BusArcView extends View {
//当前数据
private int currentValue;
//最大数据
private int maxValue = 240;
private final int maxValue = 240;
//圆弧背景的开始和结束间的夹角大小
private float mAngle = 270;
private final float mAngle = 270;
//上次绘制圆弧夹角
private float lastAngle = 0;
@@ -75,13 +75,13 @@ public class BusArcView extends View {
mTextPaint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
//绘制中心的数值
mTextPaint.getTextBounds(mValue, 0, mValue.length(), mRect);
canvas.drawText(mValue, getWidth() / 2, getHeight() / 2 + mRect.height() / 2 - 10, mTextPaint);
canvas.drawText(mValue, getWidth() / 2.0f, getHeight() / 2.0f + mRect.height() / 2.0f - 10, mTextPaint);
mTextPaint.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
//绘制中心文字描述
mTextPaint.setTextSize(getResources().getDimension(R.dimen.sweeper_ext_arcView_des_text_size));
mTextPaint.getTextBounds(mDes, 0, mDes.length(), mRect);
canvas.drawText(mDes, getWidth() / 2, getHeight() * 17 / 20 + mRect.height() / 2, mTextPaint);
canvas.drawText(mDes, getWidth() / 2.0f, getHeight() * 17.0f / 20.0f + mRect.height() / 2.0f, mTextPaint);
}
private void drawArc(Canvas canvas) {
@@ -135,13 +135,10 @@ public class BusArcView extends View {
ValueAnimator progressAnimator = ValueAnimator.ofFloat(startAngle, currentAngle);
progressAnimator.setDuration(time);
progressAnimator.setTarget(mIncludedAngle);
progressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mIncludedAngle = (float) animation.getAnimatedValue();
//重新绘制,不然不会出现效果
postInvalidate();
}
progressAnimator.addUpdateListener(animation -> {
mIncludedAngle = (float) animation.getAnimatedValue();
//重新绘制,不然不会出现效果
postInvalidate();
});
//开始执行动画
progressAnimator.start();

View File

@@ -5,6 +5,8 @@ import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_SOURCE_ADA
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_TYPE_SOCKET_AUTOPILOT;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
import static java.util.Collections.emptyList;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
@@ -123,8 +125,8 @@ public class TaxiModel {
private volatile String mPrevOrderNo = ""; //前一次的新到单id当次和前一次orderId相同时本次不再弹出
private volatile OrderQueryRespBean.Result mNewBookingOrder; //新到待抢预约单
private volatile OrderQueryRespBean.Result mCurrentOCHOrder; //当前订单
private volatile List<OrderQueryRespBean.Result> mInServiceList = Collections.emptyList(); //进行中订单
private volatile List<OrderQueryRespBean.Result> mWaitServiceList = Collections.emptyList(); //待服务订单
private List<OrderQueryRespBean.Result> mInServiceList = Collections.synchronizedList(emptyList()); //进行中订单
private volatile List<OrderQueryRespBean.Result> mWaitServiceList = emptyList(); //待服务订单
private ITaxiADASStatusCallback mADASStatusCallback; //Model->Presenter自动驾驶状态相关
private ITaxiCarOperationalCallback mCarOperationalCallback; //Model->Presenter登录状态和司机今日接单状态
@@ -135,7 +137,7 @@ public class TaxiModel {
private volatile boolean isRestartAutopilot = false;
private final List<MogoLocation> mRoutePoints = new ArrayList<>();
private int mPreRouteIndex = 0;
private final int mPreRouteIndex = 0;
private double mLongitude, mLatitude;
private MogoLocation mLocation = null;
@@ -180,37 +182,34 @@ public class TaxiModel {
//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_TAXI + TAG, "UndeliverableException");
}
if ((e instanceof IOException)) {//
// fine, irrelevant network problem or API that throws on cancellation
CallerLogger.d(M_TAXI + TAG, "IOException");
return;
}
if (e instanceof InterruptedException) {
// fine, some blocking code was interrupted by a dispose call
CallerLogger.d(M_TAXI + TAG, "InterruptedException");
return;
}
if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) {
// that's likely a bug in the application
CallerLogger.d(M_TAXI + 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_TAXI + TAG, "IllegalStateException");
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
return;
}
CallerLogger.d(M_TAXI + TAG, "Undeliverable exception");
RxJavaPlugins.setErrorHandler(e -> {
if (e instanceof UndeliverableException) {
e = e.getCause();
CallerLogger.d(M_TAXI + TAG, "UndeliverableException");
}
if ((e instanceof IOException)) {//
// fine, irrelevant network problem or API that throws on cancellation
CallerLogger.d(M_TAXI + TAG, "IOException");
return;
}
if (e instanceof InterruptedException) {
// fine, some blocking code was interrupted by a dispose call
CallerLogger.d(M_TAXI + TAG, "InterruptedException");
return;
}
if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) {
// that's likely a bug in the application
CallerLogger.d(M_TAXI + 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_TAXI + TAG, "IllegalStateException");
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
return;
}
CallerLogger.d(M_TAXI + TAG, "Undeliverable exception");
});
}
@@ -1595,8 +1594,8 @@ public class TaxiModel {
/**
* 上报订单剩余里程和时间 单位KM, M 单位:秒
*
* @param lastSumLength
* @param duration
* @param lastSumLength 上报订单剩余里程
* @param duration 上报订单剩余时间
*/
public void reportOrderRemain(long lastSumLength, long duration) {// 米/秒
if (mCurrentOCHOrder == null) return;
@@ -1737,18 +1736,15 @@ public class TaxiModel {
mOrderStatusCallback.onNaviToEnd(false, isShow);
}
} else {//若直接要显示导航地图则直接导航, 若不是则2s后若无轨迹数据使用高德导航
if (isShow && mRoutePoints.size() == 0 && mOrderStatusCallback != null) {
if (isShow && mOrderStatusCallback != null) {
mOrderStatusCallback.onNaviToEnd(true, true);
} else {
UiThreadHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (mRoutePoints.size() == 0 && mOrderStatusCallback != null) {
mOrderStatusCallback.onNaviToEnd(true, false);
}
UiThreadHandler.postDelayed(() -> {
if (mRoutePoints.size() == 0 && mOrderStatusCallback != null) {
mOrderStatusCallback.onNaviToEnd(true, false);
}
}, 2000l);
}, 2000L);
}
}

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/**, 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.exclusions", "**/AndroidManifest.xml, **/src/test/**, com/mogo/eagle/core/utilcode, **/*.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

@@ -30,7 +30,6 @@ import okhttp3.RequestBody;
* @since: 10/28/21
*/
public class NoticeNetWorkManager {
private static volatile NoticeNetWorkManager requestNoticeManager;
private final INoticeApiService mNoticeApiService;
private NoticeNetWorkManager() {
@@ -39,14 +38,11 @@ public class NoticeNetWorkManager {
}
public static NoticeNetWorkManager getInstance() {
if (requestNoticeManager == null) {
synchronized (NoticeNetWorkManager.class) {
if (requestNoticeManager == null) {
requestNoticeManager = new NoticeNetWorkManager();
}
}
}
return requestNoticeManager;
return Holder.requestNoticeManager;
}
private static final class Holder{
private static final NoticeNetWorkManager requestNoticeManager = new NoticeNetWorkManager();
}
/**
@@ -88,7 +84,7 @@ public class NoticeNetWorkManager {
* 反馈交警是否接受事故任务
*
* @param infoId 事故id
* @param sn
* @param sn sn
* @param status 是否接受 0否 1是
*/
public void sendAccidentAcceptStatus(String infoId, String sn, int status) {

View File

@@ -6,14 +6,12 @@ import android.text.TextUtils;
//播放试听
public class Audition implements MediaPlayer.OnPreparedListener, MediaPlayer.OnCompletionListener{
private static volatile Audition INSTANCE;
public MediaPlayer mediaPlayer;
private String oldPath;
private OnAuditionListener listener;
public interface OnAuditionListener {
void onAuditionCompletion();
}
public void registerOnAuditionListener(OnAuditionListener listener) {
@@ -28,16 +26,12 @@ public class Audition implements MediaPlayer.OnPreparedListener, MediaPlayer.OnC
}
public static Audition getInstance() {
if (INSTANCE == null) {
synchronized (Audition.class) {
if (INSTANCE == null) {
INSTANCE = new Audition();
}
}
}
return INSTANCE;
return Holder.INSTANCE;
}
private static final class Holder{
private static final Audition INSTANCE = new Audition();
}
public boolean isPlaying() {
return mediaPlayer != null && mediaPlayer.isPlaying();

View File

@@ -7,9 +7,7 @@ import com.zhjt.mogo_core_function_devatools.badcase.record.listener.RecordListe
public class RecordManager {
private static final String TAG = RecordManager.class.getSimpleName();
@SuppressLint("StaticFieldLeak")
private volatile static RecordManager instance;
private final RecordHelper recordHelper;
/**
* 录音配置
@@ -21,14 +19,11 @@ public class RecordManager {
}
public static RecordManager getInstance() {
if (instance == null) {
synchronized (RecordManager.class) {
if (instance == null) {
instance = new RecordManager();
}
}
}
return instance;
return Holder.instance;
}
private static final class Holder{
private static final RecordManager instance = new RecordManager();
}
// /**

View File

@@ -12,19 +12,18 @@ import androidx.annotation.Nullable;
public class SharpView extends View {
private int mWidth =0; //三角形的宽度
private int mHeight =0; //三角形的高度
private Context mContext;
private int mWidth = 0; //三角形的宽度
private int mHeight = 0; //三角形的高度
private final Paint paint = new Paint();
private final Path path = new Path();
public SharpView(Context context) {
super(context);
this.mContext=context;
initView();
}
public SharpView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
this.mContext=context;
initView();
}
@@ -32,28 +31,27 @@ public class SharpView extends View {
mWidth = 25;
mHeight = 25;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
setMeasuredDimension(mWidth,mHeight);
setMeasuredDimension(mWidth, mHeight);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//创建画笔
Paint paint = new Paint();
paint.setColor(Color.parseColor("#FFFFFFFF"));
paint.setAntiAlias(true); //抗锯齿
paint.setStyle(Paint.Style.FILL);//实线
//创建路径
Path path = new Path();
path.moveTo(0,mHeight);
path.lineTo(mWidth,mHeight);
path.lineTo(mWidth/2,0);
path.moveTo(0, mHeight);
path.lineTo(mWidth, mHeight);
path.lineTo(mWidth / 2.0f, 0);
path.close();//闭合路径
//画在画布上
canvas.drawPath(path,paint);
canvas.drawPath(path, paint);
}
}

View File

@@ -5,6 +5,7 @@ import static com.mogo.eagle.core.data.biz.dispatch.DispatchAdasAutoPilotLocRece
import static com.mogo.eagle.core.data.biz.dispatch.DispatchAdasAutoPilotLocReceiverBean.DISPATCH_TYPE_START;
import static com.mogo.eagle.core.data.biz.dispatch.DispatchAdasAutoPilotLocReceiverBean.DISPATCH_TYPE_STOP;
import android.annotation.SuppressLint;
import android.content.Context;
import com.mogo.commons.voice.AIAssist;
@@ -12,6 +13,7 @@ import com.mogo.eagle.core.data.biz.dispatch.DispatchAdasAutoPilotLocReceiverBea
public class DispatchDialogManager {
@SuppressLint("StaticFieldLeak")
private static volatile DispatchDialogManager manager;
private static final byte[] obj = new byte[0];
private final Context mContext;

View File

@@ -22,13 +22,13 @@ import com.mogo.eagle.core.function.hmi.R;
public class SpeedChartView extends View {
//中心的文字描述
private String mDes = "KM/H";
private final String mDes = "KM/H";
//根据数据显示的圆弧Paint
private Paint mArcPaint;
//圆弧颜色
private int mArcColor;
//圆弧的画笔的宽度
private float mStrokeWith = getResources().getDimension(R.dimen.module_ext_arcView_stroke_with);
private final float mStrokeWith = getResources().getDimension(R.dimen.module_ext_arcView_stroke_with);
//文字描述的paint
private Paint mTextPaint;
@@ -37,9 +37,9 @@ public class SpeedChartView extends View {
//当前数据
private int currentValue;
//最大数据
private int maxValue = 240;
private final int maxValue = 240;
//圆弧背景的开始和结束间的夹角大小
private float mAngle = 270;
private final float mAngle = 270;
//上次绘制圆弧夹角
private float lastAngle = 0;
@@ -73,13 +73,13 @@ public class SpeedChartView extends View {
mTextPaint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
//绘制中心的数值
mTextPaint.getTextBounds(mValue, 0, mValue.length(), mRect);
canvas.drawText(mValue, getWidth() / 2, getHeight() / 2 + mRect.height() / 2 - 10, mTextPaint);
canvas.drawText(mValue, getWidth() / 2.0f, getHeight() / 2.0f + mRect.height() / 2.0f - 10, mTextPaint);
mTextPaint.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
//绘制中心文字描述
mTextPaint.setTextSize(getResources().getDimension(R.dimen.module_ext_arcView_des_text_size));
mTextPaint.getTextBounds(mDes, 0, mDes.length(), mRect);
canvas.drawText(mDes, getWidth() / 2, getHeight() * 17 / 20 + mRect.height() / 2, mTextPaint);
canvas.drawText(mDes, getWidth() / 2.0f, getHeight() * 17.0f / 20.0f + mRect.height() / 2.0f, mTextPaint);
}
private void drawArc(Canvas canvas) {

View File

@@ -27,6 +27,7 @@ public class RouteOverlayDrawer {
private Handler mRenderHandler;
private final IMoGoOverlayManager mogoOverlayManager;
private static volatile RouteOverlayDrawer sInstance;
private static final byte[] obj = new byte[0];
private Polyline.Options mPolylineOptions;
private static final int COLOR_LIGHT = Color.parseColor("#BAEBF5");
@@ -55,7 +56,7 @@ public class RouteOverlayDrawer {
public static RouteOverlayDrawer getInstance() {
if (sInstance == null) {
synchronized (RouteOverlayDrawer.class) {
synchronized (obj) {
if (sInstance == null) {
sInstance = new RouteOverlayDrawer();
}

View File

@@ -142,11 +142,7 @@ public class CarOverlay {
if (directionMarker == null) {
directionMarker = aMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f).setFlat(true).icon(fourCornersDescriptor).position(mLatLng));
if (isDirectionVisible) {
directionMarker.setVisible(true);
} else {
directionMarker.setVisible(false);
}
directionMarker.setVisible(isDirectionVisible);
}
carMarker.setVisible(true);
newAngle = bearing;
@@ -269,7 +265,7 @@ public class CarOverlay {
}
try {
IPoint p = carMarker.getGeoPoint();
double newX = 0, newY = 0;
double newX, newY;
if (currentFrameIndex++ < carMoveAnimationFrameNum) {
newX = mapAnchorBackup.x + dXOffStep * currentFrameIndex;
newY = mapAnchorBackup.y + dYOffStep * currentFrameIndex;

View File

@@ -31,8 +31,6 @@ public final class NetConfig {
private final Set< Interceptor > interceptors = new ArraySet<>();
private final Set< Interceptor > networkInterceptors = new ArraySet<>();
private final HostnameVerifier allowAllHostnameVerifier = (hostname, session) -> true;
private String signaturePrefix = "com.foundation.network";
private final HostnameVerifier hostnameVerifier = OkHostnameVerifier.INSTANCE;
private Map< String, Object > publicParams;

View File

@@ -60,7 +60,7 @@ public class S2FractalBuilder {
*/
private double offsetFraction = 0;
private Random rand;
private final Random rand;
/** You must call setMaxLevel() or setLevelForApproxMaxMedges() before calling makeLoop(). */
public S2FractalBuilder(Random rand) {
@@ -124,7 +124,7 @@ public class S2FractalBuilder {
/** Returns level from values in the range [1.5 * (4 ^ n), 6 * (4 ^ n)]. */
private static int levelFromEdges(int edges) {
return (int) Math.ceil(0.5 * Math.log(edges / 3) / Math.log(2));
return (int) Math.ceil(0.5 * Math.log(edges / 3.0f) / Math.log(2));
}
/**

View File

@@ -49,12 +49,12 @@ public class GlideCircleBitmapTransform extends BitmapTransformation {
borderPaint.setStrokeWidth( mBorderWidth );
borderPaint.setColor( mBorderColor );
borderPaint.setAntiAlias( true );
canvas.drawCircle( radius, radius, radius - mBorderWidth / 2, borderPaint );
canvas.drawCircle( radius, radius, radius - mBorderWidth / 2.0f, borderPaint );
}
Paint paint = new Paint();
paint.setShader( new BitmapShader( bitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP ) );
paint.setAntiAlias( true );
canvas.drawCircle( radius, radius, radius - mBorderWidth, paint );
canvas.drawCircle( radius, radius, (float) (radius - mBorderWidth), paint );
DiskLruCacheManager.getInstance( mContext ).put( mKey, result );

View File

@@ -39,7 +39,7 @@ public class GlideRoundBitmapTransform extends BitmapTransformation {
}
int width = toTransform.getWidth();
int height = toTransform.getHeight();
RectF rectF = new RectF( mBorderWidth, mBorderWidth, width - mBorderWidth, height - mBorderWidth );
RectF rectF = new RectF( mBorderWidth, mBorderWidth, (float) (width - mBorderWidth), (float) (height - mBorderWidth) );
Bitmap result = pool.get( width, height, toTransform.getConfig() );
// if ( result == null ) { //get() func always return not null
// result = toTransform.copy( toTransform.getConfig(), true );

View File

@@ -307,12 +307,12 @@ public final class ColorUtils {
int[] cColor = hexToArgb(centerColor);
int[] eColor = hexToArgb(endColor);
if (step >= 3) {
int colorStep = (int) Math.floor(step/2);
int colorStep = (int) Math.floor(step/2.0f);
// 计算每一步的差值
float aStep = (cColor[0] - sColor[0]) / colorStep;
float rStep = (cColor[1] - sColor[1]) / colorStep;
float gStep = (cColor[2] - sColor[2]) / colorStep;
float bStep = (cColor[3] - sColor[3]) / colorStep;
float aStep = (float) (cColor[0] - sColor[0]) / colorStep;
float rStep = (float) (cColor[1] - sColor[1]) / colorStep;
float gStep = (float) (cColor[2] - sColor[2]) / colorStep;
float bStep = (float) (cColor[3] - sColor[3]) / colorStep;
for (int i = 0; i < colorStep; i++) {
@@ -322,10 +322,10 @@ public final class ColorUtils {
(int)(gStep * i + sColor[2]),
(int)(bStep * i + sColor[3])));
}
float aStep_ = (eColor[0] - cColor[0]) / colorStep;
float rStep_ = (eColor[1] - cColor[1]) / colorStep;
float gStep_ = (eColor[2] - cColor[2]) / colorStep;
float bStep_ = (eColor[3] - cColor[3]) / colorStep;
float aStep_ = (float) (eColor[0] - cColor[0]) / colorStep;
float rStep_ = (float) (eColor[1] - cColor[1]) / colorStep;
float gStep_ = (float) (eColor[2] - cColor[2]) / colorStep;
float bStep_ = (float) (eColor[3] - cColor[3]) / colorStep;
for (int i = 0; i < colorStep; i++) {
gradientColorArr.add(

View File

@@ -777,14 +777,14 @@ public final class ConvertUtils {
SpannableStringBuilder spannable = new SpannableStringBuilder();
int length = value.length();
if (length > 1) {
/**
/*
* 对于长度大于1的数对首位进行赋值
* 对于两位数: 如果首位为“1”则拼接的字符串为“”
*/
spannable.append(getChinese(number / (int) Math.pow(10, length - 1), length))
spannable.append(getChinese(number / (int) Math.pow(10.0f, length - 1.0f), length))
.append(getUnitChinese(length));
// 如果该数值取余数为0则直接返回已有字符例如100直接返回一百
if (number % (int) Math.pow(10, length - 1) == 0) {
if (number % (int) Math.pow(10.0f, length - 1.0f) == 0) {
return spannable.toString();
}
}

View File

@@ -182,10 +182,10 @@ public class ShadowUtils {
private float mShadowHorizScale = 1f;
private float mShadowBottomScale = 1f;
private Paint mCornerShadowPaint;
private Paint mEdgeShadowPaint;
private final Paint mCornerShadowPaint;
private final Paint mEdgeShadowPaint;
private RectF mContentBounds;
private final RectF mContentBounds;
private float mCornerRadius;
@@ -210,7 +210,7 @@ public class ShadowUtils {
private float mRotation;
private boolean isCircle;
private final boolean isCircle;
public ShadowDrawable(Drawable content, float radius,
float shadowSize, float maxShadowSize, int shadowColor, boolean isCircle) {
@@ -494,7 +494,7 @@ public class ShadowUtils {
// We could have different top-bottom offsets to avoid extra gap above but in that case
// center aligning Views inside the CardView would be problematic.
if (isCircle) {
mCornerRadius = bounds.width() / 2;
mCornerRadius = bounds.width() / 2.0f;
}
final float verticalOffset = mRawMaxShadowSize * mShadowMultiplier;
mContentBounds.set(bounds.left + mRawMaxShadowSize, bounds.top + verticalOffset,
@@ -679,7 +679,7 @@ public class ShadowUtils {
public void setWrappedDrawable(Drawable drawable) {
if (this.mDrawable != null) {
this.mDrawable.setCallback((Callback) null);
this.mDrawable.setCallback(null);
}
this.mDrawable = drawable;

View File

@@ -1,5 +1,6 @@
package com.mogo.eagle.core.utilcode.util;
import android.annotation.SuppressLint;
import android.media.*;
import android.content.*;
import android.os.*;
@@ -21,20 +22,15 @@ public class SoundPoolUtils {
private int resId;
private Context mContext;
private volatile static SoundPoolUtils INSTANCE;
private SoundPoolUtils(){}
public static SoundPoolUtils getSoundPool(){
if (INSTANCE == null){
synchronized (SoundPoolUtils.class){
if (INSTANCE == null){
INSTANCE = new SoundPoolUtils();
}
}
}
return INSTANCE;
return Holder.INSTANCE;
}
private static final class Holder{
@SuppressLint("StaticFieldLeak")
private static final SoundPoolUtils INSTANCE = new SoundPoolUtils();
}
public SoundPoolUtils(){}
//播放资源文件
public void playSoundWithRedId(Context context,int resId){
@@ -63,30 +59,20 @@ public class SoundPoolUtils {
if (mSoundPool == null){
// For Android SDK >= 21
if (Build.VERSION.SDK_INT >= 21 ) {
AudioAttributes audioAttrib = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_GAME)
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.build();
AudioAttributes audioAttrib = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_GAME)
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.build();
SoundPool.Builder builder= new SoundPool.Builder();
builder.setAudioAttributes(audioAttrib).setMaxStreams(MAX_STREAMS);
SoundPool.Builder builder= new SoundPool.Builder();
builder.setAudioAttributes(audioAttrib).setMaxStreams(MAX_STREAMS);
this.mSoundPool = builder.build();
} else {// for Android SDK < 21
// SoundPool(int maxStreams, int streamType, int srcQuality)
this.mSoundPool = new SoundPool(MAX_STREAMS, AudioManager.STREAM_MUSIC, 0);
}
this.mSoundPool = builder.build();
}
// When Sound Pool load complete.
this.mSoundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
playSound();
}
});
this.mSoundPool.setOnLoadCompleteListener((soundPool, sampleId, status) -> playSound());
//load res
this.mSoundId =this.mSoundPool.load(this.mContext,this.resId,1);
@@ -108,10 +94,10 @@ public class SoundPoolUtils {
//play the sound res
private void playSound(){
float leftVolumn = volume;
float rightVolumn = volume;
float leftVolume = volume;
float rightVolume = volume;
// Play sound of gunfire. Returns the ID of the new stream.
int streamId = this.mSoundPool.play(this.mSoundId,leftVolumn, rightVolumn, 1, 0, 1f);
int streamId = this.mSoundPool.play(this.mSoundId,leftVolume, rightVolume, 1, 0, 1f);
}
}

View File

@@ -1031,7 +1031,7 @@ public final class SpanUtils {
// }
// }
canvas.drawText(text.toString(), x, y - ((y + fm.descent + y + fm.ascent) / 2 - (bottom + top) / 2), paint);
canvas.drawText(text.toString(), x, y - ((y + fm.descent + y + fm.ascent) / 2.0f - (bottom + top) / 2.0f), paint);
}
}
@@ -1200,11 +1200,11 @@ public final class SpanUtils {
sBulletPath.addCircle(0.0f, 0.0f, radius, Path.Direction.CW);
}
c.save();
c.translate(x + dir * radius, (top + bottom) / 2.0f);
c.translate((float)(x + dir * radius), (top + bottom) / 2.0f);
c.drawPath(sBulletPath, p);
c.restore();
} else {
c.drawCircle(x + dir * radius, (top + bottom) / 2.0f, radius, p);
c.drawCircle((float)(x + dir * radius), (top + bottom) / 2.0f, radius, p);
}
p.setColor(oldColor);
p.setStyle(style);
@@ -1386,7 +1386,7 @@ public final class SpanUtils {
if (mVerticalAlignment == ALIGN_TOP) {
transY = top;
} else if (mVerticalAlignment == ALIGN_CENTER) {
transY = (bottom + top - rect.height()) / 2;
transY = (bottom + top - rect.height()) / 2.0f;
} else if (mVerticalAlignment == ALIGN_BASELINE) {
transY = y - rect.height();
} else {
@@ -1417,7 +1417,7 @@ public final class SpanUtils {
}
static class ShaderSpan extends CharacterStyle implements UpdateAppearance {
private Shader mShader;
private final Shader mShader;
private ShaderSpan(final Shader shader) {
this.mShader = shader;

View File

@@ -16,22 +16,15 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class MogoStatusManager implements IMogoStatusManager {
private static volatile MogoStatusManager sInstance;
private static final byte[] obj = new byte[0];
private MogoStatusManager() {
}
public static MogoStatusManager getInstance() {
if (sInstance == null) {
synchronized (obj) {
if (sInstance == null) {
sInstance = new MogoStatusManager();
}
}
}
return sInstance;
return Holder.sInstance;
}
private static final class Holder{
private static final MogoStatusManager sInstance = new MogoStatusManager();
}
/**

View File

@@ -86,8 +86,8 @@ public class LaneMarkTools {
{
Panel_Image_Scale = scale;
PANEL_IMAGE_WIDTH = (int) (screenWidth/4 * Panel_Image_Scale);
PANEL_IMAGE_HEIGHT = (int) (screenHeight/3 * Panel_Image_Scale);
PANEL_IMAGE_WIDTH = (int) (screenWidth/4.0 * Panel_Image_Scale);
PANEL_IMAGE_HEIGHT = (int) (screenHeight/3.0 * Panel_Image_Scale);
LANE_PANELBORDER_MARGIN = (int) (5 * Panel_Image_Scale);
LANE_PANELBORDER_RADIAN = (int) (10 * Panel_Image_Scale);
@@ -154,12 +154,12 @@ public class LaneMarkTools {
paint.setColor(Color.GREEN);
paint.setAntiAlias(true);
Path path = new Path();
path.moveTo(ARROW_IMAGE_WIDTH / 2, 0);
path.lineTo(ARROW_IMAGE_WIDTH, ARROW_IMAGE_HEIGHT / 2);
path.lineTo(ARROW_IMAGE_WIDTH, ARROW_IMAGE_HEIGHT / 2 + ARROW_THICKNESS);
path.lineTo(ARROW_IMAGE_WIDTH / 2, ARROW_THICKNESS);
path.lineTo(0, ARROW_IMAGE_HEIGHT / 2 + ARROW_THICKNESS);
path.lineTo(0, ARROW_IMAGE_HEIGHT / 2);
path.moveTo(ARROW_IMAGE_WIDTH / 2.0f, 0);
path.lineTo(ARROW_IMAGE_WIDTH, ARROW_IMAGE_HEIGHT / 2.0f);
path.lineTo(ARROW_IMAGE_WIDTH, ARROW_IMAGE_HEIGHT / 2.0f + ARROW_THICKNESS);
path.lineTo(ARROW_IMAGE_WIDTH / 2.0f, ARROW_THICKNESS);
path.lineTo(0, ARROW_IMAGE_HEIGHT / 2.0f + ARROW_THICKNESS);
path.lineTo(0, ARROW_IMAGE_HEIGHT / 2.0f);
path.close();
canvas.drawPath(path, paint);
BitmapInfo info = new BitmapInfo();
@@ -186,7 +186,7 @@ public class LaneMarkTools {
paint.setColor(Color.GREEN);
paint.setAntiAlias(true);
Path path = new Path();
path.moveTo(TRIANGLE_IMAGE_WIDTH / 2, 0);
path.moveTo(TRIANGLE_IMAGE_WIDTH / 2.0f, 0);
path.lineTo(TRIANGLE_IMAGE_WIDTH, TRIANGLE_IMAGE_HEIGHT);
path.lineTo(0, TRIANGLE_IMAGE_HEIGHT);
path.close();
@@ -289,8 +289,8 @@ public class LaneMarkTools {
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(ARC_GOTO_SECTION_WIDTH);
paint.setAntiAlias(true);
float arcGotoSectionPositionX = (LANE_WIDTH - ARC_RADIUS * 2) / 2;
float arcGotoSectionPositionY = LANE_HEIGHT / 3;
float arcGotoSectionPositionX = (LANE_WIDTH - ARC_RADIUS * 2.0f) / 2.0f;
float arcGotoSectionPositionY = LANE_HEIGHT / 3.0f;
canvas.drawLine(arcGotoSectionPositionX, arcGotoSectionPositionY,
arcGotoSectionPositionX, arcGotoSectionPositionY + ARC_INTO_SECTION_HEIGHT,
paint);
@@ -320,14 +320,14 @@ public class LaneMarkTools {
paint.setStrokeWidth(ARC_GOTO_SECTION_WIDTH);
paint.setAntiAlias(true);
float arcGotoSectionPositionX = (LANE_WIDTH - ARC_RADIUS * 2) / 2;
float arcGotoSectionPositionY = LANE_HEIGHT / 3;
float arcGotoSectionPositionX = (LANE_WIDTH - ARC_RADIUS * 2.0f) / 2.0f;
float arcGotoSectionPositionY = LANE_HEIGHT / 3.0f;
canvas.drawLine(arcGotoSectionPositionX, arcGotoSectionPositionY,
arcGotoSectionPositionX, arcGotoSectionPositionY + ARC_GOTO_SECTION_HEIGHT,
paint);
float arcIntoSectionPositionX = arcGotoSectionPositionX + ARC_RADIUS * 2;
float arcIntoSectionPositionY = LANE_HEIGHT / 3;
float arcIntoSectionPositionY = LANE_HEIGHT / 3.0f;
canvas.drawLine(arcIntoSectionPositionX, arcIntoSectionPositionY,
arcIntoSectionPositionX, arcIntoSectionPositionY + ARC_INTO_SECTION_HEIGHT,
paint);
@@ -348,7 +348,7 @@ public class LaneMarkTools {
canvas.save();
canvas.translate(translationX, translationY);
canvas.rotate(180);
canvas.drawBitmap(arrowImage, -(arrowImage.getWidth() / 2),0, paint);
canvas.drawBitmap(arrowImage, -(arrowImage.getWidth() / 2.0f),0, paint);
canvas.restore();
BitmapInfo info = new BitmapInfo();
@@ -378,7 +378,7 @@ public class LaneMarkTools {
paint.setStrokeWidth(STRAIGHT_SECTION_WIDTH);
paint.setAntiAlias(true);
Bitmap arrowImage = getRenderArrowImage(isW == AHEAD_BIT_MASK ? false : true).bitmap;
Bitmap arrowImage = getRenderArrowImage(isW != AHEAD_BIT_MASK).bitmap;
int arrowPositionX = (LANE_WIDTH - arrowImage.getWidth()) / 2;
int arrowPositionY = (LANE_HEIGHT - ARROW_THICKNESS - STRAIGHT_SECTION_HEIGHT) / 2;
canvas.drawBitmap(arrowImage, arrowPositionX, arrowPositionY, paint);
@@ -429,13 +429,13 @@ public class LaneMarkTools {
canvas.drawPath(path, paint);
Bitmap arrowImage = getRenderArrowImage(isW == LEFT_TWO_BIT_MASK ? false : true).bitmap;
Bitmap arrowImage = getRenderArrowImage(isW != LEFT_TWO_BIT_MASK).bitmap;
int translationX = endX - ARROW_THICKNESS;
int translationY = endY;
canvas.save();
canvas.translate(translationX, translationY);
canvas.rotate(-90);
canvas.drawBitmap(arrowImage, -(arrowImage.getWidth() / 2), 0, paint);
canvas.drawBitmap(arrowImage, -(arrowImage.getWidth() / 2.0f), 0, paint);
canvas.restore();
BitmapInfo info = new BitmapInfo();
@@ -479,13 +479,13 @@ public class LaneMarkTools {
canvas.drawPath(path, paint);
Bitmap arrowImage = getRenderArrowImage(isW == RIGHT_TWO_BIT_MASK ? false : true).bitmap;
Bitmap arrowImage = getRenderArrowImage(isW != RIGHT_TWO_BIT_MASK).bitmap;
int translationX = endX + ARROW_THICKNESS;
int translationY = endY;
canvas.save();
canvas.translate(translationX, translationY);
canvas.rotate(90);
canvas.drawBitmap(arrowImage, -(arrowImage.getWidth() / 2), 0, paint);
canvas.drawBitmap(arrowImage, -(arrowImage.getWidth() / 2.0f), 0, paint);
canvas.restore();
BitmapInfo info = new BitmapInfo();
@@ -707,8 +707,8 @@ public class LaneMarkTools {
paint.setStrokeWidth(RIGHT_TURN_VERTICAL_SECTION_WIDTH);
paint.setAntiAlias(true);
float startX = LANE_WIDTH / 3;
float startY = LANE_HEIGHT - LANE_HEIGHT / 4;
float startX = LANE_WIDTH / 3.0f;
float startY = LANE_HEIGHT - LANE_HEIGHT / 4.0f;
float endX = startX;
float endY = startY - RIGHT_TURN_VERTICAL_SECTION_HEIGHT;
@@ -717,20 +717,20 @@ public class LaneMarkTools {
paint.setStyle(Style.FILL);
Path path = new Path();
path.moveTo(endX - RIGHT_TURN_VERTICAL_SECTION_WIDTH / 2, endY);
path.lineTo(endX - RIGHT_TURN_VERTICAL_SECTION_WIDTH / 2, endY + RIGHT_FRONT_TURN_SLOPE_THICKNESS);
path.lineTo(endX - RIGHT_TURN_VERTICAL_SECTION_WIDTH / 2 + RIGHT_FRONT_TURN_SLOPE_WIDTH, endY);
path.lineTo(endX - RIGHT_TURN_VERTICAL_SECTION_WIDTH / 2 + RIGHT_FRONT_TURN_SLOPE_WIDTH, endY - RIGHT_FRONT_TURN_SLOPE_THICKNESS);
path.moveTo(endX - RIGHT_TURN_VERTICAL_SECTION_WIDTH / 2.0f, endY);
path.lineTo(endX - RIGHT_TURN_VERTICAL_SECTION_WIDTH / 2.0f, endY + RIGHT_FRONT_TURN_SLOPE_THICKNESS);
path.lineTo(endX - RIGHT_TURN_VERTICAL_SECTION_WIDTH / 2.0f + RIGHT_FRONT_TURN_SLOPE_WIDTH, endY);
path.lineTo(endX - RIGHT_TURN_VERTICAL_SECTION_WIDTH / 2.0f + RIGHT_FRONT_TURN_SLOPE_WIDTH, endY - RIGHT_FRONT_TURN_SLOPE_THICKNESS);
canvas.drawPath(path, paint);
Bitmap triangleImage = getRenderTriangleImage(isW).bitmap;
float translationX = endX - RIGHT_TURN_VERTICAL_SECTION_WIDTH / 2 + RIGHT_FRONT_TURN_SLOPE_WIDTH + TRIANGLE_IMAGE_HEIGHT;
float translationY = endY - RIGHT_FRONT_TURN_SLOPE_THICKNESS / 2;
float translationX = endX - RIGHT_TURN_VERTICAL_SECTION_WIDTH / 2.0f + RIGHT_FRONT_TURN_SLOPE_WIDTH + TRIANGLE_IMAGE_HEIGHT;
float translationY = endY - RIGHT_FRONT_TURN_SLOPE_THICKNESS / 2.0f;
canvas.save();
canvas.translate(translationX, translationY);
canvas.rotate(90);
canvas.drawBitmap(triangleImage, -(triangleImage.getWidth() / 2), 0, paint);
canvas.drawBitmap(triangleImage, -(triangleImage.getWidth() / 2.0f), 0, paint);
canvas.restore();
BitmapInfo info = new BitmapInfo();
@@ -769,10 +769,10 @@ public class LaneMarkTools {
paint.setStyle(Style.FILL);
Path path = new Path();
path.moveTo(endX + LEFT_TURN_VERTICAL_SECTION_WIDTH / 2, endY);
path.lineTo(endX + LEFT_TURN_VERTICAL_SECTION_WIDTH / 2, endY + LEFT_FRONT_TURN_SLOPE_THICKNESS);
path.lineTo(endX + LEFT_TURN_VERTICAL_SECTION_WIDTH / 2 - LEFT_FRONT_TURN_SLOPE_WIDTH, endY);
path.lineTo(endX + LEFT_TURN_VERTICAL_SECTION_WIDTH / 2 - LEFT_FRONT_TURN_SLOPE_WIDTH, endY - LEFT_FRONT_TURN_SLOPE_THICKNESS);
path.moveTo(endX + LEFT_TURN_VERTICAL_SECTION_WIDTH / 2.0f, endY);
path.lineTo(endX + LEFT_TURN_VERTICAL_SECTION_WIDTH / 2.0f, endY + LEFT_FRONT_TURN_SLOPE_THICKNESS);
path.lineTo(endX + LEFT_TURN_VERTICAL_SECTION_WIDTH / 2.0f - LEFT_FRONT_TURN_SLOPE_WIDTH, endY);
path.lineTo(endX + LEFT_TURN_VERTICAL_SECTION_WIDTH / 2.0f - LEFT_FRONT_TURN_SLOPE_WIDTH, endY - LEFT_FRONT_TURN_SLOPE_THICKNESS);
canvas.drawPath(path, paint);
@@ -782,7 +782,7 @@ public class LaneMarkTools {
canvas.save();
canvas.translate(translationX, translationY);
canvas.rotate(-90);
canvas.drawBitmap(triangleImage, -(triangleImage.getWidth() / 2), 0, paint);
canvas.drawBitmap(triangleImage, -(triangleImage.getWidth() / 2.0f), 0, paint);
canvas.restore();
BitmapInfo info = new BitmapInfo();
info.bitmap = bitmap;
@@ -807,8 +807,8 @@ public class LaneMarkTools {
paint.setStrokeWidth(LEFT_TURN_VERTICAL_SECTION_WIDTH);
paint.setAntiAlias(true);
Bitmap leftFrontTurnLaneArrow = getRenderLeftFrontTurnLaneArrow(isW == LEFT_TWO_BIT_MASK?false : true).bitmap;
Bitmap UTurnLaneArrow = getRenderUTurnLaneArrow(isW == UTURN_BIT_MASK?false : true).bitmap;
Bitmap leftFrontTurnLaneArrow = getRenderLeftFrontTurnLaneArrow(isW != LEFT_TWO_BIT_MASK).bitmap;
Bitmap UTurnLaneArrow = getRenderUTurnLaneArrow(isW != UTURN_BIT_MASK).bitmap;
int translationX = 0;
int translationY = LANE_HEIGHT / 4;
@@ -864,8 +864,8 @@ public class LaneMarkTools {
Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Bitmap UTurnLaneArrow = getRenderUTurnLaneArrow(isW == UTURN_BIT_MASK ? false : true).bitmap;
Bitmap rightFrontTurnLaneArrow = getRenderRightFrontTurnLaneArrow(isW == RIGHT_TWO_BIT_MASK ? false : true).bitmap;
Bitmap UTurnLaneArrow = getRenderUTurnLaneArrow(isW != UTURN_BIT_MASK).bitmap;
Bitmap rightFrontTurnLaneArrow = getRenderRightFrontTurnLaneArrow(isW != RIGHT_TWO_BIT_MASK).bitmap;
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setStyle(Style.STROKE);
@@ -873,7 +873,7 @@ public class LaneMarkTools {
paint.setAntiAlias(true);
float translationX = -ARC_RADIUS;
float translationY = LANE_HEIGHT / 4;
float translationY = LANE_HEIGHT / 4.0f;
canvas.save();
if(isW != UTURN_BIT_MASK)
{
@@ -884,8 +884,8 @@ public class LaneMarkTools {
if(isW != RIGHT_TWO_BIT_MASK)
{
translationX = RIGHT_FRONT_TURN_SLOPE_WIDTH / 2;
translationY = -(LANE_HEIGHT / 8);
translationX = RIGHT_FRONT_TURN_SLOPE_WIDTH / 2.0f;
translationY = -(LANE_HEIGHT / 8.0f);
canvas.translate(translationX, translationY);
canvas.drawBitmap(rightFrontTurnLaneArrow, 0, 0, paint);
canvas.translate(-translationX, -translationY);
@@ -894,15 +894,15 @@ public class LaneMarkTools {
if(isW == UTURN_BIT_MASK)
{
translationX = -ARC_RADIUS;
translationY = LANE_HEIGHT / 4;
translationY = LANE_HEIGHT / 4.0f;
canvas.translate(translationX, translationY);
canvas.drawBitmap(UTurnLaneArrow, 0, 0, paint);
canvas.translate(-translationX, -translationY);
}
else if(isW == RIGHT_TWO_BIT_MASK)
{
translationX = RIGHT_FRONT_TURN_SLOPE_WIDTH / 2;
translationY = -(LANE_HEIGHT / 8);
translationX = RIGHT_FRONT_TURN_SLOPE_WIDTH / 2.0f;
translationY = -(LANE_HEIGHT / 8.0f);
canvas.translate(translationX, translationY);
canvas.drawBitmap(rightFrontTurnLaneArrow, 0, 0, paint);
canvas.translate(-translationX, -translationY);
@@ -934,8 +934,8 @@ public class LaneMarkTools {
paint.setAntiAlias(true);
Bitmap straightLaneArrow = getRenderStraightLaneArrow(isW).bitmap;
Bitmap leftFrontTurnArrow = getRenderLeftFrontTurnLaneArrow(isW == LEFT_TWO_BIT_MASK ? false : true).bitmap;
Bitmap RightFrontTurnArrow = getRenderRightFrontTurnLaneArrow(isW == RIGHT_TWO_BIT_MASK ? false : true).bitmap;
Bitmap leftFrontTurnArrow = getRenderLeftFrontTurnLaneArrow(isW != LEFT_TWO_BIT_MASK).bitmap;
Bitmap RightFrontTurnArrow = getRenderRightFrontTurnLaneArrow(isW != RIGHT_TWO_BIT_MASK).bitmap;
int translationX = -(LEFT_FRONT_TURN_SLOPE_WIDTH / 2);
int translationY = LANE_HEIGHT / 6;
canvas.save();
@@ -1015,7 +1015,7 @@ public class LaneMarkTools {
paint.setAntiAlias(true);
Bitmap straightLaneArrow = getRenderStraightLaneArrow(type).bitmap;
Bitmap UTurnLaneArrow = getRenderUTurnLaneArrow(type == UTURN_BIT_MASK ? false : true).bitmap;
Bitmap UTurnLaneArrow = getRenderUTurnLaneArrow(type != UTURN_BIT_MASK).bitmap;
int translationX = -ARC_RADIUS;
int translationY = LANE_HEIGHT / 4;
@@ -1228,7 +1228,7 @@ public class LaneMarkTools {
}else if(mark.isUTurn)
{
//获取 "调头" 车道箭头图元
bitmap = getRenderUTurnLaneArrow(highType == UTURN_BIT_MASK ? false : true);
bitmap = getRenderUTurnLaneArrow(highType != UTURN_BIT_MASK);
}
return bitmap;

View File

@@ -81,14 +81,14 @@ public class DirectionLayer extends ImageView implements MapStatusListener {
return;
}
canvas.save();
canvas.translate(getWidth() / 2, getHeight() / 2);
canvas.translate(getWidth() / 2.0f, getHeight() / 2.0f);
// mCamera.save();
// mCamera.rotateX(90 - mapController.getDAngle());
// mCamera.getMatrix(matrix);
// mCamera.restore();
canvas.concat(matrix);
canvas.rotate(mMapController.getMapViewRotation());
canvas.translate(-getWidth() / 2, -getHeight() / 2);
canvas.translate(-getWidth() / 2.0f, -getHeight() / 2.0f);
super.onDraw(canvas);
canvas.restore();
postInvalidate();

View File

@@ -65,7 +65,7 @@ public class PubFunction
*/
public static double GetLineAngle(int nX1, int nY1, int nX2, int nY2)
{
return getAngleToNorth((nX2 - nX1)/5, (nY2 - nY1)/4);
return getAngleToNorth((nX2 - nX1)/5.0f, (nY2 - nY1)/4.0f);
}
}