Skip to content

Please create PROGRESS method #656

Closed

Description

@crysan

Hi,

Can you implement a method of progress?
It is necessary to indicate the progress of the html page downloaded.

Thanks

Activity

  1. Stephan972 commented on Aug 22, 2016

    @Stephan972

    Can you please detail what you expect?

  2. crysan commented on Aug 23, 2016

    @crysan
    Author

    Example:

    Document doc = Jsoup.connect("http://example.com")
    .userAgent("Mozilla")
    .timeout(3000)
    .onProgress (long totalBytes, long downlaodedBytes, int progress){
    tada();
    }
    .post();

  3. Stephan972 commented on Aug 23, 2016

    @Stephan972
  4. crysan commented on Aug 23, 2016

    @crysan
    Author

    int progress = 0(%) - 100(%) downloaded

    The code in the example is invalid Java code. Can you adress this?
    I know. Just gave the example of the approximate realization to obtain information about how to download the object.

    What happen if the total size is unknown?
    At the beginning of the boot progress = 0. At the end of progress = 100. The intermediate result is unknown.

  5. Stephan972 commented on Aug 23, 2016

    @Stephan972
  6. jhy commented on Aug 23, 2016

    @jhy
    Owner

    Yes I know what you mean, like in the Android Progress methods. Good idea,
    thanks!

  7. InputNeuron commented on Feb 8, 2017

    @InputNeuron

    It I think this could be implemented by just returning the position of the byte stream every time an element is hit

  8. self-assigned this
    on Jul 5, 2024
  9. added this to the 1.18.1 milestone on Jul 5, 2024
  10. added
    improvement
    on Jul 5, 2024
  11. jhy commented on Jul 5, 2024

    @jhy
    Owner

    OK it took me a little while to get to this. But still, less then a decade!

    Coming with #2164.

    The signature looks like:

    @FunctionalInterface
    public interface Progress<ProgressContext> {
        /**
         Called to report progress. Note that this will be executed by the same thread that is doing the work, so either
         don't take to long, or hand it off to another thread.
         @param processed the number of bytes processed so far.
         @param total the total number of expected bytes, or -1 if unknown.
         @param percent the percentage of completion, 0.0..100.0. If the expected total is unknown, % will remain at zero
         until complete.
         @param context the object that progress was made on.
         */
        void onProgress(int processed, int total, float percent, ProgressContext context);
    }

    So that we can pass a Response in for the context, so you can get the URL, headers etc. And we can also add other progress events, like during parsing, uploads, etc.

  12. linked a pull request that will close this issueAdded a Response progress event interface #2164on Jul 5, 2024
  13. added a commit that references this issue on Jul 5, 2024
    8c8f3f9
  14. crysan commented on Jul 8, 2024

    @crysan
    Author

    Thank you!
    I am very surprised that you have not forgotten about my request, because you have already forgotten about it.
    Yes, this question is also relevant to me.
    Thank you for your hard work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

improvement

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions