InstabugSwipeDelegate.java 3.03 KB
package com.instabug.library.interaction;

import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import com.instabug.library.Instabug;

public class InstabugSwipeDelegate
{
  private static final int DIRECTION_DOWN = 2;
  private static final int DIRECTION_LEFT = 3;
  private static final int DIRECTION_RIGHT = 4;
  private static final int DIRECTION_UP = 1;
  private int mDirectionNeeded;
  private final a mForwarder;
  private boolean mGoodCycle = false;
  private int mPointerCountNeeded = 0;
  
  public InstabugSwipeDelegate(a parama, GestureConfig paramGestureConfig)
  {
    this.mForwarder = parama;
    parama = paramGestureConfig;
    if (paramGestureConfig == null) {
      parama = GestureConfig.ThreeSwipeUp;
    }
    switch (1.a[parama.ordinal()])
    {
    default: 
      return;
    case 1: 
      this.mDirectionNeeded = 1;
      this.mPointerCountNeeded = 3;
      return;
    }
    this.mDirectionNeeded = 3;
    this.mPointerCountNeeded = 2;
  }
  
  private boolean isDirectionValid(MotionEvent paramMotionEvent1, MotionEvent paramMotionEvent2)
  {
    boolean bool = true;
    if ((paramMotionEvent1 == null) || (paramMotionEvent2 == null)) {
      bool = false;
    }
    do
    {
      do
      {
        return bool;
        switch (this.mDirectionNeeded)
        {
        case 2: 
        default: 
          return false;
        }
      } while (paramMotionEvent1.getY() > paramMotionEvent2.getY());
      return false;
    } while ((paramMotionEvent1.getX() > paramMotionEvent2.getX()) && (paramMotionEvent1.getX() - paramMotionEvent2.getX() >= Math.abs(paramMotionEvent1.getY() - paramMotionEvent2.getY())));
    return false;
  }
  
  public void onTouchEvent(MotionEvent paramMotionEvent)
  {
    if (paramMotionEvent.getPointerCount() >= this.mPointerCountNeeded) {
      this.mGoodCycle = true;
    }
    switch (paramMotionEvent.getAction() & 0xFF)
    {
    }
    do
    {
      this.mForwarder.onInstabugGestureEvent(paramMotionEvent);
      return;
    } while (paramMotionEvent.getPointerCount() >= this.mPointerCountNeeded);
  }
  
  public static enum GestureConfig
  {
    ThreeSwipeUp,  TwoSwipeLeft;
    
    private GestureConfig() {}
  }
  
  public class GestureListener
    extends GestureDetector.SimpleOnGestureListener
  {
    public GestureListener() {}
    
    public boolean onFling(MotionEvent paramMotionEvent1, MotionEvent paramMotionEvent2, float paramFloat1, float paramFloat2)
    {
      if ((InstabugSwipeDelegate.this.isDirectionValid(paramMotionEvent1, paramMotionEvent2)) && (InstabugSwipeDelegate.this.mGoodCycle)) {
        Instabug.invoke();
      }
      InstabugSwipeDelegate.access$102(InstabugSwipeDelegate.this, false);
      return false;
    }
  }
  
  public static abstract interface a
  {
    public abstract void onInstabugGestureEvent(MotionEvent paramMotionEvent);
  }
}


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