[2.13.0] add func of binding car change model

This commit is contained in:
zhongchao
2022-12-09 12:01:51 +08:00
parent 3964223177
commit e7648bd9b1
18 changed files with 105 additions and 103 deletions

View File

@@ -1,37 +0,0 @@
package com.mogo.eagle.core.function.bindingcar;
import android.content.Context;
import com.mogo.eagle.core.function.api.bindingcar.BindingcarCallBack;
import com.mogo.eagle.core.function.bindingcar.network.BindingcarNetWorkManager;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
/**
* @author lixiaopeng
* @description
* @since: 10/27/21
*/
public class BindingcarManager {
private String TAG = "BindingcarManager";
private static BindingcarManager mBindingcarManager;
private Context mContext;
public static synchronized BindingcarManager getInstance() {
synchronized (BindingcarManager.class) {
if (mBindingcarManager == null) {
mBindingcarManager = new BindingcarManager();
}
}
return mBindingcarManager;
}
protected void getBindingcarInfo() {
}
protected void modifyCarInfo(BindingcarCallBack callBack) {
}
}

View File

@@ -1,5 +1,7 @@
package com.mogo.eagle.core.function.bindingcar.network;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BINDING;
import android.content.Context;
import android.util.Log;
@@ -7,8 +9,11 @@ import com.mogo.commons.constants.HostConst;
import com.mogo.commons.constants.SharedPrefsConstants;
import com.mogo.eagle.core.data.bindingcar.BindingcarInfo;
import com.mogo.eagle.core.data.bindingcar.ModifyBindingcarInfo;
import com.mogo.eagle.core.data.config.HdMapBuildConfig;
import com.mogo.eagle.core.function.api.bindingcar.BindingcarCallBack;
import com.mogo.eagle.core.function.bindingcar.R;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.eagle.core.function.call.map.CallerHDMapManager;
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
import com.mogo.eagle.core.network.utils.GsonUtil;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
@@ -57,9 +62,8 @@ public class BindingcarNetWorkManager {
* @param macAddress mac地址
*/
public void getBindingcarInfo(Context context, String macAddress, String widevineIDWithMd5, int screenType) {
// String macAddress1 = "48:b0:2d:3a:bc:78";
// String macAddress1 = "48:b0:2d:4d:b9:63";
// String sn = "X20202203105S688HZ";
// String macAddress1 = "48:b0:2d:4d:33:40";
// String sn = "X2020220417KA94QIN";
BindingcarRequest request = new BindingcarRequest(macAddress, widevineIDWithMd5, screenType);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
@@ -74,36 +78,28 @@ public class BindingcarNetWorkManager {
@Override
public void onNext(@NonNull BindingcarInfo info) {
if (info != null && info.getData() != null) {
CallerLogger.INSTANCE.d(TAG, "getBindingcarInfo onNext info.getData() =" + info.getData().toString());
Log.d(TAG, "getBindingcarInfo onNext info.getData() =" + info.getData().toString());
if (info.getData().getCompare().equals("0")) {
CallerHmiManager.INSTANCE.showBindingcarDialog();
} else if (info.getData().getCompare().equals("3")) {
CallerHmiManager.INSTANCE.showModifyBindingcarDialog();
} else if (info.getData().getCompare().equals("null")) {
TipToast.shortTip("当前工控机没有入库");
CallerLogger.INSTANCE.d(M_BINDING + TAG, "getBindingcarInfo onNext info.getData() =" + info.getData().toString());
switch (info.getData().getCompare()) {
case "0":
CallerHmiManager.INSTANCE.showBindingcarDialog();
break;
case "3":
CallerHmiManager.INSTANCE.showModifyBindingcarDialog();
break;
case "null":
TipToast.shortTip("当前工控机没有入库");
break;
}
//根据车辆类型切换不同的车辆模型,只针对红旗做处理
// if (info.getData().getVendor().equals("一汽红旗")) { //TODO
// CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.hq_h9);
// }
// else if (info.getData().getVendor().equals("东风汽车集团")) {
// CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.chuzuche);
// } else if (info.getData().getVendor().equals("金旅星辰")) {
// CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.xiaobache);
// } else {
// CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.chuzuche);
// }
updateCarVrIconRes(info.getData().getBrandId());
SharedPrefsMgr.getInstance(context).putString(SharedPrefsConstants.CAR_INFO, GsonUtils.toJson(info.getData()));
}
}
@Override
public void onError(@NonNull Throwable e) {
CallerLogger.INSTANCE.e(TAG, "getBindingcarInfo onError e = " + e.toString() + "---e.getMessage = " + e.getMessage());
CallerLogger.INSTANCE.e(M_BINDING + TAG, "getBindingcarInfo onError e = " + e.toString() + "---e.getMessage = " + e.getMessage());
}
@Override
@@ -132,14 +128,14 @@ public class BindingcarNetWorkManager {
public void onNext(@NonNull ModifyBindingcarInfo info) {
if (info != null) {
callBack.callBackResult(info);
Log.d(TAG, "modifyBindingcar onNext code = " + info.code + "---msg = " + info.msg + "--info.toString() = " + info.toString());
CallerLogger.INSTANCE.d(TAG, "modifyBindingcar onNext code = " + info.code + "---msg = " + info.msg + "--info.toString() = " + info.toString());
CallerLogger.INSTANCE.d(M_BINDING + TAG, "modifyBindingcar onNext code = " + info.code + "---msg = " + info.msg + "--info.toString() = " + info.toString());
updateCarVrIconRes(info.getBrandId());
}
}
@Override
public void onError(@NonNull Throwable e) {
CallerLogger.INSTANCE.e(TAG, "modifyBindingcar onError e = " + e.toString() + "---e.getMessage = " + e.getMessage());
CallerLogger.INSTANCE.e(M_BINDING + TAG, "modifyBindingcar onError e = " + e.toString() + "---e.getMessage = " + e.getMessage());
}
@Override
@@ -149,4 +145,30 @@ public class BindingcarNetWorkManager {
}
private void updateCarVrIconRes(String brandId){
if(brandId == null || brandId.isEmpty()){
return;
}
CallerLogger.INSTANCE.d(M_BINDING + TAG,"updateCarVrIconRes : " + brandId);
switch (brandId){
case "1":
CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.chuzuche);
HdMapBuildConfig.currentCarVrIconRes =R.raw.chuzuche;
break;
case "2":
CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.hq_h9);
HdMapBuildConfig.currentCarVrIconRes =R.raw.hq_h9;
break;
case "3":
CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.xiaobache);
HdMapBuildConfig.currentCarVrIconRes =R.raw.xiaobache;
break;
default:
CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.chuzuche);
HdMapBuildConfig.currentCarVrIconRes =R.raw.chuzuche;
break;
}
}
}