AvatarBuilderPreviewView.java 17.8 KB
package com.bitstrips.imoji.abv3.preview;

import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.support.v4.view.GestureDetectorCompat;
import android.util.AttributeSet;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import java.util.ArrayList;

public class AvatarBuilderPreviewView
  extends View
{
  public static final float BACKGROUND_BODY_OFFSET = 0.2F;
  private static final String a = AvatarBuilderPreviewView.class.getSimpleName();
  private AvatarBuilderPreviewMode b;
  private AvatarBuilderPreviewListener c;
  private int d;
  private int e;
  private int f;
  private int g;
  private int h;
  private int i;
  private int j;
  private boolean k;
  private AnimatorSet l;
  private AvatarBuilderPreviewDecorator m;
  private AvatarBuilderPreviewFlash n;
  private GestureDetectorCompat o;
  private boolean p;
  private ObjectAnimator q;
  
  public AvatarBuilderPreviewView(Context paramContext)
  {
    super(paramContext);
    b();
  }
  
  public AvatarBuilderPreviewView(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    b();
  }
  
  private void a(AnimatorSet paramAnimatorSet, boolean paramBoolean)
  {
    if (this.l != null) {
      this.l.cancel();
    }
    this.l = paramAnimatorSet;
    ((ObjectAnimator)paramAnimatorSet.getChildAnimations().get(0)).addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
    {
      public final void onAnimationUpdate(ValueAnimator paramAnonymousValueAnimator)
      {
        AvatarBuilderPreviewView.this.invalidate();
      }
    });
    if (paramBoolean) {}
    for (long l1 = 250L;; l1 = 0L)
    {
      paramAnimatorSet.setDuration(l1);
      paramAnimatorSet.start();
      return;
    }
  }
  
  private void a(boolean paramBoolean)
  {
    switch (5.a[this.b.ordinal()])
    {
    }
    for (;;)
    {
      invalidate();
      return;
      setPreviewFullScreen(paramBoolean);
      continue;
      setSplitView(paramBoolean);
      continue;
      setUserImageFullScreen(paramBoolean);
      continue;
      setPreviewFullScreenBody(paramBoolean);
    }
  }
  
  private void b()
  {
    this.d = getResources().getDimensionPixelSize(2131361928);
    this.e = getResources().getDimensionPixelSize(2131361927);
    this.f = getResources().getDimensionPixelSize(2131361924);
    this.g = getResources().getDimensionPixelSize(2131361926);
    this.h = getResources().getDimensionPixelSize(2131361925);
    this.i = getResources().getDimensionPixelSize(2131361922);
    this.j = getResources().getDimensionPixelSize(2131361923);
    setOnTouchListener(new View.OnTouchListener()
    {
      public final boolean onTouch(View paramAnonymousView, MotionEvent paramAnonymousMotionEvent)
      {
        AvatarBuilderPreviewView.a(AvatarBuilderPreviewView.this).onTouchEvent(paramAnonymousMotionEvent);
        return true;
      }
    });
    this.m = new AvatarBuilderPreviewDecorator(this);
    this.n = new AvatarBuilderPreviewFlash(this);
    setPreviewMode(AvatarBuilderPreviewMode.PREVIEW_FULL_SCREEN);
    this.o = new GestureDetectorCompat(getContext(), new GestureDetector.OnGestureListener()
    {
      public final boolean onDown(MotionEvent paramAnonymousMotionEvent)
      {
        return true;
      }
      
      public final boolean onFling(MotionEvent paramAnonymousMotionEvent1, MotionEvent paramAnonymousMotionEvent2, float paramAnonymousFloat1, float paramAnonymousFloat2)
      {
        if ((paramAnonymousMotionEvent1.getX() - paramAnonymousMotionEvent2.getX() > AvatarBuilderPreviewView.d(AvatarBuilderPreviewView.this)) && (Math.abs(paramAnonymousFloat1) > AvatarBuilderPreviewView.e(AvatarBuilderPreviewView.this)))
        {
          AvatarBuilderPreviewView.a();
          if (AvatarBuilderPreviewView.c(AvatarBuilderPreviewView.this) != null) {
            AvatarBuilderPreviewView.c(AvatarBuilderPreviewView.this).onPreviewRightToLeftSwipe();
          }
        }
        do
        {
          return true;
          if ((paramAnonymousMotionEvent2.getX() - paramAnonymousMotionEvent1.getX() <= AvatarBuilderPreviewView.d(AvatarBuilderPreviewView.this)) || (Math.abs(paramAnonymousFloat1) <= AvatarBuilderPreviewView.e(AvatarBuilderPreviewView.this))) {
            break;
          }
          AvatarBuilderPreviewView.a();
        } while (AvatarBuilderPreviewView.c(AvatarBuilderPreviewView.this) == null);
        AvatarBuilderPreviewView.c(AvatarBuilderPreviewView.this).onPreviewLeftToRightSwipe();
        return true;
        return false;
      }
      
      public final void onLongPress(MotionEvent paramAnonymousMotionEvent)
      {
        float f1 = paramAnonymousMotionEvent.getX();
        float f2 = paramAnonymousMotionEvent.getY();
        AvatarBuilderPreviewView.a();
        if ((AvatarBuilderPreviewView.a(AvatarBuilderPreviewView.this, f1, f2)) && (AvatarBuilderPreviewView.this.hasUserImage()) && (AvatarBuilderPreviewView.c(AvatarBuilderPreviewView.this) != null)) {
          AvatarBuilderPreviewView.c(AvatarBuilderPreviewView.this).onPreviewUserImageLongPress();
        }
      }
      
      public final boolean onScroll(MotionEvent paramAnonymousMotionEvent1, MotionEvent paramAnonymousMotionEvent2, float paramAnonymousFloat1, float paramAnonymousFloat2)
      {
        return false;
      }
      
      public final void onShowPress(MotionEvent paramAnonymousMotionEvent) {}
      
      public final boolean onSingleTapUp(MotionEvent paramAnonymousMotionEvent)
      {
        float f1 = paramAnonymousMotionEvent.getX();
        float f2 = paramAnonymousMotionEvent.getY();
        AvatarBuilderPreviewView.a();
        new StringBuilder("onSingleTapUp x: ").append(f1).append(" y: ").append(f2);
        switch (AvatarBuilderPreviewView.5.a[AvatarBuilderPreviewView.b(AvatarBuilderPreviewView.this).ordinal()])
        {
        }
        for (;;)
        {
          return true;
          if (AvatarBuilderPreviewView.a(AvatarBuilderPreviewView.this, f1, f2)) {
            if (AvatarBuilderPreviewView.this.hasUserImage())
            {
              AvatarBuilderPreviewView.this.setPreviewMode(AvatarBuilderPreviewMode.SPLIT_VIEW);
            }
            else if (AvatarBuilderPreviewView.c(AvatarBuilderPreviewView.this) != null)
            {
              AvatarBuilderPreviewView.c(AvatarBuilderPreviewView.this).onPreviewPlaceholderTap();
              continue;
              if (AvatarBuilderPreviewView.a(AvatarBuilderPreviewView.this, f1, f2))
              {
                if (AvatarBuilderPreviewView.this.hasUserImage()) {
                  AvatarBuilderPreviewView.this.setPreviewMode(AvatarBuilderPreviewMode.PREVIEW_MINIMIZED);
                } else if (AvatarBuilderPreviewView.c(AvatarBuilderPreviewView.this) != null) {
                  AvatarBuilderPreviewView.c(AvatarBuilderPreviewView.this).onPreviewPlaceholderTap();
                }
              }
              else if (AvatarBuilderPreviewView.b(AvatarBuilderPreviewView.this, f1, f2))
              {
                AvatarBuilderPreviewView.this.setPreviewMode(AvatarBuilderPreviewMode.PREVIEW_FULL_SCREEN);
                continue;
                if (AvatarBuilderPreviewView.b(AvatarBuilderPreviewView.this, f1, f2)) {
                  AvatarBuilderPreviewView.this.setPreviewMode(AvatarBuilderPreviewMode.SPLIT_VIEW);
                }
              }
            }
          }
        }
      }
    });
  }
  
  private void setPreviewFullScreen(boolean paramBoolean)
  {
    int i1 = getWidth();
    int i2 = getHeight();
    AnimatorSet localAnimatorSet = new AnimatorSet();
    localAnimatorSet.playTogether(new Animator[] { ObjectAnimator.ofFloat(this.m, "previewLeft", new float[] { this.m.getPreviewLeft(), 0.0F }), ObjectAnimator.ofFloat(this.m, "previewRight", new float[] { this.m.getPreviewRight(), i1 }), ObjectAnimator.ofFloat(this.m, "previewTop", new float[] { this.m.getPreviewTop(), 0.0F }), ObjectAnimator.ofFloat(this.m, "previewBottom", new float[] { this.m.getPreviewBottom(), i2 }), ObjectAnimator.ofFloat(this.m, "previewTopOffset", new float[] { this.m.getPreviewTopOffset(), this.f }), ObjectAnimator.ofFloat(this.m, "userImageLeft", new float[] { this.m.getUserImageLeft(), this.e }), ObjectAnimator.ofFloat(this.m, "userImageRight", new float[] { this.m.getUserImageRight(), this.e + this.d }), ObjectAnimator.ofFloat(this.m, "userImageTop", new float[] { this.m.getUserImageTop(), i2 - this.e - this.d }), ObjectAnimator.ofFloat(this.m, "userImageBottom", new float[] { this.m.getUserImageBottom(), i2 - this.e }), ObjectAnimator.ofFloat(this.m, "userImageCircleRadiusPercentage", new float[] { this.m.getUserImageCircleRadiusPercentage(), 0.5F }), ObjectAnimator.ofFloat(this.m, "previewCircleRadiusPercentage", new float[] { this.m.getPreviewCircleRadiusPercentage(), 0.0F }), ObjectAnimator.ofFloat(this.m, "backgroundOffset", new float[] { this.m.getBackgroundOffset(), 0.0F }), ObjectAnimator.ofFloat(this.m, "minimizedBackgroundOpacity", new float[] { this.m.getMinimizedBackgroundOpacity(), 0.0F }), ObjectAnimator.ofFloat(this.m, "previewZoom", new float[] { this.m.getPreviewZoom(), 2.3F }), ObjectAnimator.ofFloat(this.m, "userImageHiddenOffset", new float[] { this.m.getUserImageHiddenOffset(), 0.0F }) });
    a(localAnimatorSet, paramBoolean);
  }
  
  private void setPreviewFullScreenBody(boolean paramBoolean)
  {
    int i1 = getWidth();
    int i2 = getHeight();
    AnimatorSet localAnimatorSet = new AnimatorSet();
    localAnimatorSet.playTogether(new Animator[] { ObjectAnimator.ofFloat(this.m, "previewLeft", new float[] { this.m.getPreviewLeft(), 0.0F }), ObjectAnimator.ofFloat(this.m, "previewRight", new float[] { this.m.getPreviewRight(), i1 }), ObjectAnimator.ofFloat(this.m, "previewTop", new float[] { this.m.getPreviewTop(), 0.0F }), ObjectAnimator.ofFloat(this.m, "previewBottom", new float[] { this.m.getPreviewBottom(), i2 }), ObjectAnimator.ofFloat(this.m, "previewTopOffset", new float[] { this.m.getPreviewTopOffset(), this.f }), ObjectAnimator.ofFloat(this.m, "userImageLeft", new float[] { this.m.getUserImageLeft(), this.e }), ObjectAnimator.ofFloat(this.m, "userImageRight", new float[] { this.m.getUserImageRight(), this.e + this.d }), ObjectAnimator.ofFloat(this.m, "userImageTop", new float[] { this.m.getUserImageTop(), i2 - this.e - this.d }), ObjectAnimator.ofFloat(this.m, "userImageBottom", new float[] { this.m.getUserImageBottom(), i2 - this.e }), ObjectAnimator.ofFloat(this.m, "userImageCircleRadiusPercentage", new float[] { this.m.getUserImageCircleRadiusPercentage(), 0.5F }), ObjectAnimator.ofFloat(this.m, "previewCircleRadiusPercentage", new float[] { this.m.getPreviewCircleRadiusPercentage(), 0.0F }), ObjectAnimator.ofFloat(this.m, "backgroundOffset", new float[] { this.m.getBackgroundOffset(), 0.2F }), ObjectAnimator.ofFloat(this.m, "minimizedBackgroundOpacity", new float[] { this.m.getMinimizedBackgroundOpacity(), 0.0F }), ObjectAnimator.ofFloat(this.m, "previewZoom", new float[] { this.m.getPreviewZoom(), 1.0F }), ObjectAnimator.ofFloat(this.m, "userImageHiddenOffset", new float[] { this.m.getUserImageHiddenOffset(), 2.0F }) });
    a(localAnimatorSet, paramBoolean);
  }
  
  private void setSplitView(boolean paramBoolean)
  {
    int i1 = getWidth();
    int i2 = getHeight();
    int i3 = i1 / 2;
    AnimatorSet localAnimatorSet = new AnimatorSet();
    localAnimatorSet.playTogether(new Animator[] { ObjectAnimator.ofFloat(this.m, "previewLeft", new float[] { this.m.getPreviewLeft(), i3 }), ObjectAnimator.ofFloat(this.m, "previewRight", new float[] { this.m.getPreviewRight(), i1 }), ObjectAnimator.ofFloat(this.m, "previewTop", new float[] { this.m.getPreviewTop(), 0.0F }), ObjectAnimator.ofFloat(this.m, "previewBottom", new float[] { this.m.getPreviewBottom(), i2 }), ObjectAnimator.ofFloat(this.m, "previewTopOffset", new float[] { this.m.getPreviewTopOffset(), this.g }), ObjectAnimator.ofFloat(this.m, "userImageLeft", new float[] { this.m.getUserImageLeft(), 0.0F }), ObjectAnimator.ofFloat(this.m, "userImageRight", new float[] { this.m.getUserImageRight(), i3 }), ObjectAnimator.ofFloat(this.m, "userImageTop", new float[] { this.m.getUserImageTop(), 0.0F }), ObjectAnimator.ofFloat(this.m, "userImageBottom", new float[] { this.m.getUserImageBottom(), i2 }), ObjectAnimator.ofFloat(this.m, "userImageCircleRadiusPercentage", new float[] { this.m.getUserImageCircleRadiusPercentage(), 0.0F }), ObjectAnimator.ofFloat(this.m, "previewCircleRadiusPercentage", new float[] { this.m.getPreviewCircleRadiusPercentage(), 0.0F }), ObjectAnimator.ofFloat(this.m, "backgroundOffset", new float[] { this.m.getBackgroundOffset(), 0.0F }), ObjectAnimator.ofFloat(this.m, "minimizedBackgroundOpacity", new float[] { this.m.getMinimizedBackgroundOpacity(), 0.0F }), ObjectAnimator.ofFloat(this.m, "previewZoom", new float[] { this.m.getPreviewZoom(), 1.5F }), ObjectAnimator.ofFloat(this.m, "userImageHiddenOffset", new float[] { this.m.getUserImageHiddenOffset(), 0.0F }) });
    a(localAnimatorSet, paramBoolean);
  }
  
  private void setUserImageFullScreen(boolean paramBoolean)
  {
    int i1 = getWidth();
    int i2 = getHeight();
    AnimatorSet localAnimatorSet = new AnimatorSet();
    localAnimatorSet.playTogether(new Animator[] { ObjectAnimator.ofFloat(this.m, "previewLeft", new float[] { this.m.getPreviewLeft(), i1 - this.e - this.d }), ObjectAnimator.ofFloat(this.m, "previewRight", new float[] { this.m.getPreviewRight(), i1 - this.e }), ObjectAnimator.ofFloat(this.m, "previewTop", new float[] { this.m.getPreviewTop(), this.m.getPreviewBottom() - this.d }), ObjectAnimator.ofFloat(this.m, "previewBottom", new float[] { this.m.getPreviewBottom(), i2 - this.e }), ObjectAnimator.ofFloat(this.m, "previewTopOffset", new float[] { this.m.getPreviewTopOffset(), this.h }), ObjectAnimator.ofFloat(this.m, "userImageLeft", new float[] { this.m.getUserImageLeft(), 0.0F }), ObjectAnimator.ofFloat(this.m, "userImageRight", new float[] { this.m.getUserImageRight(), i1 }), ObjectAnimator.ofFloat(this.m, "userImageTop", new float[] { this.m.getUserImageTop(), 0.0F }), ObjectAnimator.ofFloat(this.m, "userImageBottom", new float[] { this.m.getUserImageBottom(), i2 }), ObjectAnimator.ofFloat(this.m, "userImageCircleRadiusPercentage", new float[] { this.m.getUserImageCircleRadiusPercentage(), 0.0F }), ObjectAnimator.ofFloat(this.m, "previewCircleRadiusPercentage", new float[] { this.m.getPreviewCircleRadiusPercentage(), 0.5F }), ObjectAnimator.ofFloat(this.m, "backgroundOffset", new float[] { this.m.getBackgroundOffset(), 0.0F }), ObjectAnimator.ofFloat(this.m, "minimizedBackgroundOpacity", new float[] { this.m.getMinimizedBackgroundOpacity(), 1.0F }), ObjectAnimator.ofFloat(this.m, "previewZoom", new float[] { this.m.getPreviewZoom(), 2.3F }), ObjectAnimator.ofFloat(this.m, "userImageHiddenOffset", new float[] { this.m.getUserImageHiddenOffset(), 0.0F }) });
    a(localAnimatorSet, paramBoolean);
  }
  
  public void animateFlashes()
  {
    this.n.startAnimation();
  }
  
  public void draw(Canvas paramCanvas)
  {
    super.draw(paramCanvas);
    AvatarBuilderPreviewDecorator localAvatarBuilderPreviewDecorator = this.m;
    if (this.b == AvatarBuilderPreviewMode.PREVIEW_FULL_SCREEN) {}
    for (boolean bool = true;; bool = false)
    {
      localAvatarBuilderPreviewDecorator.draw(paramCanvas, bool, this.k);
      this.n.draw(paramCanvas);
      return;
    }
  }
  
  public AvatarBuilderPreviewMode getPreviewMode()
  {
    return this.b;
  }
  
  public boolean hasUserImage()
  {
    return this.m.getUserImage() != null;
  }
  
  public void onSizeChanged(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    a(false);
  }
  
  public void setAnimationsEnabled(boolean paramBoolean)
  {
    this.p = paramBoolean;
  }
  
  public void setBrandBackground(Bitmap paramBitmap)
  {
    this.m.setBrandBackgroundImage(paramBitmap);
    invalidate();
  }
  
  public void setFullBodyPreviewDecorator(boolean paramBoolean)
  {
    this.m.setFullBodyPreview(paramBoolean);
  }
  
  public void setListener(AvatarBuilderPreviewListener paramAvatarBuilderPreviewListener)
  {
    this.c = paramAvatarBuilderPreviewListener;
  }
  
  public void setPreview(Bitmap paramBitmap)
  {
    this.m.setPreviewImage(paramBitmap);
    invalidate();
  }
  
  public void setPreviewMode(AvatarBuilderPreviewMode paramAvatarBuilderPreviewMode)
  {
    if (paramAvatarBuilderPreviewMode == this.b) {
      return;
    }
    this.b = paramAvatarBuilderPreviewMode;
    if (this.c != null) {
      this.c.onPreviewModeChanged(this.b);
    }
    a(this.p);
  }
  
  public void setUserImage(Bitmap paramBitmap)
  {
    this.m.setUserImage(paramBitmap);
    invalidate();
  }
  
  public void setUserImageEnabled(boolean paramBoolean)
  {
    this.k = paramBoolean;
    invalidate();
  }
  
  public void startLoading()
  {
    if (this.q != null) {
      this.q.cancel();
    }
    this.q = ((ObjectAnimator)AnimatorInflater.loadAnimator(getContext(), 2131034112));
    this.q.setTarget(this.m);
    this.q.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
    {
      public final void onAnimationUpdate(ValueAnimator paramAnonymousValueAnimator)
      {
        AvatarBuilderPreviewView.this.invalidate();
      }
    });
    this.q.start();
  }
  
  public void stopFlashes()
  {
    this.n.stopAnimation();
  }
  
  public void stopLoading()
  {
    if (this.q != null)
    {
      this.q.cancel();
      this.q = null;
      this.m.setTint(0.0F);
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/abv3/preview/AvatarBuilderPreviewView.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */