Ejemplo n.º 1
0
  /**
   * @param startChild View closest to start of the list. (top or left)
   * @param endChild View closest to end of the list (bottom or right)
   */
  static int computeScrollOffset(
      RecyclerView.State state,
      OrientationHelper orientation,
      View startChild,
      View endChild,
      RecyclerView.LayoutManager lm,
      boolean smoothScrollbarEnabled,
      boolean reverseLayout) {
    if (lm.getChildCount() == 0
        || state.getItemCount() == 0
        || startChild == null
        || endChild == null) {
      return 0;
    }
    final int minPosition = Math.min(lm.getPosition(startChild), lm.getPosition(endChild));
    final int maxPosition = Math.max(lm.getPosition(startChild), lm.getPosition(endChild));
    final int itemsBefore =
        reverseLayout
            ? Math.max(0, state.getItemCount() - maxPosition - 1)
            : Math.max(0, minPosition - 1);
    if (!smoothScrollbarEnabled) {
      return itemsBefore;
    }
    final int laidOutArea =
        Math.abs(orientation.getDecoratedEnd(endChild) - orientation.getDecoratedStart(startChild));
    final int itemRange = Math.abs(lm.getPosition(startChild) - lm.getPosition(endChild)) + 1;
    final float avgSizePerRow = (float) laidOutArea / itemRange;

    return Math.round(
        itemsBefore * avgSizePerRow
            + (orientation.getStartAfterPadding() - orientation.getDecoratedStart(startChild)));
  }
 static int computeScrollOffset(
     RecyclerView.State paramState,
     OrientationHelper paramOrientationHelper,
     View paramView1,
     View paramView2,
     RecyclerView.LayoutManager paramLayoutManager,
     boolean paramBoolean1,
     boolean paramBoolean2) {
   int i = 0;
   int j = i;
   if (paramLayoutManager.getChildCount() != 0) {
     j = i;
     if (paramState.getItemCount() != 0) {
       j = i;
       if (paramView1 != null) {
         if (paramView2 != null) {
           break label45;
         }
         j = i;
       }
     }
   }
   return j;
   label45:
   i =
       Math.min(
           paramLayoutManager.getPosition(paramView1), paramLayoutManager.getPosition(paramView2));
   j =
       Math.max(
           paramLayoutManager.getPosition(paramView1), paramLayoutManager.getPosition(paramView2));
   if (paramBoolean2) {}
   for (i = Math.max(0, paramState.getItemCount() - j - 1); ; i = Math.max(0, i)) {
     j = i;
     if (!paramBoolean1) {
       break;
     }
     j =
         Math.abs(
             paramOrientationHelper.getDecoratedEnd(paramView2)
                 - paramOrientationHelper.getDecoratedStart(paramView1));
     int k =
         Math.abs(
             paramLayoutManager.getPosition(paramView1)
                 - paramLayoutManager.getPosition(paramView2));
     float f = j / (k + 1);
     return Math.round(
         i * f
             + (paramOrientationHelper.getStartAfterPadding()
                 - paramOrientationHelper.getDecoratedStart(paramView1)));
   }
 }