public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { RecyclerView.ViewHolder vh = null; View cell = null; switch (viewType) { case Tx: // Inflate the item cell = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.chat_cell_tx, parent, false); // Create a ViewHolder to find and hold these view references, and register OnClick with the view holder: vh = new ChatTxHolder(cell); break; case Rx: // Inflate the item cell = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.chat_cell_rx, parent, false); // Create a ViewHolder to find and hold these view references, and register OnClick with the view holder: vh = new ChatRxHolder(cell); break; } return(vh); }
private void BindTxHolder(ChatTxHolder vh, int position) { var message = Messages[position]; if (vh != null && message != null) { // Set up the Avatar #if DEBUG // for Testing if (ProfileImageUri != null) { // TODOD //get image resource and set } else if (Email == null || Email.Contains("bluemetal.com")) { vh.Avatar.SetProfileResource(Resource.Drawable.greyhound_kimmie); } else if (!string.IsNullOrWhiteSpace(Initials)) { vh.Avatar.SetText(Initials); } else { vh.Avatar.SetInitials("ALISON SUMMERFIELD"); } #else if (ProfileImageUri != null) { // TODOD //get image resource and set } else { vh.Avatar.SetText(Initials); } #endif // Set up the Icon and Title var isNewActionPlan = message.IsNewActionPlan && message.ActionPlan != null; if (isNewActionPlan) { Tuple <string, Color> messageSettings = Constants.GetChatMessageButtonSettings(_context, message.ActionPlan.Name, message.ActionPlan.Icon); vh.Icon.SetImageResource(GetIconResourceId(messageSettings.Item1)); vh.Icon.BackgroundTintList = ColorStateList.ValueOf(messageSettings.Item2); vh.Title.Text = message.ActionPlan.Name; vh.Icon.Visibility = ViewStates.Visible; vh.Title.Visibility = ViewStates.Visible; vh.IndicatorHolder.Visibility = ViewStates.Visible; } else { vh.Icon.Visibility = ViewStates.Gone; vh.Title.Visibility = ViewStates.Gone; vh.IndicatorHolder.Visibility = ViewStates.Gone; } // Set up the Message Text vh.Text.Text = message.Text; } }