@Override public void onBindViewHolder(MyViewHolder holder, int position) { final AbstractDataProvider.Data item = mProvider.getItem(position); // set text holder.mTextView.setText(item.getText()); // set background resource (target view ID: container) final int dragState = holder.getDragStateFlags(); if (((dragState & Draggable.STATE_FLAG_IS_UPDATED) != 0)) { int bgResId; if ((dragState & Draggable.STATE_FLAG_IS_ACTIVE) != 0) { bgResId = R.drawable.bg_item_dragging_active_state; // need to clear drawable state here to get correct appearance of the dragging item. DrawableUtils.clearState(holder.mContainer.getForeground()); } else if ((dragState & Draggable.STATE_FLAG_DRAGGING) != 0) { bgResId = R.drawable.bg_item_dragging_state; } else { bgResId = R.drawable.bg_item_normal_state; } holder.mContainer.setBackgroundResource(bgResId); } }
@Override public void onBindViewHolder(MyViewHolder holder, int position) { final AbstractDataProvider.Data item = mProvider.getItem(position); holder.mContainer.setCanSwipeLeft(mCanSwipeLeft); holder.mContainer.setCanSwipeRight(!mCanSwipeLeft); holder.mTextView.setText(item.getText()); }
@Override protected void onPerformAction() { super.onPerformAction(); AbstractDataProvider.Data item = mAdapter.mProvider.getItem(mPosition); if (item.isPinned()) { item.setPinned(false); mAdapter.notifyItemChanged(mPosition); } }