public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { int viewType = GetItemViewType(position); if (viewType == TYPE_HEADER) { HeaderViewHolder headerViewHolder = viewHolder as HeaderViewHolder; SetSpannableString(headerViewHolder.mTransactionNumber, "Transaction #: ", mItems[position].Id.ToString()); SetSpannableString(headerViewHolder.mTransactionDate, "Date: ", GetFormattedDateTimeString(mItems[position].TransactionDateTime)); SetSpannableString(headerViewHolder.mCashier, "Cashier: ", mItems[position].CashierName); SetSpannableString(headerViewHolder.mRunner, "Runner: ", GetRunnerName(mItems[position].RunnerId)); } else if (viewType == TYPE_ITEM) { DetailsViewHolder detailsHolder = viewHolder as DetailsViewHolder; detailsHolder.mProductSizeAndName.Text = mItems[position].ProductName; string pieces = mItems[position].ProductCountOnCart > 1 ? " pcs * " : " pc * "; detailsHolder.mQuantityAndPrice.Text = mItems[position].ProductCountOnCart + pieces + string.Format("{0:n}", mItems[position].ProductPrice); detailsHolder.mOrigAmount.Visibility = mItems[position].ProductDiscountAmount > 0 ? ViewStates.Visible : ViewStates.Invisible; detailsHolder.mOrigAmount.Text = mPesoSign + string.Format("{0:n}", mItems[position].ProductOrigPrice); detailsHolder.mDiscountedAmount.Text = mPesoSign + string.Format("{0:n}", mItems[position].ProductSubTotalPrice); } else //footer { FooterViewHolder footerViewHolder = viewHolder as FooterViewHolder; footerViewHolder.mTotalAmount.Text = mPesoSign + string.Format("{0:n}", mItems[position].FooterTotalAmount); } }
public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { if (mIsReceipt) { ReceiptViewHolder receiptHolder = viewHolder as ReceiptViewHolder; receiptHolder.mMainView.Click -= MMainView_Click; //unsubscibe to avoid multiple firing of clicks receiptHolder.mMainView.Click += MMainView_Click; //set click event for row receiptHolder.mProductSizeAndName.Text = mTransactionItems[position].ProductName; string pieces = mTransactionItems[position].ProductCountOnCart > 1 ? " pcs * " : " pc * "; receiptHolder.mQuantityAndPrice.Text = mTransactionItems[position].ProductCountOnCart + pieces + string.Format("{0:n}", mTransactionItems[position].ProductPrice); receiptHolder.mOrigAmount.Visibility = mTransactionItems[position].ProductDiscountAmount > 0 ? ViewStates.Visible : ViewStates.Invisible; receiptHolder.mOrigAmount.Text = mPesoSign + string.Format("{0:n}", mTransactionItems[position].ProductOrigPrice); receiptHolder.mDiscountedAmount.Text = mPesoSign + string.Format("{0:n}", mTransactionItems[position].ProductSubTotalPrice); } else { DetailsViewHolder myHolder = viewHolder as DetailsViewHolder; myHolder.mMainView.Click -= MMainView_Click; //unsubscibe to avoid multiple firing of clicks myHolder.mMainView.Click += MMainView_Click; //set click event for row myHolder.mProductName.Text = mTransactionItems[position].ProductName; myHolder.mProductPrice.Text = mPesoSign + string.Format("{0:n}", mTransactionItems[position].ProductPrice); myHolder.mQuantityOnCart.Text = mTransactionItems[position].ProductCountOnCart.ToString() + " X"; myHolder.mSubtotalAmount.Text = mPesoSign + string.Format("{0:n}", mTransactionItems[position].ProductSubTotalPrice); } }
public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { View itemView; if (viewType == TYPE_HEADER) { itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.transactions_fragment_receipt_preview_header, parent, false); TextView txtTransactionNumber = itemView.FindViewById <TextView>(Resource.Id.txtTransactionNumber); TextView txtTransactionDate = itemView.FindViewById <TextView>(Resource.Id.txtDate); TextView txtCashier = itemView.FindViewById <TextView>(Resource.Id.txtCashier); TextView txtRunner = itemView.FindViewById <TextView>(Resource.Id.txtRunnerName); HeaderViewHolder view = new HeaderViewHolder(itemView) { mTransactionNumber = txtTransactionNumber, mTransactionDate = txtTransactionDate, mCashier = txtCashier, mRunner = txtRunner }; return(view); } else if (viewType == TYPE_ITEM) { itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.transactions_fragment_receipt_preview_child, parent, false); TextView txtItemName = itemView.FindViewById <TextView>(Resource.Id.txtItemName); TextView txtQtyAndPrice = itemView.FindViewById <TextView>(Resource.Id.txtQtyAndPrice); TextView txtOrigAmount = itemView.FindViewById <TextView>(Resource.Id.txtOrigAmount); TextView txtDiscountedAmount = itemView.FindViewById <TextView>(Resource.Id.txtDiscountedAmount); DetailsViewHolder view = new DetailsViewHolder(itemView) { mProductSizeAndName = txtItemName, mQuantityAndPrice = txtQtyAndPrice, mOrigAmount = txtOrigAmount, mDiscountedAmount = txtDiscountedAmount }; return(view); } else //footer { itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.transactions_fragment_receipt_preview_childfooter, parent, false); TextView txtTotalAmount = itemView.FindViewById <TextView>(Resource.Id.txtTotal); FooterViewHolder view = new FooterViewHolder(itemView) { mTotalAmount = txtTotalAmount }; return(view); } }
public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { int resourceLayout = mIsReceipt ? Resource.Layout.transactions_fragment_receipt_preview_child : Resource.Layout.transactions_fragment_items_fragment_row; View itemView = LayoutInflater.From(parent.Context).Inflate(resourceLayout, parent, false); if (mIsReceipt) { TextView txtItemName = itemView.FindViewById <TextView>(Resource.Id.txtItemName); TextView txtQtyAndPrice = itemView.FindViewById <TextView>(Resource.Id.txtQtyAndPrice); TextView txtOrigAmount = itemView.FindViewById <TextView>(Resource.Id.txtOrigAmount); TextView txtDiscountedAmount = itemView.FindViewById <TextView>(Resource.Id.txtDiscountedAmount); ReceiptViewHolder view = new ReceiptViewHolder(itemView) { mProductSizeAndName = txtItemName, mQuantityAndPrice = txtQtyAndPrice, mOrigAmount = txtOrigAmount, mDiscountedAmount = txtDiscountedAmount }; return(view); } else { TextView txtProductName = itemView.FindViewById <TextView>(Resource.Id.txtItemName); TextView txtProductPrice = itemView.FindViewById <TextView>(Resource.Id.txtItemPrice); TextView txtQuantityOnCart = itemView.FindViewById <TextView>(Resource.Id.txtQty); TextView txtSubTotalAmount = itemView.FindViewById <TextView>(Resource.Id.txtSubTotal); DetailsViewHolder view = new DetailsViewHolder(itemView) { mProductName = txtProductName, mProductPrice = txtProductPrice, mQuantityOnCart = txtQuantityOnCart, mSubtotalAmount = txtSubTotalAmount }; return(view); } }