public void applyStyle(MessagesListStyle style)
 {
     if (time != null)
     {
         time.SetTextColor(new Color(style.getOutcomingTimeTextColor()));
         time.SetTextSize(Android.Util.ComplexUnitType.Px, style.getOutcomingTimeTextSize());
         time.SetTypeface(time.Typeface, TypefaceStyle.Normal);
     }
 }
 public void applyStyle(MessagesListStyle style)
 {
     if (text != null)
     {
         text.SetTextColor(new Color(style.getDateHeaderTextColor()));
         text.SetTextSize(Android.Util.ComplexUnitType.Px, style.getDateHeaderTextSize());
         text.SetTypeface(text.Typeface, TypefaceStyle.Normal);
         text.SetPadding(style.getDateHeaderPadding(), style.getDateHeaderPadding(), style.getDateHeaderPadding(), style.getDateHeaderPadding());
     }
 }
            public void applyStyle(MessagesListStyle style)
            {
                if (time != null)
                {
                    time.SetTextColor(new Color(style.getIncomingTimeTextColor()));
                    time.SetTextSize(Android.Util.ComplexUnitType.Px, style.getIncomingTimeTextSize());
                    time.SetTypeface(time.Typeface, TypefaceStyle.Normal);
                }

                if (userAvatar != null)
                {
                    userAvatar.LayoutParameters.Width  = style.getIncomingAvatarWidth();
                    userAvatar.LayoutParameters.Height = style.getIncomingAvatarHeight();
                }
            }
            public new void applyStyle(MessagesListStyle style)
            {
                base.applyStyle(style);
                if (time != null)
                {
                    time.SetTextColor(new Color(style.getOutcomingImageTimeTextColor()));
                    time.SetTextSize(Android.Util.ComplexUnitType.Px, style.getOutcomingImageTimeTextSize());
                    time.SetTypeface(time.Typeface, TypefaceStyle.Normal);
                }

                if (imageOverlay != null)
                {
                    imageOverlay.Background = style.getOutcomingImageOverlayDrawable();
                }
            }
            public new void applyStyle(MessagesListStyle style)
            {
                base.applyStyle(style);
                if (bubble != null)
                {
                    bubble.SetPadding(style.getOutcomingDefaultBubblePaddingLeft(), style.getOutcomingDefaultBubblePaddingTop(), style.getOutcomingDefaultBubblePaddingRight(), style.getOutcomingDefaultBubblePaddingBottom());
                    bubble.Background = style.getOutcomingBubbleDrawable();
                }

                if (text != null)
                {
                    text.SetTextColor(new Color(style.getOutcomingTextColor()));
                    text.SetTextSize(Android.Util.ComplexUnitType.Px, style.getOutcomingTextSize());
                    text.SetTypeface(text.Typeface, TypefaceStyle.Normal);
                    text.AutoLinkMask = Android.Text.Util.MatchOptions.All;
                    text.SetLinkTextColor(new Color(style.getOutcomingTextLinkColor()));
                    //configureLinksBehavior(text);
                }
            }
        /*
         * PRIVATE METHODS
         * */

        internal virtual ViewHolder getHolder(ViewGroup parent, int viewType, MessagesListStyle messagesListStyle)
        {
            switch (viewType)
            {
            case VIEW_TYPE_DATE_HEADER:
                return(getDateHolder(parent, dateHeaderLayout, dateHeaderHolder, messagesListStyle));

            case VIEW_TYPE_TEXT_MESSAGE:
                var tmp = getHolder(parent, incomingTextConfig, messagesListStyle);
                //var tmp2 = tmp as ViewHolder<T>;
                return(tmp);

            case -VIEW_TYPE_TEXT_MESSAGE:
                return(getHolder(parent, outcomingTextConfig, messagesListStyle));

            case VIEW_TYPE_IMAGE_MESSAGE:
            // return getHolder<MESSAGE>(parent, incomingImageConfig, messagesListStyle) as ViewHolder<T>;
            case -VIEW_TYPE_IMAGE_MESSAGE:
            // return getHolder<MESSAGE>(parent, outcomingImageConfig, messagesListStyle) as ViewHolder<T>;
            default:
                foreach (ContentTypeConfig typeConfig in customContentTypes)
                {
                    if (Math.Abs(typeConfig.type) == Math.Abs(viewType))
                    {
                        if (viewType > 0)
                        {
                            return(getHolder(parent, typeConfig.incomingConfig, messagesListStyle));
                        }
                        else
                        {
                            return(getHolder(parent, typeConfig.outcomingConfig, messagesListStyle));
                        }
                    }
                }
                break;
            }
            return(null);
        }
        //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
        //ORIGINAL LINE: private <HOLDER extends com.stfalcon.chatkit.commons.ViewHolder> com.stfalcon.chatkit.commons.ViewHolder getHolder(android.view.ViewGroup parent, @LayoutRes int layout, Class<HOLDER> holderClass, MessagesListStyle style)
        private ViewHolder getHolder(ViewGroup parent, int layout, Type holderClass, MessagesListStyle style)
        {
            View v = LayoutInflater.From(parent.Context).Inflate(layout, parent, false);

            try
            {
                if (holderClass == typeof(DefaultIncomingTextMessageViewHolder))
                {
                    var result = new IncomingTextMessageViewHolder(v);
                    result.applyStyle(style);
                    return(result);
                }
                else if (holderClass == typeof(DefaultOutcomingTextMessageViewHolder))
                {
                    var result = new OutcomingTextMessageViewHolder(v);
                    result.applyStyle(style);
                    return(result);
                }
                else if (holderClass == typeof(DefaultIncomingImageMessageViewHolder))
                {
                    var result = new IncomingImageMessageViewHolder(v);
                    result.applyStyle(style);
                    return(result);
                }
                else if (holderClass == typeof(DefaultOutcomingImageMessageViewHolder))
                {
                    var result = new OutcomingImageMessageViewHolder(v);
                    result.applyStyle(style);
                    return(result);
                }
                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }
 private void ParseStyle(Context context, IAttributeSet attrs)
 {
     messagesListStyle = MessagesListStyle.Parse(context, attrs);
 }
        private ViewHolder getDateHolder(ViewGroup parent, int layout, Type holderClass, MessagesListStyle style)
        {
            View v      = LayoutInflater.From(parent.Context).Inflate(layout, parent, false);
            var  result = new DefaultDateHeaderViewHolder(v);

            result.applyStyle(style);
            return(result);
        }
        private ViewHolder getHolder(ViewGroup parent, HolderConfig holderConfig, MessagesListStyle style)
        {
            var tmp = getHolder(parent, holderConfig.layout, holderConfig.holder, style);

            return(tmp);
        }
        public static MessagesListStyle Parse(Context context, IAttributeSet attrs)
        {
            MessagesListStyle style      = new MessagesListStyle(context, attrs);
            TypedArray        typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.MessagesList);

            style.textAutoLinkMask      = typedArray.GetInt(Resource.Styleable.MessagesList_textAutoLink, 0);
            style.incomingTextLinkColor = typedArray.GetColor(Resource.Styleable.MessagesList_incomingTextLinkColor,
                                                              style.GetSystemAccentColor());
            style.outcomingTextLinkColor = typedArray.GetColor(Resource.Styleable.MessagesList_outcomingTextLinkColor,
                                                               style.GetSystemAccentColor());

            style.incomingAvatarWidth = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_incomingAvatarWidth,
                                                                         style.GetDimension(Resource.Dimension.message_avatar_width));
            style.incomingAvatarHeight = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_incomingAvatarHeight,
                                                                          style.GetDimension(Resource.Dimension.message_avatar_height));

            style.incomingBubbleDrawable     = typedArray.GetResourceId(Resource.Styleable.MessagesList_incomingBubbleDrawable, -1);
            style.incomingDefaultBubbleColor = typedArray.GetColor(Resource.Styleable.MessagesList_incomingDefaultBubbleColor,
                                                                   style.GetColor(Resource.Color.white_two));
            style.incomingDefaultBubblePressedColor = typedArray.GetColor(Resource.Styleable.MessagesList_incomingDefaultBubblePressedColor,
                                                                          style.GetColor(Resource.Color.white_two));
            style.incomingDefaultBubbleSelectedColor = typedArray.GetColor(Resource.Styleable.MessagesList_incomingDefaultBubbleSelectedColor,
                                                                           style.GetColor(Resource.Color.cornflower_blue_two_24));

            style.incomingImageOverlayDrawable            = typedArray.GetResourceId(Resource.Styleable.MessagesList_incomingImageOverlayDrawable, -1);
            style.incomingDefaultImageOverlayPressedColor = typedArray.GetColor(Resource.Styleable.MessagesList_incomingDefaultImageOverlayPressedColor,
                                                                                style.GetColor(Resource.Color.transparent));
            style.incomingDefaultImageOverlaySelectedColor = typedArray.GetColor(Resource.Styleable.MessagesList_incomingDefaultImageOverlaySelectedColor,
                                                                                 style.GetColor(Resource.Color.cornflower_blue_light_40));

            style.incomingDefaultBubblePaddingLeft = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_incomingBubblePaddingLeft,
                                                                                      style.GetDimension(Resource.Dimension.message_padding_left));
            style.incomingDefaultBubblePaddingRight = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_incomingBubblePaddingRight,
                                                                                       style.GetDimension(Resource.Dimension.message_padding_right));
            style.incomingDefaultBubblePaddingTop = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_incomingBubblePaddingTop,
                                                                                     style.GetDimension(Resource.Dimension.message_padding_top));
            style.incomingDefaultBubblePaddingBottom = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_incomingBubblePaddingBottom,
                                                                                        style.GetDimension(Resource.Dimension.message_padding_bottom));
            style.incomingTextColor = typedArray.GetColor(Resource.Styleable.MessagesList_incomingTextColor,
                                                          style.GetColor(Resource.Color.dark_grey_two));
            style.incomingTextSize = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_incomingTextSize,
                                                                      style.GetDimension(Resource.Dimension.message_text_size));
            style.incomingTextStyle = typedArray.GetInt(Resource.Styleable.MessagesList_incomingTextStyle, 0);

            style.incomingTimeTextColor = typedArray.GetColor(Resource.Styleable.MessagesList_incomingTimeTextColor,
                                                              style.GetColor(Resource.Color.warm_grey_four));
            style.incomingTimeTextSize = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_incomingTimeTextSize,
                                                                          style.GetDimension(Resource.Dimension.message_time_text_size));
            style.incomingTimeTextStyle = typedArray.GetInt(Resource.Styleable.MessagesList_incomingTimeTextStyle, 0);

            style.incomingImageTimeTextColor = typedArray.GetColor(Resource.Styleable.MessagesList_incomingImageTimeTextColor,
                                                                   style.GetColor(Resource.Color.warm_grey_four));
            style.incomingImageTimeTextSize = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_incomingImageTimeTextSize,
                                                                               style.GetDimension(Resource.Dimension.message_time_text_size));
            style.incomingImageTimeTextStyle = typedArray.GetInt(Resource.Styleable.MessagesList_incomingImageTimeTextStyle, 0);

            style.outcomingBubbleDrawable     = typedArray.GetResourceId(Resource.Styleable.MessagesList_outcomingBubbleDrawable, -1);
            style.outcomingDefaultBubbleColor = typedArray.GetColor(Resource.Styleable.MessagesList_outcomingDefaultBubbleColor,
                                                                    style.GetColor(Resource.Color.cornflower_blue_two));
            style.outcomingDefaultBubblePressedColor = typedArray.GetColor(Resource.Styleable.MessagesList_outcomingDefaultBubblePressedColor,
                                                                           style.GetColor(Resource.Color.cornflower_blue_two));
            style.outcomingDefaultBubbleSelectedColor = typedArray.GetColor(Resource.Styleable.MessagesList_outcomingDefaultBubbleSelectedColor,
                                                                            style.GetColor(Resource.Color.cornflower_blue_two_24));

            style.outcomingImageOverlayDrawable            = typedArray.GetResourceId(Resource.Styleable.MessagesList_outcomingImageOverlayDrawable, -1);
            style.outcomingDefaultImageOverlayPressedColor = typedArray.GetColor(Resource.Styleable.MessagesList_outcomingDefaultImageOverlayPressedColor,
                                                                                 style.GetColor(Resource.Color.transparent));
            style.outcomingDefaultImageOverlaySelectedColor = typedArray.GetColor(Resource.Styleable.MessagesList_outcomingDefaultImageOverlaySelectedColor,
                                                                                  style.GetColor(Resource.Color.cornflower_blue_light_40));

            style.outcomingDefaultBubblePaddingLeft = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_outcomingBubblePaddingLeft,
                                                                                       style.GetDimension(Resource.Dimension.message_padding_left));
            style.outcomingDefaultBubblePaddingRight = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_outcomingBubblePaddingRight,
                                                                                        style.GetDimension(Resource.Dimension.message_padding_right));
            style.outcomingDefaultBubblePaddingTop = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_outcomingBubblePaddingTop,
                                                                                      style.GetDimension(Resource.Dimension.message_padding_top));
            style.outcomingDefaultBubblePaddingBottom = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_outcomingBubblePaddingBottom,
                                                                                         style.GetDimension(Resource.Dimension.message_padding_bottom));
            style.outcomingTextColor = typedArray.GetColor(Resource.Styleable.MessagesList_outcomingTextColor,
                                                           style.GetColor(Resource.Color.white));
            style.outcomingTextSize = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_outcomingTextSize,
                                                                       style.GetDimension(Resource.Dimension.message_text_size));
            style.outcomingTextStyle = typedArray.GetInt(Resource.Styleable.MessagesList_outcomingTextStyle, 0);

            style.outcomingTimeTextColor = typedArray.GetColor(Resource.Styleable.MessagesList_outcomingTimeTextColor,
                                                               style.GetColor(Resource.Color.white60));
            style.outcomingTimeTextSize = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_outcomingTimeTextSize,
                                                                           style.GetDimension(Resource.Dimension.message_time_text_size));
            style.outcomingTimeTextStyle = typedArray.GetInt(Resource.Styleable.MessagesList_outcomingTimeTextStyle, 0);

            style.outcomingImageTimeTextColor = typedArray.GetColor(Resource.Styleable.MessagesList_outcomingImageTimeTextColor,
                                                                    style.GetColor(Resource.Color.warm_grey_four));
            style.outcomingImageTimeTextSize = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_outcomingImageTimeTextSize,
                                                                                style.GetDimension(Resource.Dimension.message_time_text_size));
            style.outcomingImageTimeTextStyle = typedArray.GetInt(Resource.Styleable.MessagesList_outcomingImageTimeTextStyle, 0);

            style.dateHeaderPadding = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_dateHeaderPadding,
                                                                       style.GetDimension(Resource.Dimension.message_date_header_padding));
            style.dateHeaderFormat    = typedArray.GetString(Resource.Styleable.MessagesList_dateHeaderFormat);
            style.dateHeaderTextColor = typedArray.GetColor(Resource.Styleable.MessagesList_dateHeaderTextColor,
                                                            style.GetColor(Resource.Color.warm_grey_two));
            style.dateHeaderTextSize = typedArray.GetDimensionPixelSize(Resource.Styleable.MessagesList_dateHeaderTextSize,
                                                                        style.GetDimension(Resource.Dimension.message_date_header_text_size));
            style.dateHeaderTextStyle = typedArray.GetInt(Resource.Styleable.MessagesList_dateHeaderTextStyle, 0);

            typedArray.Recycle();

            return(style);
        }