Ignore:
Timestamp:
2015-08-11T15:43:11+02:00 (10 years ago)
Author:
nokutu
Message:

Fixed bug related to progress numbers during upload and added unit test for PluginState class

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

Legend:

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

    r31475 r31482  
    176176      }
    177177      this.ex.shutdown();
    178       PluginState.finishUpload();
    179178    }
    180179  }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/PluginState.java

    r31474 r31482  
    1818  private static int runningDownloads = 0;
    1919  /** Images that have to be uploaded. */
    20   public static int imagesToUpload = 0;
     20  protected static int imagesToUpload = 0;
    2121  /** Images that have been uploaded. */
    2222  public static int imagesUploaded = 0;
     
    3333   */
    3434  public static void finishDownload() {
     35    if (runningDownloads == 0)
     36      throw new IllegalStateException(
     37          "The amount of running downlaods is less or equals to 0");
    3538    runningDownloads--;
    3639  }
     
    4346  public static boolean isDownloading() {
    4447    return runningDownloads > 0;
    45   }
    46 
    47   /**
    48    * Called when an upload is finished.
    49    */
    50   public static void finishUpload() {
    51     if (imagesUploaded >= imagesToUpload) {
    52       imagesUploaded = 0;
    53       imagesToUpload = 0;
    54     }
    5548  }
    5649
     
    7164   */
    7265  public static void imagesToUpload(int amount) {
     66    if (imagesToUpload <= imagesUploaded) {
     67      imagesToUpload = 0;
     68      imagesUploaded = 0;
     69    }
    7370    imagesToUpload += amount;
    7471  }
     
    8077    imagesUploaded++;
    8178    if (imagesToUpload == imagesUploaded) {
    82       finishedUploadDialog();
     79      if (Main.main != null)
     80        finishedUploadDialog();
    8381    }
    8482  }
Note: See TracChangeset for help on using the changeset viewer.