private static ISpanned RemoveLastChar(ICharSequence text)
        {
            var builder = new SpannableStringBuilder(text);

            builder.Delete(text.Length() - 1, text.Length());
            return(builder);
        }
Example #2
0
            string subString(ICharSequence source, int start, int end)
            {
                start = System.Math.Max(0, start);
                start = System.Math.Min(source.Length(), start); //the begin index, inclusive.
                end   = System.Math.Max(0, end);
                end   = System.Math.Min(source.Length(), end);   // the end index, exclusive.


                if (start >= 0 && end >= 0 && end >= start)
                {
                    return(source.SubSequence(start, end));
                }

                return(string.Empty);
            }
Example #3
0
        protected override FilterResults PerformFiltering(ICharSequence constraint)
        {
            if (constraint != null && constraint.Length() > 0)
            {
                string query = constraint.ToString().ToUpper();
                JavaList <AppUsers> foundFilter = new JavaList <AppUsers>();
                for (int i = 0; i < currentList.Size(); i++)
                {
                    string name    = currentList[i].Name;
                    string email   = currentList[i].Email;
                    string contact = currentList[i].PhoneNumber;

                    if (name.ToUpper().Contains(query.ToString()) ||
                        email.ToUpper().Contains(query.ToString()) ||
                        contact.ToUpper().Contains(query.ToString()))
                    {
                        foundFilter.Add(new AppUsers {
                            Name          = currentList[i].Name
                            , PhoneNumber = currentList[i].PhoneNumber
                            , Email       = currentList[i].Email
                        });
                    }
                }
                filterResults.Count  = foundFilter.Size();
                filterResults.Values = foundFilter;
            }
            else
            {
                filterResults.Count  = currentList.Size();
                filterResults.Values = currentList;
            }

            return(filterResults);
        }
Example #4
0
 public void OnTextChanged(ICharSequence s, int start, int before, int count)
 {
     if (s.Length() > 0)
     {
         m_iStartChan = Convert.ToInt32(s.ToString()) - 1;
     }
 }
Example #5
0
        protected override FilterResults PerformFiltering(ICharSequence constraint)
        {
            var results = new FilterResults();

            if (constraint == null || constraint.Length() == 0)
            {
                results.Values = new Java.Util.ArrayList(Originals.ToList());
                results.Count  = Originals.Count;
            }
            else
            {
                var values = new Java.Util.ArrayList();
                var sorted = _sortingAlgorithm(constraint.ToString(), Originals).ToList();

                for (var index = 0; index < sorted.Count; index++)
                {
                    var item = sorted[index];
                    values.Add(item);
                }

                results.Values = values;
                results.Count  = sorted.Count;
            }

            return(results);
        }
Example #6
0
        /// <summary>
        /// A method for getting tokens containing mutible words
        /// </summary>
        private ICharSequence InnerToken(ICharSequence text)
        {
            int i = text.Length();

            // Find the first space in the Token, going backwards
            while (i > 0 && text.CharAt(i - 1) == ' ')
            {
                i--;
            }

            if (i > 0 && text.CharAt(i - 1) == ' ')
            {
                return text;
            }
            else
            {
                if (text.GetType().IsInstanceOfType(typeof(ISpanned)))
                {
                    SpannableString sp = new SpannableString(text + " ");
                    TextUtils.CopySpansFrom((ISpanned)text, 0, text.Length(), Java.Lang.Class.FromType(typeof(Java.Lang.Object)), sp, 0);
                    return sp;
                }
                else
                {
                    return new Java.Lang.String(text + " ");
                }
            }
        }
Example #7
0
            protected override FilterResults PerformFiltering(ICharSequence constraint)
            {
                FilterResults results = new FilterResults();

                if (constraint != null && constraint.Length() > 0)
                {
                    List <UserItem> matchList = new List <UserItem>();
                    foreach (UserItem item in friendsCustomAdapter.persons.ToList())

                    {
                        if (item.Name.Contains(constraint.ToString().ToUpper()))
                        {
                            matchList.Add(item);
                        }
                    }

                    Java.Lang.Object[] resultsValues;
                    resultsValues = new Java.Lang.Object[matchList.Count];
                    for (int i = 0; i < matchList.Count; i++)
                    {
                        UserItem myObj = matchList[i];

                        resultsValues[i] = new JavaObjectWrapper <UserItem>()
                        {
                            Obj = myObj
                        };
                    }

                    results.Count  = matchList.Count;
                    results.Values = resultsValues;
                }
                return(results);
            }
Example #8
0
        protected override FilterResults PerformFiltering(ICharSequence constraint)
        {
            var results = new FilterResults();

            if (constraint == null || constraint.Length() == 0)
            {
                results.Values = Originals.ToList().ToArrayList();
                results.Count  = Originals.Count;
            }
            else
            {
                var values = new ArrayList();
                var sorted = _sortingAlgorithm(constraint.ToString(), Originals).ToList();

                foreach (var item in sorted)
                {
                    values.Add(item);
                }

                results.Values = values;
                results.Count  = sorted.Count;
            }

            return(results);
        }
        public void OnInput(MaterialDialog p0, ICharSequence p1)
        {
            try
            {
                if (TypeDialog == "Report")
                {
                    if (p1.Length() > 0)
                    {
                        if (Methods.CheckConnectivity())
                        {
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Video.Report_Video_Http(Videodata.Id, p1.ToString())
                            });

                            Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_received_your_report), ToastLength.Short).Show();
                        }
                        else
                        {
                            Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                        }
                    }
                    else
                    {
                        Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_The_name_can_not_be_blank), ToastLength.Short).Show();
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Example #10
0
        protected override FilterResults PerformFiltering(ICharSequence constraint)
        {
            FilterResults filterResults = new FilterResults();

            if (constraint != null && constraint.Length() > 0)
            {
                string          query         = constraint.ToString().ToUpper();
                JavaList <Item> filteredItems = new JavaList <Item>();

                for (int i = 0; i < currentItems.NumItems; i++)
                {
                    string itemName = currentItems[i].Text;
                    if (itemName.ToUpper().Contains(query.ToString()))
                    {
                        filteredItems.Add(currentItems[i]);
                    }
                }
                filterResults.Count  = filteredItems.Count;
                filterResults.Values = filteredItems;
            }
            else
            {
                filterResults.Count  = currentItems.NumItems;
                filterResults.Values = currentItems.getItems();
            }
            return(filterResults);
        }
Example #11
0
            public ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend)
            {
                var empty        = string.Empty.AsJavaString();
                var sourceLength = source.Length();

                if (sourceLength > 1)
                {
                    return(source.ToString().AsJavaString());
                }

                if (sourceLength == 0)
                {
                    onDeletionDetected();
                    return("0".AsCharSequence());
                }

                var lastChar = source.CharAt(sourceLength - 1);

                if (char.IsDigit(lastChar))
                {
                    int digit = int.Parse(lastChar.ToString());
                    onDigitEntered(digit);

                    return(empty);
                }

                return(empty);
            }
        public void OnInput(MaterialDialog p0, ICharSequence p1)
        {
            try
            {
                if (p1.Length() > 0)
                {
                    var strName = p1.ToString();

                    if (!IMethods.CheckConnectivity())
                    {
                        Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection),
                                       ToastLength.Short).Show();
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(PassedId))
                        {
                            var data = Client.Global.Post_Actions(PassedId, "commet", strName).ConfigureAwait(false);
                        }
                        else
                        {
                            Toast.MakeText(this, GetString(Resource.String.Lbl_something_went_wrong), ToastLength.Short)
                            .Show();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
Example #13
0
            protected override FilterResults PerformFiltering(ICharSequence constraint)
            {
                var returnParking = new FilterResults();
                var results       = new List <ParkingModel>();

                if (adapter.mItems == null)
                {
                    adapter.mItems = adapter.filteredList;
                }

                if (constraint == null || constraint.Length() == 0)
                {
                    results.Clear();
                    results.AddRange(adapter.original);
                }

                else if (adapter.mItems != null && adapter.mItems.Any())
                {
                    results.AddRange(adapter.mItems.Where(parking => parking.carPlateNumber.ToLower()
                                                          .Contains(constraint.ToString())));
                }

                returnParking.Values = FromArray(results.Select(p => p.ToJavaObject()).ToArray());

                returnParking.Count = results.Count;

                constraint.Dispose();

                return(returnParking);
            }
        public void AddReadMoreTo(AppCompatTextView textView, ICharSequence text)
        {
            try
            {
                if (TextLengthType == TypeCharacter)
                {
                    if (text.Length() <= TextLength)
                    {
                        textView.SetText(text, TextView.BufferType.Spannable);
                        //wael textView.SetTextFuture(PrecomputedTextCompat.GetTextFuture(text, TextViewCompat.GetTextMetricsParams(textView), null));
                        return;
                    }
                }
                else
                {
                    // If TYPE_LINE
                    textView.SetLines(TextLength);
                    //wael textView.SetTextFuture(PrecomputedTextCompat.GetTextFuture(text, TextViewCompat.GetTextMetricsParams(textView), null));
                    textView.SetText(text, TextView.BufferType.Spannable);
                }

                textView.Post(new StRunnable(this, textView, text));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        protected override FilterResults PerformFiltering(ICharSequence constraint)
        {
            FilterResults filterResults = new FilterResults();

            if (constraint != null && constraint.Length() > 0)
            {
                string        query        = constraint.ToString().ToUpper();
                List <string> foundfilters = new List <string>();
                for (int i = 0; i < currentList.Count(); i++)
                {
                    string galaxy = currentList[i];
                    if (galaxy.ToUpper().Contains(query.ToString()))
                    {
                        foundfilters.Add(galaxy);
                    }
                }
                filterResults.Count  = foundfilters.Count;               // Using size property to count....
                filterResults.Values = foundfilters.ToString();          // here i am converting Java.Lang.object to String..
            }
            else
            {
                filterResults.Count  = currentList.Count;
                filterResults.Values = currentList.ToString();                // here i am converting Java.Lang.object to String..
            }
            return(filterResults);
        }
Example #16
0
 public void OnInput(MaterialDialog p0, ICharSequence p1)
 {
     try
     {
         if (TypeDialog == "Report")
         {
             if (p1.Length() > 0)
             {
                 if (IMethods.CheckConnectivity())
                 {
                     Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_received_your_report), ToastLength.Short).Show();
                 }
                 else
                 {
                     Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                 }
             }
             else
             {
                 Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_The_name_can_not_be_blank), ToastLength.Short).Show();
             }
         }
     }
     catch (Exception exception)
     {
         Crashes.TrackError(exception);
     }
 }
        public void OnInput(MaterialDialog p0, ICharSequence p1)
        {
            try
            {
                if (p1.Length() > 0)
                {
                    var strName = p1.ToString();

                    if (!Methods.CheckConnectivity())
                    {
                        Toast.MakeText(MainContext, MainContext.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                    }
                    else
                    {
                        if (TypeClass == "Comment")
                        {
                            //TypeClass
                            var adapterGlobal = CommentActivity.GetInstance()?.MAdapter;
                            var dataGlobal    = adapterGlobal?.CommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id);
                            if (dataGlobal != null)
                            {
                                dataGlobal.Text = strName;
                                var index = adapterGlobal.CommentList.IndexOf(dataGlobal);
                                if (index > -1)
                                {
                                    adapterGlobal.NotifyItemChanged(index);
                                }
                            }
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Comment.EditCommentAsync(CommentObject.Id, strName)
                            });
                        }
                        else if (TypeClass == "Reply")
                        {
                            //TypeClass
                            var adapterGlobal = ReplyCommentActivity.GetInstance()?.MAdapter;
                            var dataGlobal    = adapterGlobal?.ReplyCommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id);
                            if (dataGlobal != null)
                            {
                                dataGlobal.Text = strName;
                                var index = adapterGlobal.ReplyCommentList.IndexOf(dataGlobal);
                                if (index > -1)
                                {
                                    adapterGlobal.NotifyItemChanged(index);
                                }
                            }

                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Comment.EditCommentAsync(CommentObject.Id, strName, "edit_reply")
                            });
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #18
0
 public virtual void OnTextChanged(ICharSequence s, int start, int before, int count)
 {
     if (string.IsNullOrWhiteSpace(Element.Text) && (s.Length() == 0))
     {
         return;
     }
     ((IElementController)Element).SetValueFromRenderer(Entry.TextProperty, s.ToString());
 }
Example #19
0
        public virtual void OnTextChanged(ICharSequence s, int start, int before, int count)
        {
            if (Element == null || (string.IsNullOrWhiteSpace(Element.Text) && (s.Length() == 0)) || Control == null || Control.Handle == IntPtr.Zero || EditText == null || EditText.Handle == IntPtr.Zero)
            {
                return;
            }

            ((IElementController)Element)?.SetValueFromRenderer(Entry.TextProperty, s.ToString());
        }
Example #20
0
        void ITextWatcher.OnTextChanged(ICharSequence s, int start, int before, int count)
        {
            if (string.IsNullOrEmpty(_EntryCell.ValueText) && s.Length() == 0)
            {
                return;
            }

            _EntryCell.ValueText = s?.ToString();
        }
        public virtual void OnTextChanged(ICharSequence s, int start, int before, int count)
        {
            if ((!Element.IsAlive() && (s.Length() == 0)) || !Control.IsAlive() || !Control.EditText.IsAlive())
            {
                return;
            }

            ((IElementController)Element)?.SetValueFromRenderer(Entry.TextProperty, s.ToString());
        }
Example #22
0
        public static Android.Text.StaticLayout StaticLayout(ICharSequence source, Android.Text.TextPaint paint, int width, Android.Text.Layout.Alignment align, float spacingmult, float spacingadd, bool includepad)
        {
            //P42.Utils.Debug.Message(source.ToString(), "ENTER");
            var builder = Android.Text.StaticLayout.Builder.Obtain(source, 0, source.Length(), paint, width).SetAlignment(align).SetLineSpacing(spacingadd, spacingmult).SetIncludePad(includepad);
            var layout  = builder.Build();

            //P42.Utils.Debug.Message(source.ToString(), "EXIT");
            return(layout);
        }
Example #23
0
        void ITextWatcher.OnTextChanged(ICharSequence s, int start, int before, int count)
        {
            if (string.IsNullOrEmpty(Entry.Text) && s.Length() == 0)
            {
                return;
            }

            ((IElementController)Element).SetValueFromRenderer(Entry.TextProperty, s.ToString());
        }
        /// <summary>
        /// Computes the specified context.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="context">The context.</param>
        /// <param name="size">The font size.</param>
        /// <returns></returns>
        public static ICharSequence Compute(this ICharSequence text, Context context, Single size)
        {
            if (text == null || text.Length() == 0)
            {
                return(text);
            }

            return(ParsingUtil.Parse(context, Iconize.Modules, text, size, null));
        }
        public override bool CommitText(ICharSequence text, int newCursorPosition)
        {
            if (text.Length() != 0)
            {
                TargetView.OnCommitText(text.ToString());
                return(true);
            }

            return(base.CommitText(text, newCursorPosition));
        }
        public void OnInput(MaterialDialog p0, ICharSequence p1)
        {
            try
            {
                if (p1.Length() <= 0)
                {
                    return;
                }

                var strName = p1.ToString();
                if (!string.IsNullOrEmpty(strName) || !string.IsNullOrWhiteSpace(strName))
                {
                    switch (TypeDialog)
                    {
                    case "About":
                    {
                        MainSettings.SharedData?.Edit()?.PutString("about_me_key", strName)?.Commit();
                        AboutMePref.Summary = strName;

                        var dataUser = ListUtils.MyProfileList?.FirstOrDefault();
                        if (dataUser != null)
                        {
                            dataUser.About = strName;
                            SAbout         = strName;

                            var sqLiteDatabase = new SqLiteDatabase();
                            sqLiteDatabase.Insert_Or_Update_To_MyProfileTable(dataUser);
                        }

                        if (Methods.CheckConnectivity())
                        {
                            var dataPrivacy = new Dictionary <string, string>
                            {
                                { "about", strName }
                            };

                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                    () => RequestsAsync.Global.UpdateUserDataAsync(dataPrivacy)
                                });
                        }
                        else
                        {
                            Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long)?.Show();
                        }

                        break;
                    }
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Example #27
0
        public ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend)
        {
            if (source != null && source.Length() > 0)
            {
                var includesInvalidCharacter = false;

                var destLength  = dend - dstart + 1;
                var adjustStart = source.Length() - destLength;

                var sb = new StringBuilder(end - start);
                for (var i = start; i < end; i++)
                {
                    var c = source.CharAt(i);
                    if (IsCharAllowed(c))
                    {
                        if (i >= adjustStart)
                        {
                            sb.Append(source, i, i + 1);
                        }
                    }
                    else
                    {
                        includesInvalidCharacter = true;
                    }
                }

                if (!includesInvalidCharacter)
                {
                    return(null);
                }

                if (source is ISpanned spanned)
                {
                    var sp = new SpannableString(sb);
                    TextUtils.CopySpansFrom(spanned, start, sb.Length(), null, sp, 0);
                    return(sp);
                }

                return(sb);
            }
            return(null);
        }
 public void BeforeTextChanged(ICharSequence s, int start, int count, int after)
 {
     if (s.Length() > 4)
     {
         mTextInputLayout.SetError("学号输入错误!");
         mTextInputLayout.SetErrorEnabled(true);
     }
     else
     {
         mTextInputLayout.SetErrorEnabled(false);
     }
 }
 private static ICharSequence limitCharSequenceLength(ICharSequence cs)
 {
     if (cs == null)
     {
         return(cs);
     }
     if (cs.Length() > MaxCharSequenceLength)
     {
         cs = cs.SubSequenceFormatted(0, MaxCharSequenceLength);
     }
     return(cs);
 }
 /// <summary>
 /// Applies a custom typeface span to the text.
 /// </summary>
 /// <param name="s">text to apply it too.</param>
 /// <param name="typeface">typeface to apply.</param>
 /// <returns>Either the passed in Object or new Spannable with the typeface span applied.</returns>
 internal static ICharSequence ApplyTypefaceSpan(ICharSequence s, Typeface typeface)
 {
     if (s == null || s.Length() <= 0)
     {
         return(s);
     }
     if (!(s is ISpannable))
     {
         s = new SpannableString(s);
     }
     ((ISpannable)s).SetSpan(TypefaceUtils.GetSpan(typeface), 0, s.Length(), SpanTypes.ExclusiveExclusive);
     return(s);
 }
 public void PutText(SpannableString originalText)
 {
     _originalText = originalText;
     if (_originalText.Length() > TRIM_LENGTH)
     {
         _trimmedText = TextUtils.ConcatFormatted(_originalText.SubSequenceFormatted(0, TRIM_LENGTH),
                                                  new SpannableString("..."));
     }
     else
     {
         _trimmedText = _originalText;
     }
     this.TextFormatted = _trimmedText;
 }
 public void OnInput(MaterialDialog p0, ICharSequence p1)
 {
     try
     {
         if (p1.Length() > 0)
         {
             CodeName = p1.ToString();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
        public int FindTokenEnd(ICharSequence text, int cursor)
        {
            int i = cursor;
            int len = text.Length();

            while (i < len)
            {
                if (SplitChar.Contains(text.CharAt(i)))
                {
                    return i;
                }
                else
                {
                    i++;
                }
            }

            return len;
        }
Example #34
0
        /// <summary>
        /// Find the end of the Token
        /// </summary>
        public int FindTokenEnd(ICharSequence text, int cursor)
        {
            int i = cursor;
            int len = text.Length();

            while (i < len)
            {
                // If a space is hit, then the token has ended
                if (text.CharAt(i) == ' ')
                {
                    return i;
                }
                else
                {
                    i++;
                }
            }

            return len;
        }
Example #35
0
 /**
  * 计算分享内容的字数,一个汉字=两个英文字母,一个中文标点=两个英文标点 注意:该函数的不适用于对单个字符进行计算,因为单个字符四舍五入后都是1
  *
  * @param c
  * @return
  */
 private long calculateLength(ICharSequence c)
 {
     double len = 0;
     for (var i = 0; i < c.Length(); i++)
     {
         var tmp = (int)c.CharAt(i);
         if (tmp >= 0x4e00 && tmp <= 0x9fbb)//中文
         {
             len += 2;
         }
         else
         {
             len += 1;
         }
         //if (tmp > 0 && tmp < 127)
         //{
         //    len += 0.5;
         //}
         //else
         //{
         //    len++;
         //}
     }
     return (long)System.Math.Round(len);
 }
 public void OnTextChanged(ICharSequence cs, int arg1, int arg2,
         int arg3)
 {
     if (cs.Length() <= 0)
     {
         return;
     }
     string city = (poiSearchDemo.FindViewById<EditText>(Resource.Id.city)).Text;
     /**
      * 使用建议搜索服务获取建议列表,结果在OnSuggestionResult()中更新
      */
     poiSearchDemo.mSearch.SuggestionSearch(cs.ToString(), city);
 }
        public ICharSequence TerminateTokenFormatted(ICharSequence text)
        {
            int i = text.Length();

            while (i > 0 && text.CharAt(i - 1) == ' ') {
            i--;
            }

            if (i > 0 && SplitChar.Contains(text.CharAt(i - 1))) {
            return text;
            } else {
            // Try not to use a space as a token character
            var token = (SplitChar.Count > 1 && SplitChar[0] == ' ' ? SplitChar[1] : SplitChar[0]) + " ";

            if (text is ISpanned) {
                SpannableString sp = new SpannableString(text + token);

                TextUtils.CopySpansFrom((ISpanned)text, 0, text.Length(), null, sp, 0);
                return sp;
            } else {
                return (text + token).ToAndroidString();
            }
            }
        }
        protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
        {
            base.OnMeasure (widthMeasureSpec, heightMeasureSpec);
            return;

            _inMeasure = true;
            //base.OnMeasure (widthMeasureSpec, heightMeasureSpec);
            try {
                var availableWidth = MeasureSpec.GetSize (widthMeasureSpec) - CompoundPaddingLeft - CompoundPaddingRight;
                var availableHeight = MeasureSpec.GetSize (heightMeasureSpec) - CompoundPaddingTop - CompoundPaddingBottom;

                _originalText = GetOriginalText ();

                if (_originalText == null || _originalText.Length () == 0 || availableWidth <= 0) {
                    SetMeasuredDimension (widthMeasureSpec, heightMeasureSpec);
                    return;
                }

                var textPaint = Paint;
                var targetTextSize = _maxTextSize;
                var originalText = new Java.Lang.String (_originalText.ToString ());
                var finalText = originalText;

                var textSize = GetTextSize (originalText, textPaint, targetTextSize);
                var textExcedsBounds = textSize.Height () > availableHeight || textSize.Width () > availableWidth;

                if (_shrinkTextSize && textExcedsBounds) {
                    var heightMultiplier = availableHeight / (float)textSize.Height ();
                    var widthMultiplier = availableWidth / (float)textSize.Width ();
                    var multiplier = System.Math.Min (heightMultiplier, widthMultiplier);

                    targetTextSize = System.Math.Max (targetTextSize * multiplier, _minTextSize);

                    textSize = GetTextSize (finalText, textPaint, targetTextSize);
                }
                if (textSize.Width () > availableWidth) {
                    var modifiedText = new StringBuilder ();
                    var lines = originalText.Split (Java.Lang.JavaSystem.GetProperty ("line.separator"));
                    for (var i = 0; i < lines.Length; i++) {
                        modifiedText.Append (ResizeLine (textPaint, lines [i], availableWidth));
                        if (i != lines.Length - 1)
                            modifiedText.Append (Java.Lang.JavaSystem.GetProperty ("line.separator"));
                    }

                    finalText = new Java.Lang.String (modifiedText);
                    textSize = GetTextSize (finalText, textPaint, targetTextSize);
                }

                textPaint.TextSize = targetTextSize;

                var isMultiline = finalText.IndexOf ('\n') > -1;
                if (isMultiline) {
                    SetLineSpacing (LineSpacingExtra, LineSpacingMultiplierMultiline);
                    SetIncludeFontPadding (false);
                } else {
                    SetLineSpacing (LineSpacingExtra, LineSpacingMultiplierSingleline);
                    SetIncludeFontPadding (true);
                }

                Text = finalText + "\u200B";

                var measuredWidth = textSize.Width () + CompoundPaddingLeft + CompoundPaddingRight;
                var measureHeight = textSize.Height () + CompoundPaddingTop + CompoundPaddingBottom;

                measureHeight = System.Math.Max (measureHeight, MeasureSpec.GetSize (heightMeasureSpec));
                SetMeasuredDimension (measuredWidth, measureHeight);
            } finally {
                _inMeasure = false;

            }
        }
 private static ICharSequence limitCharSequenceLength(ICharSequence cs) {
   if (cs == null) {
     return cs;
   }
   if (cs.Length() > MaxCharSequenceLength) {
     cs = cs.SubSequenceFormatted(0, MaxCharSequenceLength);
   }
   return cs;
 }