Ignore:
Timestamp:
2017-12-28T03:04:16+01:00 (22 months ago)
Author:
Don-vip
Message:

see #15654 - fix icon flickering (regression from r13250)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r13250 r13252  
    4646import java.util.concurrent.ExecutorService;
    4747import java.util.concurrent.Executors;
     48import java.util.function.Consumer;
    4849import java.util.regex.Matcher;
    4950import java.util.regex.Pattern;
     
    659660     *
    660661     * This method returns immediately and runs the image request asynchronously.
     662     * @param action the action that will deal with the image
    661663     *
    662664     * @return the future of the requested image
    663      * @since 10714
    664      */
    665     public CompletableFuture<ImageIcon> getAsync() {
     665     * @since 13252
     666     */
     667    public CompletableFuture<Void> getAsync(Consumer<? super ImageIcon> action) {
    666668        return isRemote()
    667                 ? CompletableFuture.supplyAsync(this::get, IMAGE_FETCHER)
    668                 : CompletableFuture.completedFuture(get());
     669                ? CompletableFuture.supplyAsync(this::get, IMAGE_FETCHER).thenAcceptAsync(action)
     670                : CompletableFuture.completedFuture(get()).thenAccept(action);
    669671    }
    670672
     
    703705     *
    704706     * This method returns immediately and runs the image request asynchronously.
     707     * @param action the action that will deal with the image
    705708     *
    706709     * @return the future of the requested image
    707      * @since 10714
    708      */
    709     public CompletableFuture<ImageResource> getResourceAsync() {
     710     * @since 13252
     711     */
     712    public CompletableFuture<Void> getResourceAsync(Consumer<? super ImageResource> action) {
    710713        return isRemote()
    711                 ? CompletableFuture.supplyAsync(this::getResource, IMAGE_FETCHER)
    712                 : CompletableFuture.completedFuture(getResource());
     714                ? CompletableFuture.supplyAsync(this::getResource, IMAGE_FETCHER).thenAcceptAsync(action)
     715                : CompletableFuture.completedFuture(getResource()).thenAccept(action);
    713716    }
    714717
Note: See TracChangeset for help on using the changeset viewer.