SharedElementCallback.java 5.58 KB
package android.support.v4.app;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.View;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import java.util.List;
import java.util.Map;

public abstract class SharedElementCallback
{
  private static int b = 1048576;
  private Matrix a;
  
  public Parcelable onCaptureSharedElementSnapshot(View paramView, Matrix paramMatrix, RectF paramRectF)
  {
    ImageView localImageView;
    Drawable localDrawable;
    Object localObject;
    if ((paramView instanceof ImageView))
    {
      localImageView = (ImageView)paramView;
      localDrawable = localImageView.getDrawable();
      localObject = localImageView.getBackground();
      if ((localDrawable != null) && (localObject == null))
      {
        i = localDrawable.getIntrinsicWidth();
        j = localDrawable.getIntrinsicHeight();
        if ((i <= 0) || (j <= 0))
        {
          localObject = null;
          if (localObject == null) {
            break label294;
          }
          paramView = new Bundle();
          paramView.putParcelable("sharedElement:snapshot:bitmap", (Parcelable)localObject);
          paramView.putString("sharedElement:snapshot:imageScaleType", localImageView.getScaleType().toString());
          if (localImageView.getScaleType() == ImageView.ScaleType.MATRIX)
          {
            paramMatrix = localImageView.getImageMatrix();
            paramRectF = new float[9];
            paramMatrix.getValues(paramRectF);
            paramView.putFloatArray("sharedElement:snapshot:imageMatrix", paramRectF);
          }
          localObject = paramView;
        }
      }
    }
    label294:
    do
    {
      do
      {
        return (Parcelable)localObject;
        f = Math.min(1.0F, b / (i * j));
        if (((localDrawable instanceof BitmapDrawable)) && (f == 1.0F))
        {
          localObject = ((BitmapDrawable)localDrawable).getBitmap();
          break;
        }
        i = (int)(i * f);
        j = (int)(j * f);
        localObject = Bitmap.createBitmap(i, j, Bitmap.Config.ARGB_8888);
        Canvas localCanvas = new Canvas((Bitmap)localObject);
        Rect localRect = localDrawable.getBounds();
        int k = localRect.left;
        int m = localRect.top;
        int n = localRect.right;
        int i1 = localRect.bottom;
        localDrawable.setBounds(0, 0, i, j);
        localDrawable.draw(localCanvas);
        localDrawable.setBounds(k, m, n, i1);
        break;
        j = Math.round(paramRectF.width());
        i = Math.round(paramRectF.height());
        localImageView = null;
        localObject = localImageView;
      } while (j <= 0);
      localObject = localImageView;
    } while (i <= 0);
    float f = Math.min(1.0F, b / (j * i));
    int j = (int)(j * f);
    int i = (int)(i * f);
    if (this.a == null) {
      this.a = new Matrix();
    }
    this.a.set(paramMatrix);
    this.a.postTranslate(-paramRectF.left, -paramRectF.top);
    this.a.postScale(f, f);
    paramMatrix = Bitmap.createBitmap(j, i, Bitmap.Config.ARGB_8888);
    paramRectF = new Canvas(paramMatrix);
    paramRectF.concat(this.a);
    paramView.draw(paramRectF);
    return paramMatrix;
  }
  
  public View onCreateSnapshotView(Context paramContext, Parcelable paramParcelable)
  {
    if ((paramParcelable instanceof Bundle))
    {
      paramParcelable = (Bundle)paramParcelable;
      Object localObject = (Bitmap)paramParcelable.getParcelable("sharedElement:snapshot:bitmap");
      if (localObject == null) {
        return null;
      }
      paramContext = new ImageView(paramContext);
      paramContext.setImageBitmap((Bitmap)localObject);
      paramContext.setScaleType(ImageView.ScaleType.valueOf(paramParcelable.getString("sharedElement:snapshot:imageScaleType")));
      if (paramContext.getScaleType() == ImageView.ScaleType.MATRIX)
      {
        paramParcelable = paramParcelable.getFloatArray("sharedElement:snapshot:imageMatrix");
        localObject = new Matrix();
        ((Matrix)localObject).setValues(paramParcelable);
        paramContext.setImageMatrix((Matrix)localObject);
      }
    }
    for (;;)
    {
      return paramContext;
      if ((paramParcelable instanceof Bitmap))
      {
        paramParcelable = (Bitmap)paramParcelable;
        paramContext = new ImageView(paramContext);
        paramContext.setImageBitmap(paramParcelable);
      }
      else
      {
        paramContext = null;
      }
    }
  }
  
  public void onMapSharedElements(List<String> paramList, Map<String, View> paramMap) {}
  
  public void onRejectSharedElements(List<View> paramList) {}
  
  public void onSharedElementEnd(List<String> paramList, List<View> paramList1, List<View> paramList2) {}
  
  public void onSharedElementStart(List<String> paramList, List<View> paramList1, List<View> paramList2) {}
  
  public void onSharedElementsArrived(List<String> paramList, List<View> paramList1, OnSharedElementsReadyListener paramOnSharedElementsReadyListener)
  {
    paramOnSharedElementsReadyListener.onSharedElementsReady();
  }
  
  public static abstract interface OnSharedElementsReadyListener
  {
    public abstract void onSharedElementsReady();
  }
}


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