コード例 #1
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.ConversationMessageRowView, parent, false);
            ConversationMessageViewHolder vh = new ConversationMessageViewHolder(itemView);

            return(vh);
        }
コード例 #2
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            var currentItem = this.Messages[position];
            ConversationMessageViewHolder vh = holder as ConversationMessageViewHolder;

            SetLayotParameters(currentItem, vh);
            vh.MessageHeader.Text  = currentItem.MessageHeader;
            vh.MessageContent.Text = currentItem.MessageContent;

            RaiseOnInfiniteScrollWhenItemIsLastInList(currentItem, vh);
        }
コード例 #3
0
 private static void SetLayotParameters(ConversationMessage currentItem, ConversationMessageViewHolder vh)
 {
     RelativeLayout.LayoutParams parameters = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent);
     if (currentItem.UserWasSender)
     {
         parameters.AddRule(LayoutRules.AlignParentLeft);
         parameters.SetMargins(10, 5, 50, 15);
         vh.MessageLayout.Background = ContextCompat.GetDrawable(Application.Context, Resource.Drawable.conversation_user_message_background_border);
         var color = new Color(141, 110, 99);
         vh.MessageHeader.SetTextColor(color);
         vh.MessageContent.SetTextColor(color);
     }
     else
     {
         parameters.AddRule(LayoutRules.AlignParentRight);
         parameters.SetMargins(50, 5, 10, 15);
         vh.MessageLayout.Background = ContextCompat.GetDrawable(Application.Context, Resource.Drawable.conversation_sender_message_background_border);
         var color = new Color(239, 235, 233);
         vh.MessageHeader.SetTextColor(color);
         vh.MessageContent.SetTextColor(color);
     }
     vh.MessageLayout.LayoutParameters = parameters;
 }
コード例 #4
0
 private void RaiseOnInfiniteScrollWhenItemIsLastInList(ConversationMessage currentItem, ConversationMessageViewHolder viewHolder)
 {
     if (this.Messages.IndexOf(currentItem) == (this.Messages.Count - 1) && !InfiniteScrollDisabled)
     {
         this.infiniteScrollListener.OnInfiniteScroll();
     }
 }