Пример #1
0
  private void onLocationFirstReceived() {
    mDJDatabase.clearSamplePoints();
    mCurrDrivingJournal = new DrivingJournalItem();
    mCurrDrivingJournal.setAppDriveLogId(
        UUID.randomUUID().toString().toUpperCase(Locale.getDefault()));
    mCurrDrivingJournal.setAppUserNo(mPreferences.getString(BaseActivity.NAME, ""));
    mCurrDrivingJournal.setAppPlatform(INFO.MOBILE_PLATFORM);
    mCurrDrivingJournal.setVehicleNo(mPreferences.getString(BaseActivity.VEHICLENUM, ""));
    mCurrDrivingJournal.setStartTime(System.currentTimeMillis());
    mCurrDrivingJournal.setStartLat(mCurrBDLocation.getLatitude() + "");
    mCurrDrivingJournal.setStartLon(mCurrBDLocation.getLongitude() + "");
    mCurrDrivingJournal.setStartPlace(mCurrBDLocation.getAddrStr());
    mCurrDrivingJournal.setOilKind(mPreferences.getString(BaseActivity.EXTRA_DEFAUL_TOIL_KIND, ""));

    startRecord();
  }
Пример #2
0
  private void sendToUpdateCC(Intent intent) {
    mVoltage = intent.getStringExtra(BaseConnectOBDService.EXTRA_BATTERY_VOLTAGE);
    mTemperature = intent.getStringExtra(BaseConnectOBDService.EXTRA_OIL_TANK_TEMPERATURE);
    mOnRoadTime = System.currentTimeMillis() - mCurrDrivingJournal.getStartTime();
    mOnRoadDistance =
        SomeUtil.fmtDouble(intent.getStringExtra(BaseConnectOBDService.EXTRA_TOTAL_DISTANCE))
            - mStartDistance;
    mAvgOilWear =
        SomeUtil.fmtDouble(intent.getStringExtra(BaseConnectOBDService.EXTRA_AVG_OIL_WEAR));

    Intent broadCast = new Intent(ACTION_UPDATE_VEHICLE_CONDITION);
    broadCast.putExtra(EXTRA_CURR_BATTERY_VOLTAGE, mVoltage);
    broadCast.putExtra(EXTRA_CURR_TANK_TEMPERATURE, mTemperature);
    broadCast.putExtra(EXTRA_CURR_AVG_OIL_WEAR, SomeUtil.doubleToString(mAvgOilWear));
    broadCast.putExtra(EXTRA_CURR_ON_ROAD_DISTANCE, SomeUtil.doubleToString(mOnRoadDistance));
    broadCast.putExtra(EXTRA_CURR_ON_ROAD_TIME, mOnRoadTime);
    sendBroadcast(broadCast);

    saveCC();
  }
Пример #3
0
  private void onActionStopReceived() {
    stopRecord();
    ArrayList<SamplePoint> samplePonitList = mDJDatabase.querySPList();
    if (mOnRoadDistance >= 1d) {
      mDJDatabase.clearSamplePoints();
      return;
    } else {
      mCurrDrivingJournal.setPlaceNotes(SomeUtil.getStrSamplePoints(samplePonitList));
    }
    mCurrDrivingJournal.setEndTime(System.currentTimeMillis());
    mCurrDrivingJournal.setEndLat(mCurrBDLocation.getLatitude() + "");
    mCurrDrivingJournal.setEndLon(mCurrBDLocation.getLongitude() + "");
    mCurrDrivingJournal.setEndPlace(mCurrBDLocation.getAddrStr());
    mCurrDrivingJournal.setTravelTime(
        mCurrDrivingJournal.getEndTime() - mCurrDrivingJournal.getStartTime());
    mCurrDrivingJournal.setDistance(mOnRoadDistance);
    double oilPrice =
        SomeUtil.stringToDouble(mPreferences.getString(BaseActivity.EXTRA_DEFAULT_OIL_PRICE, ""));
    mCurrDrivingJournal.setOilPrice(oilPrice);
    mCurrDrivingJournal.setOilWear(mAvgOilWear);
    mCurrDrivingJournal.setTotalOilMoney(getOilCost(oilPrice));
    mCurrDrivingJournal.setStatus(DrivingJournalStatus.NOT_UPLOAD.toString());
    mCurrDrivingJournal.setLastUpdateTime(System.currentTimeMillis());
    mDJDatabase.insertDJItem(mCurrDrivingJournal);
    mDJDatabase.clearSamplePoints();

    saveCC();
  }