protected override void Dispose(bool disposing) { if (disposing) { if (null != ItemBackgroundDrawable) ItemBackgroundDrawable.Dispose(); if (null != _inflater) _inflater.Dispose(); if (null != _overflowAction) _overflowAction.Dispose(); ItemBackgroundDrawable = null; _inflater = null; _barView = null; _logoView = null; _backIndicator = null; _titleView = null; _actionsView = null; _homeBtn = null; _homeLayout = null; _progress = null; _titleLayout = null; _context = null; _overflowAction = null; } base.Dispose(disposing); }
public ActionBar(Context context, IAttributeSet attrs) : base(context, attrs) { _context = context; ResourceIdManager.UpdateIdValues(); _inflater = LayoutInflater.From(context); //_inflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService); _barView = (RelativeLayout)_inflater.Inflate(Resource.Layout.actionbar, null); AddView(_barView); _logoView = _barView.FindViewById(Resource.Id.actionbar_home_logo) as ImageView; _homeLayout = _barView.FindViewById<RelativeLayout>(Resource.Id.actionbar_home_bg); _homeBtn = _barView.FindViewById<ImageButton>(Resource.Id.actionbar_home_btn); _backIndicator = _barView.FindViewById(Resource.Id.actionbar_home_is_back); _titleView = _barView.FindViewById<TextView>(Resource.Id.actionbar_title); _actionsView = _barView.FindViewById<LinearLayout>(Resource.Id.actionbar_actions); _progress = _barView.FindViewById<ProgressBar>(Resource.Id.actionbar_progress); _titleLayout = _barView.FindViewById<RelativeLayout>(Resource.Id.actionbar_title_layout); _overflowAction = new OverflowActionBarAction(context); //Custom Attributes (defined in Attrs.xml) var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.actionbar); var title = a.GetString(Resource.Styleable.actionbar_title); if (null != title) Title = title; var titleColor = a.GetColor(Resource.Styleable.actionbar_title_color, Resources.GetColor(Resource.Color.actionbar_title)); TitleColor = titleColor; var separatorColor = a.GetColor(Resource.Styleable.actionbar_separator, Resources.GetColor(Resource.Color.actionbar_separator)); _actionsView.SetBackgroundColor(separatorColor); using (var background = a.GetDrawable(Resource.Styleable.actionbar_background)) //recycling the drawable immediately { if (null != background) BackgroundDrawable = background; } var backgroundItem = a.GetDrawable(Resource.Styleable.actionbar_background_item); if (null != backgroundItem) ItemBackgroundDrawable = backgroundItem; a.Recycle(); }