Request.java 10.5 KB
package com.squareup.picasso;

import android.graphics.Bitmap.Config;
import android.net.Uri;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;

public final class Request
{
  private static final long d = TimeUnit.SECONDS.toNanos(5L);
  int a;
  long b;
  public int c;
  public final boolean centerCrop;
  public final boolean centerInside;
  public final Bitmap.Config config;
  public final boolean hasRotationPivot;
  public final boolean onlyScaleDown;
  public final Picasso.Priority priority;
  public final int resourceId;
  public final float rotationDegrees;
  public final float rotationPivotX;
  public final float rotationPivotY;
  public final String stableKey;
  public final int targetHeight;
  public final int targetWidth;
  public final List<Transformation> transformations;
  public final Uri uri;
  
  private Request(Uri paramUri, int paramInt1, String paramString, List<Transformation> paramList, int paramInt2, int paramInt3, boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3, float paramFloat1, float paramFloat2, float paramFloat3, boolean paramBoolean4, Bitmap.Config paramConfig, Picasso.Priority paramPriority)
  {
    this.uri = paramUri;
    this.resourceId = paramInt1;
    this.stableKey = paramString;
    if (paramList == null) {}
    for (this.transformations = null;; this.transformations = Collections.unmodifiableList(paramList))
    {
      this.targetWidth = paramInt2;
      this.targetHeight = paramInt3;
      this.centerCrop = paramBoolean1;
      this.centerInside = paramBoolean2;
      this.onlyScaleDown = paramBoolean3;
      this.rotationDegrees = paramFloat1;
      this.rotationPivotX = paramFloat2;
      this.rotationPivotY = paramFloat3;
      this.hasRotationPivot = paramBoolean4;
      this.config = paramConfig;
      this.priority = paramPriority;
      return;
    }
  }
  
  public final String a()
  {
    long l = System.nanoTime() - this.b;
    if (l > d) {
      return b() + '+' + TimeUnit.NANOSECONDS.toSeconds(l) + 's';
    }
    return b() + '+' + TimeUnit.NANOSECONDS.toMillis(l) + "ms";
  }
  
  final String b()
  {
    return "[R" + this.a + ']';
  }
  
  public final Builder buildUpon()
  {
    return new Builder(this, (byte)0);
  }
  
  public final boolean c()
  {
    return (hasSize()) || (this.rotationDegrees != 0.0F);
  }
  
  public final boolean d()
  {
    return this.transformations != null;
  }
  
  public final boolean hasSize()
  {
    return (this.targetWidth != 0) || (this.targetHeight != 0);
  }
  
  public final String toString()
  {
    StringBuilder localStringBuilder = new StringBuilder("Request{");
    if (this.resourceId > 0) {
      localStringBuilder.append(this.resourceId);
    }
    while ((this.transformations != null) && (!this.transformations.isEmpty()))
    {
      Iterator localIterator = this.transformations.iterator();
      while (localIterator.hasNext())
      {
        Transformation localTransformation = (Transformation)localIterator.next();
        localStringBuilder.append(' ').append(localTransformation.key());
      }
      localStringBuilder.append(this.uri);
    }
    if (this.stableKey != null) {
      localStringBuilder.append(" stableKey(").append(this.stableKey).append(')');
    }
    if (this.targetWidth > 0) {
      localStringBuilder.append(" resize(").append(this.targetWidth).append(',').append(this.targetHeight).append(')');
    }
    if (this.centerCrop) {
      localStringBuilder.append(" centerCrop");
    }
    if (this.centerInside) {
      localStringBuilder.append(" centerInside");
    }
    if (this.rotationDegrees != 0.0F)
    {
      localStringBuilder.append(" rotation(").append(this.rotationDegrees);
      if (this.hasRotationPivot) {
        localStringBuilder.append(" @ ").append(this.rotationPivotX).append(',').append(this.rotationPivotY);
      }
      localStringBuilder.append(')');
    }
    if (this.config != null) {
      localStringBuilder.append(' ').append(this.config);
    }
    localStringBuilder.append('}');
    return localStringBuilder.toString();
  }
  
  public static final class Builder
  {
    int a;
    int b;
    Picasso.Priority c;
    private Uri d;
    private int e;
    private String f;
    private boolean g;
    private boolean h;
    private boolean i;
    private float j;
    private float k;
    private float l;
    private boolean m;
    private List<Transformation> n;
    private Bitmap.Config o;
    
    public Builder(int paramInt)
    {
      setResourceId(paramInt);
    }
    
    public Builder(Uri paramUri)
    {
      setUri(paramUri);
    }
    
    Builder(Uri paramUri, int paramInt, Bitmap.Config paramConfig)
    {
      this.d = paramUri;
      this.e = paramInt;
      this.o = paramConfig;
    }
    
    private Builder(Request paramRequest)
    {
      this.d = paramRequest.uri;
      this.e = paramRequest.resourceId;
      this.f = paramRequest.stableKey;
      this.a = paramRequest.targetWidth;
      this.b = paramRequest.targetHeight;
      this.g = paramRequest.centerCrop;
      this.h = paramRequest.centerInside;
      this.j = paramRequest.rotationDegrees;
      this.k = paramRequest.rotationPivotX;
      this.l = paramRequest.rotationPivotY;
      this.m = paramRequest.hasRotationPivot;
      this.i = paramRequest.onlyScaleDown;
      if (paramRequest.transformations != null) {
        this.n = new ArrayList(paramRequest.transformations);
      }
      this.o = paramRequest.config;
      this.c = paramRequest.priority;
    }
    
    final boolean a()
    {
      return (this.d != null) || (this.e != 0);
    }
    
    public final Request build()
    {
      if ((this.h) && (this.g)) {
        throw new IllegalStateException("Center crop and center inside can not be used together.");
      }
      if ((this.g) && (this.a == 0) && (this.b == 0)) {
        throw new IllegalStateException("Center crop requires calling resize with positive width and height.");
      }
      if ((this.h) && (this.a == 0) && (this.b == 0)) {
        throw new IllegalStateException("Center inside requires calling resize with positive width and height.");
      }
      if (this.c == null) {
        this.c = Picasso.Priority.NORMAL;
      }
      return new Request(this.d, this.e, this.f, this.n, this.a, this.b, this.g, this.h, this.i, this.j, this.k, this.l, this.m, this.o, this.c, (byte)0);
    }
    
    public final Builder centerCrop()
    {
      if (this.h) {
        throw new IllegalStateException("Center crop can not be used after calling centerInside");
      }
      this.g = true;
      return this;
    }
    
    public final Builder centerInside()
    {
      if (this.g) {
        throw new IllegalStateException("Center inside can not be used after calling centerCrop");
      }
      this.h = true;
      return this;
    }
    
    public final Builder clearCenterCrop()
    {
      this.g = false;
      return this;
    }
    
    public final Builder clearCenterInside()
    {
      this.h = false;
      return this;
    }
    
    public final Builder clearOnlyScaleDown()
    {
      this.i = false;
      return this;
    }
    
    public final Builder clearResize()
    {
      this.a = 0;
      this.b = 0;
      this.g = false;
      this.h = false;
      return this;
    }
    
    public final Builder clearRotation()
    {
      this.j = 0.0F;
      this.k = 0.0F;
      this.l = 0.0F;
      this.m = false;
      return this;
    }
    
    public final Builder config(Bitmap.Config paramConfig)
    {
      this.o = paramConfig;
      return this;
    }
    
    public final Builder onlyScaleDown()
    {
      if ((this.b == 0) && (this.a == 0)) {
        throw new IllegalStateException("onlyScaleDown can not be applied without resize");
      }
      this.i = true;
      return this;
    }
    
    public final Builder priority(Picasso.Priority paramPriority)
    {
      if (paramPriority == null) {
        throw new IllegalArgumentException("Priority invalid.");
      }
      if (this.c != null) {
        throw new IllegalStateException("Priority already set.");
      }
      this.c = paramPriority;
      return this;
    }
    
    public final Builder resize(int paramInt1, int paramInt2)
    {
      if (paramInt1 < 0) {
        throw new IllegalArgumentException("Width must be positive number or 0.");
      }
      if (paramInt2 < 0) {
        throw new IllegalArgumentException("Height must be positive number or 0.");
      }
      if ((paramInt2 == 0) && (paramInt1 == 0)) {
        throw new IllegalArgumentException("At least one dimension has to be positive number.");
      }
      this.a = paramInt1;
      this.b = paramInt2;
      return this;
    }
    
    public final Builder rotate(float paramFloat)
    {
      this.j = paramFloat;
      return this;
    }
    
    public final Builder rotate(float paramFloat1, float paramFloat2, float paramFloat3)
    {
      this.j = paramFloat1;
      this.k = paramFloat2;
      this.l = paramFloat3;
      this.m = true;
      return this;
    }
    
    public final Builder setResourceId(int paramInt)
    {
      if (paramInt == 0) {
        throw new IllegalArgumentException("Image resource ID may not be 0.");
      }
      this.e = paramInt;
      this.d = null;
      return this;
    }
    
    public final Builder setUri(Uri paramUri)
    {
      if (paramUri == null) {
        throw new IllegalArgumentException("Image URI may not be null.");
      }
      this.d = paramUri;
      this.e = 0;
      return this;
    }
    
    public final Builder stableKey(String paramString)
    {
      this.f = paramString;
      return this;
    }
    
    public final Builder transform(Transformation paramTransformation)
    {
      if (paramTransformation == null) {
        throw new IllegalArgumentException("Transformation must not be null.");
      }
      if (paramTransformation.key() == null) {
        throw new IllegalArgumentException("Transformation key must not be null.");
      }
      if (this.n == null) {
        this.n = new ArrayList(2);
      }
      this.n.add(paramTransformation);
      return this;
    }
    
    public final Builder transform(List<? extends Transformation> paramList)
    {
      if (paramList == null) {
        throw new IllegalArgumentException("Transformation list must not be null.");
      }
      int i2 = paramList.size();
      int i1 = 0;
      while (i1 < i2)
      {
        transform((Transformation)paramList.get(i1));
        i1 += 1;
      }
      return this;
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/picasso/Request.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */