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

[feat] Added download progress for NetworkImageNode #1489

Conversation

zhongwuzw
Copy link
Contributor

Currently, seems we don't have any property to observe download progress, it's useful for user who can handle progress things(like progress indicator) by observing download progress.

Copy link
Member

@nguyenhuy nguyenhuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that this can come in handy in many cases. Let's work together to get this through!

@@ -133,6 +133,13 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (readonly) CGFloat renderedImageQuality;

/**
* Loading progress of the current image.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call it "download progress" to be a bit clearer and consistent with PINRemoteImage.

Suggested change
* Loading progress of the current image.
* Download progress of the current image.

@@ -133,6 +133,13 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (readonly) CGFloat renderedImageQuality;

/**
* Loading progress of the current image.
* When downloading a network image, this value would be updated to track downloading progress. ( number between 0.0 and 1.0 )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* When downloading a network image, this value would be updated to track downloading progress. ( number between 0.0 and 1.0 )
* When downloading a network image, this value would be updated to track download progress (value between 0 and 1)

/**
* Loading progress of the current image.
* When downloading a network image, this value would be updated to track downloading progress. ( number between 0.0 and 1.0 )
* If the URL is unset, this is 1.0 if defaultImage or image is set to non-nil.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* If the URL is unset, this is 1.0 if defaultImage or image is set to non-nil.
* If the URL is unset, this is 1 if defaultImage or image is set to non-nil.

Source/ASNetworkImageNode.mm Outdated Show resolved Hide resolved
return ASLockedSelf(_loadingProgress);
}

- (void)_locked_setLoadingProgress:(CGFloat)loadingProgress
Copy link
Member

@nguyenhuy nguyenhuy Jun 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add an explanation why we're dispatching to the main queue here. Something similar to what _setCurrentImageQuality has.

return ASLockedSelf(_loadingProgress);
}

- (void)_locked_setLoadingProgress:(CGFloat)loadingProgress
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- (void)_locked_setLoadingProgress:(CGFloat)loadingProgress
- (void)_setDownloadProgress:(CGFloat)downloadProgress

* When downloading a network image, this value would be updated to track downloading progress. ( number between 0.0 and 1.0 )
* If the URL is unset, this is 1.0 if defaultImage or image is set to non-nil.
*/
@property (readonly) CGFloat loadingProgress;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@property (readonly) CGFloat loadingProgress;
@property (readonly) CGFloat downloadProgress;

@zhongwuzw
Copy link
Contributor Author

@nguyenhuy I renamed to downloadProgress, please review again. :)

if (strongSelf == nil) {
return;
}
[strongSelf _updateDownloadedProgress:progress downloadIdentifier:downloadIdentifier];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bit more concise.

if (strongSelf != nil) {
  [strongSelf _updateDownloadedProgress:progress downloadIdentifier:downloadIdentifier];
}

@@ -768,6 +817,7 @@ - (void)_lazilyLoadImageIfNecessary
UIImage *newImage;
if (imageContainer != nil) {
[strongSelf _setCurrentImageQuality:1.0];
[self _setDownloadProgress:1.0];
Copy link
Member

@nguyenhuy nguyenhuy Jul 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only remaining blocker for this PR!

Suggested change
[self _setDownloadProgress:1.0];
[strongSelf _setDownloadProgress:1.0];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢 Seems I just do the copied. Thanks! 👍

Copy link
Member

@nguyenhuy nguyenhuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now. Thanks for the contribution!

Copy link
Member

@nguyenhuy nguyenhuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will land as soon as you address these last nits.

/**
* Download progress of the current image.
* When downloading a network image, this value would be updated to track download progress (value between 0 and 1)
* If the URL is unset, this is 1 if defaultImage or image is set to non-nil.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the URL is unset, this is 1 if defaultImage or image is set to non-nil.

This line is not true for download progress because the progress should be 0 (set here).

}

/**
* Always use these methods internally to update the current image quality
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Always use these methods internally to update the current image quality
* Always use these methods internally to update the current download progress

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Thanks! 👍

@zhongwuzw
Copy link
Contributor Author

@nguyenhuy Done.

@nguyenhuy nguyenhuy merged commit 9cedd4e into TextureGroup:master Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants