Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions picasso/src/main/java/com/squareup/picasso/BitmapHunter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Copy Markdown
Collaborator Author

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.

this.action = action;
this.priority = (action != null ? action.getPriority() : LOW);
}

@Override public void run() {
Expand Down Expand Up @@ -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.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

redundant null check since we already checked on line 244.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This did not take into consideration action which might be there.

if (actions == null && !hasMultiple) {
if (!hasAny) {
return newPriority;
}

Expand All @@ -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()) {
Expand Down Expand Up @@ -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();

Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down