Beispiel #1
0
 bool AView.IOnTouchListener.OnTouch(AView v, MotionEvent e)
 {
     ((Element.Children.First() as Layout).Children.First() as Label).Text = Issue1942.SuccessString;
     ViewTreeObserver.RemoveOnGlobalLayoutListener(this);
     _gridChild.SetOnTouchListener(null);
     return(true);
 }
        public void OnGlobalLayout()
        {
            _bottomBar.ShyHeightAlreadyCalculated = true;

            int newHeight = _outerContainer.Height + _navBarHeightCopy;

            _outerContainer.LayoutParameters.Height = newHeight;

            if (_bottomBar.IsShy)
            {
                int defaultOffset = _bottomBar.UseExtraOffset ? _navBarHeightCopy : 0;
                _bottomBar.TranslationY = defaultOffset;
                ((CoordinatorLayout.LayoutParams)_bottomBar.LayoutParameters).Behavior = new BottomNavigationBehavior <View>(newHeight, defaultOffset, _isShy, _isTabletMode);
            }

            ViewTreeObserver obs = _outerContainer.ViewTreeObserver;

            if (obs.IsAlive)
            {
                if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean)
                {
                    obs.RemoveOnGlobalLayoutListener(this);
                }
                else
                {
                    obs.RemoveGlobalOnLayoutListener(this);
                }
            }
        }
Beispiel #3
0
        public void OnGlobalLayout()
        {
            var view = tabsContainer.GetChildAt(0);

            if ((int)Build.VERSION.SdkInt < 16)
            {
                ViewTreeObserver.RemoveGlobalOnLayoutListener(this);
            }
            else
            {
                ViewTreeObserver.RemoveOnGlobalLayoutListener(this);
            }

            if (isPaddingMiddle)
            {
                int halfWidthFirstTab = view.Width / 2;
                padding = Width / 2 - halfWidthFirstTab;
            }

            SetPadding(padding, PaddingTop, padding, PaddingBottom);
            if (scrollOffset == 0)
            {
                scrollOffset = Width / 2 - padding;
            }
        }
Beispiel #4
0
        public void RemoveFromWindow()
        {
            if (Parent is ViewGroup parent)
            {
                parent.RemoveView(this);
            }


            if (_bitmap != null)
            {
                _bitmap.Recycle();
                _bitmap = null;
            }

            _eraser           = null;
            _animationFactory = null;
            _canvas           = null;
            _handler          = null;

            if ((int)Build.VERSION.SdkInt < 16)
            {
                ViewTreeObserver.RemoveGlobalOnLayoutListener(this);
            }
            else
            {
                ViewTreeObserver.RemoveOnGlobalLayoutListener(this);
            }
            //mLayoutListener = null;

            _prefsManager?.Close();

            _prefsManager = null;
        }
Beispiel #5
0
        public void OnGlobalLayout()
        {
            var view = tabsContainer.GetChildAt(0);

            if ((int)Build.VERSION.SdkInt < 16)
            {
                ViewTreeObserver.RemoveGlobalOnLayoutListener(this);
            }
            else
            {
                ViewTreeObserver.RemoveOnGlobalLayoutListener(this);
            }

            if (isPaddingMiddle)
            {
                int halfWidthFirstTab = view.Width / 2;
                paddingLeft = paddingRight = Width / 2 - halfWidthFirstTab;
            }

            SetPadding(paddingLeft, PaddingTop, paddingRight, PaddingBottom);
            if (scrollOffset == 0)
            {
                scrollOffset = Width / 2 - paddingLeft;
            }


            currentPosition       = pager.CurrentItem;
            currentPositionOffset = 0f;
            ScrollToChild(currentPosition, 0);
            UpdateSelection(currentPosition);
        }
Beispiel #6
0
        void myTabbedPage_Disappearing(object sender, EventArgs e)
        {
            mMenu.Hide();

            listener.GlobalLayout -= listener_GlobalLayout;
            ViewTreeObserver.RemoveOnGlobalLayoutListener(listener);
            //_isFirstDesign = true;
            //_activity.ActionBar.SetCustomView(UIHelper.GetLayoutResource("empty_layout"));
        }
Beispiel #7
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                ViewTreeObserver.RemoveOnGlobalLayoutListener(this);
                _gridChild.SetOnTouchListener(null);
                _gridChild = null;
            }

            base.Dispose(disposing);
        }
Beispiel #8
0
 private void RemoveGlobals()
 {
     if ((int)Build.VERSION.SdkInt < 16)
     {
         ViewTreeObserver.RemoveGlobalOnLayoutListener(MyOnGlobalLayoutListner);
     }
     else
     {
         ViewTreeObserver.RemoveOnGlobalLayoutListener(MyOnGlobalLayoutListner);
     }
 }
Beispiel #9
0
        void ClearLayoutListener()
        {
            if (_carouselViewLayoutListener == null)
            {
                return;
            }

            ViewTreeObserver?.RemoveOnGlobalLayoutListener(_carouselViewLayoutListener);
            _carouselViewLayoutListener.LayoutReady -= LayoutReady;
            _carouselViewLayoutListener              = null;
        }
Beispiel #10
0
 private void Initialize()
 {
     ViewTreeObserver.AddOnGlobalLayoutListener(new GlobalLayoutListener((obj) =>
     {
         ViewTreeObserver.RemoveOnGlobalLayoutListener(obj);
         // Generate simple Triangulation for initial draw
         Triangulation = new Triangulation(Width, Height);
         Triangulation.PropertyChanged += Triangulation_PropertyChanged;
         Invalidate();
     }));
 }
Beispiel #11
0
        public void OnGlobalLayout()
        {
            ViewTreeObserver vto = ViewTreeObserver;

            vto.RemoveOnGlobalLayoutListener(this);

            if (this.LineCount <= mMaxLines)
            {
                SetText(mFullText, BufferType.Normal);
            }
            else
            {
                MovementMethod = LinkMovementMethod.Instance;
                ShowLess();
            }
        }
Beispiel #12
0
        public void OnGlobalLayout()
        {
            ViewTreeObserver obs = tv.ViewTreeObserver;

            obs.RemoveOnGlobalLayoutListener(this);

            lineCount = tv.LineCount;
            if (isPartial && lineCount > maxLines)
            {
                //tv.Ellipsize = ellipsize;
                tv.SetMaxLines(maxLines);
                tv.RequestLayout();
            }

            listerner.LineCountDetected(tv);
        }
Beispiel #13
0
        public void OnGlobalLayout()
        {
            int newHeight = _outerContainer.Height + _navBarHeightCopy;

            _outerContainer.LayoutParameters.Height = newHeight;

            ViewTreeObserver obs = _outerContainer.ViewTreeObserver;

            if (obs.IsAlive)
            {
                if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean)
                {
                    obs.RemoveOnGlobalLayoutListener(this);
                }
                else
                {
                    obs.RemoveGlobalOnLayoutListener(this);
                }
            }
        }
Beispiel #14
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.TabbedPage> e)
        {
            base.OnElementChanged(e);

            if (!_isFirstDesign)
            {
                return;
            }

            if (e.OldElement != null)
            {
                listener.GlobalLayout -= listener_GlobalLayout;
                ViewTreeObserver.RemoveOnGlobalLayoutListener(listener);
            }

            if (e.NewElement != null)
            {
                listener.GlobalLayout += listener_GlobalLayout;
                ViewTreeObserver.AddOnGlobalLayoutListener(listener);
            }

            myTabbedPage = (MvvmAspire.Controls.TabbedPage)Element;

            if (_activity == null)
            {
                _activity = this.Context as Activity;

                if (myTabbedPage.TabScreenLocation == TabGravity.Bottom)
                {
                    mMenu = new CustomMenuPopUp(this.Context, this, _activity.LayoutInflater);
                }
                else
                {
                    mMenu = new CustomMenu(this.Context, this, _activity.LayoutInflater);
                }

                mMenu.SetBadgeLocation(myTabbedPage.BadgeLocation);
                mMenu.SetItemsCountInLine(myTabbedPage.ActiveIcons.Count);
                if (myTabbedPage.BackgroundDrawable != null && myTabbedPage.SelectedDrawable != null)
                {
                    mMenu.SetBackgroundDrawable(myTabbedPage.BackgroundDrawable.File, myTabbedPage.SelectedDrawable.File);
                }

                if (myTabbedPage.TabScreenLocation == TabGravity.Bottom)
                {
                    originalPadding = myTabbedPage.Padding.Bottom;
                }
                else
                {
                    originalPadding = myTabbedPage.Padding.Top;
                }
            }

            if (childrenIcons.Count == 0)
            {
                for (int i = 0; i < myTabbedPage.Children.Count; i++)
                {
                    if (myTabbedPage.Children[i].Icon.File != null)
                    {
                        childrenIcons.Add(myTabbedPage.Children[i].Icon.File);
                    }
                }
            }

            myTabbedPage.Appearing    += myTabbedPage_Appearing;
            myTabbedPage.Disappearing += myTabbedPage_Disappearing;
        }
Beispiel #15
0
        public void OnGlobalLayout()
        {
            var tag = tv.Tag as ExpandableTextViewTag;

            if (tag == null)
            {
                throw new InvalidOperationException("Unable to handle a TextView without Tag.");
            }

            ViewTreeObserver obs = tv.ViewTreeObserver;

            obs.RemoveOnGlobalLayoutListener(this);

            if (tag.LineCount < 0)
            {
                tag.LineCount = tv.LineCount;
                if (tag.FormattedText == null)
                {
                    var spanned = tv.TextFormatted as ISpannable;
                    if (spanned != null)
                    {
                        tag.FormattedText = spanned;
                    }

                    if (tag.AutoLinkOptions != null)
                    {
                        SpannableStringBuilder ssb =
                            tag.FormattedText == null
                                                                ? new SpannableStringBuilder(tv.Text)
                                                                : new SpannableStringBuilder(tag.FormattedText);

                        Linkify.AddLinks(ssb, tag.AutoLinkOptions.AutoLinkMask);

                        if (!tag.AutoLinkOptions.IsLinkUnderline)
                        {
                            FixedTextUtils.RemoveLinkUnderline(ssb);
                        }

                        tag.FormattedText = ssb;
                    }
                }
            }

            if (tag.IsPartial)
            {
                if (tv.LineCount > tag.MaxLines)
                {
                    int lineStartIndex = tv.Layout.GetLineStart(tag.MaxLines - 1);
                    int lineEndIndex   = tv.Layout.GetLineEnd(tag.MaxLines - 1);

                    int remainLineWidth;
                    if (tag.ViewMoreLessOptions == null)
                    {
                        Rect apostropheRect = new Rect();
                        tv.Paint.GetTextBounds(Apostrophe, 0, Apostrophe.Length, apostropheRect);
                        remainLineWidth =
                            tv.Width
                            - (apostropheRect.Width() * 5 / 3)
                            - tv.TotalPaddingLeft - tv.TotalPaddingRight;
                    }
                    else
                    {
                        Rect viewMoreRect = new Rect();
                        tv.Paint.GetTextBounds(tag.ViewMoreLessOptions.ViewMore, 0, tag.ViewMoreLessOptions.ViewMore.Length, viewMoreRect);
                        Rect apostropheRect = new Rect();
                        tv.Paint.GetTextBounds(Apostrophe, 0, Apostrophe.Length, apostropheRect);
                        remainLineWidth =
                            tv.Width
                            - (int)Math.Round(viewMoreRect.Width() * (1.0f + 3.0f / (float)(tag.ViewMoreLessOptions.ViewMore.Length)) * ViewMoreLessProportion)
                            - apostropheRect.Width()
                            - tv.TotalPaddingLeft - tv.TotalPaddingRight;
                    }

                    String test        = tv.Text.Substring(lineStartIndex, lineEndIndex - lineStartIndex);
                    int    returnIndex = test.IndexOf('\r');
                    if (returnIndex < 0)
                    {
                        returnIndex = test.IndexOf('\n');
                    }

                    if (returnIndex >= 0)
                    {
                        test = test.Substring(0, returnIndex);
                    }

                    Rect testRect = new Rect();
                    while (test.Length > 0)
                    {
                        tv.Paint.GetTextBounds(test, 0, test.Length, testRect);
                        if (testRect.Width() < remainLineWidth)
                        {
                            break;
                        }

                        test = test.Substring(0, test.Length - 1);
                    }

                    if (tag.ViewMoreLessOptions == null)
                    {
                        if (tag.FormattedText == null)
                        {
                            tv.Text = tv.Text.Substring(0, lineStartIndex + test.Length) + Apostrophe;
                        }
                        else
                        {
                            var ssbPartial = new SpannableStringBuilder(
                                tag.FormattedText.SubSequenceFormatted(0, lineStartIndex + test.Length));
                            ssbPartial.Append(Apostrophe);
                            tv.TextFormatted = ssbPartial;
                        }
                    }
                    else
                    {
                        if (tag.FormattedText == null)
                        {
                            String text = tv.Text.Substring(0, lineStartIndex + test.Length) + Apostrophe + " ";
                            var    ssb  = new SpannableStringBuilder(text);
                            ssb.Append(StyleViewMoreLess(tag));
                            tv.TextFormatted = ssb;
                        }
                        else
                        {
                            var ssbPartial = new SpannableStringBuilder(
                                tag.FormattedText.SubSequenceFormatted(0, lineStartIndex + test.Length));
                            ssbPartial.Append(Apostrophe + " ");
                            ssbPartial.Append(StyleViewMoreLess(tag));
                            tv.TextFormatted = ssbPartial;
                        }
                    }
                    tv.ScrollTo(0, 0);

                    if (tag.ClickSwitch)
                    {
                        tv.SetOnClickListener(this);
                    }
                }
                else if (tag.AutoLinkOptions != null)
                {
                    tv.TextFormatted = tag.FormattedText;
                }
            }
            else
            {
                if (tag.ViewMoreLessOptions == null)
                {
                    if (tag.FormattedText == null)
                    {
                        tv.Text = tag.Text;
                    }
                    else
                    {
                        tv.TextFormatted = tag.FormattedText;
                    }
                }
                else
                {
                    if (tag.FormattedText == null)
                    {
                        String text = tag.Text + " ";
                        var    ssb  = new SpannableStringBuilder(text);
                        ssb.Append(StyleViewMoreLess(tag));
                        tv.TextFormatted = ssb;
                    }
                    else
                    {
                        var ssb = new SpannableStringBuilder(tag.FormattedText);
                        ssb.Append(" ");
                        ssb.Append(StyleViewMoreLess(tag));
                        tv.TextFormatted = ssb;
                    }
                }

                tv.ScrollTo(0, 0);
            }

            if (tag.Listerner != null)
            {
                tag.Listerner.LineCountDetected(tv);
            }
        }