Java Code Examples for androidx.recyclerview.widget.RecyclerView#ViewHolder
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: SideMenultItemAnimator.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private boolean endChangeAnimationIfNecessary(ChangeInfo changeInfo, RecyclerView.ViewHolder item) { boolean oldItem = false; if (changeInfo.newHolder == item) { changeInfo.newHolder = null; } else if (changeInfo.oldHolder == item) { changeInfo.oldHolder = null; oldItem = true; } else { return false; } item.itemView.setAlpha(1); item.itemView.setTranslationX(0); item.itemView.setTranslationY(0); dispatchChangeFinished(item, oldItem); return true; }
Example 2
Source File: PortfolioSection.java From SectionedRecyclerViewAdapter with MIT License | 6 votes |
@Override public void onBindItemViewHolder(final RecyclerView.ViewHolder holder, final int position, final List<Object> payloads) { final PortfolioItemViewHolder itemHolder = (PortfolioItemViewHolder) holder; final PortfolioItem item = list.get(position); for (Object obj : payloads) { if (obj instanceof ItemPriceUpdate) { itemHolder.tvHoldingPrice.setText(String.valueOf(item.holdingPrice)); itemHolder.tvPrice.setText(String.valueOf(item.price)); itemHolder.tvDelta.setText(String.valueOf(item.delta)); itemHolder.tvDelta.setTextColor(item.deltaColor); } } itemHolder.rootView.setOnClickListener(v -> clickListener.onItemRootViewClicked(this, itemHolder.getAdapterPosition()) ); }
Example 3
Source File: SimpleAnimationAdapter.java From UltimateRecyclerView with Apache License 2.0 | 6 votes |
@Override public void onBindHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int position) { TextView textView = (TextView) viewHolder.itemView.findViewById(R.id.stick_text); textView.setText(String.valueOf(getItem(position).charAt(0))); // viewHolder.itemView.setBackgroundColor(Color.parseColor("#AA70DB93")); viewHolder.itemView.setBackgroundColor(Color.parseColor("#AAffffff")); ImageView imageView = (ImageView) viewHolder.itemView.findViewById(R.id.stick_img); SecureRandom imgGen = new SecureRandom(); switch (imgGen.nextInt(3)) { case 0: imageView.setImageResource(R.drawable.scn1); break; case 1: imageView.setImageResource(R.drawable.jr13); break; case 2: imageView.setImageResource(R.drawable.jr16); break; } }
Example 4
Source File: RvItemClickSupport.java From Aria with Apache License 2.0 | 5 votes |
@Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (mOnItemKeyListener != null) { RecyclerView.ViewHolder holder = mRecyclerView.getChildViewHolder(v); return mOnItemKeyListener.onKey(v, keyCode, holder.getAdapterPosition(), event); } return false; }
Example 5
Source File: ScaleInRightAnimator.java From recyclerview-animators with Apache License 2.0 | 5 votes |
@Override protected void animateAddImpl(final RecyclerView.ViewHolder holder) { ViewCompat.animate(holder.itemView) .scaleX(1) .scaleY(1) .setDuration(getAddDuration()) .setInterpolator(mInterpolator) .setListener(new DefaultAddVpaListener(holder)) .setStartDelay(getAddDelay(holder)) .start(); }
Example 6
Source File: ChatMessagesAdapter.java From revolution-irc with GNU General Public License v3.0 | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { int viewType = holder.getItemViewType(); Object msg = getMessage(position); if (viewType == TYPE_MESSAGE || viewType == TYPE_MESSAGE_WITH_NEW_MESSAGE_MARKER) { ((MessageHolder) holder).bind((MessageItem) msg); } else if (viewType == TYPE_DAY_MARKER) { ((DayMarkerHolder) holder).bind((DayMarkerItem) msg); } }
Example 7
Source File: ContactsSection.java From SectionedRecyclerViewAdapter with MIT License | 5 votes |
@Override public void onBindItemViewHolder(final RecyclerView.ViewHolder holder, final int position) { final ItemViewHolder itemHolder = (ItemViewHolder) holder; final Contact contact = filteredList.get(position); itemHolder.tvItem.setText(contact.name); itemHolder.imgItem.setImageResource(contact.profileImage); itemHolder.rootView.setOnClickListener(v -> clickListener.onItemRootViewClicked(this, itemHolder.getAdapterPosition()) ); }
Example 8
Source File: GroupInviteActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { switch (holder.getItemViewType()) { case 0: TextSettingsCell textCell = (TextSettingsCell) holder.itemView; if (position == copyLinkRow) { textCell.setText(LocaleController.getString("CopyLink", R.string.CopyLink), true); } else if (position == shareLinkRow) { textCell.setText(LocaleController.getString("ShareLink", R.string.ShareLink), false); } else if (position == revokeLinkRow) { textCell.setText(LocaleController.getString("RevokeLink", R.string.RevokeLink), true); } break; case 1: TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView; if (position == shadowRow) { privacyCell.setText(""); privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow)); } else if (position == linkInfoRow) { TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(chat_id); if (ChatObject.isChannel(chat) && !chat.megagroup) { privacyCell.setText(LocaleController.getString("ChannelLinkInfo", R.string.ChannelLinkInfo)); } else { privacyCell.setText(LocaleController.getString("LinkInfo", R.string.LinkInfo)); } privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow)); } break; case 2: TextBlockCell textBlockCell = (TextBlockCell) holder.itemView; textBlockCell.setText(invite != null ? invite.link : "error", false); break; } }
Example 9
Source File: ThemesHorizontalListCell.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { InnerThemeView view = (InnerThemeView) holder.itemView; ArrayList<Theme.ThemeInfo> arrayList; int p = position; if (position < defaultThemes.size()) { arrayList = defaultThemes; } else { arrayList = darkThemes; p -= defaultThemes.size(); } view.setTheme(arrayList.get(p), position == getItemCount() - 1, position == 0); }
Example 10
Source File: ExpandableStickyDecoration.java From OmegaRecyclerView with MIT License | 4 votes |
private void drawStickyHeader(Canvas canvas, RecyclerView.ViewHolder stickyHeader) { drawHeader(canvas, stickyHeader, mDrawingInfo.sticky.left, mDrawingInfo.sticky.top); }
Example 11
Source File: SortFragment.java From prayer-times-android with Apache License 2.0 | 4 votes |
@Override public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) { onItemMove(viewHolder.getAdapterPosition(), target.getAdapterPosition()); return true; }
Example 12
Source File: ChatFragmentSendMessageHelper.java From revolution-irc with GNU General Public License v3.0 | 4 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { return makeMovementFlags(0, ItemTouchHelper.START | ItemTouchHelper.END); }
Example 13
Source File: DefaultEndlessRecyclerAdapter.java From GestureViews with Apache License 2.0 | 4 votes |
@Override public final void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List<Object> payloads) { onBindViewHolder(holder, position); }
Example 14
Source File: MyItemTouchHelpCallback.java From HaoReader with GNU General Public License v3.0 | 4 votes |
@Override public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { if (onItemTouchCallbackListener != null) { onItemTouchCallbackListener.onSwiped(viewHolder.getLayoutPosition()); } }
Example 15
Source File: GroupChannelListAdapter.java From SendBird-Android with MIT License | 4 votes |
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.list_item_group_channel, parent, false); return new ChannelHolder(view); }
Example 16
Source File: AbsDelegationAdapter.java From AdapterDelegates with Apache License 2.0 | 4 votes |
@Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { delegatesManager.onBindViewHolder(items, position, holder, null); }
Example 17
Source File: ItemDragAndSwipeCallback.java From BaseProject with Apache License 2.0 | 4 votes |
@Override public void onMoved(RecyclerView recyclerView, RecyclerView.ViewHolder source, int fromPos, RecyclerView.ViewHolder target, int toPos, int x, int y) { super.onMoved(recyclerView, source, fromPos, target, toPos, x, y); mAdapter.onItemDragMoving(source, target); }
Example 18
Source File: JoinGroupAlert.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public boolean isEnabled(RecyclerView.ViewHolder holder) { return false; }
Example 19
Source File: Section.java From SectionedRecyclerViewAdapter with MIT License | 2 votes |
/** * Bind the data to the ViewHolder for the Footer of this Section. * * @param holder ViewHolder for the Footer of this Section * @param payloads A non-null and non-empty list of merged payloads. */ @SuppressWarnings("PMD.EmptyMethodInAbstractClassShouldBeAbstract") public void onBindFooterViewHolder(final RecyclerView.ViewHolder holder, @SuppressWarnings("unused") final List<Object> payloads) { this.onBindFooterViewHolder(holder); }
Example 20
Source File: SectionedRecyclerViewAdapter.java From mollyim-android with GNU General Public License v3.0 | votes |
protected @NonNull abstract RecyclerView.ViewHolder createHeaderViewHolder(@NonNull ViewGroup parent);