gv.java 8.54 KB
import android.annotation.TargetApi;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.Path.FillType;
import android.graphics.RadialGradient;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.Drawable;
import android.support.annotation.RequiresApi;
import android.support.v7.cardview.R.color;
import android.support.v7.cardview.R.dimen;

@TargetApi(9)
@RequiresApi(9)
final class gv
  extends Drawable
{
  static final double a = Math.cos(Math.toRadians(45.0D));
  static gv.a c;
  final int b;
  Paint d;
  Paint e;
  Paint f;
  final RectF g;
  float h;
  Path i;
  float j;
  float k;
  float l;
  float m;
  ColorStateList n;
  boolean o = true;
  private final int p;
  private final int q;
  private boolean r = true;
  private boolean s = false;
  
  gv(Resources paramResources, ColorStateList paramColorStateList, float paramFloat1, float paramFloat2, float paramFloat3)
  {
    this.p = paramResources.getColor(R.color.cardview_shadow_start_color);
    this.q = paramResources.getColor(R.color.cardview_shadow_end_color);
    this.b = paramResources.getDimensionPixelSize(R.dimen.cardview_compat_inset_shadow);
    this.d = new Paint(5);
    a(paramColorStateList);
    this.e = new Paint(5);
    this.e.setStyle(Paint.Style.FILL);
    this.h = ((int)(0.5F + paramFloat1));
    this.g = new RectF();
    this.f = new Paint(this.e);
    this.f.setAntiAlias(false);
    a(paramFloat2, paramFloat3);
  }
  
  static float a(float paramFloat1, float paramFloat2, boolean paramBoolean)
  {
    if (paramBoolean) {
      return (float)(1.5F * paramFloat1 + (1.0D - a) * paramFloat2);
    }
    return 1.5F * paramFloat1;
  }
  
  private static int a(float paramFloat)
  {
    int i2 = (int)(0.5F + paramFloat);
    int i1 = i2;
    if (i2 % 2 == 1) {
      i1 = i2 - 1;
    }
    return i1;
  }
  
  static float b(float paramFloat1, float paramFloat2, boolean paramBoolean)
  {
    float f1 = paramFloat1;
    if (paramBoolean) {
      f1 = (float)(paramFloat1 + (1.0D - a) * paramFloat2);
    }
    return f1;
  }
  
  final void a(float paramFloat1, float paramFloat2)
  {
    if (paramFloat1 < 0.0F) {
      throw new IllegalArgumentException("Invalid shadow size " + paramFloat1 + ". Must be >= 0");
    }
    if (paramFloat2 < 0.0F) {
      throw new IllegalArgumentException("Invalid max shadow size " + paramFloat2 + ". Must be >= 0");
    }
    float f1 = a(paramFloat1);
    paramFloat2 = a(paramFloat2);
    paramFloat1 = f1;
    if (f1 > paramFloat2)
    {
      if (!this.s) {
        this.s = true;
      }
      paramFloat1 = paramFloat2;
    }
    if ((this.m == paramFloat1) && (this.k == paramFloat2)) {
      return;
    }
    this.m = paramFloat1;
    this.k = paramFloat2;
    this.l = ((int)(paramFloat1 * 1.5F + this.b + 0.5F));
    this.j = (this.b + paramFloat2);
    this.o = true;
    invalidateSelf();
  }
  
  final void a(ColorStateList paramColorStateList)
  {
    ColorStateList localColorStateList = paramColorStateList;
    if (paramColorStateList == null) {
      localColorStateList = ColorStateList.valueOf(0);
    }
    this.n = localColorStateList;
    this.d.setColor(this.n.getColorForState(getState(), this.n.getDefaultColor()));
  }
  
  public final void a(boolean paramBoolean)
  {
    this.r = paramBoolean;
    invalidateSelf();
  }
  
  public final void draw(Canvas paramCanvas)
  {
    int i2 = 1;
    float f1;
    float f2;
    float f3;
    int i1;
    int i3;
    float f4;
    if (this.o)
    {
      Object localObject1 = getBounds();
      f1 = this.k * 1.5F;
      this.g.set(((Rect)localObject1).left + this.k, ((Rect)localObject1).top + f1, ((Rect)localObject1).right - this.k, ((Rect)localObject1).bottom - f1);
      localObject1 = new RectF(-this.h, -this.h, this.h, this.h);
      Object localObject2 = new RectF((RectF)localObject1);
      ((RectF)localObject2).inset(-this.l, -this.l);
      if (this.i == null)
      {
        this.i = new Path();
        this.i.setFillType(Path.FillType.EVEN_ODD);
        this.i.moveTo(-this.h, 0.0F);
        this.i.rLineTo(-this.l, 0.0F);
        this.i.arcTo((RectF)localObject2, 180.0F, 90.0F, false);
        this.i.arcTo((RectF)localObject1, 270.0F, -90.0F, false);
        this.i.close();
        f1 = this.h / (this.h + this.l);
        localObject1 = this.e;
        f2 = this.h;
        f3 = this.l;
        i1 = this.p;
        i3 = this.p;
        int i4 = this.q;
        localObject2 = Shader.TileMode.CLAMP;
        ((Paint)localObject1).setShader(new RadialGradient(0.0F, 0.0F, f2 + f3, new int[] { i1, i3, i4 }, new float[] { 0.0F, f1, 1.0F }, (Shader.TileMode)localObject2));
        localObject1 = this.f;
        f1 = -this.h;
        f2 = this.l;
        f3 = -this.h;
        f4 = this.l;
        i1 = this.p;
        i3 = this.p;
        i4 = this.q;
        localObject2 = Shader.TileMode.CLAMP;
        ((Paint)localObject1).setShader(new LinearGradient(0.0F, f1 + f2, 0.0F, f3 - f4, new int[] { i1, i3, i4 }, new float[] { 0.0F, 0.5F, 1.0F }, (Shader.TileMode)localObject2));
        this.f.setAntiAlias(false);
        this.o = false;
      }
    }
    else
    {
      paramCanvas.translate(0.0F, this.m / 2.0F);
      f1 = -this.h - this.l;
      f2 = this.h + this.b + this.m / 2.0F;
      if (this.g.width() - 2.0F * f2 <= 0.0F) {
        break label906;
      }
      i1 = 1;
      label506:
      if (this.g.height() - 2.0F * f2 <= 0.0F) {
        break label912;
      }
    }
    for (;;)
    {
      i3 = paramCanvas.save();
      paramCanvas.translate(this.g.left + f2, this.g.top + f2);
      paramCanvas.drawPath(this.i, this.e);
      if (i1 != 0) {
        paramCanvas.drawRect(0.0F, f1, this.g.width() - 2.0F * f2, -this.h, this.f);
      }
      paramCanvas.restoreToCount(i3);
      i3 = paramCanvas.save();
      paramCanvas.translate(this.g.right - f2, this.g.bottom - f2);
      paramCanvas.rotate(180.0F);
      paramCanvas.drawPath(this.i, this.e);
      if (i1 != 0)
      {
        f3 = this.g.width();
        f4 = -this.h;
        paramCanvas.drawRect(0.0F, f1, f3 - 2.0F * f2, this.l + f4, this.f);
      }
      paramCanvas.restoreToCount(i3);
      i1 = paramCanvas.save();
      paramCanvas.translate(this.g.left + f2, this.g.bottom - f2);
      paramCanvas.rotate(270.0F);
      paramCanvas.drawPath(this.i, this.e);
      if (i2 != 0) {
        paramCanvas.drawRect(0.0F, f1, this.g.height() - 2.0F * f2, -this.h, this.f);
      }
      paramCanvas.restoreToCount(i1);
      i1 = paramCanvas.save();
      paramCanvas.translate(this.g.right - f2, this.g.top + f2);
      paramCanvas.rotate(90.0F);
      paramCanvas.drawPath(this.i, this.e);
      if (i2 != 0) {
        paramCanvas.drawRect(0.0F, f1, this.g.height() - 2.0F * f2, -this.h, this.f);
      }
      paramCanvas.restoreToCount(i1);
      paramCanvas.translate(0.0F, -this.m / 2.0F);
      c.a(paramCanvas, this.g, this.h, this.d);
      return;
      this.i.reset();
      break;
      label906:
      i1 = 0;
      break label506;
      label912:
      i2 = 0;
    }
  }
  
  public final int getOpacity()
  {
    return -3;
  }
  
  public final boolean getPadding(Rect paramRect)
  {
    int i1 = (int)Math.ceil(a(this.k, this.h, this.r));
    int i2 = (int)Math.ceil(b(this.k, this.h, this.r));
    paramRect.set(i2, i1, i2, i1);
    return true;
  }
  
  public final boolean isStateful()
  {
    return ((this.n != null) && (this.n.isStateful())) || (super.isStateful());
  }
  
  protected final void onBoundsChange(Rect paramRect)
  {
    super.onBoundsChange(paramRect);
    this.o = true;
  }
  
  protected final boolean onStateChange(int[] paramArrayOfInt)
  {
    int i1 = this.n.getColorForState(paramArrayOfInt, this.n.getDefaultColor());
    if (this.d.getColor() == i1) {
      return false;
    }
    this.d.setColor(i1);
    this.o = true;
    invalidateSelf();
    return true;
  }
  
  public final void setAlpha(int paramInt)
  {
    this.d.setAlpha(paramInt);
    this.e.setAlpha(paramInt);
    this.f.setAlpha(paramInt);
  }
  
  public final void setColorFilter(ColorFilter paramColorFilter)
  {
    this.d.setColorFilter(paramColorFilter);
  }
  
  static abstract interface a
  {
    public abstract void a(Canvas paramCanvas, RectF paramRectF, float paramFloat, Paint paramPaint);
  }
}


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