androidx.recyclerview.widget.RecyclerView.ViewHolder Java Examples

The following examples show how to use androidx.recyclerview.widget.RecyclerView.ViewHolder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExpandableItemAnimator.java    From OmegaRecyclerView with MIT License 6 votes vote down vote up
@Nullable
private OmegaExpandableRecyclerView.Adapter.ChildViewHolder tryGetOffsettedViewHolder(
        List<ViewHolder> holders,
        OmegaExpandableRecyclerView.Adapter.ChildViewHolder forHolder,
        int offset) {
    int adapterPosition = forHolder.getAdapterPosition();
    int targetAdapterPosition =
            (adapterPosition == RecyclerView.NO_POSITION ? forHolder.animationHelper.visibleAdapterPosition : adapterPosition)
                    + offset;
    for (ViewHolder holder : holders) {
        if (holder instanceof OmegaExpandableRecyclerView.Adapter.ChildViewHolder) {
            OmegaExpandableRecyclerView.Adapter.ChildViewHolder cvh = (OmegaExpandableRecyclerView.Adapter.ChildViewHolder) holder;
            int holderAdapterPosition = cvh.getAdapterPosition() == RecyclerView.NO_POSITION ?
                    cvh.animationHelper.visibleAdapterPosition :
                    cvh.getAdapterPosition();
            if (holderAdapterPosition == targetAdapterPosition) {
                return cvh;
            }
        }
    }
    return null;
}
 
Example #2
Source File: ExpandableItemAnimator.java    From OmegaRecyclerView with MIT License 6 votes vote down vote up
private void scheduleAddAnimation(final ArrayList<ViewHolder> additions, boolean forceDelay, boolean hasRemovals, boolean hasMoves, boolean hasChanges) {
    if (!additions.isEmpty()) {
        mAdditionsList.add(additions);
        Runnable adder = new Runnable() {
            public void run() {
                proceedWithAnimationHelper(additions, new UnVoidFunction<ViewHolder>() {
                    @Override
                    public void apply(ViewHolder param) {
                        runAddAnimation(param);
                    }
                }, true);
                mAdditionsList.remove(additions);
            }
        };
        if (hasRemovals || hasMoves || hasChanges) {
            View view = additions.get(0).itemView;
            long totalDelay = getTotalDelay(hasRemovals, hasMoves, hasChanges);
            ViewCompat.postOnAnimationDelayed(view, adder, forceDelay || isNeedAddingDelay() ? totalDelay : 0L);
        } else {
            adder.run();
        }
    }
}
 
Example #3
Source File: ItemTouchHelper.java    From Carbon with Apache License 2.0 6 votes vote down vote up
private ViewHolder findSwipedView(MotionEvent motionEvent) {
    final RecyclerView.LayoutManager lm = mRecyclerView.getLayoutManager();
    if (mActivePointerId == ACTIVE_POINTER_ID_NONE) {
        return null;
    }
    final int pointerIndex = motionEvent.findPointerIndex(mActivePointerId);
    final float dx = motionEvent.getX(pointerIndex) - mInitialTouchX;
    final float dy = motionEvent.getY(pointerIndex) - mInitialTouchY;
    final float absDx = Math.abs(dx);
    final float absDy = Math.abs(dy);
    if (absDx < mSlop && absDy < mSlop) {
        return null;
    }
    if (absDx > absDy && lm.canScrollHorizontally()) {
        return null;
    } else if (absDy > absDx && lm.canScrollVertically()) {
        return null;
    }
    View child = findChildView(motionEvent);
    if (child == null) {
        return null;
    }
    return mRecyclerView.getChildViewHolder(child);
}
 
Example #4
Source File: FriendsRecyclerAdapter.java    From toktok-android with GNU General Public License v3.0 6 votes vote down vote up
@NonNull
@Override
public FriendsRecyclerViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
    final RelativeLayout itemView = (RelativeLayout) LayoutInflater.from(viewGroup.getContext())
            .inflate(R.layout.fragment_home_friends_item, viewGroup, false);

    return new FriendsRecyclerViewHolder(itemView, () -> {
        ViewHolder holder = (ViewHolder) itemView.getTag();

        if (expandedItem == holder.getLayoutPosition()) {
            notifyItemChanged(expandedItem);
            expandedItem = -1;
        } else {
            if (expandedItem >= 0) {
                notifyItemChanged(expandedItem);
            }

            expandedItem = holder.getLayoutPosition();
            notifyItemChanged(expandedItem);
        }
    });
}
 
Example #5
Source File: ItemTouchHelper.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
RecoverAnimation(ViewHolder viewHolder, int animationType,
        int actionState, float startDx, float startDy, float targetX, float targetY) {
    mActionState = actionState;
    mAnimationType = animationType;
    mViewHolder = viewHolder;
    mStartDx = startDx;
    mStartDy = startDy;
    mTargetX = targetX;
    mTargetY = targetY;
    mValueAnimator = ValueAnimator.ofFloat(0f, 1f);
    mValueAnimator.addUpdateListener(
            new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    setFraction(animation.getAnimatedFraction());
                }
            });
    mValueAnimator.setTarget(viewHolder.itemView);
    mValueAnimator.addListener(this);
    setFraction(0f);
}
 
Example #6
Source File: ItemTouchHelper.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private int checkVerticalSwipe(ViewHolder viewHolder, int flags) {
    if ((flags & (UP | DOWN)) != 0) {
        final int dirFlag = mDy > 0 ? DOWN : UP;
        if (mVelocityTracker != null && mActivePointerId > -1) {
            mVelocityTracker.computeCurrentVelocity(PIXELS_PER_SECOND,
                    mCallback.getSwipeVelocityThreshold(mMaxSwipeVelocity));
            final float xVelocity = mVelocityTracker.getXVelocity(mActivePointerId);
            final float yVelocity = mVelocityTracker.getYVelocity(mActivePointerId);
            final int velDirFlag = yVelocity > 0f ? DOWN : UP;
            final float absYVelocity = Math.abs(yVelocity);
            if ((velDirFlag & flags) != 0 && velDirFlag == dirFlag
                    && absYVelocity >= mCallback.getSwipeEscapeVelocity(mSwipeEscapeVelocity)
                    && absYVelocity > Math.abs(xVelocity)) {
                return velDirFlag;
            }
        }

        final float threshold = mRecyclerView.getHeight() * mCallback
                .getSwipeThreshold(viewHolder);
        if ((flags & dirFlag) != 0 && Math.abs(mDy) > threshold) {
            return dirFlag;
        }
    }
    return 0;
}
 
Example #7
Source File: FlexibleItemAnimator.java    From FlexibleAdapter with Apache License 2.0 6 votes vote down vote up
private void runChangeAnimation(boolean removalsPending, boolean changesPending) {
    // Change animation to run in parallel with move animations
    if (changesPending) {
        final ArrayList<ChangeInfo> changes = new ArrayList<>();
        changes.addAll(mPendingChanges);
        mChangesList.add(changes);
        mPendingChanges.clear();
        Runnable changer = new Runnable() {
            @Override
            public void run() {
                for (ChangeInfo change : changes) {
                    animateChangeImpl(change);
                }
                changes.clear();
                mChangesList.remove(changes);
            }
        };
        if (removalsPending) {
            ViewHolder holder = changes.get(0).oldHolder;
            ViewCompat.postOnAnimationDelayed(holder.itemView, changer, getRemoveDuration());
        } else {
            changer.run();
        }
    }
}
 
Example #8
Source File: ListsMainDemoFragment.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int position) {
  switch (getItemViewType(position)) {
    case ITEM_SINGLE_LINE:
      bind((SingleLineItemViewHolder) viewHolder);
      break;
    case ITEM_TWO_LINE:
      bind((TwoLineItemViewHolder) viewHolder);
      break;
    case ITEM_THREE_LINE:
      bind((ThreeLineItemViewHolder) viewHolder);
      break;
    default: // fall out
  }

  viewHolder.itemView.setOnClickListener(
      v ->
          Toast.makeText(v.getContext(), R.string.mtrl_list_item_clicked, Toast.LENGTH_SHORT)
              .show());
}
 
Example #9
Source File: StickyHeaderDecoration.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
protected @NonNull ViewHolder getHeader(RecyclerView parent, StickyHeaderAdapter adapter, int position) {
  final long key = adapter.getHeaderId(position);

  ViewHolder headerHolder = headerCache.get(key);
  if (headerHolder == null) {

    if (key != StickyHeaderAdapter.NO_HEADER_ID) {
      headerHolder = adapter.onCreateHeaderViewHolder(parent, position);
      //noinspection unchecked
      adapter.onBindHeaderViewHolder(headerHolder, position);
    }

    if (headerHolder == null) {
      headerHolder = new RecyclerView.ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.null_recyclerview_header, parent, false)) {
      };
    }

    headerCache.put(key, headerHolder);
  }

  final View header = headerHolder.itemView;

  int widthSpec   = View.MeasureSpec.makeMeasureSpec(parent.getWidth(), View.MeasureSpec.EXACTLY);
  int heightSpec  = View.MeasureSpec.makeMeasureSpec(parent.getHeight(), View.MeasureSpec.UNSPECIFIED);

  int childWidth  = ViewGroup.getChildMeasureSpec(widthSpec,
                                                  parent.getPaddingLeft() + parent.getPaddingRight(), header.getLayoutParams().width);
  int childHeight = ViewGroup.getChildMeasureSpec(heightSpec,
                                                  parent.getPaddingTop() + parent.getPaddingBottom(), header.getLayoutParams().height);

  header.measure(childWidth, childHeight);
  header.layout(0, 0, header.getMeasuredWidth(), header.getMeasuredHeight());

  return headerHolder;
}
 
Example #10
Source File: ItemTouchHelperExtension.java    From CrazyDaily with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if we should swap w/ another view holder.
 */
private void moveIfNecessary(ViewHolder viewHolder) {
    if (mRecyclerView.isLayoutRequested()) {
        return;
    }
    if (mActionState != ACTION_STATE_DRAG) {
        return;
    }

    final float threshold = mCallback.getMoveThreshold(viewHolder);
    final int x = (int) (mSelectedStartX + mDx);
    final int y = (int) (mSelectedStartY + mDy);
    if (Math.abs(y - viewHolder.itemView.getTop()) < viewHolder.itemView.getHeight() * threshold
            && Math.abs(x - viewHolder.itemView.getLeft())
            < viewHolder.itemView.getWidth() * threshold) {
        return;
    }
    List<ViewHolder> swapTargets = findSwapTargets(viewHolder);
    if (swapTargets.size() == 0) {
        return;
    }
    // may swap.
    ViewHolder target = mCallback.chooseDropTarget(viewHolder, swapTargets, x, y);
    if (target == null) {
        mSwapTargets.clear();
        mDistances.clear();
        return;
    }
    final int toPosition = target.getAdapterPosition();
    final int fromPosition = viewHolder.getAdapterPosition();
    if (mCallback.onMove(mRecyclerView, viewHolder, target)) {
        // keep target visible
        mCallback.onMoved(mRecyclerView, viewHolder, fromPosition,
                target, toPosition, x, y);
    }
}
 
Example #11
Source File: QueueAnimator.java    From Jockey with Apache License 2.0 5 votes vote down vote up
@Override
public boolean animateRemove(ViewHolder holder) {
    if (shouldAnimateRemove(holder)) {
        return super.animateRemove(holder);
    } else {
        dispatchRemoveFinished(holder);
        return false;
    }
}
 
Example #12
Source File: DialogsItemAnimator.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean animateAdd(final ViewHolder holder) {
    resetAnimation(holder);
    if (holder.itemView instanceof DialogCell) {
        ((DialogCell) holder.itemView).setClipProgress(1.0f);
    } else {
        holder.itemView.setAlpha(0);
    }
    mPendingAdditions.add(holder);
    return true;
}
 
Example #13
Source File: CursorRecyclerViewAdapter.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public final void onViewRecycled(ViewHolder holder) {
  if (!(holder instanceof HeaderFooterViewHolder)) {
    onItemViewRecycled((VH)holder);
  }
}
 
Example #14
Source File: DialogsItemAnimator.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void endChangeAnimation(List<ChangeInfo> infoList, ViewHolder item) {
    for (int i = infoList.size() - 1; i >= 0; i--) {
        ChangeInfo changeInfo = infoList.get(i);
        if (endChangeAnimationIfNecessary(changeInfo, item)) {
            if (changeInfo.oldHolder == null && changeInfo.newHolder == null) {
                infoList.remove(changeInfo);
            }
        }
    }
}
 
Example #15
Source File: DataEntryAdapter.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    if (viewType == IMAGE)
        return ((ImageRow) rows.get(IMAGE)).onCreate(parent, totalFields, imageSelector, rendering);
    else
        return rows.get(viewType).onCreate(parent);
}
 
Example #16
Source File: FlexibleItemAnimator.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
private void doAnimateAdd(final ViewHolder holder, final int index) {
    Log.v("AnimateAdd on itemId=%s position=%s", holder.getItemId(), holder.getLayoutPosition());
    boolean consumed = false;
    if (holder instanceof AnimatedViewHolder) {
        consumed = ((AnimatedViewHolder) holder).animateAddImpl(new DefaultAddVpaListener(holder), getAddDuration(), index);
    }
    if (!consumed) {
        animateAddImpl(holder, index);
    }
    mAddAnimations.add(holder);
}
 
Example #17
Source File: CursorRecyclerViewAdapter.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public @NonNull final ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
  switch (viewType) {
  case HEADER_TYPE:
  case FOOTER_TYPE:
    return new HeaderFooterViewHolder(LayoutInflater.from(context).inflate(R.layout.cursor_adapter_header_footer_view, parent, false));
  default:
    return onCreateItemViewHolder(parent, viewType);
  }
}
 
Example #18
Source File: FlexibleItemAnimator.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
private void endChangeAnimation(List<ChangeInfo> infoList, ViewHolder item) {
    for (int i = infoList.size() - 1; i >= 0; i--) {
        ChangeInfo changeInfo = infoList.get(i);
        if (endChangeAnimationIfNecessary(changeInfo, item)) {
            if (changeInfo.oldHolder == null && changeInfo.newHolder == null) {
                infoList.remove(changeInfo);
            }
        }
    }
}
 
Example #19
Source File: DialogsItemAnimator.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder,ItemHolderInfo info, int fromX, int fromY, int toX, int toY) {
    if (oldHolder.itemView instanceof DialogCell) {
        resetAnimation(oldHolder);
        resetAnimation(newHolder);
        oldHolder.itemView.setAlpha(1.0f);
        newHolder.itemView.setAlpha(0.0f);
        newHolder.itemView.setTranslationX(0.0f);
        mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY));
        return true;
    }
    return false;
}
 
Example #20
Source File: FlipDownItemAnimator.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
@Override
protected ViewPropertyAnimatorCompat animateRemoveImpl(ViewHolder holder) {
    return ViewCompat.animate(holder.itemView)
                     .rotationY(90)
                     .translationX(-(holder.itemView.getMeasuredWidth() / 4))
                     .scaleX(0.5F)
                     .scaleY(0.5F)
                     .setInterpolator(new AccelerateInterpolator());
}
 
Example #21
Source File: ItemTouchHelper.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks if we should swap w/ another view holder.
 */
@SuppressWarnings("WeakerAccess") /* synthetic access */
void moveIfNecessary(ViewHolder viewHolder) {
    if (mRecyclerView.isLayoutRequested()) {
        return;
    }
    if (mActionState != ACTION_STATE_DRAG) {
        return;
    }

    final float threshold = mCallback.getMoveThreshold(viewHolder);
    final int x = (int) (mSelectedStartX + mDx);
    final int y = (int) (mSelectedStartY + mDy);
    if (Math.abs(y - viewHolder.itemView.getTop()) < viewHolder.itemView.getHeight() * threshold
            && Math.abs(x - viewHolder.itemView.getLeft())
            < viewHolder.itemView.getWidth() * threshold) {
        return;
    }
    List<ViewHolder> swapTargets = findSwapTargets(viewHolder);
    if (swapTargets.size() == 0) {
        return;
    }
    // may swap.
    ViewHolder target = mCallback.chooseDropTarget(viewHolder, swapTargets, x, y);
    if (target == null) {
        mSwapTargets.clear();
        mDistances.clear();
        return;
    }
    final int toPosition = target.getAdapterPosition();
    final int fromPosition = viewHolder.getAdapterPosition();
    if (mCallback.onMove(mRecyclerView, viewHolder, target)) {
        // keep target visible
        mCallback.onMoved(mRecyclerView, viewHolder, fromPosition,
                target, toPosition, x, y);
    }
}
 
Example #22
Source File: ItemTouchHelper.java    From Carbon with Apache License 2.0 5 votes vote down vote up
@Override
public void onLongPress(MotionEvent e) {
    if (!mShouldReactToLongPress) {
        return;
    }
    View child = findChildView(e);
    if (child != null) {
        ViewHolder vh = mRecyclerView.getChildViewHolder(child);
        if (vh != null) {
            if (!mCallback.hasDragFlag(mRecyclerView, vh)) {
                return;
            }
            int pointerId = e.getPointerId(0);
            // Long press is deferred.
            // Check w/ active pointer id to avoid selecting after motion
            // event is canceled.
            if (pointerId == mActivePointerId) {
                final int index = e.findPointerIndex(mActivePointerId);
                final float x = e.getX(index);
                final float y = e.getY(index);
                mInitialTouchX = x;
                mInitialTouchY = y;
                mDx = mDy = 0f;
                if (DEBUG) {
                    Log.d(TAG,
                            "onlong press: x:" + mInitialTouchX + ",y:" + mInitialTouchY);
                }
                if (mCallback.isLongPressDragEnabled()) {
                    select(vh, ACTION_STATE_DRAG);
                }
            }
        }
    }
}
 
Example #23
Source File: FlexibleItemAnimator.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
private boolean preAnimateAdd(final ViewHolder holder) {
    clear(holder.itemView);
    boolean consumed = false;
    if (holder instanceof AnimatedViewHolder) {
        consumed = ((AnimatedViewHolder) holder).preAnimateAddImpl();
    }
    return consumed || preAnimateAddImpl(holder);
}
 
Example #24
Source File: PendingItemAnimator.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
private MoveInfo(ViewHolder holder, int fromX, int fromY, int toX, int toY) {
    this.holder = holder;
    this.fromX = fromX;
    this.fromY = fromY;
    this.toX = toX;
    this.toY = toY;
}
 
Example #25
Source File: SlideItemAnimator.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
protected ViewPropertyAnimatorCompat animateRemoveImpl(ViewHolder holder) {
    final View view = holder.itemView;
    ViewCompat.animate(view).cancel();
    return ViewCompat.animate(view)
                     .translationX(Utils.getScreenDimensions(holder.itemView.getContext()).x)
                     .setInterpolator(new AnticipateOvershootInterpolator());
}
 
Example #26
Source File: ItemTouchHelper.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Called when {@link #onMove(RecyclerView, ViewHolder, ViewHolder)} returns true.
 * <p>
 * ItemTouchHelper does not create an extra Bitmap or View while dragging, instead, it
 * modifies the existing View. Because of this reason, it is important that the View is
 * still part of the layout after it is moved. This may not work as intended when swapped
 * Views are close to RecyclerView bounds or there are gaps between them (e.g. other Views
 * which were not eligible for dropping over).
 * <p>
 * This method is responsible to give necessary hint to the LayoutManager so that it will
 * keep the View in visible area. For example, for LinearLayoutManager, this is as simple
 * as calling {@link LinearLayoutManager#scrollToPositionWithOffset(int, int)}.
 *
 * Default implementation calls {@link RecyclerView#scrollToPosition(int)} if the View's
 * new position is likely to be out of bounds.
 * <p>
 * It is important to ensure the ViewHolder will stay visible as otherwise, it might be
 * removed by the LayoutManager if the move causes the View to go out of bounds. In that
 * case, drag will end prematurely.
 *
 * @param recyclerView The RecyclerView controlled by the ItemTouchHelper.
 * @param viewHolder   The ViewHolder under user's control.
 * @param fromPos      The previous adapter position of the dragged item (before it was
 *                     moved).
 * @param target       The ViewHolder on which the currently active item has been dropped.
 * @param toPos        The new adapter position of the dragged item.
 * @param x            The updated left value of the dragged View after drag translations
 *                     are applied. This value does not include margins added by
 *                     {@link RecyclerView.ItemDecoration}s.
 * @param y            The updated top value of the dragged View after drag translations
 *                     are applied. This value does not include margins added by
 *                     {@link RecyclerView.ItemDecoration}s.
 */
public void onMoved(@NonNull final RecyclerView recyclerView,
        @NonNull final ViewHolder viewHolder, int fromPos, @NonNull final ViewHolder target,
        int toPos, int x, int y) {
    final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof ViewDropHandler) {
        ((ViewDropHandler) layoutManager).prepareForDrop(viewHolder.itemView,
                target.itemView, x, y);
        return;
    }

    // if layout manager cannot handle it, do some guesswork
    if (layoutManager.canScrollHorizontally()) {
        final int minLeft = layoutManager.getDecoratedLeft(target.itemView);
        if (minLeft <= recyclerView.getPaddingLeft()) {
            recyclerView.scrollToPosition(toPos);
        }
        final int maxRight = layoutManager.getDecoratedRight(target.itemView);
        if (maxRight >= recyclerView.getWidth() - recyclerView.getPaddingRight()) {
            recyclerView.scrollToPosition(toPos);
        }
    }

    if (layoutManager.canScrollVertically()) {
        final int minTop = layoutManager.getDecoratedTop(target.itemView);
        if (minTop <= recyclerView.getPaddingTop()) {
            recyclerView.scrollToPosition(toPos);
        }
        final int maxBottom = layoutManager.getDecoratedBottom(target.itemView);
        if (maxBottom >= recyclerView.getHeight() - recyclerView.getPaddingBottom()) {
            recyclerView.scrollToPosition(toPos);
        }
    }
}
 
Example #27
Source File: FlexibleItemAnimator.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
private void doAnimateRemove(final ViewHolder holder, final int index) {
    Log.v("AnimateRemove on itemId %s", holder.getItemId());
    boolean consumed = false;
    if (holder instanceof AnimatedViewHolder) {
        consumed = ((AnimatedViewHolder) holder).animateRemoveImpl(new DefaultRemoveVpaListener(holder), getRemoveDuration(), index);
    }
    if (!consumed) {
        animateRemoveImpl(holder, index);
    }
    mRemoveAnimations.add(holder);
}
 
Example #28
Source File: ExpandableItemAnimator.java    From OmegaRecyclerView with MIT License 5 votes vote down vote up
private void endChangeAnimation(List<AnimationHelper.ChangeInfo> infoList, ViewHolder item) {
    for (int i = infoList.size() - 1; i >= 0; i--) {
        AnimationHelper.ChangeInfo changeInfo = infoList.get(i);
        if (endChangeAnimationIfNecessary(changeInfo, item)) {
            if (changeInfo.oldHolder == null && changeInfo.newHolder == null) {
                infoList.remove(changeInfo);
            }
        }
    }
}
 
Example #29
Source File: ExpandableItemAnimator.java    From OmegaRecyclerView with MIT License 5 votes vote down vote up
private void runRemoveAnimation(ViewHolder holder) {
    if (holder instanceof OmegaExpandableRecyclerView.Adapter.ChildViewHolder) {
        animateRemoveChild((OmegaExpandableRecyclerView.Adapter.ChildViewHolder) holder);
    } else {
        animateRemoveGroup(holder);
    }
    mRemoveAnimations.add(holder);
}
 
Example #30
Source File: ExpandableItemAnimator.java    From OmegaRecyclerView with MIT License 5 votes vote down vote up
@Override
public boolean animateAdd(final ViewHolder holder) {
    makeHolderInvisible(holder);
    endAnimation(holder);
    mPendingChanges.additions.add(holder);
    return true;
}