Example #1
0
        public ChipView(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr)
        {
            TypedArray a = context.Theme.ObtainStyledAttributes(attrs, Resource.Styleable.ChipView, defStyleAttr, 0);

            if (a.HasValue(Resource.Styleable.ChipView_chip_text))
            {
                _chipText = a.GetString(Resource.Styleable.ChipView_chip_text);
            }
            _hasIcon = a.GetBoolean(Resource.Styleable.ChipView_enable_icon, false);
            if (a.HasValue(Resource.Styleable.ChipView_chip_icon))
            {
                _chipIcon = a.GetDrawable(Resource.Styleable.ChipView_chip_icon);
            }
            _closable                = a.GetBoolean(Resource.Styleable.ChipView_closeable, false);
            _selectable              = a.GetBoolean(Resource.Styleable.ChipView_chip_selectable, false);
            _backgroundColor         = a.GetColor(Resource.Styleable.ChipView_chip_backgroundColor, ContextCompat.GetColor(context, Resource.Color.default_chip_background_color));
            _selectedBackgroundColor = a.GetColor(Resource.Styleable.ChipView_chip_selectedBackgroundColor, ContextCompat.GetColor(context, Resource.Color.default_chip_background_clicked_color));
            _textColor               = a.GetColor(Resource.Styleable.ChipView_chip_text_color, ContextCompat.GetColor(context, Resource.Color.default_chip_text_color));
            _selectedTextColor       = a.GetColor(Resource.Styleable.ChipView_chip_selected_text_color, ContextCompat.GetColor(context, Resource.Color.default_chip_text_clicked_color));
            _closeColor              = a.GetColor(Resource.Styleable.ChipView_chip_close_color, ContextCompat.GetColor(context, Resource.Color.default_chip_close_inactive_color));
            _selectedCloseColor      = a.GetColor(Resource.Styleable.ChipView_chip_selected_close_color, ContextCompat.GetColor(context, Resource.Color.default_chip_close_clicked_color));
            _cornerRadius            = (int)a.GetDimension(Resource.Styleable.ChipView_chip_cornerRadius, Resources.GetDimension(Resource.Dimension.chip_height) / 2);
            _strokeSize              = (int)a.GetDimension(Resource.Styleable.ChipView_chip_strokeSize, 0);
            _strokeColor             = a.GetColor(Resource.Styleable.ChipView_chip_strokeColor, ContextCompat.GetColor(context, Resource.Color.default_chip_close_clicked_color));
            if (a.HasValue(Resource.Styleable.ChipView_chip_iconText))
            {
                _iconText = a.GetString(Resource.Styleable.ChipView_chip_iconText);
            }
            _iconTextColor           = a.GetColor(Resource.Styleable.ChipView_chip_iconTextColor, ContextCompat.GetColor(context, Resource.Color.default_chip_background_clicked_color));
            _iconTextBackgroundColor = a.GetColor(Resource.Styleable.ChipView_chip_iconTextBackgroundColor, ContextCompat.GetColor(context, Resource.Color.default_chip_close_clicked_color));
            a.Recycle();
            InitalizeViews(context);
        }
        public void ApplyStylableAttributes(Context context, TypedArray a, int[] styleableRes)
        {
            if (styleableRes == Resource.Styleable.RightAngleTriangle)
            {
                if (a.HasValue(Resource.Styleable.RightAngleTriangle_rightAnglePosition))
                {
                    RightAnglePosition = (RightAnglePosition)a.GetInt(Resource.Styleable.RightAngleTriangle_rightAnglePosition, 0);
                }

                if (a.HasValue(Resource.Styleable.RightAngleTriangle_fillColor))
                {
                    FillColor = a.GetColor(Resource.Styleable.RightAngleTriangle_fillColor, Color.White);
                }

                if (a.HasValue(Resource.Styleable.RightAngleTriangle_borderWidth))
                {
                    var borderWidth = a.GetDimensionPixelSize(Resource.Styleable.RightAngleTriangle_borderWidth, 0);
                    BorderThicknessPx = borderWidth > 0 ? borderWidth : 0;
                }

                if (a.HasValue(Resource.Styleable.RightAngleTriangle_borderColor))
                {
                    BorderColor = a.GetColor(Resource.Styleable.RightAngleTriangle_borderColor, Color.Transparent);
                }
            }
        }
        /// <summary>
        /// Inflates the views in the layout.
        /// </summary>
        /// <param name="context">the current context for the view.</param>
        private void Init(Context context, IAttributeSet attrs)
        {
            LayoutInflater inflater = context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;

            inflater.Inflate(Resource.Layout.MyEditTextView, this);

            #region Finding Views
            TitleTextView = FindViewById <TextView>(Resource.Id.myedittext_tv_title);
            ErrorTextView = FindViewById <TextView>(Resource.Id.myedittext_tv_error);
            InputEditText = FindViewById <EditText>(Resource.Id.myedittext_et_input);
            #endregion

            // Default values
            Error     = "";
            InputType = TextInputType.Text;

            if (attrs != null)
            {
                TypedArray typedArray = Context.ObtainStyledAttributes(attrs, Resource.Styleable.MyEditText);


                if (typedArray.HasValue(Resource.Styleable.MyEditText_title))
                {
                    Title = typedArray.GetString(Resource.Styleable.MyEditText_title);
                }

                if (typedArray.HasValue(Resource.Styleable.MyEditText_input))
                {
                    Input = typedArray.GetString(Resource.Styleable.MyEditText_input);
                }

                if (typedArray.HasValue(Resource.Styleable.MyEditText_inputHint))
                {
                    InputHint = typedArray.GetString(Resource.Styleable.MyEditText_inputHint);
                }

                if (typedArray.HasValue(Resource.Styleable.MyEditText_error))
                {
                    Error = typedArray.GetString(Resource.Styleable.MyEditText_error);
                }

                if (typedArray.HasValue(Resource.Styleable.MyEditText_inputType))
                {
                    InputType = (TextInputType)typedArray.GetInt(Resource.Styleable.MyEditText_inputType, (int)TextInputType.Text);
                }

                typedArray.Recycle();
            }
        }
Example #4
0
 private void ApplyUnits(TypedArray attrs, int attributeIndex)
 {
     if (attrs.HasValue(attributeIndex))
     {
         _timeUnits = attrs.GetInt(attributeIndex, 0);
     }
 }
Example #5
0
 private void ApplyBackgroundColor(TypedArray attrs, int attributeIndex, View targetView)
 {
     if (attrs.HasValue(attributeIndex))
     {
         int color = attrs.GetColor(attributeIndex, 0);
         targetView.SetBackgroundColor(new Color(color));
     }
 }
Example #6
0
        public XCircleImageView(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
        {
            TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.CircleImageView, defStyle, 0);

            mBorderWidth   = a.GetDimensionPixelSize(Resource.Styleable.CircleImageView_civ_border_width, DEFAULT_BORDER_WIDTH);
            mBorderColor   = a.GetColor(Resource.Styleable.CircleImageView_civ_border_color, DEFAULT_BORDER_COLOR);
            mBorderOverlay = a.GetBoolean(Resource.Styleable.CircleImageView_civ_border_overlay, DEFAULT_BORDER_OVERLAY);
            if (a.HasValue(Resource.Styleable.CircleImageView_civ_circle_background_color))
            {
                mCircleBackgroundColor = a.GetColor(Resource.Styleable.CircleImageView_civ_circle_background_color, DEFAULT_CIRCLE_BACKGROUND_COLOR);
            }
            else if (a.HasValue(Resource.Styleable.CircleImageView_civ_fill_color))
            {
                mCircleBackgroundColor = a.GetColor(Resource.Styleable.CircleImageView_civ_fill_color, DEFAULT_CIRCLE_BACKGROUND_COLOR);
            }
            a.Recycle();
            init();
        }
Example #7
0
        protected void Initialize(IAttributeSet attrs)
        {
            if (attrs != null)
            {
                TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.MultiSpinnerSearch);

                if (a.HasValue(Resource.Styleable.MultiSpinnerSearch_hintText))
                {
                    spinnerTitle = a.GetString(Resource.Styleable.MultiSpinnerSearch_hintText);
                }

                if (a.HasValue(Resource.Styleable.MultiSpinnerSearch_emptyText))
                {
                    defaultText = a.GetString(Resource.Styleable.MultiSpinnerSearch_emptyText);
                }


                a.Recycle();
            }

            Adapter = new ArrayAdapter <string>(Context, Resource.Layout.spinner_text_view, new string[] { Label });
        }
Example #8
0
        private void Init(IAttributeSet attrs, int defStyleAttr)
        {
            TypedArray t = Context.ObtainStyledAttributes(attrs, new int[] { Resource.Attribute.clearIconDrawable, Resource.Attribute.clearIconDrawWhenFocused }, defStyleAttr, 0);

            if (t.HasValue(0))
            {
                mClearIconDrawable = t.GetDrawable(0);

                if (mClearIconDrawable != null)
                {
                    mClearIconDrawable.Callback = this;
                }
            }

            mClearIconDrawWhenFocused = t.GetBoolean(1, true);

            t.Recycle();
        }
        private void Init(Context context, IAttributeSet attrs)
        {
            clipPaint.AntiAlias = true;

            //TODO: Depreciated - create work around
            DrawingCacheEnabled = true;

            SetWillNotDraw(false);

            clipPaint.Color = Color.Blue;
            clipPaint.SetStyle(Paint.Style.Fill);
            clipPaint.StrokeWidth = 1;

            if (Build.VERSION.SdkInt <= BuildVersionCodes.OMr1)
            {
                clipPaint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.DstIn));
                SetLayerType(LayerType.Software, clipPaint); //Only works for software layers
            }
            else
            {
                clipPaint.SetXfermode(pdMode);
                SetLayerType(LayerType.Software, null); //Only works for software layers
            }

            if (attrs != null)
            {
                TypedArray attributes = context.ObtainStyledAttributes(attrs, Resource.Styleable.ShapedView);
                if (attributes.HasValue(Resource.Styleable.ShapedView_shape_clip_drawable))
                {
                    int resourceId = attributes.GetResourceId(Resource.Styleable.ShapedView_shape_clip_drawable, -1);
                    if (-1 != resourceId)
                    {
                        SetDrawable(resourceId);
                        //SetDrawable(AndroidX.AppCompat.Content.Res.AppCompatResources.GetDrawable(Context, resourceId));
                    }
                }
                attributes.Recycle();
            }
        }
        protected override void HandleStyledAttributes(TypedArray a)
        {
            base.HandleStyledAttributes(a);

            mListViewExtrasEnabled = a.GetBoolean(Resource.Styleable.PullToRefresh_ptrListViewExtrasEnabled, true);

            if (mListViewExtrasEnabled)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.widget.FrameLayout.LayoutParams lp = new android.widget.FrameLayout.LayoutParams(android.widget.FrameLayout.LayoutParams.MATCH_PARENT, android.widget.FrameLayout.LayoutParams.WRAP_CONTENT, android.view.Gravity.CENTER_HORIZONTAL);
                FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.WrapContent, GravityFlags.CenterHorizontal);

                // Create Loading Views ready for use later
                mLvHeaderLoadingFrame         = new FrameLayout(Context);
                mHeaderLoadingView            = CreateLoadingLayout(Context, PullMode.PULL_FROM_START, a);
                mHeaderLoadingView.Visibility = ViewStates.Gone;
                mLvHeaderLoadingFrame.AddView(mHeaderLoadingView, lp);
                mRefreshableView.AddHeaderView(mLvHeaderLoadingFrame, null, false);

                mLvFooterLoadingFrame         = new FrameLayout(Context);
                mFooterLoadingView            = CreateLoadingLayout(Context, PullMode.PULL_FROM_END, a);
                mFooterLoadingView.Visibility = ViewStates.Gone;
                mLvFooterLoadingFrame.AddView(mFooterLoadingView, lp);

                mLvSecondFooterLoadingFrame = new FrameLayout(Context);

                /// <summary>
                /// If the value for Scrolling While Refreshing hasn't been
                /// explicitly set via XML, enable Scrolling While Refreshing.
                /// </summary>
                if (!a.HasValue(Resource.Styleable.PullToRefresh_ptrScrollingWhileRefreshingEnabled))
                {
                    ScrollingWhileRefreshingEnabled = true;
                }
            }
        }
Example #11
0
        public void ApplyStylableAttributes(Context context, TypedArray a, int[] styleableRes)
        {
            if (styleableRes == Resource.Styleable.CircularEventGauge)
            {
                // Background Gauge Attributes

                bool  ringColorsSet = false;
                Color startColor    = Color.DarkGray;
                Color endColor      = Color.White;
                if (a.HasValue(Resource.Styleable.CircularEventGauge_ringStartColor))
                {
                    startColor    = a.GetColor(Resource.Styleable.CircularEventGauge_ringStartColor, Color.DarkGray);
                    ringColorsSet = true;
                }
                if (a.HasValue(Resource.Styleable.CircularEventGauge_ringEndColor))
                {
                    endColor      = a.GetColor(Resource.Styleable.CircularEventGauge_ringEndColor, Color.White);
                    ringColorsSet = true;
                }
                if (ringColorsSet)
                {
                    RingColors = new ShadingColorPair(startColor, endColor);
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_centerTint))
                {
                    var csl = a.GetColorStateList(Resource.Styleable.CircularEventGauge_centerTint);
                    if (csl != null)
                    {
                        CenterTint = csl;
                    }
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_centerSrc))
                {
                    CenterDrawable = a.GetDrawable(Resource.Styleable.CircularEventGauge_centerSrc);
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_ringGap))
                {
                    RingGapPx = a.GetDimensionPixelSize(Resource.Styleable.CircularEventGauge_ringGap, RingThicknessPx);
                }


                // Count Atttributes

                bool     fontPropertiesSet = false;
                Typeface typeface          = null;
                string   familyName        = null;
                string   styleName         = null;

                if (a.HasValue(Resource.Styleable.CircularEventGauge_countTypeface))
                {
                    typeface          = (Typeface)a.GetInt(Resource.Styleable.CircularEventGauge_countTypeface, 0);
                    fontPropertiesSet = true;
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_countTextStyle))
                {
                    styleName         = a.GetString(Resource.Styleable.CircularEventGauge_countTextStyle);
                    fontPropertiesSet = true;
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_countFontFamily))
                {
                    Typeface tf = null;
                    // Try to resolve as a font resource
                    try
                    {
                        var resId = a.GetResourceId(Resource.Styleable.CircularEventGauge_countFontFamily, 0);
                        tf = ResourcesCompat.GetFont(Context, resId);
                    }
                    catch (Exception ex) { }

                    if (tf == null)
                    {
                        // Try to resolve as a font asset or system font
                        familyName = a.GetString(Resource.Styleable.CircularEventGauge_countFontFamily);
                    }
                    else
                    {
                        typeface = tf;
                    }
                    fontPropertiesSet = true;
                }

                if (fontPropertiesSet)
                {
                    var typefaceAndStyle = GetTypefaceFromAttrs(typeface, familyName, styleName);
                    if (typefaceAndStyle?.Item1 != null && typefaceAndStyle?.Item1 == null)
                    {
                        CountTypeface = typefaceAndStyle.Item1;
                    }
                    else if (typefaceAndStyle?.Item1 != null && typefaceAndStyle?.Item1 != null)
                    {
                        SetCountTypeface(typefaceAndStyle.Item1, (TypefaceStyle)typefaceAndStyle.Item2);
                    }
                }


                if (a.HasValue(Resource.Styleable.CircularEventGauge_countColor))
                {
                    var csl = a.GetColorStateList(Resource.Styleable.CircularEventGauge_countColor);
                    if (csl != null)
                    {
                        CountColors = csl;
                    }
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_countAutosize))
                {
                    CountAutoSize = a.GetBoolean(Resource.Styleable.CircularEventGauge_countAutosize, true);
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_countTextSize))
                {
                    CountTextSizePx = a.GetDimensionPixelSize(Resource.Styleable.CircularEventGauge_countTextSize, PixelSizeConverter.SpToPx(20));
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_countAllCaps))
                {
                    CountAllCaps = a.GetBoolean(Resource.Styleable.CircularEventGauge_countAllCaps, true);
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_countText))
                {
                    CountText = a.GetString(Resource.Styleable.CircularEventGauge_countText);
                }



                // Label Atttributes

                fontPropertiesSet = false;
                typeface          = null;
                familyName        = null;
                styleName         = null;

                if (a.HasValue(Resource.Styleable.CircularEventGauge_labelTypeface))
                {
                    typeface          = (Typeface)a.GetInt(Resource.Styleable.CircularEventGauge_labelTypeface, 0);
                    fontPropertiesSet = true;
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_labelTextStyle))
                {
                    styleName         = a.GetString(Resource.Styleable.CircularEventGauge_labelTextStyle);
                    fontPropertiesSet = true;
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_labelFontFamily))
                {
                    Typeface tf = null;
                    // Try to resolve as a font resource
                    try
                    {
                        var resId = a.GetResourceId(Resource.Styleable.CircularEventGauge_labelFontFamily, 0);
                        tf = ResourcesCompat.GetFont(Context, resId);
                    }
                    catch (Exception ex) { }

                    if (tf == null)
                    {
                        // Try to resolve as a font asset or system font
                        familyName = a.GetString(Resource.Styleable.CircularEventGauge_labelFontFamily);
                    }
                    else
                    {
                        typeface = tf;
                    }
                    fontPropertiesSet = true;
                }

                if (fontPropertiesSet)
                {
                    var typefaceAndStyle = GetTypefaceFromAttrs(typeface, familyName, styleName);
                    if (typefaceAndStyle?.Item1 != null && typefaceAndStyle?.Item1 == null)
                    {
                        LabelTypeface = typefaceAndStyle.Item1;
                    }
                    else if (typefaceAndStyle?.Item1 != null && typefaceAndStyle?.Item1 != null)
                    {
                        SetLabelTypeface(typefaceAndStyle.Item1, (TypefaceStyle)typefaceAndStyle.Item2);
                    }
                }


                if (a.HasValue(Resource.Styleable.CircularEventGauge_labelColor))
                {
                    var csl = a.GetColorStateList(Resource.Styleable.CircularEventGauge_labelColor);
                    if (csl != null)
                    {
                        LabelColors = csl;
                    }
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_labelTextSize))
                {
                    LabelTextSizePx = a.GetDimensionPixelSize(Resource.Styleable.CircularEventGauge_labelTextSize, PixelSizeConverter.SpToPx(10));
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_labelAllCaps))
                {
                    LabelAllCaps = a.GetBoolean(Resource.Styleable.CircularEventGauge_labelAllCaps, true);
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_labelText))
                {
                    LabelText = a.GetString(Resource.Styleable.CircularEventGauge_labelText);
                }


                // Icon attributes

                if (a.HasValue(Resource.Styleable.CircularEventGauge_iconSrc))
                {
                    IconDrawable = a.GetDrawable(Resource.Styleable.CircularEventGauge_iconSrc);
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_iconSize))
                {
                    IconSizePx = a.GetDimensionPixelSize(Resource.Styleable.CircularEventGauge_iconSize, PixelSizeConverter.SpToPx(18));
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_iconTint))
                {
                    var csl = a.GetColorStateList(Resource.Styleable.CircularEventGauge_iconTint);
                    if (csl != null)
                    {
                        IconTint = csl;
                    }
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_iconTintMode))
                {
                    var mode = a.GetInt(Resource.Styleable.CircularEventGauge_iconTintMode, -1);
                    if (mode != -1)
                    {
                        IconTintMode = (PorterDuff.Mode)mode;
                    }
                }



                // Other Attributes

                if (a.HasValue(Resource.Styleable.CircularEventGauge_count))
                {
                    var count = a.GetInt(Resource.Styleable.CircularEventGauge_count, -1);
                    if (count > -1)
                    {
                        EventCount = count;
                    }
                }

                if (a.HasValue(Resource.Styleable.CircularEventGauge_active))
                {
                    Active = a.GetBoolean(Resource.Styleable.CircularEventGauge_active, true);
                }

                CreateGuage();
            }
        }
        public LoadingLayout(Context context, Mode mode, PtrOrientation scrollDirection, TypedArray attrs)
            : base(context)
        {
            //base(context);
            mMode = mode;
            mScrollDirection = scrollDirection;

            switch (scrollDirection)
            {
                case PtrOrientation.HORIZONTAL:
                    LayoutInflater.From(context).Inflate(Resource.Layout.pull_to_refresh_header_horizontal, this);
                    break;
                case PtrOrientation.VERTICAL:
                default:
                    LayoutInflater.From(context).Inflate(Resource.Layout.pull_to_refresh_header_vertical, this);
                    break;
            }

            mInnerLayout = (FrameLayout)FindViewById(Resource.Id.fl_inner);
            mHeaderText = (TextView)mInnerLayout.FindViewById(Resource.Id.pull_to_refresh_text);
            mHeaderProgress = (ProgressBar)mInnerLayout.FindViewById(Resource.Id.pull_to_refresh_progress);
            mSubHeaderText = (TextView)mInnerLayout.FindViewById(Resource.Id.pull_to_refresh_sub_text);
            mHeaderImage = (ImageView)mInnerLayout.FindViewById(Resource.Id.pull_to_refresh_image);

            FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams)mInnerLayout.LayoutParameters;

            switch (mode)
            {
                case Mode.PULL_FROM_END:
                    lp.Gravity = scrollDirection == PtrOrientation.VERTICAL ? GravityFlags.Top : GravityFlags.Left;

                    // Load in labels
                    mPullLabel = context.GetString(Resource.String.pull_to_refresh_from_bottom_pull_label);
                    mRefreshingLabel = context.GetString(Resource.String.pull_to_refresh_from_bottom_refreshing_label);
                    mReleaseLabel = context.GetString(Resource.String.pull_to_refresh_from_bottom_release_label);
                    break;

                case Mode.PULL_FROM_START:
                default:
                    lp.Gravity = scrollDirection == PtrOrientation.VERTICAL ? GravityFlags.Bottom : GravityFlags.Right;

                    // Load in labels
                    mPullLabel = context.GetString(Resource.String.pull_to_refresh_pull_label);
                    mRefreshingLabel = context.GetString(Resource.String.pull_to_refresh_refreshing_label);
                    mReleaseLabel = context.GetString(Resource.String.pull_to_refresh_release_label);
                    break;
            }



            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrHeaderBackground))
            {
                Drawable background = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrHeaderBackground);
                if (null != background)
                {
                    ViewCompat.setBackground(this, background);
                }
            }

            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrHeaderTextAppearance))
            {
                TypedValue styleID = new TypedValue();
                attrs.GetValue(Resource.Styleable.PullToRefresh_ptrHeaderTextAppearance, styleID);
                setTextAppearance(styleID.Data);
            }
            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrSubHeaderTextAppearance))
            {
                TypedValue styleID = new TypedValue();
                attrs.GetValue(Resource.Styleable.PullToRefresh_ptrSubHeaderTextAppearance, styleID);
                setSubTextAppearance(styleID.Data);
            }

            // Text Color attrs need to be set after TextAppearance attrs
            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrHeaderTextColor))
            {
                ColorStateList colors = attrs.GetColorStateList(Resource.Styleable.PullToRefresh_ptrHeaderTextColor);
                if (null != colors)
                {
                    setTextColor(colors);
                }
            }
            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrHeaderSubTextColor))
            {
                ColorStateList colors = attrs.GetColorStateList(Resource.Styleable.PullToRefresh_ptrHeaderSubTextColor);
                if (null != colors)
                {
                    setSubTextColor(colors);
                }
            }

            // Try and get defined drawable from Attrs
            Drawable imageDrawable = null;
            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrDrawable))
            {
                imageDrawable = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrDrawable);
            }

            // Check Specific Drawable from Attrs, these overrite the generic
            // drawable attr above
            switch (mode)
            {
                case Mode.PULL_FROM_START:
                default:

                    if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrDrawableStart))
                    {
                        imageDrawable = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrDrawableStart);
                    }
                    else if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrDrawableTop))
                    {
                        Utils.warnDeprecation("ptrDrawableTop", "ptrDrawableStart");
                        imageDrawable = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrDrawableTop);
                    }
                    break;

                case Mode.PULL_FROM_END:
                    if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrDrawableEnd))
                    {
                        imageDrawable = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrDrawableEnd);
                    }
                    else if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrDrawableBottom))
                    {
                        Utils.warnDeprecation("ptrDrawableBottom", "ptrDrawableEnd");
                        imageDrawable = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrDrawableBottom);
                    }
                    break;
            }

            // If we don't have a user defined drawable, load the default
            if (null == imageDrawable)
            {

                imageDrawable = context.Resources.GetDrawable(getDefaultDrawableResId());
            }

            // Set Drawable, and save width/height
            setLoadingDrawable(imageDrawable);

            reset();
        }
Example #13
0
 public bool HasValue(int index)
 {
     return(_array.HasValue(index));
 }
Example #14
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public LoadingLayout(android.content.Context context, final PullToRefresh.PullMode mode, final PullToRefresh.ScrollOrientation scrollDirection, android.content.res.TypedArray attrs)
        public LoadingLayout(Context context, PullMode mode, ScrollOrientation scrollDirection, TypedArray attrs) : base(context)
        {
            mMode            = mode;
            mScrollDirection = scrollDirection;

            switch (scrollDirection)
            {
            case ScrollOrientation.HORIZONTAL:
                LayoutInflater.From(context).Inflate(Resource.Layout.pull_to_refresh_header_horizontal, this);
                break;

            case ScrollOrientation.VERTICAL:
            default:
                LayoutInflater.From(context).Inflate(Resource.Layout.pull_to_refresh_header_vertical, this);
                break;
            }

            mInnerLayout    = (FrameLayout)FindViewById(Resource.Id.fl_inner);
            mHeaderText     = (TextView)mInnerLayout.FindViewById(Resource.Id.pull_to_refresh_text);
            mHeaderProgress = (ProgressBar)mInnerLayout.FindViewById(Resource.Id.pull_to_refresh_progress);
            mSubHeaderText  = (TextView)mInnerLayout.FindViewById(Resource.Id.pull_to_refresh_sub_text);
            mHeaderImage    = (ImageView)mInnerLayout.FindViewById(Resource.Id.pull_to_refresh_image);

            LayoutParams lp = (LayoutParams)mInnerLayout.LayoutParameters;

            switch (mode)
            {
            case PullMode.PULL_FROM_END:
                lp.Gravity = scrollDirection == ScrollOrientation.VERTICAL ? GravityFlags.Top : GravityFlags.Left;

                // Load in labels
                mPullLabel       = context.GetString(Resource.String.pull_to_refresh_pull_label);
                mRefreshingLabel = context.GetString(Resource.String.pull_to_refresh_refreshing_label);
                mReleaseLabel    = context.GetString(Resource.String.pull_to_refresh_release_label);
                break;

            case PullMode.PULL_FROM_START:
            default:
                lp.Gravity = scrollDirection == ScrollOrientation.VERTICAL ? GravityFlags.Bottom : GravityFlags.Right;

                // Load in labels
                mPullLabel       = context.GetString(Resource.String.pull_to_refresh_pull_label);
                mRefreshingLabel = context.GetString(Resource.String.pull_to_refresh_refreshing_label);
                mReleaseLabel    = context.GetString(Resource.String.pull_to_refresh_release_label);
                break;
            }

            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrHeaderBackground))
            {
                Drawable background = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrHeaderBackground);
                if (null != background)
                {
                    ViewCompat.setBackground(this, background);
                }
            }

            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrHeaderTextAppearance))
            {
                TypedValue styleID = new TypedValue();
                attrs.GetValue(Resource.Styleable.PullToRefresh_ptrHeaderTextAppearance, styleID);
                TextAppearance = styleID.Data;
            }
            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrSubHeaderTextAppearance))
            {
                TypedValue styleID = new TypedValue();
                attrs.GetValue(Resource.Styleable.PullToRefresh_ptrSubHeaderTextAppearance, styleID);
                SubTextAppearance = styleID.Data;
            }

            // Text Color attrs need to be set after TextAppearance attrs
            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrHeaderTextColor))
            {
                ColorStateList colors = attrs.GetColorStateList(Resource.Styleable.PullToRefresh_ptrHeaderTextColor);
                if (null != colors)
                {
                    TextColor = colors;
                }
            }
            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrHeaderSubTextColor))
            {
                ColorStateList colors = attrs.GetColorStateList(Resource.Styleable.PullToRefresh_ptrHeaderSubTextColor);
                if (null != colors)
                {
                    SubTextColor = colors;
                }
            }

            // Try and get defined drawable from Attrs
            Drawable imageDrawable = null;

            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrDrawable))
            {
                imageDrawable = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrDrawable);
            }

            // Check Specific Drawable from Attrs, these overrite the generic
            // drawable attr above
            switch (mode)
            {
            case PullMode.PULL_FROM_START:
            default:
                if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrDrawableStart))
                {
                    imageDrawable = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrDrawableStart);
                }
                else if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrDrawableTop))
                {
                    Utils.warnDeprecation("ptrDrawableTop", "ptrDrawableStart");
                    imageDrawable = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrDrawableTop);
                }
                break;

            case PullMode.PULL_FROM_END:
                if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrDrawableEnd))
                {
                    imageDrawable = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrDrawableEnd);
                }
                else if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrDrawableBottom))
                {
                    Utils.warnDeprecation("ptrDrawableBottom", "ptrDrawableEnd");
                    imageDrawable = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrDrawableBottom);
                }
                break;
            }

            // If we don't have a user defined drawable, load the default
            if (null == imageDrawable)
            {
                imageDrawable = context.Resources.GetDrawable(DefaultDrawableResId);
            }

            // Set Drawable, and save width/height
            LoadingDrawable = imageDrawable;

            reset();
        }