Example #1
0
 public String getDefaultVehicleId() {
   VehicleInfo defVehicle = getDefaultVehicle();
   if (defVehicle == null) {
     return null;
   }
   return defVehicle.getVehicleId();
 }
Example #2
0
 /**
  * 得到默认的车辆
  *
  * @return
  */
 public VehicleInfo getDefaultVehicle() {
   initDefaultVehicleList();
   for (VehicleInfo info : sVehicleList) {
     if ("YES".equalsIgnoreCase(info.getIsDefault())) {
       return info;
     }
   }
   return null;
 }
Example #3
0
  public void saveSomeInformation(
      Context context,
      LoginResponse loginResponse,
      SharedPreferences sharedPreferences,
      String userID,
      String userPassword) {
    if (!TextUtils.isEmpty(userID)) {
      PreferenceUtil.putString(context, BaseActivity.SETTING_INFOS, BaseActivity.NAME, userID);
    }
    if (!TextUtils.isEmpty(userPassword)) {
      PreferenceUtil.putString(
          context, BaseActivity.SETTING_INFOS, BaseActivity.PASSWORD, userPassword);
    }
    // if(imageVersion!=null&&!"".equals(imageVersion)){
    // sharedPreferences.edit()
    // .putString(BaseActivity.SCREEN, imageVersion).commit();
    // }

    // sharedPreferences.edit().putBoolean(BaseActivity.LOGINED,
    // true).commit();

    // obdLists = loginParser.getLoginResponse().getObdList();
    // mLoginHandler.sendEmptyMessage(0);
    setLogin(true);
    AppConfig appConfig = loginResponse.getAppConfig();
    if (appConfig != null) {
      String obdReadInterval = appConfig.getObdReadInterval();
      if (obdReadInterval != null && !"".equals(obdReadInterval)) {
        sharedPreferences
            .edit()
            .putString(BaseActivity.APPCONFIG_OBD_READ_INTERVAL, obdReadInterval)
            .commit();
      }
      String serverReadInterval = appConfig.getServerReadInterval();
      if (serverReadInterval != null && !"".equals(serverReadInterval)) {
        sharedPreferences
            .edit()
            .putString(BaseActivity.APPCONFIG_SERVER_READ_INTERVAL, serverReadInterval)
            .commit();
      }
      String mileageInformInterval = appConfig.getMileageInformInterval();
      if (mileageInformInterval != null && !"".equals(mileageInformInterval)) {
        sharedPreferences
            .edit()
            .putString(BaseActivity.APPCONFIG_MILEAGE_INFORM_INTERVAL, mileageInformInterval)
            .commit();
      }

      String appVehicleErrorCodeWarnIntervals = appConfig.getAppVehicleErrorCodeWarnIntervals();
      if (appVehicleErrorCodeWarnIntervals != null
          && !"".equals(appVehicleErrorCodeWarnIntervals)) {
        sharedPreferences
            .edit()
            .putString(
                BaseActivity.APPCONFIG_ERROR_ALERT_INTERVAL, appVehicleErrorCodeWarnIntervals)
            .commit();
      }

      String remainOilMassWarn = appConfig.getRemainOilMassWarn();
      if (remainOilMassWarn != null && !"".equals(remainOilMassWarn)) {
        // sharedPreferences.edit().putString(BaseActivity.APPCONFIG_OIL_ALERT_INTERVAL,
        // remainOilMassWarn).commit();
        if (remainOilMassWarn.indexOf("_") != -1) {
          try {
            TongGouService.interOne =
                Integer.parseInt(remainOilMassWarn.substring(0, remainOilMassWarn.indexOf("_")));
            TongGouService.interTwo =
                Integer.parseInt(remainOilMassWarn.substring(remainOilMassWarn.indexOf("_") + 1));
          } catch (NumberFormatException er) {
          }
        }
      }
    }

    List<OBDBindInfo> obdList = loginResponse.getObdList();
    List<VehicleInfo> vehicleList = new ArrayList<VehicleInfo>();
    for (OBDBindInfo obd : obdList) {
      VehicleInfo vehicleInfo = obd.getVehicleInfo();
      if (vehicleInfo != null) {
        vehicleInfo.setObdSN(obd.getObdSN());
        vehicleList.add(vehicleInfo);
      }
    }
    PreferenceUtil.remove(this, BaseActivity.SETTING_INFOS, BaseActivity.BRAND);
    PreferenceUtil.remove(this, BaseActivity.SETTING_INFOS, BaseActivity.MODEL);
    PreferenceUtil.remove(this, BaseActivity.SETTING_INFOS, BaseActivity.VEHICLENUM);
    PreferenceUtil.remove(this, BaseActivity.SETTING_INFOS, BaseActivity.VEHICLE_MODE_ID);
    if (vehicleList.isEmpty()) {
      queryVehicleList(context);

    } else {
      setDefaultVehicleBindOBDs(vehicleList);
    }
    // doScanOBDAndPulling();

  }
Example #4
0
  public synchronized void setDefaultVehicleBindOBDs(List<VehicleInfo> data) {
    initDefaultVehicleList();
    sVehicleList.clear();
    sVehicleList.addAll(data);
    // 更新本地车辆数据库
    VehicleManager manager = new VehicleManager();
    String userNo =
        PreferenceUtil.getString(mInstance, BaseActivity.SETTING_INFOS, BaseActivity.NAME);
    manager.updateAllVehicle(userNo, data);

    List<OBDBindInfo> newObdData = new ArrayList<OBDBindInfo>();
    MainActivity.defaultBrandAndModle = "";
    PreferenceUtil.remove(this, BaseActivity.SETTING_INFOS, BaseActivity.BRAND);
    PreferenceUtil.remove(this, BaseActivity.SETTING_INFOS, BaseActivity.MODEL);
    PreferenceUtil.remove(this, BaseActivity.SETTING_INFOS, BaseActivity.VEHICLENUM);
    PreferenceUtil.remove(this, BaseActivity.SETTING_INFOS, BaseActivity.VEHICLE_MODE_ID);
    if (data == null || data.isEmpty()) {
      stopScanOBD();
      sObdLists.clear();
      return;
    }
    for (VehicleInfo vehicle : data) {
      if ("YES".equals(vehicle.getIsDefault())) {
        String vehiBrand = vehicle.getVehicleBrand();
        String vehiModel = vehicle.getVehicleModel();
        String vehiNo = vehicle.getVehicleNo();
        String vehiModelId = vehicle.getVehicleModelId();

        if (TextUtils.isEmpty(vehiBrand)) {
          vehiBrand = "";
        } else {
          PreferenceUtil.putString(this, BaseActivity.SETTING_INFOS, BaseActivity.BRAND, vehiBrand);
        }
        if (TextUtils.isEmpty(vehiModel)) {
          vehiModel = "";
        } else {
          PreferenceUtil.putString(this, BaseActivity.SETTING_INFOS, BaseActivity.MODEL, vehiModel);
        }
        if (!TextUtils.isEmpty(vehiNo)) {
          PreferenceUtil.putString(
              this, BaseActivity.SETTING_INFOS, BaseActivity.VEHICLENUM, vehiNo);
        }
        if (!TextUtils.isEmpty(vehiModelId)) {
          PreferenceUtil.putString(
              this, BaseActivity.SETTING_INFOS, BaseActivity.VEHICLE_MODE_ID, vehiModelId);
        }
        MainActivity.defaultBrandAndModle = vehiBrand + " " + vehiModel;
        if (TextUtils.isEmpty(vehicle.getObdSN())) {
          stopScanOBD();
          continue;
        }
      }
      String obdAddress = vehicle.getObdSN();
      if (TextUtils.isEmpty(obdAddress)) {
        continue;
      }
      OBDBindInfo obd = new OBDBindInfo();
      obd.setVehicleInfo(vehicle);
      obd.setObdSN(obdAddress);
      obd.setIsDefault(vehicle.getIsDefault());
      TongGouApplication.showLog(obdAddress + "  " + vehicle.getVehicleNo());
      newObdData.add(obd);
    }
    if (TongGouApplication.connetedOBD
        && sObdLists.containsAll(newObdData)
        && newObdData.containsAll(sObdLists)) {
      TongGouApplication.showLog(
          "obdLists.containsAll(newObdData) && newObdData.containsAll(obdLists)");
    } else {
      sObdLists.clear();
      sObdLists.addAll(newObdData);
      doScanOBDAndPulling();
    }
  }
Example #5
0
  private void setVehicleInfoValue() {
    progress.setVisibility(View.GONE);
    vehicleBrandIdStr = mVehicleInfo.getVehicleBrandId();
    vehicleModelIdStr = mVehicleInfo.getVehicleModelId();
    if (mVehicleInfo.getObdSN() != null && !"null".equals(mVehicleInfo.getObdSN())) {
      mTxtOBDBinded.setVisibility(View.VISIBLE);
      bindcarvehiclevin.setText(mVehicleInfo.getVehicleVin() + ""); // 车架号
      vehicleVinStr = mVehicleInfo.getVehicleVin();
      vehicleIdStr = mVehicleInfo.getVehicleId();
      // ifAddInterface = true;
    }
    obdSNStr = mVehicleInfo.getObdSN();
    bindcarnum.setText(mVehicleInfo.getVehicleNo() + "");

    if (mVehicleInfo.getVehicleBrand() != null
        && !"".equals(mVehicleInfo.getVehicleBrand())
        && !"null".equals(mVehicleInfo.getVehicleBrand())) {
      bindcarnum2.setText(mVehicleInfo.getVehicleBrand() + "");
    }
    if (mVehicleInfo.getVehicleModel() != null
        && !"".equals(mVehicleInfo.getVehicleModel())
        && !"null".equals(mVehicleInfo.getVehicleModel())) {
      bindcarnum1.setText(mVehicleInfo.getVehicleModel() + "");
    }
    if (mVehicleInfo.getCurrentMileage() != null
        && !"".equals(mVehicleInfo.getCurrentMileage())
        && !"null".equals(mVehicleInfo.getCurrentMileage())) {

      if (mVehicleInfo.getCurrentMileage().indexOf(".") != -1) {
        String cm =
            mVehicleInfo
                .getCurrentMileage()
                .substring(0, mVehicleInfo.getCurrentMileage().indexOf("."));
        bindcarmilenow.setText(cm);
      } else {
        bindcarmilenow.setText(mVehicleInfo.getCurrentMileage() + "");
      }
    }
    if (mVehicleInfo.getNextMaintainMileage() != null
        && !"".equals(mVehicleInfo.getNextMaintainMileage())
        && !"null".equals(mVehicleInfo.getNextMaintainMileage())) {
      if (mVehicleInfo.getNextMaintainMileage().indexOf(".") != -1) {
        String nm =
            mVehicleInfo
                .getNextMaintainMileage()
                .substring(0, mVehicleInfo.getNextMaintainMileage().indexOf("."));
        bindcarnextmile.setText(nm);
      } else {
        bindcarnextmile.setText(mVehicleInfo.getNextMaintainMileage() + "");
      }
    }
    if (mVehicleInfo.getNextExamineTime() != null
        && !"".equals(mVehicleInfo.getNextExamineTime())
        && !"null".equals(mVehicleInfo.getNextExamineTime())
        && !"0".equals(mVehicleInfo.getNextExamineTime())) {
      bindcarnexttime2.setText(SomeUtil.longToStringDate(mVehicleInfo.getNextExamineTime() + ""));
    }
    if (mVehicleInfo.getNextInsuranceTime() != null
        && !"".equals(mVehicleInfo.getNextInsuranceTime())
        && !"null".equals(mVehicleInfo.getNextInsuranceTime())
        && !"0".equals(mVehicleInfo.getNextInsuranceTime())) {
      bindcarnexttime.setText(SomeUtil.longToStringDate(mVehicleInfo.getNextInsuranceTime() + ""));
    }
    if (mVehicleInfo.getRecommendShopName() != null) {
      mTxtShopBinded.setVisibility(View.VISIBLE);
      mTxtShopBinded.setText(
          String.format(
              getResources().getString(R.string.change_bindcars_shop_binded),
              mVehicleInfo.getRecommendShopName()));
    }

    if (mVehicleInfo.getVehicleVin() != null
        && !"".equals(mVehicleInfo.getVehicleVin())
        && !"null".equals(mVehicleInfo.getVehicleVin())) {
      bindcarvehiclevin.setText(mVehicleInfo.getVehicleVin() + "");
    }
    if (mVehicleInfo.getEngineNo() != null
        && !"".equals(mVehicleInfo.getEngineNo())
        && !"null".equals(mVehicleInfo.getEngineNo())) {
      TongGouApplication.showLog(
          "mVehicleInfo.getEngineNo()  +  " + mVehicleInfo.getEngineNo() + "");
      bindcarengineno.setText(mVehicleInfo.getEngineNo() + "");
    }
    if (mVehicleInfo.getRegistNo() != null
        && !"".equals(mVehicleInfo.getRegistNo())
        && !"null".equals(mVehicleInfo.getRegistNo())) {
      bindcarregistno.setText(mVehicleInfo.getRegistNo() + "");
    }

    if (mTxtOBDBinded.getVisibility() == View.VISIBLE) {
      setViewMargins(mTxtOBDBinded, 0, SomeUtil.Dp2Px(this, 5), 0, 0);
    }

    if (mTxtShopBinded.getVisibility() == View.VISIBLE) {
      if (mTxtOBDBinded.getVisibility() != View.VISIBLE) {
        setViewMargins(mTxtShopBinded, 0, SomeUtil.Dp2Px(this, 5), 0, 0);
      }
    }
  }