Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please create PROGRESS method #656

Closed
crysan opened this issue Nov 16, 2015 · 9 comments · Fixed by #2164
Closed

Please create PROGRESS method #656

crysan opened this issue Nov 16, 2015 · 9 comments · Fixed by #2164
Assignees
Milestone

Comments

@crysan
Copy link

crysan commented Nov 16, 2015

Hi,

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

Thanks

@Stephan972
Copy link

Can you please detail what you expect?

@crysan
Copy link
Author

crysan commented Aug 23, 2016

Example:

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

@Stephan972

This comment was marked as duplicate.

@crysan
Copy link
Author

crysan commented Aug 23, 2016

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.

@Stephan972

This comment was marked as duplicate.

@jhy
Copy link
Owner

jhy commented Aug 23, 2016

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

@burtonator
Copy link

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

@jhy jhy self-assigned this Jul 5, 2024
@jhy jhy added this to the 1.18.1 milestone Jul 5, 2024
@jhy jhy added the improvement label Jul 5, 2024
@jhy
Copy link
Owner

jhy commented Jul 5, 2024

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.

@jhy jhy linked a pull request Jul 5, 2024 that will close this issue
@jhy jhy closed this as completed in #2164 Jul 5, 2024
jhy added a commit that referenced this issue Jul 5, 2024
Added a Response progress event interface

Fixes #656
@crysan
Copy link
Author

crysan commented Jul 8, 2024

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants