Beispiel #1
0
        public static bool ExceedMaxLines(TextView tv)
        {
            ExpandableTextViewTag tag = tv.Tag as ExpandableTextViewTag;

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

            return(tag.LineCount > tag.MaxLines);
        }
Beispiel #2
0
        public static void Switch(TextView tv)
        {
            ExpandableTextViewTag tag = tv.Tag as ExpandableTextViewTag;

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

            tag.IsPartial = !tag.IsPartial;
            tv.RequestLayout();
            tv.ViewTreeObserver.AddOnGlobalLayoutListener(new ExpandableTextViewUtilty(tv));
        }
Beispiel #3
0
        private static ISpannable StyleViewMoreLess(ExpandableTextViewTag tag)
        {
            string expandText          = tag.IsPartial ? tag.ViewMoreLessOptions.ViewMore : tag.ViewMoreLessOptions.ViewLess;
            SpannableStringBuilder ssb = new SpannableStringBuilder(expandText);

            /*
             * ssb.SetSpan(new ViewMoreLessSpan(delegate
             * {
             *      tag.IsPartial = ! tag.IsPartial;
             *      tv.RequestLayout();
             *      tv.ViewTreeObserver.AddOnGlobalLayoutListener(new ExpandableTextViewUtilty(tv));
             * }), text.Length - expandText.Length, text.Length, 0);
             */

            ssb.SetSpan(new ForegroundColorSpan(Color.Red), 0, expandText.Length, 0);
            ssb.SetSpan(new RelativeSizeSpan(ViewMoreLessProportion), 0, expandText.Length, 0);

            return(ssb);
        }
Beispiel #4
0
        private void ProcessAutoLink(ExpandableTextViewTag tag, SpannableStringBuilder ssbPartial)
        {
            if (tag.AutoLinkOptions != null && (!tag.AutoLinkOptions.IsLinkUnderline))
            {
                var allURLSpans = tag.FormattedText.GetSpans(
                    0, tag.FormattedText.Length(), Java.Lang.Class.FromType(typeof(URLSpan)));

                var partialURLSpans = ssbPartial.GetSpans(0, ssbPartial.Length(), Java.Lang.Class.FromType(typeof(URLSpan)));
                foreach (var span in partialURLSpans)
                {
                    int startIndex = ssbPartial.GetSpanStart(span);
                    int endIndex   = ssbPartial.GetSpanEnd(span);
                    var foundSpan  = FixedTextUtils.FindSpan(tag.FormattedText, allURLSpans, startIndex).JavaCast <URLSpan>();
                    ssbPartial.RemoveSpan(span);

                    if (foundSpan != null)
                    {
                        ssbPartial.SetSpan(new NoUnderlineURLSpan(foundSpan.URL), startIndex, endIndex, 0);
                    }
                }
            }
        }
Beispiel #5
0
        public static bool IsExpandable(TextView tv)
        {
            ExpandableTextViewTag tag = tv.Tag as ExpandableTextViewTag;

            return(tag != null);
        }