Java Code Examples for androidx.recyclerview.widget.ItemTouchHelper#ACTION_STATE_IDLE
The following examples show how to use
androidx.recyclerview.widget.ItemTouchHelper#ACTION_STATE_IDLE .
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: FlexibleViewHolder.java From FlexibleAdapter with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} * * @see #toggleActivation() * @since 5.0.0-b1 */ @Override @CallSuper public void onClick(View view) { int position = getFlexibleAdapterPosition(); if (!mAdapter.isItemEnabled(position)) { return; } // Experimented that, if LongClick is not consumed, onClick is fired. We skip the // call to the listener in this case, which is allowed only in ACTION_STATE_IDLE. if (mAdapter.mItemClickListener != null && mActionState == ItemTouchHelper.ACTION_STATE_IDLE) { Log.v("onClick on position %s mode=%s", position, LayoutUtils.getModeName(mAdapter.getMode())); // Get the permission to activate the View from user if (mAdapter.mItemClickListener.onItemClick(view, position)) { // Now toggle the activation toggleActivation(); } } }
Example 2
Source File: SimpleItemTouchHelperCallback.java From YImagePicker with Apache License 2.0 | 6 votes |
@Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { // We only want the active item to change if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { if (viewHolder instanceof ItemTouchHelperViewHolder) { // Let the view holder know that this item is being moved or dragged ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder; itemViewHolder.onItemSelected(); } } super.onSelectedChanged(viewHolder, actionState); if (null != mOnSelectChangedListener) { mOnSelectChangedListener.onSelectedChanged(viewHolder, actionState); } }
Example 3
Source File: ItemTouchHelperCallback.java From FastLib with Apache License 2.0 | 6 votes |
@Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { mStarPosition = viewHolder.getAdapterPosition(); if (mOnItemTouchHelperListener != null) { mOnItemTouchHelperListener.onStart(mStarPosition); } if (viewHolder instanceof ItemTouchHelperViewHolder) { ItemTouchHelperViewHolder itemTouchHelperViewHolder = (ItemTouchHelperViewHolder) viewHolder; itemTouchHelperViewHolder.onItemSelectedChanged(); } } super.onSelectedChanged(viewHolder, actionState); }
Example 4
Source File: DailyTrendDisplayManageActivity.java From GeometricWeather with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); switch (actionState) { case ItemTouchHelper.ACTION_STATE_SWIPE: ((DailyTrendDisplayAdapter.ViewHolder) viewHolder).drawSwipe(dX); break; case ItemTouchHelper.ACTION_STATE_DRAG: ((DailyTrendDisplayAdapter.ViewHolder) viewHolder) .drawDrag(DailyTrendDisplayManageActivity.this, dY != 0); break; case ItemTouchHelper.ACTION_STATE_IDLE: ((DailyTrendDisplayAdapter.ViewHolder) viewHolder) .drawSwipe(0) .drawDrag(DailyTrendDisplayManageActivity.this, false); break; } }
Example 5
Source File: CardDisplayManageActivity.java From GeometricWeather with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); switch (actionState) { case ItemTouchHelper.ACTION_STATE_SWIPE: ((CardDisplayAdapter.ViewHolder) viewHolder) .drawSwipe(dX); break; case ItemTouchHelper.ACTION_STATE_DRAG: ((CardDisplayAdapter.ViewHolder) viewHolder) .drawDrag(CardDisplayManageActivity.this, dY != 0); break; case ItemTouchHelper.ACTION_STATE_IDLE: ((CardDisplayAdapter.ViewHolder) viewHolder) .drawSwipe(0) .drawDrag(CardDisplayManageActivity.this, false); break; } }
Example 6
Source File: ChatAttachAlertPollLayout.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { listView.setItemAnimator(itemAnimator); listView.cancelClickRunnables(false); viewHolder.itemView.setPressed(true); viewHolder.itemView.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground)); } super.onSelectedChanged(viewHolder, actionState); }
Example 7
Source File: ConversationItemSwipeCallback.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public void onChildDraw( @NonNull Canvas c, @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, float dx, float dy, int actionState, boolean isCurrentlyActive) { if (cannotSwipeViewHolder(viewHolder)) return; float sign = getSignFromDirection(viewHolder.itemView); boolean isCorrectSwipeDir = sameSign(dx, sign); if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE && isCorrectSwipeDir) { ConversationSwipeAnimationHelper.update((ConversationItem) viewHolder.itemView, Math.abs(dx), sign); handleSwipeFeedback((ConversationItem) viewHolder.itemView, Math.abs(dx)); if (canTriggerSwipe) { setTouchListener(recyclerView, viewHolder, Math.abs(dx)); } } else if (actionState == ItemTouchHelper.ACTION_STATE_IDLE || dx == 0) { ConversationSwipeAnimationHelper.update((ConversationItem) viewHolder.itemView, 0, 1); } if (dx == 0) { shouldTriggerSwipeFeedback = true; canTriggerSwipe = true; } }
Example 8
Source File: FiltersSetupActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { listView.cancelClickRunnables(false); viewHolder.itemView.setPressed(true); } super.onSelectedChanged(viewHolder, actionState); }
Example 9
Source File: FilterTabsView.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { listView.cancelClickRunnables(false); viewHolder.itemView.setPressed(true); viewHolder.itemView.setBackgroundColor(Theme.getColor(backgroundColorKey)); } super.onSelectedChanged(viewHolder, actionState); }
Example 10
Source File: CardListDemoFragment.java From material-components-android with Apache License 2.0 | 5 votes |
@Override public void onSelectedChanged(@Nullable ViewHolder viewHolder, int actionState) { super.onSelectedChanged(viewHolder, actionState); if (actionState == ItemTouchHelper.ACTION_STATE_DRAG && viewHolder != null) { dragCardView = (MaterialCardView) viewHolder.itemView; dragCardView.setDragged(true); } else if (actionState == ItemTouchHelper.ACTION_STATE_IDLE && dragCardView != null) { dragCardView.setDragged(false); dragCardView = null; } }
Example 11
Source File: TouchHelperCallback.java From SimplicityBrowser with MIT License | 5 votes |
@Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { if (viewHolder instanceof TouchHelperViewHolder) { TouchHelperViewHolder itemViewHolder = (TouchHelperViewHolder) viewHolder; itemViewHolder.onItemSelected(); } } super.onSelectedChanged(viewHolder, actionState); }
Example 12
Source File: SortFragment.java From prayer-times-android with Apache License 2.0 | 5 votes |
@Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { // We only want the active item if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { if (viewHolder instanceof ViewHolder) { ViewHolder itemViewHolder = (ViewHolder) viewHolder; itemViewHolder.itemView.setBackgroundColor(mixColor(getActivity().getResources().getColor(R.color.background), getActivity().getResources().getColor(R.color.backgroundSecondary))); } } super.onSelectedChanged(viewHolder, actionState); }
Example 13
Source File: StickersActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { if (actionState == ItemTouchHelper.ACTION_STATE_IDLE) { sendReorder(); } else { listView.cancelClickRunnables(false); viewHolder.itemView.setPressed(true); } super.onSelectedChanged(viewHolder, actionState); }
Example 14
Source File: FilterTabsView.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { listView.cancelClickRunnables(false); viewHolder.itemView.setPressed(true); viewHolder.itemView.setBackgroundColor(Theme.getColor(backgroundColorKey)); } super.onSelectedChanged(viewHolder, actionState); }
Example 15
Source File: SimpleItemTouchCallback.java From YouTube-In-Background with MIT License | 5 votes |
@Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { // We only want the active item to change if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { if (viewHolder instanceof ItemTouchViewListener) { // Let the view holder know that this item is being moved or dragged ItemTouchViewListener itemViewHolder = (ItemTouchViewListener) viewHolder; itemViewHolder.onItemSelected(); } } super.onSelectedChanged(viewHolder, actionState); }
Example 16
Source File: FiltersSetupActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { listView.cancelClickRunnables(false); viewHolder.itemView.setPressed(true); } super.onSelectedChanged(viewHolder, actionState); }
Example 17
Source File: SimpleItemTouchHelperCallback.java From andOTP with MIT License | 5 votes |
@Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { // We only want the active item to change if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { if (viewHolder instanceof ItemTouchHelperViewHolder) { // Let the view holder know that this item is being moved or dragged ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder; itemViewHolder.onItemSelected(); } } super.onSelectedChanged(viewHolder, actionState); }
Example 18
Source File: SimpleItemTouchHelperCallback.java From call_manage with MIT License | 5 votes |
@Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { // We only want the active item if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { if (viewHolder instanceof ItemTouchHelperViewHolder) { ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder; itemViewHolder.onItemSelected(); } } super.onSelectedChanged(viewHolder, actionState); }
Example 19
Source File: WaypointListAdapter.java From msdkui-android with Apache License 2.0 | 5 votes |
@Override public int getMovementFlags(final RecyclerView recyclerView, final RecyclerView.ViewHolder viewHolder) { final WaypointEntry entry = mWaypointEntries.get(viewHolder.getAdapterPosition()); final int dragFlags = entry.isDraggable() ? ItemTouchHelper.UP | ItemTouchHelper.DOWN : ItemTouchHelper.ACTION_STATE_IDLE; return makeMovementFlags(dragFlags, ItemTouchHelper.ACTION_STATE_IDLE); }
Example 20
Source File: FlexibleViewHolder.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
/** * Here we handle the event of when the ItemTouchHelper has completed the move or swipe. * <p>In this implementation, View activation is automatically handled.</p> * In case of Drag, the state will be cleared depends by current selection mode! * * @param position the position of the item released * @see #shouldActivateViewWhileSwiping() * @see #shouldAddSelectionInActionMode() * @since 5.0.0-b1 */ @Override @CallSuper public void onItemReleased(int position) { Log.v("onItemReleased position=%s mode=%s actionState=%s", position, LayoutUtils.getModeName(mAdapter.getMode()), (mActionState == ItemTouchHelper.ACTION_STATE_SWIPE ? "Swipe(1)" : "Drag(2)")); // Be sure to keep selection if MULTI and shouldAddSelectionInActionMode is active if (!alreadySelected) { if (shouldAddSelectionInActionMode() && mAdapter.getMode() == Mode.MULTI) { Log.v("onLongClick for ActionMode on position %s mode=%s", position, mAdapter.getMode()); if (mAdapter.mItemLongClickListener != null) { mAdapter.mItemLongClickListener.onItemLongClick(position); } if (mAdapter.isSelected(position)) { toggleActivation(); } } else if (shouldActivateViewWhileSwiping() && getContentView().isActivated()) { mAdapter.toggleSelection(position); toggleActivation(); } else if (mActionState == ItemTouchHelper.ACTION_STATE_DRAG) { mAdapter.toggleSelection(position); if (getContentView().isActivated()) { toggleActivation(); } } } // Reset internal action state ready for next action mLongClickSkipped = false; mActionState = ItemTouchHelper.ACTION_STATE_IDLE; }