コード例 #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)));
  }
コード例 #2
0
 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)));
   }
 }
コード例 #3
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 computeScrollExtent(
     RecyclerView.State state,
     OrientationHelper orientation,
     View startChild,
     View endChild,
     RecyclerView.LayoutManager lm,
     boolean smoothScrollbarEnabled) {
   if (lm.getChildCount() == 0
       || state.getItemCount() == 0
       || startChild == null
       || endChild == null) {
     return 0;
   }
   if (!smoothScrollbarEnabled) {
     return Math.abs(lm.getPosition(startChild) - lm.getPosition(endChild)) + 1;
   }
   final int extend =
       orientation.getDecoratedEnd(endChild) - orientation.getDecoratedStart(startChild);
   return Math.min(orientation.getTotalSpace(), extend);
 }
コード例 #4
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 computeScrollRange(
     RecyclerView.State state,
     OrientationHelper orientation,
     View startChild,
     View endChild,
     RecyclerView.LayoutManager lm,
     boolean smoothScrollbarEnabled) {
   if (lm.getChildCount() == 0
       || state.getItemCount() == 0
       || startChild == null
       || endChild == null) {
     return 0;
   }
   if (!smoothScrollbarEnabled) {
     return state.getItemCount();
   }
   // smooth scrollbar enabled. try to estimate better.
   final int laidOutArea =
       orientation.getDecoratedEnd(endChild) - orientation.getDecoratedStart(startChild);
   final int laidOutRange = Math.abs(lm.getPosition(startChild) - lm.getPosition(endChild)) + 1;
   // estimate a size for full list.
   return (int) ((float) laidOutArea / laidOutRange * state.getItemCount());
 }
コード例 #5
0
 static int computeScrollExtent(
     RecyclerView.State paramState,
     OrientationHelper paramOrientationHelper,
     View paramView1,
     View paramView2,
     RecyclerView.LayoutManager paramLayoutManager,
     boolean paramBoolean) {
   if ((paramLayoutManager.getChildCount() == 0)
       || (paramState.getItemCount() == 0)
       || (paramView1 == null)
       || (paramView2 == null)) {
     return 0;
   }
   if (!paramBoolean) {
     return Math.abs(
             paramLayoutManager.getPosition(paramView1)
                 - paramLayoutManager.getPosition(paramView2))
         + 1;
   }
   int i = paramOrientationHelper.getDecoratedEnd(paramView2);
   int j = paramOrientationHelper.getDecoratedStart(paramView1);
   return Math.min(paramOrientationHelper.getTotalSpace(), i - j);
 }
コード例 #6
0
 static int computeScrollRange(
     RecyclerView.State paramState,
     OrientationHelper paramOrientationHelper,
     View paramView1,
     View paramView2,
     RecyclerView.LayoutManager paramLayoutManager,
     boolean paramBoolean) {
   if ((paramLayoutManager.getChildCount() == 0)
       || (paramState.getItemCount() == 0)
       || (paramView1 == null)
       || (paramView2 == null)) {
     return 0;
   }
   if (!paramBoolean) {
     return paramState.getItemCount();
   }
   int i = paramOrientationHelper.getDecoratedEnd(paramView2);
   int j = paramOrientationHelper.getDecoratedStart(paramView1);
   int k =
       Math.abs(
           paramLayoutManager.getPosition(paramView1)
               - paramLayoutManager.getPosition(paramView2));
   return (int) ((i - j) / (k + 1) * paramState.getItemCount());
 }