@Override public Adapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { LinearLayout linearLayout = (LinearLayout) View.inflate(parent.getContext(), R.layout.carbon_tablelayout_row, null); linearLayout.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); linearLayout.setMinimumHeight((int) parent.getContext().getResources().getDimension(R.dimen.carbon_tableRowHeight)); float weightSum = 0; for (int i = 0; i < getColumnCount(); i++) { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, getColumnWeight(i)); linearLayout.addView(tableView.getCellRenderer(getColumnClass(i)).getView(parent.getContext()), params); weightSum += getColumnWeight(i); } linearLayout.setWeightSum(weightSum); return new ViewHolder(linearLayout); }
anchorView = child; anchorIndex = i; anchorPos = params.getViewAdapterPosition(); break;
/** * Returns true when {@code view} is a valid anchor, ie. the first view to be valid and visible. */ private boolean isViewValidAnchor(View view, RecyclerView.LayoutParams params) { if (!params.isItemRemoved() && !params.isViewInvalid()) { if (getOrientation() == VERTICAL) { if (getReverseLayout()) { return view.getTop() + view.getTranslationY() <= getHeight() + mTranslationY; } else { return view.getBottom() - view.getTranslationY() >= mTranslationY; } } else { if (getReverseLayout()) { return view.getLeft() + view.getTranslationX() <= getWidth() + mTranslationX; } else { return view.getRight() - view.getTranslationX() >= mTranslationX; } } } else { return false; } }
public void bind(MessageItem item) { itemView.setVisibility(item.mHidden ? View.GONE : View.VISIBLE); if (item.mHidden) itemView.setLayoutParams(new RecyclerView.LayoutParams(0, 0)); else if (itemView.getLayoutParams() != mDefaultLayoutParams) itemView.setLayoutParams(mDefaultLayoutParams); MessageInfo message = item.mMessage; if (mTypeface != null) mText.setTypeface(mTypeface); if (mFontSize != -1) mText.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSize); if (mMultiSelectListener != null) setSelected(mSelectedItems.contains(getItemId()) || mMultiSelectListener.isElementHighlighted(getItemId()), false); if (NotificationManager.getInstance().shouldMessageUseMentionFormatting(mFragment.getConnectionInfo(), mFragment.getChannelName(), message)) mText.setText(AlignToPointSpan.apply(mText, MessageBuilder.getInstance(mText.getContext()).buildMessageWithMention(message))); else mText.setText(AlignToPointSpan.apply(mText, MessageBuilder.getInstance(mText.getContext()).buildMessage(message))); if (mSelectListener != null) mSelectListener.applySelectionTo(itemView, getAdapterPosition()); }
public FastScrollRecyclerView(@NonNull Context context) { super(context); layout(context, null); setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); }
/** * Create the RecyclerView and set it as the dialog view. * * @return the created RecyclerView */ private RecyclerView createRecyclerView() { RecyclerView recyclerView = new RecyclerView(getContext()); RecyclerView.LayoutParams params = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); recyclerView.setLayoutParams(params); setView(recyclerView); return recyclerView; }
/** * Create the RecyclerView and set it as the dialog view. * * @return the created RecyclerView */ private RecyclerView createRecyclerView() { RecyclerView recyclerView = new RecyclerView(getContext()); RecyclerView.LayoutParams params = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); recyclerView.setLayoutParams(params); setContentView(recyclerView); return recyclerView; }
public void init(Context context, DatePickerDialog.ScrollOrientation scrollOrientation) { @RecyclerView.Orientation int layoutOrientation = scrollOrientation == DatePickerDialog.ScrollOrientation.VERTICAL ? RecyclerView.VERTICAL : RecyclerView.HORIZONTAL; LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, layoutOrientation, false); setLayoutManager(linearLayoutManager); setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); setVerticalScrollBarEnabled(false); setHorizontalScrollBarEnabled(false); setClipChildren(false); mContext = context; setUpRecyclerView(scrollOrientation); }
public SimpleGroupViewHolder(Context context) { super(View.inflate(context, R.layout.carbon_expandablerecyclerview_group, null)); itemView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); expandedIndicator = itemView.findViewById(R.id.carbon_groupExpandedIndicator); text = itemView.findViewById(R.id.carbon_groupText); }