-
Notifications
You must be signed in to change notification settings - Fork 4k
Remove bitmap hunter warnings and unneccesary checks #720
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,19 +85,19 @@ class BitmapHunter implements Runnable { | |
| Priority priority; | ||
|
|
||
| BitmapHunter(Picasso picasso, Dispatcher dispatcher, Cache cache, Stats stats, Action action, | ||
| RequestHandler requestHandler) { | ||
| RequestHandler requestHandler) { | ||
| this.sequence = SEQUENCE_GENERATOR.incrementAndGet(); | ||
| this.picasso = picasso; | ||
| this.dispatcher = dispatcher; | ||
| this.cache = cache; | ||
| this.stats = stats; | ||
| this.action = action; | ||
| this.key = action.getKey(); | ||
| this.data = action.getRequest(); | ||
| this.priority = action.getPriority(); | ||
| this.skipMemoryCache = action.skipCache; | ||
| this.requestHandler = requestHandler; | ||
| this.retryCount = requestHandler.getRetryCount(); | ||
| this.action = action; | ||
| this.priority = (action != null ? action.getPriority() : LOW); | ||
| } | ||
|
|
||
| @Override public void run() { | ||
|
|
@@ -242,9 +242,10 @@ private Priority computeNewPriority() { | |
| Priority newPriority = LOW; | ||
|
|
||
| boolean hasMultiple = actions != null && !actions.isEmpty(); | ||
| boolean hasAny = action != null || hasMultiple; | ||
|
|
||
| // Hunter has no requests, low priority. | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. redundant null check since we already checked on line 244.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This did not take into consideration |
||
| if (actions == null && !hasMultiple) { | ||
| if (!hasAny) { | ||
| return newPriority; | ||
| } | ||
|
|
||
|
|
@@ -253,6 +254,7 @@ private Priority computeNewPriority() { | |
| } | ||
|
|
||
| if (hasMultiple) { | ||
| //noinspection ForLoopReplaceableByForEach | ||
| for (int i = 0, n = actions.size(); i < n; i++) { | ||
| Priority actionPriority = actions.get(i).getPriority(); | ||
| if (actionPriority.ordinal() > newPriority.ordinal()) { | ||
|
|
@@ -338,8 +340,8 @@ static void updateThreadName(Request data) { | |
| Thread.currentThread().setName(builder.toString()); | ||
| } | ||
|
|
||
| static BitmapHunter forRequest(Picasso picasso, Dispatcher dispatcher, | ||
| Cache cache, Stats stats, Action action) { | ||
| static BitmapHunter forRequest(Picasso picasso, Dispatcher dispatcher, Cache cache, Stats stats, | ||
| Action action) { | ||
| Request request = action.getRequest(); | ||
| List<RequestHandler> requestHandlers = picasso.getRequestHandlers(); | ||
|
|
||
|
|
@@ -364,9 +366,8 @@ static Bitmap applyCustomTransformations(List<Transformation> transformations, B | |
| } catch (final RuntimeException e) { | ||
| Picasso.HANDLER.post(new Runnable() { | ||
| @Override public void run() { | ||
| throw new RuntimeException("Transformation " | ||
| + transformation.key() | ||
| + " crashed with exception.", e); | ||
| throw new RuntimeException( | ||
| "Transformation " + transformation.key() + " crashed with exception.", e); | ||
| } | ||
| }); | ||
| return null; | ||
|
|
@@ -468,10 +469,10 @@ static Bitmap transformResult(Request data, Bitmap result, int exifRotation) { | |
| // If an explicit target size has been specified and they do not match the results bounds, | ||
| // pre-scale the existing matrix appropriately. | ||
| // Keep aspect ratio if one dimension is set to 0. | ||
| float sx = targetWidth != 0 ? targetWidth / (float) inWidth | ||
| : targetHeight / (float) inHeight; | ||
| float sy = targetHeight != 0 ? targetHeight / (float) inHeight | ||
| : targetWidth / (float) inWidth; | ||
| float sx = | ||
| targetWidth != 0 ? targetWidth / (float) inWidth : targetHeight / (float) inHeight; | ||
| float sy = | ||
| targetHeight != 0 ? targetHeight / (float) inHeight : targetWidth / (float) inWidth; | ||
| matrix.preScale(sx, sy); | ||
| } | ||
| } | ||
|
|
||
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.
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.
action cannot be null here according to IJ.