コード例 #1
0
  private void renameFile(File oldFile, PictureFile pictureFile, String newGeoname) {

    pictureFile.setGeo_name(newGeoname);

    Double lat = pictureFile.getLat();
    Double lon = pictureFile.getLon();
    String geoname = newGeoname;
    Long time = pictureFile.getTime();

    String oldPath = pictureFile.getFull_path_on_device();
    int indexForSlash = oldPath.lastIndexOf("/");
    String parentPath = oldPath.substring(0, indexForSlash + 1);
    String timestamp = StorageHelper.formatTimeForFilename(time);
    String location = StorageHelper.formatLatLonGeoname(lat, lon, geoname);
    String username = daoHelper.getUserName();
    String newName = StorageHelper.formatFilename(username, location, timestamp);
    String newPath = parentPath + newName;

    pictureFile.setFilename(newName);
    pictureFile.setFull_path_on_device(newPath);

    File newFile = new File(newPath);
    oldFile.renameTo(newFile);

    Log.w(LOG_TAG, "Renamed " + oldPath + " to " + newPath);

    daoHelper.pictureFileDao.update(pictureFile);
    daoHelper.onPictureFilesUpdated();
  }
コード例 #2
0
  private String retrieveGeoName(PictureFile pictureFile) throws IOException {
    Log.w(LOG_TAG, "start retrieve geoname for pictureFile " + pictureFile.getFilename());

    String address = null;

    Context context = getApplicationContext();
    LocationHelper locationHelper = LocationHelper.getInstatce(context);
    address = locationHelper.getAddressFromLocationSync(pictureFile.getLat(), pictureFile.getLon());
    Log.w(LOG_TAG, "finish retrieve geoname for pictureFile " + pictureFile.getFilename());
    return address;
  }