Ignore:
Timestamp:
2016-01-16T15:22:13+01:00 (9 years ago)
Author:
floscher
Message:

[mapillary] Fix some minor issues

Location:
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java

    r31983 r31987  
    375375  }
    376376
    377   private void fireSelectedImageChanged(MapillaryAbstractImage oldImage,
    378                                         MapillaryAbstractImage newImage) {
     377  private void fireSelectedImageChanged(MapillaryAbstractImage oldImage, MapillaryAbstractImage newImage) {
    379378    if (this.listeners.isEmpty())
    380379      return;
    381     for (MapillaryDataListener lis : this.listeners)
     380    for (MapillaryDataListener lis : this.listeners) {
    382381      if (lis != null)
    383382        lis.selectedImageChanged(oldImage, newImage);
     383    }
    384384  }
    385385
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryExportAction.java

    r31909 r31987  
    9191    } else if (this.dialog.group.isSelected(this.dialog.rewrite.getModel())) {
    9292      ArrayList<MapillaryImportedImage> images = new ArrayList<>();
    93       for (MapillaryAbstractImage image : MapillaryLayer.getInstance()
    94           .getData().getImages())
     93      for (MapillaryAbstractImage image : MapillaryLayer.getInstance().getData().getImages()) {
    9594        if (image instanceof MapillaryImportedImage) {
    9695          images.add((MapillaryImportedImage) image);
    9796        }
     97      }
    9898      try {
    9999        Main.worker.submit(new Thread(new MapillaryExportManager(images)));
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkThread.java

    r31838 r31987  
    5858      while (!this.end && this.data.getSelectedImage().next() != null) {
    5959        MapillaryAbstractImage image = this.data.getSelectedImage();
    60         if (image instanceof MapillaryImage) {
     60        if (image != null && image.next() instanceof MapillaryImage) {
    6161          // Predownload next 10 thumbnails.
    62           for (int i = 0; i < 10; i++) {
    63             if (image.next() == null) {
    64               break;
    65             }
    66             image = image.next();
    67             CacheUtils.downloadPicture((MapillaryImage) image, CacheUtils.PICTURE.THUMBNAIL);
     62          preDownloadImages((MapillaryImage) image.next(), 10, CacheUtils.PICTURE.THUMBNAIL);
     63          if (this.waitForFullQuality) {
     64            // Start downloading 3 next full images.
     65            preDownloadImages((MapillaryImage) image.next(), 3, CacheUtils.PICTURE.FULL_IMAGE);
    6866          }
    69           if (this.waitForFullQuality)
    70             // Start downloading 3 next full images.
    71             for (int i = 0; i < 3; i++) {
    72               if (image.next() == null) {
    73                 break;
    74               }
    75               image = image.next();
    76               CacheUtils.downloadPicture((MapillaryImage) image, CacheUtils.PICTURE.FULL_IMAGE);
    77             }
    7867        }
    7968        try {
     
    117106    }
    118107    end();
     108  }
     109
     110  /**
     111   * Downloads n images into the cache beginning from the supplied start-image (including the start-image itself).
     112   * @param startImage the image to start with (this and the next n-1 images in the same sequence are downloaded)
     113   * @param n the number of images to download
     114   * @param type the quality of the image (full or thumbnail)
     115   */
     116  private void preDownloadImages(MapillaryImage startImage, int n, CacheUtils.PICTURE type) {
     117    if (n >= 1 && startImage != null) {
     118      CacheUtils.downloadPicture(startImage, type);
     119      if (startImage.next() instanceof MapillaryImage && n >= 2) {
     120        preDownloadImages((MapillaryImage) startImage.next(), n - 1, type);
     121      }
     122    }
    119123  }
    120124
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecord.java

    r31974 r31987  
    122122
    123123  private void fireRecordChanged() {
    124     for (MapillaryRecordListener lis : this.listeners)
     124    for (MapillaryRecordListener lis : this.listeners) {
    125125      if (lis != null)
    126126        lis.recordChanged();
     127    }
    127128  }
    128129
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java

    r31974 r31987  
    2626 *
    2727 */
    28 public class MapillaryDownloader {
     28public final class MapillaryDownloader {
    2929
    3030  /** Possible download modes. */
     
    3939  /** Executor that will run the petitions. */
    4040  private static ThreadPoolExecutor executor = new ThreadPoolExecutor(3, 5, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(100));
     41
     42  private MapillaryDownloader() {
     43    // Private constructor to avoid instantiation
     44  }
    4145
    4246  /**
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthUtils.java

    r31807 r31987  
    1919 *
    2020 */
    21 public class OAuthUtils {
     21public final class OAuthUtils {
     22
     23  private OAuthUtils() {
     24    // Private constructor to avoid instantiation
     25  }
    2226
    2327  /**
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/UploadUtils.java

    r31985 r31987  
    3333import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
    3434import org.apache.http.HttpEntity;
    35 import org.apache.http.HttpResponse;
    36 import org.apache.http.client.HttpClient;
     35import org.apache.http.client.methods.CloseableHttpResponse;
    3736import org.apache.http.client.methods.HttpPost;
    3837import org.apache.http.entity.ContentType;
     
    260259      HttpEntity entity = entityBuilder.build();
    261260      httpPost.setEntity(entity);
    262       HttpResponse response = httpClient.execute(httpPost);
    263 
    264       if (response.getStatusLine().toString().contains("204")) {
    265         PluginState.imageUploaded();
    266         Main.info(PluginState.getUploadString() + " (Mapillary)");
    267       } else {
    268         Main.info("Upload error");
     261      try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
     262        if (response.getStatusLine().toString().contains("204")) {
     263          PluginState.imageUploaded();
     264          Main.info(PluginState.getUploadString() + " (Mapillary)");
     265        } else {
     266          Main.info("Upload error");
     267        }
    269268      }
    270269    }
Note: See TracChangeset for help on using the changeset viewer.