Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tile image loaders based on Coil. #217
Tile image loaders based on Coil. #217
Changes from all commits
eb4b3c2
0a3d027
0cb0887
06054dc
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the ones returning
Bitmap
to be public? Which cases do we need Bitmaps (vs. ImageResources)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, I originally had them separate. You may do the first part in the suspending method of the tile service, and the conversion at the last minute. Also this form might be useful for other situations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the reason for disabling hardware?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need a Bitmap as a java object, I'll add a comment.
See https://coil-kt.github.io/coil/recipes/#palette
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs better error handling. If the response is
SuccessResult
, the drawable is non-null, but if it's anErrorResult
, this method will just swallow the error and return null. I'd argue an exception is a better idea in the latter case, especially since this is a couroutine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooooffff, this is tough.
I'm not certain about this. ImageRequest has placeholder and error images. If you set an error image you should get that rather than null.
It's also more inline with Coil compose usage. I think null is the right thing here. Even logging this isn't very useful, networks a patchy, you probably have to assume requests fail routinely and decide how to handle it. Logging isn't something you would actually want generally.
I'll add a test for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something, but my understanding is that we're wrapping a method that returns non-null (error/success result object) with one that returns a nullable, that's what I'm finding a bit concerning. But I could be overzealous on just trying to avoid null as much as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but the result is generally the Drawable.
It can be null if it fails and you don't set an error image.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want an exception on ErrorResult, I want the drawable.