package com.google.android.m4b.maps.b;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import com.google.android.m4b.maps.a.h;
import com.google.android.m4b.maps.a.j;
import com.google.android.m4b.maps.a.k;
import com.google.android.m4b.maps.a.k.a;
import com.google.android.m4b.maps.a.m;
import com.google.android.m4b.maps.a.m.a;
import com.google.android.m4b.maps.a.m.b;
import com.google.android.m4b.maps.a.o;
import com.google.android.m4b.maps.a.s;

public final class g extends k<Bitmap>
{
  private static final Object e = new Object();
  private final m.b<Bitmap> a;
  private final Bitmap.Config b;
  private final int c;
  private final int d;

  public g(String paramString, m.b<Bitmap> paramb, int paramInt1, int paramInt2, Bitmap.Config paramConfig, m.a parama)
  {
    super(0, paramString, parama);
    a(new o(1000, 2, 2.0F));
    this.a = paramb;
    this.b = paramConfig;
    this.c = 0;
    this.d = 0;
  }

  private static int a(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    if ((paramInt1 == 0) && (paramInt2 == 0))
      paramInt1 = paramInt3;
    double d1;
    do
    {
      do
      {
        return paramInt1;
        if (paramInt1 == 0)
          return (int)(paramInt2 / paramInt4 * paramInt3);
      }
      while (paramInt2 == 0);
      d1 = paramInt4 / paramInt3;
    }
    while (d1 * paramInt1 <= paramInt2);
    return (int)(paramInt2 / d1);
  }

  private static int b(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    double d1 = Math.min(paramInt1 / paramInt3, paramInt2 / paramInt4);
    for (float f = 1.0F; f * 2.0F <= d1; f *= 2.0F);
    return (int)f;
  }

  protected final m<Bitmap> a(h paramh)
  {
    while (true)
    {
      Bitmap localBitmap;
      synchronized (e)
      {
        try
        {
          byte[] arrayOfByte = paramh.a;
          BitmapFactory.Options localOptions = new BitmapFactory.Options();
          if ((this.c == 0) && (this.d == 0))
          {
            localOptions.inPreferredConfig = this.b;
            localObject3 = BitmapFactory.decodeByteArray(arrayOfByte, 0, arrayOfByte.length, localOptions);
            if (localObject3 != null)
              break label296;
            m localm2 = m.a(new j(paramh));
            localObject4 = localm2;
            return localObject4;
          }
          localOptions.inJustDecodeBounds = true;
          BitmapFactory.decodeByteArray(arrayOfByte, 0, arrayOfByte.length, localOptions);
          int i = localOptions.outWidth;
          int j = localOptions.outHeight;
          int k = a(this.c, this.d, i, j);
          int m = a(this.d, this.c, j, i);
          localOptions.inJustDecodeBounds = false;
          localOptions.inSampleSize = b(i, j, k, m);
          localBitmap = BitmapFactory.decodeByteArray(arrayOfByte, 0, arrayOfByte.length, localOptions);
          if ((localBitmap != null) && ((localBitmap.getWidth() > k) || (localBitmap.getHeight() > m)))
          {
            localObject3 = Bitmap.createScaledBitmap(localBitmap, k, m, true);
            localBitmap.recycle();
            continue;
          }
        }
        catch (OutOfMemoryError localOutOfMemoryError)
        {
          Object[] arrayOfObject = new Object[2];
          arrayOfObject[0] = Integer.valueOf(paramh.a.length);
          arrayOfObject[1] = c();
          s.c("Caught OOM for %d byte image, url=%s", arrayOfObject);
          m localm1 = m.a(new j(localOutOfMemoryError));
          return localm1;
        }
      }
      Object localObject3 = localBitmap;
      continue;
      label296: m localm3 = m.a(localObject3, d.a(paramh));
      Object localObject4 = localm3;
    }
  }

  public final k.a m()
  {
    return k.a.a;
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.google.android.m4b.maps.b.g
 * JD-Core Version:    0.6.2
 */