a.java 8.75 KB
package com.instabug.library.c;

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.os.Handler;
import android.os.Looper;
import android.util.DisplayMetrics;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageButton;
import android.widget.ImageView.ScaleType;
import com.instabug.library.IBGFloatingButtonEdge;
import com.instabug.library.R.drawable;

public class a
  implements View.OnClickListener
{
  int a;
  int b = 0;
  private FrameLayout.LayoutParams c;
  private int d;
  private int e = 0;
  private e f;
  private c g;
  private int h;
  private d i;
  
  public a(e parame)
  {
    this.f = parame;
  }
  
  public void a()
  {
    this.g.setOnClickListener(null);
    if ((this.g != null) && (this.g.getParent() != null) && ((this.g.getParent() instanceof ViewGroup))) {
      ((ViewGroup)this.g.getParent()).removeView(this.g);
    }
  }
  
  public void a(Activity paramActivity)
  {
    this.g = new c(paramActivity);
    if (this.i == null) {
      this.i = new d();
    }
    float f1 = paramActivity.getResources().getDisplayMetrics().density;
    int j = this.d;
    int k = this.e;
    this.e = paramActivity.getResources().getDisplayMetrics().heightPixels;
    this.d = paramActivity.getResources().getDisplayMetrics().widthPixels;
    this.h = ((int)(f1 * 56.0F));
    b localb = new b(paramActivity);
    Object localObject = new ShapeDrawable(new OvalShape());
    ((ShapeDrawable)localObject).getPaint().setColor(this.i.b);
    ShapeDrawable localShapeDrawable = new ShapeDrawable(new OvalShape());
    localShapeDrawable.getPaint().setColor(-1);
    localObject = new LayerDrawable(new Drawable[] { localShapeDrawable, localObject });
    ((LayerDrawable)localObject).setLayerInset(0, 0, 0, 0, 0);
    ((LayerDrawable)localObject).setLayerInset(1, 2, 2, 2, 2);
    localb.setBackgroundDrawable((Drawable)localObject);
    localObject = paramActivity.getResources().getDrawable(R.drawable.instabug_ic_ibg_logo_dark);
    ((Drawable)localObject).setColorFilter(new PorterDuffColorFilter(this.i.a, PorterDuff.Mode.SRC_IN));
    localb.setImageDrawable((Drawable)localObject);
    localb.setScaleType(ImageView.ScaleType.CENTER);
    if (this.c == null) {
      if (this.i.c == IBGFloatingButtonEdge.Left)
      {
        this.c = new FrameLayout.LayoutParams(this.h, this.h, 51);
        localb.setLayoutParams(this.c);
        localb.a(-10, this.i.d);
      }
    }
    for (;;)
    {
      localb.setOnClickListener(this);
      localb.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
      this.g.addView(localb);
      ((FrameLayout)paramActivity.getWindow().getDecorView()).addView(this.g, new ViewGroup.LayoutParams(-1, -1));
      return;
      this.c = new FrameLayout.LayoutParams(this.h, this.h, 53);
      localb.setLayoutParams(this.c);
      localb.a(this.d + 10, this.i.d);
      continue;
      f1 = this.a * this.d / j;
      float f2 = this.b * this.e / k;
      this.a = Math.round(f1);
      this.b = Math.round(f2);
      this.c.leftMargin = this.a;
      this.c.rightMargin = (this.d - this.a);
      this.c.topMargin = this.b;
      this.c.bottomMargin = (this.e - this.b);
      localb.setLayoutParams(this.c);
      b.a(localb);
    }
  }
  
  public void a(d paramd)
  {
    this.i = paramd;
  }
  
  public void onClick(View paramView)
  {
    if (this.f != null) {
      this.f.b();
    }
  }
  
  static final class a
    extends GestureDetector.SimpleOnGestureListener
  {
    public final boolean onFling(MotionEvent paramMotionEvent1, MotionEvent paramMotionEvent2, float paramFloat1, float paramFloat2)
    {
      return (Math.abs(paramMotionEvent2.getX() - paramMotionEvent1.getX()) < 90.0F) && (paramMotionEvent2.getY() - paramMotionEvent1.getY() > 90.0F);
    }
  }
  
  public class b
    extends ImageButton
  {
    private GestureDetector b;
    private boolean c = true;
    private a d;
    private long e;
    private float f;
    private float g;
    private boolean h = false;
    
    public b(Context paramContext)
    {
      super();
      this.b = new GestureDetector(paramContext, new a.a());
      this.d = new a((byte)0);
    }
    
    private void a()
    {
      float f1;
      a locala;
      if (a.a(a.this).c == IBGFloatingButtonEdge.Left)
      {
        if (a.this.a >= a.b(a.this) / 2.0F)
        {
          f1 = a.b(a.this) - a.c(a.this) + 10;
          locala = this.d;
          if (a.this.b <= a.d(a.this) - a.c(a.this)) {
            break label120;
          }
        }
        label120:
        for (f2 = a.d(a.this) - a.c(a.this) * 2;; f2 = a.this.b)
        {
          a.a(locala, f1, f2);
          return;
          f1 = -10.0F;
          break;
        }
      }
      if (a.this.a >= a.b(a.this) / 2.0F)
      {
        f1 = a.b(a.this) + 10;
        locala = this.d;
        if (a.this.b <= a.d(a.this) - a.c(a.this)) {
          break label237;
        }
      }
      label237:
      for (float f2 = a.d(a.this) - a.c(a.this) * 2;; f2 = a.this.b)
      {
        a.a(locala, f1, f2);
        return;
        f1 = a.c(a.this) - 10;
        break;
      }
    }
    
    final void a(int paramInt1, int paramInt2)
    {
      a.this.a = paramInt1;
      a.this.b = paramInt2;
      a.e(a.this).leftMargin = (a.this.a + 0);
      a.e(a.this).rightMargin = (a.b(a.this) - a.this.a);
      a.e(a.this).topMargin = (a.this.b + 0);
      a.e(a.this).bottomMargin = (a.d(a.this) - a.this.b);
      setLayoutParams(a.e(a.this));
    }
    
    public boolean onTouchEvent(MotionEvent paramMotionEvent)
    {
      if (this.c) {}
      for (boolean bool = this.b.onTouchEvent(paramMotionEvent);; bool = false)
      {
        if (bool)
        {
          a();
          return true;
        }
        float f1 = paramMotionEvent.getRawX();
        float f2 = paramMotionEvent.getRawY();
        int i = paramMotionEvent.getAction();
        if (i == 0)
        {
          this.e = System.currentTimeMillis();
          a.a(this.d);
          this.h = true;
        }
        for (;;)
        {
          this.f = f1;
          this.g = f2;
          return true;
          if (i == 1)
          {
            if (System.currentTimeMillis() - this.e < 200L) {
              performClick();
            }
            this.h = false;
            a();
          }
          else if ((i == 2) && (this.h))
          {
            float f3 = this.f;
            float f4 = f2 - this.g;
            if (a.this.b + f4 > 50.0F) {
              a((int)(f1 - f3 + a.this.a), (int)(f4 + a.this.b));
            }
            if ((this.c) && (!this.h) && (Math.abs(a.e(a.this).rightMargin) < 50) && (Math.abs(a.e(a.this).topMargin - getContext().getResources().getDisplayMetrics().heightPixels / 2) < 250)) {
              a();
            }
          }
        }
      }
    }
    
    public void setLayoutParams(ViewGroup.LayoutParams paramLayoutParams)
    {
      a.a(a.this, (FrameLayout.LayoutParams)paramLayoutParams);
      super.setLayoutParams(paramLayoutParams);
    }
    
    final class a
      implements Runnable
    {
      private Handler b = new Handler(Looper.getMainLooper());
      private float c;
      private float d;
      private long e;
      
      private a() {}
      
      public final void run()
      {
        if (a.b.this.getParent() != null)
        {
          float f1 = Math.min(1.0F, (float)(System.currentTimeMillis() - this.e) / 400.0F);
          float f2 = this.c;
          float f3 = a.this.a;
          float f4 = this.d;
          float f5 = a.this.b;
          a.b.this.a((int)((f2 - f3) * f1 + a.this.a), (int)((f4 - f5) * f1 + a.this.b));
          if (f1 < 1.0F) {
            this.b.post(this);
          }
        }
      }
    }
  }
  
  public static class c
    extends FrameLayout
  {
    public c(Context paramContext)
    {
      super();
    }
  }
  
  public static class d
  {
    public int a = -16776961;
    public int b = -1;
    public IBGFloatingButtonEdge c = IBGFloatingButtonEdge.Right;
    public int d = 250;
  }
  
  public static abstract interface e
  {
    public abstract void b();
  }
}


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