Esempio n. 1
0
        protected void Init(Context context, IAttributeSet attrs)
        {
            templateId = attrs.GetAttributeResourceValue("http://schemas.android.com/apk/res-auto", "itemTemplate", DefaultId);
            var dividerId = attrs.GetAttributeResourceValue("http://schemas.android.com/apk/res-auto", "listDivider", DefaultId);

            var layoutManager = LayoutManagerFactory(context);

            SetLayoutManager(layoutManager);

            var linearLayoutManager = layoutManager as LinearLayoutManager;

            if (linearLayoutManager != null)
            {
                //var scrollListener = new EndlessRecyclerOnScrollListener(linearLayoutManager, OnLoadMore);
                //AddOnScrollListener(scrollListener);
            }

            if (dividerId == DefaultId)
            {
                return;
            }

            var drawable      = ContextCompat.GetDrawable(context, dividerId);
            var itemDecorator = new DividerItemDecoration(context, DividerItemDecoration.Vertical);

            itemDecorator.SetDrawable(drawable);
            AddItemDecoration(itemDecorator);
        }
Esempio n. 2
0
        private void Initialize(IAttributeSet attrs = null)
        {
            Focusable = true;
            Holder.AddCallback(this);
            SetZOrderOnTop(true);
            Holder.SetFormat(Format.Transparent);

            if (attrs == null)
            {
                _gifMovie    = null;
                _movieWidth  = 0;
                _movieHeight = 0;
            }
            else
            {
                this.InitializeAttributes(attrs);
                string filePath;
                var    resourceId = attrs.GetAttributeResourceValue("http://schemas.android.com/apk/res/android", "src", 0);
                if (resourceId > 0)
                {
                    var inputStream = Context.Resources.OpenRawResource(resourceId);
                    SetAnimationStream(inputStream);
                }
                else if (!string.IsNullOrEmpty((filePath = attrs.GetAttributeValue(ElementExtensions.XmlNamespace, "file_path"))))
                {
                    FilePath = filePath;
                }
            }
        }
        /// <summary>
        /// Tries to pull the Custom Attribute directly from the TextView.
        /// </summary>
        /// <param name="context">Activity Context.</param>
        /// <param name="attrs">View Attributes.</param>
        /// <param name="attributeId">f -1 returns null.</param>
        /// <returns>null if attribute is not defined or added to View</returns>
        internal static string PullFontPathFromView(Context context, IAttributeSet attrs, int attributeId)
        {
            if (attributeId == -1 || attrs == null)
            {
                return(null);
            }

            string attributeName;

            try
            {
                attributeName = context.Resources.GetResourceEntryName(attributeId);
            }
            catch (Resources.NotFoundException e)
            {
                // invalid attribute ID
                return(null);
            }

            var stringResourceId = attrs.GetAttributeResourceValue(null, attributeName, -1);

            return(stringResourceId > 0
                    ? context.GetString(stringResourceId)
                    : attrs.GetAttributeValue(null, attributeName));
        }
Esempio n. 4
0
 private void Init(Context context = null, IAttributeSet attrs = null)
 {
     _context = context;
     if (attrs != null)
     {
         int imageResource = attrs.GetAttributeResourceValue("http://schemas.android.com/apk/res/android", "src", 0);
         ApplyBlur(imageResource);
     }
 }
Esempio n. 5
0
        void ProcessAttributeSets(IAttributeSet attrs)
        {
            var resID = attrs.GetAttributeResourceValue(null, "description", -1);
            var val   = resID == -1 ?
                        attrs.GetAttributeValue(null, "description")
                                : Context.Resources.GetString(resID);

            desc = (val ?? string.Empty).ToUpper();
        }
Esempio n. 6
0
        private void Initialize(IAttributeSet attrs)
        {
            TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.TextWithHelp);

            string helpText = a.GetString(Resource.Styleable.TextWithHelp_help_text);

            const string xmlns = "http://schemas.android.com/apk/res/android";
            string text = Context.GetString(attrs.GetAttributeResourceValue(xmlns, "text", Resource.String.ellipsis));
            Initialize(text, helpText);
        }
Esempio n. 7
0
        protected void Init(Context context, IAttributeSet attrs)
        {
            templateId = attrs.GetAttributeResourceValue("http://schemas.android.com/apk/res-auto", "itemTemplate", DefaultId);
            var dividerId     = attrs.GetAttributeResourceValue("http://schemas.android.com/apk/res-auto", "listDivider", DefaultId);
            var layoutManager = LayoutManagerFactory(context);

            SetLayoutManager(layoutManager);

            if (dividerId == DefaultId)
            {
                return;
            }

            var drawable      = ContextCompat.GetDrawable(context, dividerId);
            var itemDecorator = new DividerItemDecoration(context, DividerItemDecoration.Vertical);

            itemDecorator.SetDrawable(drawable);
            AddItemDecoration(itemDecorator);
        }
Esempio n. 8
0
        private void Initialize(IAttributeSet attrs)
        {
            TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.TextWithHelp);

            string helpText = a.GetString(Resource.Styleable.TextWithHelp_help_text);

            const string xmlns = "http://schemas.android.com/apk/res/android";
            string       text  = Context.GetString(attrs.GetAttributeResourceValue(xmlns, "text", Resource.String.ellipsis));

            Initialize(text, helpText);
        }
Esempio n. 9
0
        public SeekBarPreference(Context context, IAttributeSet attrs)
            : base(context, attrs)
        {
            _progress = 0;
            _minimumValue = attrs.GetAttributeIntValue(_applicationNamespace, "minValue", 0);
            _defaultValue = attrs.GetAttributeIntValue(_applicationNamespace, "defaultValue", 0) - _minimumValue;
            _maximumValue = attrs.GetAttributeIntValue(_applicationNamespace, "maxValue", 100) - _minimumValue;

            int suffixResourceId = attrs.GetAttributeResourceValue(_applicationNamespace, "suffix", 0);

            if (suffixResourceId > 0)
                _suffix = " " + context.Resources.GetString(suffixResourceId);

            DialogLayoutResource = Resource.Layout.TimeoutDialogPreference;
        }
Esempio n. 10
0
        public static double ParseThickness(IAttributeSet attrs, string thickness, int currentThickness)
        {
            var thicknessRes = attrs.GetAttributeResourceValue(XmlNamespace, thickness, 0);

            if (thicknessRes > 0)
            {
                return((int)(DroidFactory.MainActivity.Resources.GetDimension(thicknessRes) / DroidFactory.DisplayScale));
            }
            var thicknessAttr = attrs.GetAttributeValue(XmlNamespace, thickness);

            if (thicknessAttr != null && double.TryParse(thicknessAttr.TrimEnd('s', 'd', 'p', 'x'), out double value))
            {
                return(value);
            }
            return(currentThickness);
        }
Esempio n. 11
0
        public SeekBarPreference(Context context, IAttributeSet attrs)
            : base(context, attrs)
        {
            _progress     = 0;
            _minimumValue = attrs.GetAttributeIntValue(_applicationNamespace, "minValue", 0);
            _defaultValue = attrs.GetAttributeIntValue(_applicationNamespace, "defaultValue", 0) - _minimumValue;
            _maximumValue = attrs.GetAttributeIntValue(_applicationNamespace, "maxValue", 100) - _minimumValue;

            int suffixResourceId = attrs.GetAttributeResourceValue(_applicationNamespace, "suffix", 0);

            if (suffixResourceId > 0)
            {
                _suffix = " " + context.Resources.GetString(suffixResourceId);
            }

            DialogLayoutResource = Resource.Layout.TimeoutDialogPreference;
        }
        private void Init(IAttributeSet attrs)
        {
            int count = attrs.AttributeCount;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    string name = attrs.GetAttributeName(i);

                    if (name != null && name.Equals("numColumns"))
                    {
                        this.mNumColumnsID = attrs.GetAttributeResourceValue(i, 1);
                        UpdateColumns();
                        break;
                    }
                }
            }
            Console.WriteLine("numColumns set to: " + NumColumns);
        }
Esempio n. 13
0
        public HelpButton(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            SetGravity(GravityFlags.Center);

            img = new ImageView(context);
            img.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);

            int sourceResourceId = attrs.GetAttributeResourceValue("http://schemas.android.com/apk/res/android", "src", 0);

            img.SetImageResource(sourceResourceId);

            Click += (sender, args) =>
            {
                if (HelpClickListener != null)
                {
                    HelpClickListener(isHelp);
                }
            };

            AddView(img);
        }
Esempio n. 14
0
        public HelpButton(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            SetGravity(GravityFlags.Center);

            img = new ImageView(context);
            img.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);

            int sourceResourceId = attrs.GetAttributeResourceValue("http://schemas.android.com/apk/res/android", "src", 0);

            img.SetImageResource(sourceResourceId);

            Click += (sender, args) =>
            {
                if (HelpClickListener != null)
                {
                    HelpClickListener(isHelp);
                }
            };

            AddView(img);
        }
Esempio n. 15
0
 void ProcessAttributeSets(IAttributeSet attrs)
 {
     var resID = attrs.GetAttributeResourceValue (null, "description", -1);
     var val = resID == -1 ?
         attrs.GetAttributeValue (null, "description")
         : Context.Resources.GetString (resID);
     desc = (val ?? string.Empty).ToUpper ();
 }