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(); }
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(); }