private void FadingOutOtherItems(PopupMenu popupMenu) { // Dim out all the other list items if they exist LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager(); int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition(); int lastVisibleItemPosition = layoutManager.findLastVisibleItemPosition(); for (int i = firstVisibleItemPosition; i <= lastVisibleItemPosition; i++) { if (i == mHolder.getLayoutPosition()) continue; RecyclerViewHolder viewHolder = (RecyclerViewHolder) mRecyclerView.findViewHolderForLayoutPosition(i); View itemView = viewHolder.getItemView(); itemView.clearAnimation(); itemView.startAnimation(mFadeOut); } // Make sure to bring them back to normal after the menu is gone popupMenu.setOnDismissListener( new PopupMenu.OnDismissListener() { @Override public void onDismiss(PopupMenu popupMenu) { LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager(); int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition(); int lastVisibleItemPosition = layoutManager.findLastVisibleItemPosition(); for (int i = firstVisibleItemPosition; i <= lastVisibleItemPosition; i++) { if (i == mHolder.getLayoutPosition()) continue; RecyclerViewHolder viewHolder = (RecyclerViewHolder) mRecyclerView.findViewHolderForLayoutPosition(i); View itemView = viewHolder.getItemView(); viewHolder.getLayoutPosition(); itemView.clearAnimation(); itemView.startAnimation(mFadeIn); } } }); }
public OnShowPopupMenuClickListener( Context context, RecyclerView recyclerView, RecyclerViewHolder holder) { mContext = context; mRecyclerView = recyclerView; mPosition = holder.getLayoutPosition(); mHolder = holder; mFadeIn.setFillAfter(true); mFadeOut.setFillAfter(true); // mAlbum = album; }