@Override
  public void getItemOffsets(
      Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    super.getItemOffsets(outRect, view, parent, state);
    if (mDivider == null) {
      return;
    }

    int position = parent.getChildAdapterPosition(view);
    if (position == RecyclerView.NO_POSITION || (position == 0 && !mShowFirstDivider)) {
      return;
    }

    if (mOrientation == -1) getOrientation(parent);

    if (mOrientation == LinearLayoutManager.VERTICAL) {
      outRect.top = mDivider.getIntrinsicHeight();
      if (mShowLastDivider && position == (state.getItemCount() - 1)) {
        outRect.bottom = outRect.top;
      }
    } else {
      outRect.left = mDivider.getIntrinsicWidth();
      if (mShowLastDivider && position == (state.getItemCount() - 1)) {
        outRect.right = outRect.left;
      }
    }
  }
  @Override
  public void getItemOffsets(
      Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    super.getItemOffsets(outRect, view, parent, state);
    if (size <= 0) {
      return;
    }

    if (showFirstDivider && parent.getChildLayoutPosition(view) < 1
        || parent.getChildLayoutPosition(view) >= 1) {
      if (getOrientation(parent) == LinearLayoutManager.VERTICAL) {
        outRect.top = size;
      } else {
        outRect.left = size;
      }
    }

    if (showLastDivider && parent.getChildAdapterPosition(view) == getTotalItemCount(parent) - 1) {
      if (getOrientation(parent) == LinearLayoutManager.VERTICAL) {
        outRect.bottom = size;
      } else {
        outRect.right = size;
      }
    }
  }
  @Override
  public void getItemOffsets(
      Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    super.getItemOffsets(outRect, view, parent, state);

    outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
  }
    @Override
    public void getItemOffsets(
        Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
      super.getItemOffsets(outRect, view, parent, state);

      outRect.bottom = space * 2;
    }
示例#5
0
  @Override
  public void getItemOffsets(Rect outRect, View view, RecyclerView rv, RecyclerView.State state) {
    super.getItemOffsets(outRect, view, rv, state);

    debugLog("getItemOffsets");

    debugLog("View top = " + view.getTop());
    if (selectedDragItemPos != -1) {
      int itemPos = rv.getChildPosition(view);
      debugLog("itemPos =" + itemPos);

      if (!canDragOver(itemPos)) {
        return;
      }

      // Movement of finger
      float totalMovement = fingerY - fingerAnchorY;

      if (itemPos == selectedDragItemPos) {
        view.setVisibility(View.INVISIBLE);
      } else {
        // Make view visible incase invisible
        view.setVisibility(View.VISIBLE);

        // Find middle of the floatingItem
        float floatMiddleY = floatingItemBounds.top + floatingItemBounds.height() / 2;

        // Moving down the list
        // These will auto-animate if the device continually sends touch motion events
        // if (totalMovment>0)
        {
          if ((itemPos > selectedDragItemPos) && (view.getTop() < floatMiddleY)) {
            float amountUp = (floatMiddleY - view.getTop()) / (float) view.getHeight();
            //  amountUp *= 0.5f;
            if (amountUp > 1) amountUp = 1;

            outRect.top = -(int) (floatingItemBounds.height() * amountUp);
            outRect.bottom = (int) (floatingItemBounds.height() * amountUp);
          }
        } // Moving up the list
        // else if (totalMovment < 0)
        {
          if ((itemPos < selectedDragItemPos) && (view.getBottom() > floatMiddleY)) {
            float amountDown = ((float) view.getBottom() - floatMiddleY) / (float) view.getHeight();
            //  amountDown *= 0.5f;
            if (amountDown > 1) amountDown = 1;

            outRect.top = (int) (floatingItemBounds.height() * amountDown);
            outRect.bottom = -(int) (floatingItemBounds.height() * amountDown);
          }
        }
      }
    } else {
      outRect.top = 0;
      outRect.bottom = 0;
      // Make view visible incase invisible
      view.setVisibility(View.VISIBLE);
    }
  }
  @Override
  public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    if (mDivider == null) {
      super.onDrawOver(c, parent, state);
      return;
    }

    // Initialization needed to avoid compiler warning
    int left = 0, right = 0, top = 0, bottom = 0, size;
    int orientation = mOrientation != -1 ? mOrientation : getOrientation(parent);
    int childCount = parent.getChildCount();

    if (orientation == LinearLayoutManager.VERTICAL) {
      size = mDivider.getIntrinsicHeight();
      left = parent.getPaddingLeft();
      right = parent.getWidth() - parent.getPaddingRight();
    } else { // horizontal
      size = mDivider.getIntrinsicWidth();
      top = parent.getPaddingTop();
      bottom = parent.getHeight() - parent.getPaddingBottom();
    }

    for (int i = mShowFirstDivider ? 0 : 1; i < childCount; i++) {
      View child = parent.getChildAt(i);
      RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();

      if (orientation == LinearLayoutManager.VERTICAL) {
        top = child.getTop() - params.topMargin - size;
        bottom = top + size;
      } else { // horizontal
        left = child.getLeft() - params.leftMargin;
        right = left + size;
      }
      mDivider.setBounds(left, top, right, bottom);
      mDivider.draw(c);
    }

    // show last divider
    if (mShowLastDivider && childCount > 0) {
      View child = parent.getChildAt(childCount - 1);
      if (parent.getChildAdapterPosition(child) == (state.getItemCount() - 1)) {
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        if (orientation == LinearLayoutManager.VERTICAL) {
          top = child.getBottom() + params.bottomMargin;
          bottom = top + size;
        } else { // horizontal
          left = child.getRight() + params.rightMargin;
          right = left + size;
        }
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
      }
    }
  }
 @Override
 public void getItemOffsets(
     Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
   super.getItemOffsets(outRect, view, parent, state);
   int value = (parent.getChildLayoutPosition(view) < mNumberOfChildren) ? mHeaderHeight : 0;
   if (mReversed) {
     outRect.bottom = value;
   } else {
     outRect.top = value;
   }
 }
示例#8
0
  @Override
  public void getItemOffsets(Rect rect, View view, RecyclerView parent, RecyclerView.State state) {
    super.getItemOffsets(rect, view, parent, state);

    if (parent.getChildLayoutPosition(view) < 1) return;

    if (getOrientation(parent) == LinearLayoutManager.VERTICAL) {
      rect.top = mDivider.getIntrinsicHeight();
    } else {
      rect.left = mDivider.getIntrinsicWidth();
    }
  }
 @Override
 public void getItemOffsets(
     Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
   super.getItemOffsets(outRect, view, parent, state);
   RecyclerView.Adapter adapter = parent.getAdapter();
   final int position = parent.getChildAdapterPosition(view);
   final int size = view.getResources().getDimensionPixelSize(R.dimen.video_decoration_size);
   if (position == 0) {
     outRect.set(size, size * 4, size, 0);
   } else if (position == adapter.getItemCount() - 1) {
     outRect.set(size, 0, size, size * 4);
   } else {
     outRect.set(size, 0, size, 0);
   }
 }
 @Override
 public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
   super.onDraw(c, parent, state);
   // layout basically just gets drawn on the reserved space on top of the first view
   mLayout.layout(parent.getLeft(), 0, parent.getRight(), mLayout.getMeasuredHeight());
   for (int i = 0; i < parent.getChildCount(); i++) {
     View view = parent.getChildAt(i);
     if (parent.getChildAdapterPosition(view) == 0) {
       c.save();
       final int height = mLayout.getMeasuredHeight();
       final int top = view.getTop() - height;
       c.translate(0, top);
       mLayout.draw(c);
       c.restore();
       break;
     }
   }
 }
示例#11
0
  @Override
  public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
    super.onDraw(c, parent, state);

    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
      final View child = parent.getChildAt(i);
      RecyclerView v = new RecyclerView(parent.getContext());
      final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
      final int top = child.getBottom() + params.bottomMargin;
      final int bottom = top + mDivider.getIntrinsicHeight();
      mDivider.setBounds(left, top, right, bottom);
      mDivider.draw(c);
    }
  }
    @Override
    public void getItemOffsets(
        Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
      super.getItemOffsets(outRect, view, parent, state);

      SectionMultiAdapter<Data.SkinData> adapter =
          (SectionMultiAdapter<Data.SkinData>) parent.getAdapter();
      int position = parent.getChildAdapterPosition(view);
      //            @SectionMultiAdapter.ItemTypeSectionSummaryWhere int type =
      // adapter.getItemTypeByPosition(position);
      //            Log.e("LLL", ""+position+" , "+type);
      //            if (SectionMultiAdapter.ItemTypeSectionSummary.ITEM_HEADER == type) {
      //                return;
      //            }

      SectionMultiAdapter.DataItemWrapper wrapper = adapter.getItemInfo(position);
      if (wrapper.itemType == SectionMultiAdapter.ItemTypeSectionSummary.ITEM_DATA) {
        outRect.left = wrapper.positionOfGroup % 2 == 0 ? left : 0;
        outRect.right = left;
        outRect.top = left;
        return;
      }
    }
示例#13
0
 @Override
 public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
   super.onScrolled(recyclerView, dx, dy);
   debugLog("Scrolled: " + dx + " " + dy);
   fingerAnchorY -= dy;
 }
示例#14
0
 @Override
 public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
   super.onScrollStateChanged(recyclerView, newState);
 }
 /**
  * 装饰的绘制在Item条目绘制之后调用,因此装饰将浮于Item之上
  *
  * @param c
  * @param parent
  * @param state
  */
 @Override
 public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
   super.onDrawOver(c, parent, state);
 }