Beispiel #1
0
        // Max of 2 characters
        public static void SetBadgeText(Context context, IMenuItem item, string text, Color backgroundColor, Color textColor)
        {
            //var iconized = Iconize.FindIconForKey("fa-envelope");
            //if (iconized != null)
            //{
            //    var drawable = new IconDrawable(context, iconized).Color(Android.Graphics.Color.ParseColor("#7fadf7")).SizeDp(30);
            //    item.SetIcon(drawable);
            //}

            if (item.Icon == null)
            {
                return;
            }

            BadgeDrawable badge = null;
            Drawable      icon  = item.Icon;

            if (item.Icon is LayerDrawable)
            {
                LayerDrawable lDrawable = item.Icon as LayerDrawable;

                if (string.IsNullOrEmpty(text) || text == "0")
                {
                    icon = lDrawable.GetDrawable(0);
                    lDrawable.Dispose();
                }
                else
                {
                    for (var i = 0; i < lDrawable.NumberOfLayers; i++)
                    {
                        if (lDrawable.GetDrawable(i) is BadgeDrawable)
                        {
                            badge = lDrawable.GetDrawable(i) as BadgeDrawable;
                            break;
                        }
                    }

                    if (badge == null)
                    {
                        badge = new BadgeDrawable(context, backgroundColor, textColor);
                        icon  = new LayerDrawable(new Drawable[] { item.Icon, badge });
                    }
                }
            }
            else
            {
                badge = new BadgeDrawable(context, backgroundColor, textColor);
                icon  = new LayerDrawable(new Drawable[] { item.Icon, badge });
            }

            badge?.SetBadgeText(text);

            item.SetIcon(icon);
            icon.Dispose();
        }
        // Max of 2 characters
        public static void SetBadgeText(Context context, IMenuItem item, string text, Color backgroundColor, Color textColor)
        {
            if (item.Icon == null)
            {
                return;
            }

            BadgeDrawable badge = null;
            Drawable      icon  = item.Icon;


            if (item.Icon is LayerDrawable)
            {
                LayerDrawable lDrawable = item.Icon as LayerDrawable;

                if (string.IsNullOrEmpty(text) || text == "0")
                {
                    icon = lDrawable.GetDrawable(0);
                    lDrawable.Dispose();
                }
                else
                {
                    for (var i = 0; i < lDrawable.NumberOfLayers; i++)
                    {
                        if (lDrawable.GetDrawable(i) is BadgeDrawable)
                        {
                            badge = lDrawable.GetDrawable(i) as BadgeDrawable;
                            break;
                        }
                    }

                    if (badge == null)
                    {
                        badge = new BadgeDrawable(context, backgroundColor, textColor);
                        icon  = new LayerDrawable(new Drawable[] { item.Icon, badge });
                    }
                }
            }
            else
            {
                badge = new BadgeDrawable(context, backgroundColor, textColor);
                icon  = new LayerDrawable(new Drawable[] { item.Icon, badge });
            }

            badge?.SetBadgeText(text);

            item.SetIcon(icon);
            icon.Dispose();
        }
        public void OnDetached()
        {
            if (notSupported)
            {
                return;
            }

            _thumb.Dispose();
            _progress.Dispose();

            _thumb                 = null;
            _progress              = null;
            _orgProgress           = null;
            _orgThumb              = null;
            _orgProgressBackground = null;
            _seekbar               = null;
            _element               = null;
        }
        public void OnDetached()
        {
            if (notSupported)
            {
                return;
            }

            _minDrawable.ClearColorFilter();
            _maxDrawable.ClearColorFilter();

            _minDrawable.Dispose();
            _maxDrawable.Dispose();
            _thumb.Dispose();
            _progress.Dispose();

            _minDrawable = null;
            _maxDrawable = null;
            _thumb       = null;
            _progress    = null;
            _orgProgress = null;
            _orgThumb    = null;
            _seekbar     = null;
            _element     = null;
        }