public IndicatorLayout(Context context, Mode mode)

            : base(context)
        {
            //super(context);
            mArrowImageView = new ImageView(context);

            Drawable arrowD = Resources.GetDrawable(Resource.Drawable.indicator_arrow);
            mArrowImageView.SetImageDrawable(arrowD);

            int padding = Resources.GetDimensionPixelSize(Resource.Dimension.indicator_internal_padding);
            mArrowImageView.SetPadding(padding, padding, padding, padding);
            AddView(mArrowImageView);

            int inAnimResId, outAnimResId;
            switch (mode)
            {
                case Mode.PULL_FROM_END:
                    inAnimResId = Resource.Animation.slide_in_from_bottom;
                    outAnimResId = Resource.Animation.slide_out_to_bottom;
                    SetBackgroundResource(Resource.Drawable.indicator_bg_bottom);

                    // Rotate Arrow so it's pointing the correct way
                    mArrowImageView.SetScaleType(Android.Widget.ImageView.ScaleType.Matrix);
                    Matrix matrix = new Matrix();

                    matrix.SetRotate(180f, arrowD.IntrinsicWidth / 2f, arrowD.IntrinsicHeight / 2f);
                    mArrowImageView.ImageMatrix = matrix;
                    break;
                default:
                case Mode.PULL_FROM_START:
                    inAnimResId = Resource.Animation.slide_in_from_top;
                    outAnimResId = Resource.Animation.slide_out_to_top;
                    SetBackgroundResource(Resource.Drawable.indicator_bg_top);
                    break;
            }

            mInAnim = AnimationUtils.LoadAnimation(context, inAnimResId);
            mInAnim.SetAnimationListener(this);

            mOutAnim = AnimationUtils.LoadAnimation(context, outAnimResId);
            mOutAnim.SetAnimationListener(this);

            IInterpolator interpolator = new LinearInterpolator();

            //mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);
            mRotateAnimation = new RotateAnimation(0, -180, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f);


            mRotateAnimation.Interpolator = interpolator;
            mRotateAnimation.Duration = DEFAULT_ROTATION_ANIMATION_DURATION;
            mRotateAnimation.FillAfter = true;

            mResetRotateAnimation = new RotateAnimation(-180, 0, Dimension.RelativeToSelf, 0.5f,
                    Dimension.RelativeToSelf, 0.5f);
            mResetRotateAnimation.Interpolator = interpolator;
            mResetRotateAnimation.Duration = DEFAULT_ROTATION_ANIMATION_DURATION;
            mResetRotateAnimation.FillAfter = true;

        }
        public FlipLoadingLayout(Context context, Mode mode, PTROrientation scrollDirection, TypedArray attrs)
            : base(context, mode, scrollDirection, attrs)
        {
            //super(context, mode, scrollDirection, attrs);

            int rotateAngle = mode == Mode.PULL_FROM_START ? -180 : 180;

            mRotateAnimation = new RotateAnimation(0, rotateAngle, Dimension.RelativeToSelf, 0.5f,
                    Dimension.RelativeToSelf, 0.5f);
            mRotateAnimation.Interpolator = ANIMATION_INTERPOLATOR;
            mRotateAnimation.Duration = FLIP_ANIMATION_DURATION;
            mRotateAnimation.FillAfter = true;

            mResetRotateAnimation = new RotateAnimation(rotateAngle, 0, Dimension.RelativeToSelf, 0.5f,
                    Dimension.RelativeToSelf, 0.5f);
            mResetRotateAnimation.Interpolator = ANIMATION_INTERPOLATOR;
            mResetRotateAnimation.Duration = FLIP_ANIMATION_DURATION;
            mResetRotateAnimation.FillAfter = true;
        }
        public RotateLoadingLayout(Context context, Mode mode, PtrOrientation scrollDirection, TypedArray attrs)
            : base(context, mode, scrollDirection, attrs)
        {
            //super(context, mode, scrollDirection, attrs);

            mRotateDrawableWhilePulling = attrs.GetBoolean(Resource.Styleable.PullToRefresh_ptrRotateDrawableWhilePulling, true);

            mHeaderImage.SetScaleType(ImageView.ScaleType.Matrix);
            mHeaderImageMatrix = new Matrix();
            mHeaderImage.ImageMatrix = mHeaderImageMatrix;

            mRotateAnimation = new RotateAnimation(0, 720, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf,
                    0.5f);

            mRotateAnimation.Interpolator = ANIMATION_INTERPOLATOR;
            mRotateAnimation.Duration = ROTATION_ANIMATION_DURATION;
            mRotateAnimation.RepeatCount = Animation.Infinite;
            mRotateAnimation.RepeatMode = RepeatMode.Restart;

        }
        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();
        }
 public PullToRefreshWebView2(Context context, Mode mode)
     :base(context,mode)
 {
     //super(context, mode);
 }