a.java 4.88 KB
package com.instabug.library.d;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ProgressBar;
import com.instabug.library.R.id;
import com.instabug.library.R.layout;
import com.instabug.library.internal.d.a.b;
import com.instabug.library.internal.d.a.b.b;
import com.instabug.library.model.a.a;
import com.instabug.library.util.InstabugSDKLogger;
import com.instabug.library.view.ScaleImageView;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class a
  extends Fragment
{
  private String a;
  private ProgressBar b;
  private ScaleImageView c;
  private float d;
  private float e;
  
  public static a a(String paramString)
  {
    a locala = new a();
    Bundle localBundle = new Bundle();
    localBundle.putString("img_url", paramString);
    locala.setArguments(localBundle);
    return locala;
  }
  
  public float a(float paramFloat, Context paramContext)
  {
    return paramContext.getResources().getDisplayMetrics().densityDpi / 160.0F * paramFloat;
  }
  
  public Bitmap a(Bitmap paramBitmap, float paramFloat1, float paramFloat2)
  {
    Bitmap localBitmap = Bitmap.createBitmap((int)paramFloat1, (int)paramFloat2, Bitmap.Config.ARGB_8888);
    if ((paramBitmap.getWidth() < paramBitmap.getHeight()) && (paramFloat1 > paramFloat2)) {}
    while ((paramBitmap.getWidth() > paramBitmap.getHeight()) && (paramFloat1 < paramFloat2)) {
      return paramBitmap;
    }
    Canvas localCanvas = new Canvas(localBitmap);
    Matrix localMatrix = new Matrix();
    if (paramBitmap.getWidth() < paramBitmap.getHeight()) {
      localMatrix.setScale(paramFloat1 / paramBitmap.getWidth(), paramFloat2 / paramBitmap.getHeight());
    }
    for (;;)
    {
      localCanvas.drawBitmap(paramBitmap, localMatrix, new Paint());
      return localBitmap;
      localMatrix.setScale(paramFloat2 / paramBitmap.getHeight(), paramFloat1 / paramBitmap.getWidth());
    }
  }
  
  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    if (getArguments() != null) {
      this.a = getArguments().getString("img_url");
    }
    while (paramBundle == null) {
      return;
    }
    this.a = paramBundle.getString("img_url");
  }
  
  @Nullable
  public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle)
  {
    paramLayoutInflater = paramLayoutInflater.inflate(R.layout.instabug_lyt_attachment, paramViewGroup, false);
    this.b = ((ProgressBar)paramLayoutInflater.findViewById(R.id.instabug_attachment_progress_bar));
    this.c = ((ScaleImageView)paramLayoutInflater.findViewById(R.id.instabug_img_attachment));
    return paramLayoutInflater;
  }
  
  public void onSaveInstanceState(Bundle paramBundle)
  {
    super.onSaveInstanceState(paramBundle);
    paramBundle.putString("img_url", this.a);
  }
  
  public void onViewCreated(View paramView, @Nullable Bundle paramBundle)
  {
    super.onViewCreated(paramView, paramBundle);
    paramView = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(paramView);
    this.d = (paramView.widthPixels - (int)a(24.0F, getActivity()));
    this.e = (paramView.heightPixels - (int)a(24.0F, getActivity()));
    paramView = b.a(getActivity(), this.a, a.a.a);
    b.a(getActivity(), paramView, new b.b()
    {
      public final void a(com.instabug.library.model.a paramAnonymousa)
      {
        InstabugSDKLogger.d(this, "Asset Entity downloaded: " + paramAnonymousa.c().getPath());
        try
        {
          paramAnonymousa = a.this.a(BitmapFactory.decodeStream(new FileInputStream(paramAnonymousa.c())), a.a(a.this), a.b(a.this));
          a.c(a.this).setImageBitmap(paramAnonymousa);
          if (a.d(a.this).getVisibility() == 0) {
            a.d(a.this).setVisibility(8);
          }
          return;
        }
        catch (FileNotFoundException paramAnonymousa)
        {
          InstabugSDKLogger.e(this, "Asset Entity downloading got FileNotFoundException error", paramAnonymousa);
        }
      }
      
      public final void a(Throwable paramAnonymousThrowable)
      {
        InstabugSDKLogger.e(this, "Asset Entity downloading got error", paramAnonymousThrowable);
      }
    });
  }
}


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