Exemplo n.º 1
0
 public String getVersionName() {
   try {
     return UpdateUtil.getLocalPackageInfo(TongGouApplication.getInstance()).versionName;
   } catch (NameNotFoundException e) {
     return "1.0";
   }
 }
Exemplo n.º 2
0
 @Override
 public void onGetPermissionState(int iError) {
   if (iError == MKEvent.ERROR_PERMISSION_DENIED) {
     // Log.d("cccccc", "cccccccccccccccccccccccccccccccccc");
     TongGouApplication.getInstance().m_bKeyRight = false;
   }
 }
Exemplo n.º 3
0
    public void onReceive(Context context, Intent intent) {

      if (!TongGouApplication.getInstance().isLogin()) {
        // 游客模式没有消息
        return;
      }

      Runnable mRunnable =
          new Runnable() {
            public void run() {
              // 提示消息中心更新UI的广播
              Intent intentDisplay = new Intent();
              intentDisplay.setAction(TongGouService.TONGGOU_ACTION_DISPLAY_MESSAGE);
              sendBroadcast(intentDisplay);

              timehandler.removeCallbacks(this); // 移除定时任务
            }
          };
      timehandler.postDelayed(mRunnable, 1500); // 延迟执行this,即runable,为了播放提示音

      HomePageActivity.this.runOnUiThread(
          new Runnable() {
            public void run() {
              int newMessagesCount =
                  getSharedPreferences(BaseActivity.SETTING_INFOS, 0)
                      .getInt(BaseActivity.NEW_MESSAGE_COUNT, 0);
              if (newMessagesCount > 0) { // 有新消息		
                ((TextView) findViewById(R.id.new_message_count)).setText(newMessagesCount + "");
                findViewById(R.id.new_message_count_bg).setVisibility(View.VISIBLE);
              } else {
                findViewById(R.id.new_message_count_bg).setVisibility(View.GONE);
              }
            }
          });
    }
Exemplo n.º 4
0
 public void onBackPressed() {
   ChangeBindCarsActivity.this.finish();
   if (TongGouApplication.getInstance().isLogin()) {
     // 连接obd
     BaseConnectOBDService.addingCar = false;
     Intent intent = new Intent(); // 创建Intent对象
     intent.setAction(TongGouService.TONGGOU_ACTION_START);
     intent.putExtra("com.tonggou.server", "SCAN_OBD");
     sendBroadcast(intent); // 发送广播
   }
 }
Exemplo n.º 5
0
 private void addDevice(BluetoothDevice devs) {
   boolean finded = false;
   for (int i = 0; i < devices.size(); i++) {
     if (devices.get(i).getAddress().equals(devs.getAddress())) {
       finded = true;
     }
   }
   if (!finded
       && (!"".equals(devs.getAddress()) && (!"".equals(devs.getName())))
       && devs.getAddress() != null
       && devs.getName() != null) {
     devices.add(devs);
     if (DEBUG)
       TongGouApplication.showLog(
           "devices added name:" + devs.getName() + " + addr: " + devs.getAddress());
   }
 }
Exemplo n.º 6
0
 public void onResume() {
   super.onResume();
   if (!TongGouApplication.getInstance().isLogin()) {
     // 游客模式没有消息
     findViewById(R.id.new_message_count_bg).setVisibility(View.GONE);
     return;
   }
   int newMessagesCount =
       getSharedPreferences(BaseActivity.SETTING_INFOS, 0)
           .getInt(BaseActivity.NEW_MESSAGE_COUNT, 0);
   if (newMessagesCount > 0) { // 有新消息		
     ((TextView) findViewById(R.id.new_message_count)).setText(newMessagesCount + "");
     findViewById(R.id.new_message_count_bg).setVisibility(View.VISIBLE);
   } else {
     findViewById(R.id.new_message_count_bg).setVisibility(View.GONE);
   }
 }
Exemplo n.º 7
0
  public void deInit() {
    stopScanOBD();
    stopPollingMsg();
    TongGouApplication.showLog("deInit()   @@@@@@@@@@@@@@@@@@@");
    TongGouService.allowPollingMessage = false;
    if (TongGouApplication.sObdLists != null) {
      TongGouApplication.sObdLists.clear();
    }
    MainActivity.haveFaultCode = false;
    setLogin(false);
    getSharedPreferences(BaseActivity.SETTING_INFOS, 0)
        .edit()
        // .putBoolean(BaseActivity.LOGINED, false)
        .putString(BaseActivity.PHONENAME, null)
        .putString(BaseActivity.SERVICE, null)
        .putString(BaseActivity.PHONE, null)
        .putString(BaseActivity.BRAND, null)
        .putString(BaseActivity.MODEL, null)
        .putString(BaseActivity.VEHICLENUM, null)
        .putString(BaseActivity.CHECKVOICE, null)
        .putString(BaseActivity.VEHICLE_MODE_ID, "")
        .putString(BaseActivity.APPCONFIG_OIL_LAST_STATUS, "2")
        .putInt(BaseActivity.NEW_MESSAGE_COUNT, 0)
        .commit();

    CarConditionQueryActivity.ssyhStr = "- -";
    CarConditionQueryActivity.pjyhStr = "- - l/h";
    CarConditionQueryActivity.syylStr = "- -";
    CarConditionQueryActivity.sxwdStr = "- -";
    TongGouApplication.connetedVehicleName = "";
    TongGouApplication.connetedVIN = "";
    TongGouApplication.connetedObdSN = "";
    TongGouApplication.connetedVehicleID = "";
    MainActivity.defaultBrandAndModle = "";
    BaseConnectOBDService.cmile = null;
    sVehicleList = null;
  }
Exemplo n.º 8
0
  /**
   * 发送车况信息
   *
   * @param oilWear 油耗
   * @param currentMileage 里程
   * @param instantOilWear 瞬时油耗
   * @param oilWearPerHundred 百公里油耗
   * @param oilMassStr 油量
   * @param engineCoolantTemperature 发动机冷却液
   * @param batteryVoltage 电瓶电压
   */
  private void sendVehicleCondition(
      String oilWear,
      String currentMileage,
      String instantOilWear,
      String oilWearPerHundred,
      String oilMassStr,
      String engineCoolantTemperature,
      String batteryVoltage) {
    String vehicleVin = TongGouApplication.connetedVIN;
    String userNo =
        getSharedPreferences(BaseActivity.SETTING_INFOS, 0).getString(BaseActivity.NAME, "");
    String obdSN = TongGouApplication.connetedObdSN;
    String vehicleId = TongGouApplication.connetedVehicleID;

    long reportTime = System.currentTimeMillis();

    String oilStr = "";
    if (oilWear != null && !"".equals(oilWear) && !"N/A".equals(oilWear)) {
      oilStr = ",\"oilWear\":" + Double.valueOf(oilWear);
    }
    String currentMilStr = "";
    if (currentMileage != null && !"".equals(currentMileage) && !"N/A".equals(currentMileage)) {
      currentMilStr = ",\"currentMileage\":" + Integer.valueOf(currentMileage);
    }
    String instantOilWearStr = "";
    if (instantOilWear != null && !"".equals(instantOilWear) && !"N/A".equals(instantOilWear)) {
      instantOilWearStr = ",\"instantOilWear\":" + Double.valueOf(instantOilWear);
    }
    String oilWearPerHundredStr = "";
    if (oilWearPerHundred != null
        && !"".equals(oilWearPerHundred)
        && !"N/A".equals(oilWearPerHundred)) {
      oilWearPerHundredStr = ",\"oilWearPerHundred\":" + Double.valueOf(oilWearPerHundred);
    }
    String oilMassStrs = "";
    if (oilMassStr != null && !"%".equals(oilMassStr) && !"N/A%".equals(oilMassStr)) {
      oilMassStrs = ",\"oilMass\":\"" + oilMassStr + "\"";
    }
    String engineCoolantTemStr = "";
    if (engineCoolantTemperature != null
        && !"".equals(engineCoolantTemperature)
        && !"N/A".equals(engineCoolantTemperature)) {
      engineCoolantTemStr =
          ",\"engineCoolantTemperature\":" + Double.valueOf(engineCoolantTemperature);
    }
    String batteryVoltageStr = "";
    if (batteryVoltage != null && !"".equals(batteryVoltage) && !"N/A".equals(batteryVoltage)) {
      batteryVoltageStr = ",\"batteryVoltage\":" + Double.valueOf(batteryVoltage);
    }

    String url = INFO.HTTP_HEAD + INFO.HOST_IP + "/vehicle/condition";
    CommonParser commonParser = new CommonParser();
    long vehicleIdLong = 0;
    try {
      vehicleIdLong = Long.valueOf(vehicleId);
    } catch (NumberFormatException e) {
      TongGouApplication.showLog("车辆 id 没有获取到");
    }
    String valuePairs =
        "{\"vehicleId\":"
            + vehicleIdLong
            + ",\"vehicleVin\":\""
            + vehicleVin
            + "\""
            + ",\"userNo\":\""
            + userNo
            + "\""
            + ",\"obdSN\":\""
            + obdSN
            + "\""
            + oilStr
            + currentMilStr
            + instantOilWearStr
            + oilWearPerHundredStr
            + oilMassStrs
            + engineCoolantTemStr
            + batteryVoltageStr
            + ",\"reportTime\":"
            + reportTime
            + "}";
    TongGouApplication.showLog("发送报告参数:     ---  " + valuePairs);
    Network.getNetwork(this).httpPutUpdateString(url, valuePairs.getBytes(), commonParser);
  }
Exemplo n.º 9
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();
    }
  }
Exemplo n.º 10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.changebindcars);

    // ifAddInterface = false;
    findViewById(R.id.back).setFocusableInTouchMode(true);
    bindcarvehiclevin = (EditText) findViewById(R.id.bindcarvehiclevin); // 车架号
    bindcarengineno = (EditText) findViewById(R.id.bindcarengineno); // 发动机号
    bindcarregistno = (EditText) findViewById(R.id.bindcarregistno); // 登记证书号
    progress = (ProgressBar) findViewById(R.id.shopdetilmappro);
    progress.setVisibility(View.GONE);
    vehicleIdStr = getIntent().getStringExtra("tonggou.veId");
    bindcarnum = (EditText) findViewById(R.id.bindcar_num);
    bindcarmilenow = (EditText) findViewById(R.id.bindcarmilenow);
    bindcarnextmile = (EditText) findViewById(R.id.bindcarnextmile);
    bindcarnexttime = (TextView) findViewById(R.id.bindcarnexttime);
    bindcarnexttime2 = (TextView) findViewById(R.id.bindcarnexttime2);
    mTxtOBDBinded = (TextView) findViewById(R.id.txt_Change_bindcars_OBDBinded);
    mTxtShopBinded = (TextView) findViewById(R.id.txt_Change_bindcars_ShopBinded);

    bindcarnum.setOnKeyListener(
        new OnKeyListener() {
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == 66 && event.getAction() == KeyEvent.ACTION_UP) {
              bindcarvehiclevin.requestFocus();
            }
            return false;
          }
        });

    bindcarvehiclevin.setOnKeyListener(
        new OnKeyListener() {

          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == 66 && event.getAction() == KeyEvent.ACTION_UP) {
              bindcarengineno.requestFocus();
            }
            return false;
          }
        });
    bindcarengineno.setOnKeyListener(
        new OnKeyListener() {
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == 66 && event.getAction() == KeyEvent.ACTION_UP) {
              bindcarregistno.requestFocus();
            }
            return false;
          }
        });
    bindcarregistno.setOnKeyListener(
        new OnKeyListener() {
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == 66 && event.getAction() == KeyEvent.ACTION_UP) {
              bindcarmilenow.requestFocus();
            }
            return false;
          }
        });

    bindcarmilenow.setOnKeyListener(
        new OnKeyListener() {
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == 66 && event.getAction() == KeyEvent.ACTION_UP) {
              bindcarnextmile.requestFocus();
            }
            return false;
          }
        });

    bindcarnum.clearFocus();
    bindcarvehiclevin.clearFocus();
    bindcarengineno.clearFocus();
    bindcarregistno.clearFocus();
    bindcarmilenow.clearFocus();

    bindcar_submit = (TextView) findViewById(R.id.bindcar_submit);
    bindcar_submit.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            vehicleNoStr = bindcarnum.getText().toString().toUpperCase();
            if (!SomeUtil.isVehicleNo(vehicleNoStr)) {
              TongGouApplication.showToast("请输入正确的车牌号");
              return;
            }

            vehicleModelStr = bindcarnum1.getText().toString().trim();
            vehicleBrandStr = bindcarnum2.getText().toString().trim();

            bindcarnextmileStr = bindcarnextmile.getText().toString().trim();
            bindcarcurrentmileStr = bindcarmilenow.getText().toString().trim();
            bindcarnexttimeStr = bindcarnexttime.getText().toString().trim();
            bindcarnexttime2Str = bindcarnexttime2.getText().toString().trim();

            vehicleVinStr = bindcarvehiclevin.getText().toString().trim();
            vehicleEnginNoStr = bindcarengineno.getText().toString().trim();
            vehicleRegistNoStr = bindcarregistno.getText().toString().trim();

            Time localTime = new Time("Asia/Hong_Kong");
            localTime.setToNow();
            long nextInsuranceTimeLong = SomeUtil.StringDateToLong(bindcarnexttimeStr); // 保险时间
            long nowTime =
                SomeUtil.StringDateToLong(localTime.format("%Y-%m-%d %H:%M").toString()); // 保险时间
            long nextExamineTimeLong = SomeUtil.StringDateToLong(bindcarnexttime2Str); // 验车时间

            if (vehicleModelStr == null || "".equals(vehicleModelStr)) {
              Toast.makeText(ChangeBindCarsActivity.this, "请选择车辆品牌", Toast.LENGTH_SHORT).show();
              return;
            }
            if (vehicleBrandStr == null || "".equals(vehicleBrandStr)) {
              Toast.makeText(ChangeBindCarsActivity.this, "请选择车型", Toast.LENGTH_SHORT).show();
              return;
            }

            if (vehicleVinStr != null && !"".equals(vehicleVinStr)) {
              try {
                Integer.parseInt(vehicleVinStr);
                meterOk = true;
              } catch (Exception e) {
                meterOk = false;
              }
            } else {
              meterOk = true;
            }
            if (!TextUtils.isEmpty(vehicleEnginNoStr)) {
              try {
                Integer.parseInt(vehicleEnginNoStr);
                meterOk = true;
              } catch (Exception e) {
                meterOk = false;
              }
            } else {
              meterOk = true;
            }
            if (vehicleRegistNoStr != null && !"".equals(vehicleRegistNoStr)) {
              try {
                Integer.parseInt(vehicleRegistNoStr);
                meterOk = true;
              } catch (Exception e) {
                meterOk = false;
              }
            } else {
              meterOk = true;
            }

            if (bindcarcurrentmileStr != null && !"".equals(bindcarcurrentmileStr)) {
              try {
                Integer.parseInt(bindcarcurrentmileStr);
                meterOk = true;
              } catch (Exception e) {
                meterOk = false;
                Toast.makeText(ChangeBindCarsActivity.this, "当前里程输入不正确", Toast.LENGTH_SHORT).show();
              }
            } else {
              meterOk = true;
            }

            if (meterOk) {
              if (bindcarnextmileStr != null && !"".equals(bindcarnextmileStr)) {
                try {
                  Integer.parseInt(bindcarnextmileStr);
                  meterOk2 = true;
                } catch (Exception e) {
                  meterOk2 = false;
                  Toast.makeText(ChangeBindCarsActivity.this, "下次保养里程输入不正确", Toast.LENGTH_SHORT)
                      .show();
                }
              } else {
                meterOk2 = true;
              }
            }
            if (meterOk && meterOk2) {
              if (bindcarnexttimeStr != null && !"".equals(bindcarnexttimeStr)) {
                if (nextInsuranceTimeLong >= nowTime) {
                  timeOk = true;
                } else {
                  timeOk = false;
                  Toast.makeText(ChangeBindCarsActivity.this, "下次保险的时间不能早于当前时间", Toast.LENGTH_SHORT)
                      .show();
                }

              } else {
                timeOk = true;
              }
            }
            if (timeOk && meterOk && meterOk2) {

              if (bindcarnexttime2Str != null && !"".equals(bindcarnexttime2Str)) {
                if (nextExamineTimeLong >= nowTime) {
                  timeOk2 = true;
                } else {
                  timeOk2 = false;
                  Toast.makeText(ChangeBindCarsActivity.this, "下次验车的时间不能早于当前时间", Toast.LENGTH_SHORT)
                      .show();
                }
              } else {
                timeOk2 = true;
              }
            }

            if (meterOk && meterOk2 && timeOk && timeOk2) {

              TongGouApplication.showLog(
                  "@@@ "
                      + bindcarnexttime.getText().toString()
                      + "   "
                      + bindcarnexttime2.getText().toString());
              mVehicleInfo.setVehicleVin(vehicleVinStr);
              mVehicleInfo.setNextInsuranceTime(
                  "" + SomeUtil.StringDateToLong(bindcarnexttime.getText().toString()));
              mVehicleInfo.setNextExamineTime(
                  "" + SomeUtil.StringDateToLong(bindcarnexttime2.getText().toString()));
              mVehicleInfo.setNextMaintainMileage(bindcarnextmileStr);
              mVehicleInfo.setCurrentMileage(bindcarcurrentmileStr);
              mVehicleInfo.setEngineNo(vehicleEnginNoStr);
              mVehicleInfo.setRegistNo(vehicleRegistNoStr);
              mVehicleInfo.setVehicleBrand(vehicleBrandStr);
              mVehicleInfo.setVehicleModel(vehicleModelStr);
              mVehicleInfo.setVehicleBrandId(vehicleBrandIdStr);
              mVehicleInfo.setVehicleModelId(vehicleModelIdStr);
              mVehicleInfo.setVehicleNo(vehicleNoStr);

              // 判断用户是否登录
              if (!TongGouApplication.getInstance().isLogin()) {

                GuestVehicleManager manager = new GuestVehicleManager();
                if (manager.update(mVehicleInfo)) {
                  Intent intent = new Intent();
                  intent.putExtra("tonggou.isOk", "yes");
                  setResult(Activity.RESULT_OK, intent);
                  finish();
                }
                return;
              }

              if (obdSNStr != null && !"".equals(obdSNStr) && !"null".equals(obdSNStr)) {
                showLoadingDialog("保存中...");
                new Thread() {
                  public void run() {

                    // 停掉连接obd
                    Intent intentS = new Intent();
                    intentS.setAction(TongGouService.TONGGOU_ACTION_START);
                    intentS.putExtra("com.tonggou.server", "STOP");
                    sendBroadcast(intentS);
                  }
                }.start();
                bindObd(
                    vehicleIdStr,
                    vehicleVinStr,
                    vehicleNoStr,
                    vehicleModelStr,
                    vehicleModelIdStr,
                    vehicleBrandStr,
                    vehicleBrandIdStr,
                    obdSNStr,
                    sharedPreferences.getString(BaseActivity.NAME, ""));
              } else {
                updateVehicleInfo(
                    vehicleIdStr,
                    mVehicleInfo.getVehicleVin(),
                    vehicleNoStr,
                    vehicleModelStr,
                    vehicleModelIdStr,
                    vehicleBrandStr,
                    vehicleBrandIdStr,
                    obdSNStr,
                    currentUsername);
              }
            }
          }
        });
    back = findViewById(R.id.left_button);
    back.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            ChangeBindCarsActivity.this.finish();

            // 连接obd
            BaseConnectOBDService.addingCar = false;
            Intent intent = new Intent(); // 创建Intent对象
            intent.setAction(TongGouService.TONGGOU_ACTION_START);
            intent.putExtra("com.tonggou.server", "SCAN_OBD");
            sendBroadcast(intent); // 发送广播
          }
        });
    bindcarnexttime.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(ChangeBindCarsActivity.this);
            View view =
                LayoutInflater.from(ChangeBindCarsActivity.this)
                    .inflate(R.layout.date_time_dialog, null);
            final DatePicker datePicker = (DatePicker) view.findViewById(R.id.date_picker);
            final TimePicker timePicker =
                (android.widget.TimePicker) view.findViewById(R.id.time_picker);

            Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis(System.currentTimeMillis());
            datePicker.init(
                cal.get(Calendar.YEAR),
                cal.get(Calendar.MONTH),
                cal.get(Calendar.DAY_OF_MONTH),
                null);

            timePicker.setIs24HourView(true);
            timePicker.setCurrentHour(cal.get(Calendar.HOUR_OF_DAY));
            timePicker.setCurrentMinute(cal.get(Calendar.MINUTE));
            builder.setView(view);

            builder.setTitle("选取时间");
            builder.setPositiveButton(
                "确  定",
                new DialogInterface.OnClickListener() {

                  @Override
                  public void onClick(DialogInterface dialog, int which) {

                    timePicker.clearFocus();
                    StringBuffer sb = new StringBuffer();
                    sb.append(
                        String.format(
                            "%d-%02d-%02d",
                            datePicker.getYear(),
                            datePicker.getMonth() + 1,
                            datePicker.getDayOfMonth()));
                    sb.append("  ");
                    if (timePicker.getCurrentHour() < 10) {
                      sb.append("0");
                    }
                    sb.append(timePicker.getCurrentHour())
                        .append(":"); // .append(timePicker.getCurrentMinute());
                    if (timePicker.getCurrentMinute() < 10) {
                      sb.append("0");
                    }
                    sb.append(timePicker.getCurrentMinute());

                    bindcarnexttime.setText(sb);
                    // etEndTime.requestFocus();

                    dialog.cancel();
                  }
                });
            Dialog dialog = builder.create();
            dialog.show();
          }
        });
    bindcarnexttime2.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(ChangeBindCarsActivity.this);
            View view =
                LayoutInflater.from(ChangeBindCarsActivity.this)
                    .inflate(R.layout.date_time_dialog, null);
            final DatePicker datePicker = (DatePicker) view.findViewById(R.id.date_picker);
            final TimePicker timePicker =
                (android.widget.TimePicker) view.findViewById(R.id.time_picker);

            Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis(System.currentTimeMillis());
            datePicker.init(
                cal.get(Calendar.YEAR),
                cal.get(Calendar.MONTH),
                cal.get(Calendar.DAY_OF_MONTH),
                null);

            timePicker.setIs24HourView(true);
            timePicker.setCurrentHour(cal.get(Calendar.HOUR_OF_DAY));
            timePicker.setCurrentMinute(cal.get(Calendar.MINUTE));
            builder.setView(view);

            builder.setTitle("选取时间");
            builder.setPositiveButton(
                "确  定",
                new DialogInterface.OnClickListener() {

                  @Override
                  public void onClick(DialogInterface dialog, int which) {

                    timePicker.clearFocus();
                    StringBuffer sb = new StringBuffer();
                    sb.append(
                        String.format(
                            "%d-%02d-%02d",
                            datePicker.getYear(),
                            datePicker.getMonth() + 1,
                            datePicker.getDayOfMonth()));
                    sb.append("  ");
                    if (timePicker.getCurrentHour() < 10) {
                      sb.append("0");
                    }
                    sb.append(timePicker.getCurrentHour()).append(":");
                    if (timePicker.getCurrentMinute() < 10) {
                      sb.append("0");
                    }
                    sb.append(timePicker.getCurrentMinute());

                    bindcarnexttime2.setText(sb);

                    dialog.cancel();
                  }
                });
            Dialog dialog = builder.create();
            dialog.show();
          }
        });
    bindcarnum2 = (TextView) findViewById(R.id.changebindcars_bindcarnum2);
    bindcarnum2.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(ChangeBindCarsActivity.this, AppointmentNetWorkSearch.class);
            intent.putExtra("tonggou.from", "pinpai");
            intent.putExtra("tonggou.pinpai", "");
            startActivityForResult(intent, 1010);
          }
        });
    bindcarnum1 = (TextView) findViewById(R.id.changebindcars_bindcarnum1);
    bindcarnum1.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            if (vehicleBrandIdStr != null && !"".equals(vehicleBrandIdStr)) {
              Intent intent =
                  new Intent(ChangeBindCarsActivity.this, AppointmentNetWorkSearch.class);
              intent.putExtra("tonggou.from", "chexing");
              intent.putExtra("tonggou.pinpai", vehicleBrandIdStr);
              startActivityForResult(intent, 2020);
            } else {
              Toast.makeText(
                      ChangeBindCarsActivity.this,
                      getString(R.string.brand_first),
                      Toast.LENGTH_SHORT)
                  .show();
            }
          }
        });

    // if( mVehicleInfo != null ) {
    // setVehicleInfoValue();
    // } else {

    if (TongGouApplication.getInstance().isLogin()) {
      doQuerySingleVehicleInfo(vehicleIdStr);

    } else { // 若是游客,则从数据看中查询车辆
      GuestVehicleManager manager = new GuestVehicleManager();
      mVehicleInfo = manager.getVehicle(vehicleIdStr);
      setVehicleInfoValue();
    }

    // 停掉连接obd
    BaseConnectOBDService.addingCar = true;
    Intent intentS = new Intent();
    intentS.setAction(TongGouService.TONGGOU_ACTION_START);
    intentS.putExtra("com.tonggou.server", "STOP");
    sendBroadcast(intentS);
  }
Exemplo n.º 11
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);
      }
    }
  }
Exemplo n.º 12
0
  public NetworkState httpPutUpdateString(
      String uri, byte[] valuePairs, JSONParseInterface jsonParser) {
    // 测试代码/////////////////////////////////////////////
    // String jsonData = "[{\"id\":\"22\",\"content\":内容1},{\"id\":\"33\",\"content\":内容2}]";
    // String jsonData = "[{id:22,content:内容1},{id:33,content:内容2}]";
    // jsonParser.parsing(jsonData);    //解析
    ////////////////////////////////////////////////////////
    NetworkState netState = new NetworkState();
    //		if(wapIf()){
    //			uri="http://"+CMWAP_GATEWAY+uri.substring(uri.indexOf("/", 8));
    //		}
    int stateCode;
    HttpPut httpPut = new HttpPut(uri);
    httpPut.setHeader(
        "Accept-Language",
        (Locale.getDefault().getLanguage() + "-" + Locale.getDefault().getCountry()).toLowerCase());
    if (JSESSIONIDStr != null) {
      httpPut.setHeader("Cookie", "JSESSIONID=" + JSESSIONIDStr);
    }
    httpPut.setHeader("Content-Type", "application/json;charset=UTF-8");

    try {
      httpPut.setEntity(new ByteArrayEntity(valuePairs));

      HttpResponse httpResponse = defaultHttpClient.execute(httpPut);
      stateCode = httpResponse.getStatusLine().getStatusCode();
      if (stateCode != 200) {
        netState.setNetworkState(false);
        netState.setErrorMessage(NetworkState.ERROR_SERVER_ERROR_MESSAGE);
        // Log.d("NETT", NetworkState.ERROR_SERVER_ERROR_MESSAGE+":"+stateCode+uri);
        return netState;
      }

      getCookie(defaultHttpClient);

      HttpEntity httpEntity = httpResponse.getEntity();
      InputStream is = null;
      if (httpResponse.getEntity().getContentEncoding() == null
          || httpResponse.getEntity().getContentEncoding().getValue().toLowerCase().indexOf("gzip")
              < 0) {
        is = new ByteArrayInputStream(EntityUtils.toByteArray(httpEntity));
      } else {
        is = new GZIPInputStream(new ByteArrayInputStream(EntityUtils.toByteArray(httpEntity)));
      }

      byte[] con = readInStream(is);
      String str = new String(con);
      if (str != null && str.indexOf("登录过期") != -1 && str.indexOf("-202") != -1) {
        if (appContext instanceof BaseActivity) {
          BaseActivity ba = ((BaseActivity) appContext);
          //////////////////////////////////////
          ba.exit();
          ba.deInit();
          ///////////////////////////////////////
          new Thread() {
            public void run() {
              // 停掉连接obd
              Intent intent = new Intent();
              intent.setAction(TongGouService.TONGGOU_ACTION_START);
              intent.putExtra("com.tonggou.server", "STOP");
              appContext.sendBroadcast(intent);
            }
          }.start();

          Intent toLogin = new Intent(appContext, LoginActivity.class);
          toLogin.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
          toLogin.putExtra("tonggou.loginExpire", "登录过期,请重新登录。");
          appContext.startActivity(toLogin);
        }
      }
      TongGouApplication.showLog(str);
      // Log.d("NETT", str);
      jsonParser.parsing(str); // 解析
      netState.setNetworkState(true);

      return netState;

    } catch (IOException ie) {
      netState.setNetworkState(false);
      ie.printStackTrace();
      if (ie instanceof SocketTimeoutException) {
        if ("en".equals(Locale.getDefault().getLanguage().toLowerCase())) {

          netState.setErrorMessage(NetworkState.ERROR_CLIENT_ERROR_SOCKETTIMEOUT_MESSAGE_EN);
        } else {
          netState.setErrorMessage(NetworkState.ERROR_CLIENT_ERROR_SOCKETTIMEOUT_MESSAGE);
        }
        return netState;
      }
      if ("en".equals(Locale.getDefault().getLanguage().toLowerCase())) {
        netState.setErrorMessage(NetworkState.ERROR_CLIENT_ERROR_TIMEOUT_MESSAGE_EN);
      } else {
        netState.setErrorMessage(NetworkState.ERROR_CLIENT_ERROR_TIMEOUT_MESSAGE);
      }

    } catch (FactoryConfigurationError e) {
      netState.setNetworkState(false);
      netState.setErrorMessage(NetworkState.ERROR_RESPONSE_ERROR_MESSAGE);
    } catch (NullPointerException ex) {
      netState.setNetworkState(false);
      netState.setErrorMessage(NetworkState.ERROR_RESPONSE_ERROR_MESSAGE);
    }
    return netState;
  }
Exemplo n.º 13
0
  public NetworkState httpGetUpdateString(String uri, JSONParseInterface jsonParser) {
    NetworkState netState = new NetworkState();
    int stateCode;
    HttpGet httpGet = new HttpGet(uri);
    TongGouApplication.showLog("url  - " + uri);

    httpGet.setHeader(
        "Accept-Language",
        (Locale.getDefault().getLanguage() + "-" + Locale.getDefault().getCountry()).toLowerCase());
    if (JSESSIONIDStr != null) {
      httpGet.setHeader("Cookie", "JSESSIONID=" + JSESSIONIDStr);
    }
    httpGet.setHeader("Content-Type", "application/json;charset=UTF-8");
    try {

      HttpResponse httpResponse = defaultHttpClient.execute(httpGet);
      stateCode = httpResponse.getStatusLine().getStatusCode();
      if (stateCode != 200) {
        netState.setNetworkState(false);
        netState.setErrorMessage(NetworkState.ERROR_SERVER_ERROR_MESSAGE);
        // Log.d("NETT", NetworkState.ERROR_SERVER_ERROR_MESSAGE+":"+stateCode+uri);
        return netState;
      }

      getCookie(defaultHttpClient);

      HttpEntity httpEntity = httpResponse.getEntity();
      InputStream is = null;
      if (httpResponse.getEntity().getContentEncoding() == null
          || httpResponse.getEntity().getContentEncoding().getValue().toLowerCase().indexOf("gzip")
              < 0) {
        is = new ByteArrayInputStream(EntityUtils.toByteArray(httpEntity));
      } else {
        is = new GZIPInputStream(new ByteArrayInputStream(EntityUtils.toByteArray(httpEntity)));
      }

      byte[] con = readInStream(is);
      String str = new String(con);
      // Log.d("NETT", str+"::::>"+uri);

      if (str != null && str.indexOf("登录过期") != -1 && str.indexOf("-202") != -1) {
        // Log.d("RRRR", "RRRRRRRRRRRRRRRRRRRRRRRR登录过期");
        if (appContext instanceof BaseActivity) {
          BaseActivity ba = ((BaseActivity) appContext);
          //////////////////////////////////////
          ba.exit();
          ba.deInit();
          ///////////////////////////////////////
          new Thread() {
            public void run() {
              // 停掉连接obd
              Intent intent = new Intent();
              intent.setAction(TongGouService.TONGGOU_ACTION_START);
              intent.putExtra("com.tonggou.server", "STOP");
              appContext.sendBroadcast(intent);
            }
          }.start();

          Intent toLogin = new Intent(appContext, LoginActivity.class);
          toLogin.putExtra("tonggou.loginExpire", "登录过期,请重新登录。");
          toLogin.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
          if (!((BaseActivity) appContext).isFinishing()) {
            appContext.startActivity(toLogin);
          }
        }
        /*if(reloging){
        	return netState;
        }
        reloging = true;
        while(!login()){
        	count++;
        	if(count>=5){
        		jsonParser.parsing(str);    //解析
        		netState.setNetworkState(true);
        		count = 0;
        		return netState;
        	}
        }
        reloging = false;
        httpGetUpdateString(uri,jsonParser);*/
      }
      jsonParser.parsing(str); // 解析
      TongGouApplication.showLog("httpPut  - " + str);
      netState.setNetworkState(true);
      return netState;

    } catch (IOException ie) {
      netState.setNetworkState(false);
      ie.printStackTrace();
      if (ie instanceof SocketTimeoutException) {
        if ("en".equals(Locale.getDefault().getLanguage().toLowerCase())) {

          netState.setErrorMessage(NetworkState.ERROR_CLIENT_ERROR_SOCKETTIMEOUT_MESSAGE_EN);
        } else {
          netState.setErrorMessage(NetworkState.ERROR_CLIENT_ERROR_SOCKETTIMEOUT_MESSAGE);
        }
        return netState;
      }
      if ("en".equals(Locale.getDefault().getLanguage().toLowerCase())) {
        netState.setErrorMessage(NetworkState.ERROR_CLIENT_ERROR_TIMEOUT_MESSAGE_EN);
      } else {
        netState.setErrorMessage(NetworkState.ERROR_CLIENT_ERROR_TIMEOUT_MESSAGE);
      }

    } catch (FactoryConfigurationError e) {
      netState.setNetworkState(false);
      netState.setErrorMessage(NetworkState.ERROR_RESPONSE_ERROR_MESSAGE);
    } catch (NullPointerException ex) {
      netState.setNetworkState(false);
      netState.setErrorMessage(NetworkState.ERROR_RESPONSE_ERROR_MESSAGE);
    }
    return netState;
  }