LinearSnapHelper.java 7.63 KB
package android.support.v7.widget;

import android.graphics.PointF;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;

public class LinearSnapHelper
  extends SnapHelper
{
  @Nullable
  private OrientationHelper b;
  @Nullable
  private OrientationHelper c;
  
  private int a(RecyclerView.LayoutManager paramLayoutManager, OrientationHelper paramOrientationHelper, int paramInt1, int paramInt2)
  {
    int[] arrayOfInt = calculateScrollDistance(paramInt1, paramInt2);
    Object localObject1 = null;
    Object localObject2 = null;
    paramInt1 = Integer.MAX_VALUE;
    int i = Integer.MIN_VALUE;
    int n = paramLayoutManager.getChildCount();
    float f;
    int k;
    label48:
    int j;
    Object localObject3;
    if (n == 0)
    {
      f = 1.0F;
      if (f <= 0.0F) {
        return 0;
      }
    }
    else
    {
      k = 0;
      if (k < n)
      {
        View localView = paramLayoutManager.getChildAt(k);
        int m = paramLayoutManager.getPosition(localView);
        j = paramInt1;
        localObject3 = localObject1;
        if (m == -1) {
          break label292;
        }
        paramInt2 = paramInt1;
        if (m < paramInt1)
        {
          paramInt2 = m;
          localObject1 = localView;
        }
        j = paramInt2;
        localObject3 = localObject1;
        if (m <= i) {
          break label292;
        }
        localObject2 = localObject1;
        localObject1 = localView;
        paramInt1 = m;
      }
    }
    for (;;)
    {
      k += 1;
      localObject3 = localObject2;
      i = paramInt1;
      paramInt1 = paramInt2;
      localObject2 = localObject1;
      localObject1 = localObject3;
      break label48;
      if ((localObject1 == null) || (localObject2 == null))
      {
        f = 1.0F;
        break;
      }
      paramInt2 = Math.min(paramOrientationHelper.getDecoratedStart((View)localObject1), paramOrientationHelper.getDecoratedStart((View)localObject2));
      paramInt2 = Math.max(paramOrientationHelper.getDecoratedEnd((View)localObject1), paramOrientationHelper.getDecoratedEnd((View)localObject2)) - paramInt2;
      if (paramInt2 == 0)
      {
        f = 1.0F;
        break;
      }
      f = paramInt2 * 1.0F / (i - paramInt1 + 1);
      break;
      if (Math.abs(arrayOfInt[0]) > Math.abs(arrayOfInt[1])) {}
      for (paramInt1 = arrayOfInt[0]; paramInt1 > 0; paramInt1 = arrayOfInt[1]) {
        return (int)Math.floor(paramInt1 / f);
      }
      return (int)Math.ceil(paramInt1 / f);
      label292:
      paramInt1 = i;
      paramInt2 = j;
      localObject1 = localObject2;
      localObject2 = localObject3;
    }
  }
  
  private static int a(@NonNull RecyclerView.LayoutManager paramLayoutManager, @NonNull View paramView, OrientationHelper paramOrientationHelper)
  {
    int j = paramOrientationHelper.getDecoratedStart(paramView);
    int k = paramOrientationHelper.getDecoratedMeasurement(paramView) / 2;
    if (paramLayoutManager.getClipToPadding()) {}
    for (int i = paramOrientationHelper.getStartAfterPadding() + paramOrientationHelper.getTotalSpace() / 2;; i = paramOrientationHelper.getEnd() / 2) {
      return k + j - i;
    }
  }
  
  @NonNull
  private OrientationHelper a(@NonNull RecyclerView.LayoutManager paramLayoutManager)
  {
    if ((this.b == null) || (this.b.mLayoutManager != paramLayoutManager)) {
      this.b = OrientationHelper.createVerticalHelper(paramLayoutManager);
    }
    return this.b;
  }
  
  @Nullable
  private static View a(RecyclerView.LayoutManager paramLayoutManager, OrientationHelper paramOrientationHelper)
  {
    Object localObject1 = null;
    Object localObject2 = null;
    int n = paramLayoutManager.getChildCount();
    if (n == 0) {}
    int j;
    int i;
    int k;
    label45:
    do
    {
      return (View)localObject2;
      if (!paramLayoutManager.getClipToPadding()) {
        break;
      }
      j = paramOrientationHelper.getStartAfterPadding() + paramOrientationHelper.getTotalSpace() / 2;
      i = Integer.MAX_VALUE;
      k = 0;
      localObject2 = localObject1;
    } while (k >= n);
    localObject2 = paramLayoutManager.getChildAt(k);
    int m = Math.abs(paramOrientationHelper.getDecoratedStart((View)localObject2) + paramOrientationHelper.getDecoratedMeasurement((View)localObject2) / 2 - j);
    if (m < i)
    {
      localObject1 = localObject2;
      i = m;
    }
    for (;;)
    {
      k += 1;
      break label45;
      j = paramOrientationHelper.getEnd() / 2;
      break;
    }
  }
  
  @NonNull
  private OrientationHelper b(@NonNull RecyclerView.LayoutManager paramLayoutManager)
  {
    if ((this.c == null) || (this.c.mLayoutManager != paramLayoutManager)) {
      this.c = OrientationHelper.createHorizontalHelper(paramLayoutManager);
    }
    return this.c;
  }
  
  public int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager paramLayoutManager, @NonNull View paramView)
  {
    int[] arrayOfInt = new int[2];
    if (paramLayoutManager.canScrollHorizontally()) {
      arrayOfInt[0] = a(paramLayoutManager, paramView, b(paramLayoutManager));
    }
    while (paramLayoutManager.canScrollVertically())
    {
      arrayOfInt[1] = a(paramLayoutManager, paramView, a(paramLayoutManager));
      return arrayOfInt;
      arrayOfInt[0] = 0;
    }
    arrayOfInt[1] = 0;
    return arrayOfInt;
  }
  
  public View findSnapView(RecyclerView.LayoutManager paramLayoutManager)
  {
    if (paramLayoutManager.canScrollVertically()) {
      return a(paramLayoutManager, a(paramLayoutManager));
    }
    if (paramLayoutManager.canScrollHorizontally()) {
      return a(paramLayoutManager, b(paramLayoutManager));
    }
    return null;
  }
  
  public int findTargetSnapPosition(RecyclerView.LayoutManager paramLayoutManager, int paramInt1, int paramInt2)
  {
    if (!(paramLayoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider)) {
      paramInt2 = -1;
    }
    int j;
    label152:
    label170:
    label175:
    label180:
    do
    {
      return paramInt2;
      j = paramLayoutManager.getItemCount();
      if (j == 0) {
        return -1;
      }
      Object localObject = findSnapView(paramLayoutManager);
      if (localObject == null) {
        return -1;
      }
      int k = paramLayoutManager.getPosition((View)localObject);
      if (k == -1) {
        return -1;
      }
      localObject = ((RecyclerView.SmoothScroller.ScrollVectorProvider)paramLayoutManager).computeScrollVectorForPosition(j - 1);
      if (localObject == null) {
        return -1;
      }
      if (paramLayoutManager.canScrollHorizontally())
      {
        int i = a(paramLayoutManager, b(paramLayoutManager), paramInt1, 0);
        paramInt1 = i;
        if (((PointF)localObject).x < 0.0F) {
          paramInt1 = -i;
        }
        if (!paramLayoutManager.canScrollVertically()) {
          break label170;
        }
        i = a(paramLayoutManager, a(paramLayoutManager), 0, paramInt2);
        paramInt2 = i;
        if (((PointF)localObject).y < 0.0F) {
          paramInt2 = -i;
        }
        if (!paramLayoutManager.canScrollVertically()) {
          break label175;
        }
      }
      for (;;)
      {
        if (paramInt2 != 0) {
          break label180;
        }
        return -1;
        paramInt1 = 0;
        break;
        paramInt2 = 0;
        break label152;
        paramInt2 = paramInt1;
      }
      paramInt2 = k + paramInt2;
      paramInt1 = paramInt2;
      if (paramInt2 < 0) {
        paramInt1 = 0;
      }
      paramInt2 = paramInt1;
    } while (paramInt1 < j);
    return j - 1;
  }
}


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