public SimpleMenuItem (SimpleMenu menu, int id, int order, ICharSequence title) { mMenu = menu; mId = id; mOrder = order; mTitle = title; }
/** * Create a new instance of MyFragment that will be initialized * with the given arguments. */ internal static MyFragment NewInstance(ICharSequence label) { MyFragment f = new MyFragment(); Bundle b = new Bundle(); b.PutCharSequence("label", label); f.SetArguments(b); return f; }
public static ICharSequence Parse(Context context, IList<IconFontDescriptorWrapper> iconFontDescriptors, ICharSequence text, TextView target) { context = context.ApplicationContext; // Analyse the text and replace {} blocks With the appropriate character // Retain all transformations in the accumulator var spannableBuilder = new SpannableStringBuilder(text); RecursivePrepareSpannableIndexes(context, text.ToString(), spannableBuilder, iconFontDescriptors, 0); var isAnimated = HasAnimatedSpans(spannableBuilder); // If animated, periodically invalidate the TextView so that the // CustomTypefaceSpan can redraw itself if (isAnimated) { if (target == null) { throw new ArgumentException("You can't use \"spin\" without providing the target TextView."); } if (!(target is IHasOnViewAttachListener)) { throw new ArgumentException(target.GetType().Name + " does not implement " + "HasOnViewAttachListener. Please use IconTextView, IconButton or IconToggleButton."); } ((IHasOnViewAttachListener) target).OnViewAttachListener = new OnViewAttachListenerOnViewAttachListenerAnonymousInnerClassHelper(target); } else if (target is IHasOnViewAttachListener) { ((IHasOnViewAttachListener) target).OnViewAttachListener = null; } return spannableBuilder; }
/// <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 + " "); } } }
void ITextWatcher.BeforeTextChanged(ICharSequence s, int start, int count, int after) { if (BeforeTextChanged != null) { BeforeTextChanged(s, start, count, after); } }
void ITextWatcher.OnTextChanged(ICharSequence s, int start, int before, int count) { if (OnTextChanged != null) { OnTextChanged(new TextChangedEventArgs(s, start, before, count)); } }
/// <summary> /// /// </summary> /// <param name="field">Name of the field query will use.</param> /// <param name="term">Term token to use for building term for the query</param> /// <param name="minSimilarity">similarity value</param> /// <param name="begin">position in the query string</param> /// <param name="end">position in the query string</param> public FuzzyQueryNode(string field, ICharSequence term, float minSimilarity, int begin, int end) : base(field, term, begin, end) { this.similarity = minSimilarity; IsLeaf = true; }
private static ICharSequence EscapeChar(ICharSequence str, CultureInfo locale) { if (str == null || str.Length == 0) return str; ICharSequence buffer = str; // regular escapable Char for terms for (int i = 0; i < escapableTermChars.Length; i++) { buffer = ReplaceIgnoreCase(buffer, escapableTermChars[i].ToLower(locale), "\\", locale); } // First Character of a term as more escaping chars for (int i = 0; i < escapableTermExtraFirstChars.Length; i++) { if (buffer[0] == escapableTermExtraFirstChars[i][0]) { buffer = new StringCharSequenceWrapper("\\" + buffer[0] + buffer.SubSequence(1, buffer.Length).ToString()); break; } } return buffer; }
/** * Parse attributes during inflation from a view hierarchy into the * arguments we handle. */ public override void OnInflate(global::Android.App.Activity activity, IAttributeSet attrs, Bundle savedInstanceState) { base.OnInflate(activity, attrs, savedInstanceState); TypedArray a = activity.ObtainStyledAttributes(attrs, R.Styleables.FragmentArguments.AllIds); mLabel = a.GetText(R.Styleables.FragmentArguments.label & 0xFFFF); a.Recycle(); }
protected override FilterResults PerformFiltering(ICharSequence constraint) { var results = performFilteringHandler(constraint.ToString()); return new FilterResults { Count = results.Size(), Values = results }; }
protected override FilterResults PerformFiltering (ICharSequence constraint) { if (filterResults == null) { filterResults = new FilterResults (); } Task.Run (async () => await SearchWithStringAsync (constraint)); return filterResults; }
/// <summary> /// Create a non-escaped <see cref="ICharSequence"/> /// </summary> public UnescapedCharSequence(ICharSequence text) { this.chars = new char[text.Length]; this.wasEscaped = new bool[text.Length]; for (int i = 0; i < text.Length; i++) { this.chars[i] = text[i]; this.wasEscaped[i] = false; } }
protected override FilterResults PerformFiltering(ICharSequence constraint) { var stringConstraint = constraint == null ? string.Empty : constraint.ToString(); var count = _owner.SetConstraintAndWaitForDataChange(stringConstraint); return new FilterResults { Count = count }; }
async Task SearchWithStringAsync (ICharSequence constraint) { var searchString = constraint?.ToString (); if (searchString == null) { LocationResults = new List<WuAcLocation> (); ResultStrings = new List<SpannableString> (); return; } bool canceled = false; try { ResultStrings = new List<SpannableString> (); if (!string.IsNullOrWhiteSpace (searchString)) { LocationResults = await WuAcClient.GetAsync (searchString); Java.Lang.Object [] matchObjects = new Java.Lang.Object [LocationResults.Count]; for (int i = 0; i < LocationResults.Count; i++) { var name = LocationResults [i].name; ResultStrings.Add (name.GetSearchResultSpannableString (searchString)); matchObjects [i] = new Java.Lang.String (name); } filterResults.Values = matchObjects; filterResults.Count = LocationResults.Count; } else { LocationResults = new List<WuAcLocation> (); } } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine (ex.Message); canceled = true; } finally { if (!canceled) { publish = true; Activity.RunOnUiThread (() => PublishResults (constraint, filterResults)); } } }
public override void Draw(Canvas canvas, ICharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) { PrepView(); canvas.Save(); //Centering the token looks like a better strategy that aligning the bottom int padding = (bottom - top - View.Bottom) / 2; canvas.Translate(x, bottom - View.Bottom - padding); View.Draw(canvas); canvas.Restore(); }
public void BeforeTextChanged(ICharSequence s, int start, int count, int after) { if (s.Length() > 4) { mTextInputLayout.SetError("学号输入错误!"); mTextInputLayout.SetErrorEnabled(true); } else { mTextInputLayout.SetErrorEnabled(false); } }
public ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { for (int i = start; i < end; ++i) { if (!Character.IsDigit(source.CharAt(i)) && !backgroundHintTextView.IsCharInFilter(source.CharAt(i))) { return new Java.Lang.String(""); } } return null; }
public override void OnAuthenticationError(FingerprintState errorCode, ICharSequence errString) { base.OnAuthenticationError(errorCode, errString); var message = errString != null ? errString.ToString() : string.Empty; var result = new FingerprintAuthenticationResult { Status = FingerprintAuthenticationResultStatus.Failed, ErrorMessage = message }; if (errorCode == FingerprintState.ErrorLockout) { result.Status = FingerprintAuthenticationResultStatus.TooManyAttempts; } SetResultSafe(result); }
private ICharSequence EscapeQuoted(ICharSequence str, CultureInfo locale) { if (str == null || str.Length == 0) return str; ICharSequence buffer = str; for (int i = 0; i < escapableQuotedChars.Length; i++) { buffer = ReplaceIgnoreCase(buffer, escapableTermChars[i].ToLower(locale), "\\", locale); } return buffer; }
public override int GetSize(Paint paint, ICharSequence text, int start, int end, Paint.FontMetricsInt fm) { LocalPaint.Set(paint); ApplyCustomTypeFace(LocalPaint, _typeface); LocalPaint.GetTextBounds(_icon, 0, 1, TextBounds); if (fm != null) { fm.Descent = (int) (TextBounds.Height()*BaselineRatio); fm.Ascent = -(TextBounds.Height() - fm.Descent); fm.Top = fm.Ascent; fm.Bottom = fm.Descent; } return TextBounds.Width(); }
public override int GetSize(Paint paint, ICharSequence text, int start, int end, Paint.FontMetricsInt fm) { LOCAL_PAINT.Set(paint); ApplyCustomTypeFace(LOCAL_PAINT, type); LOCAL_PAINT.GetTextBounds(icon, 0, 1, TEXT_BOUNDS); if (fm != null) { float baselineRatio = baselineAligned ? 0 : BASELINE_RATIO; fm.Descent = (int)(TEXT_BOUNDS.Height() * baselineRatio); fm.Ascent = -(TEXT_BOUNDS.Height() - fm.Descent); fm.Top = fm.Ascent; fm.Bottom = fm.Descent; } return TEXT_BOUNDS.Width(); }
public int FindTokenStart(ICharSequence text, int cursor) { int i = cursor; while (i > 0 && !SplitChar.Contains(text.CharAt(i - 1))) { i--; } while (i < cursor && text.CharAt(i) == ' ') { i++; } return i; }
public ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { try { var val = dest.ToString().Insert(dstart, source.ToString()); var input = int.Parse(val); if (IsInRange(_min, _max, input)) return null; } catch (Exception ex) { } return new String(string.Empty); }
/// <summary> /// Find the start of the Token /// </summary> public int FindTokenStart(ICharSequence text, int cursor) { int i = cursor; // Moved i, untill it hits a space, first going back, the going forward while (i > 0 && text.CharAt(i - 1) != ' ') { i--; } while (i < cursor && text.CharAt(i) == ' ') { i++; } return i; }
public override void Draw(Canvas canvas, ICharSequence text, Int32 start, Int32 end, Single x, Int32 top, Int32 y, Int32 bottom, Paint paint) { ApplyCustomTypeFace(paint, _type); paint.GetTextBounds(_icon, 0, 1, TEXT_BOUNDS); canvas.Save(); var baselineRatio = _baselineAligned ? 0f : BASELINE_RATIO; if (_rotate) { var rotation = (SystemClock.CurrentThreadTimeMillis() - _rotationStartTime) / (Single)ROTATION_DURATION * 360f; var centerX = x + TEXT_BOUNDS.Width() / 2f; var centerY = y - TEXT_BOUNDS.Height() / 2f + TEXT_BOUNDS.Height() * baselineRatio; canvas.Rotate(rotation, centerX, centerY); } canvas.DrawText(_icon, x - TEXT_BOUNDS.Left, y - TEXT_BOUNDS.Bottom + TEXT_BOUNDS.Height() * baselineRatio, paint); canvas.Restore(); }
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; }
public override void Draw(Canvas canvas, ICharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) { ApplyCustomTypeFace(paint, _typeface); paint.GetTextBounds(_icon, 0, 1, TextBounds); canvas.Save(); if (_rotate) { var rotation = (DateTimeHelpers.CurrentUnixTimeMillis() - _rotationStartTime)/(float) RotationDuration* 360f; var centerX = x + TextBounds.Width()/2f; var centerY = y - TextBounds.Height()/2f + TextBounds.Height()*BaselineRatio; canvas.Rotate(rotation, centerX, centerY); } canvas.DrawText(_icon, x - TextBounds.Left, y - TextBounds.Bottom + TextBounds.Height()*BaselineRatio, paint); canvas.Restore(); }
/// <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; }
public override void Draw(Canvas canvas, ICharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) { ApplyCustomTypeFace(paint, type); paint.GetTextBounds(icon, 0, 1, TEXT_BOUNDS); canvas.Save(); float baselineRatio = baselineAligned ? 0f : BASELINE_RATIO; if (rotate) { long time = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; float rotation = (time - rotationStartTime) / (float)ROTATION_DURATION * 360f; float centerX = x + TEXT_BOUNDS.Width() / 2f; float centerY = y - TEXT_BOUNDS.Height() / 2f + TEXT_BOUNDS.Height() * baselineRatio; canvas.Rotate(rotation, centerX, centerY); } canvas.DrawText(icon, x - TEXT_BOUNDS.Left, y - TEXT_BOUNDS.Bottom + TEXT_BOUNDS.Height() * baselineRatio, paint); canvas.Restore(); }
public override int GetSize(Paint paint, ICharSequence text, int start, int end, Paint.FontMetricsInt fm) { PrepView(); if (fm != null) { //We need to make sure the layout allots enough space for the view int height = View.MeasuredHeight; int need = height - (fm.Descent - fm.Ascent); if (need > 0) { int ascent = need / 2; //This makes sure the text drawing area will be tall enough for the view fm.Descent += need - ascent; fm.Ascent -= ascent; fm.Bottom += need - ascent; fm.Top -= need / 2; } } return View.Right; }
public static int HashCodeAscii(ICharSequence bytes) { int hash = HashCodeAsciiSeed; int remainingBytes = bytes.Count & 7; // Benchmarking shows that by just naively looping for inputs 8~31 bytes long we incur a relatively large // performance penalty (only achieve about 60% performance of loop which iterates over each char). So because // of this we take special provisions to unroll the looping for these conditions. switch (bytes.Count) { case 31: case 30: case 29: case 28: case 27: case 26: case 25: case 24: hash = HashCodeAsciiCompute( bytes, bytes.Count - 24, HashCodeAsciiCompute( bytes, bytes.Count - 16, HashCodeAsciiCompute(bytes, bytes.Count - 8, hash))); break; case 23: case 22: case 21: case 20: case 19: case 18: case 17: case 16: hash = HashCodeAsciiCompute( bytes, bytes.Count - 16, HashCodeAsciiCompute(bytes, bytes.Count - 8, hash)); break; case 15: case 14: case 13: case 12: case 11: case 10: case 9: case 8: hash = HashCodeAsciiCompute(bytes, bytes.Count - 8, hash); break; case 7: case 6: case 5: case 4: case 3: case 2: case 1: case 0: break; default: for (int i = bytes.Count - 8; i >= remainingBytes; i -= 8) { hash = HashCodeAsciiCompute(bytes, i, hash); } break; } switch (remainingBytes) { case 7: return(((hash * HashCodeC1 + HashCodeAsciiSanitizsByte(bytes[0])) * HashCodeC2 + HashCodeAsciiSanitizeShort(bytes, 1)) * HashCodeC1 + HashCodeAsciiSanitizeInt(bytes, 3)); case 6: return((hash * HashCodeC1 + HashCodeAsciiSanitizeShort(bytes, 0)) * HashCodeC2 + HashCodeAsciiSanitizeInt(bytes, 2)); case 5: return((hash * HashCodeC1 + HashCodeAsciiSanitizsByte(bytes[0])) * HashCodeC2 + HashCodeAsciiSanitizeInt(bytes, 1)); case 4: return(hash * HashCodeC1 + HashCodeAsciiSanitizeInt(bytes, 0)); case 3: return((hash * HashCodeC1 + HashCodeAsciiSanitizsByte(bytes[0])) * HashCodeC2 + HashCodeAsciiSanitizeShort(bytes, 1)); case 2: return(hash * HashCodeC1 + HashCodeAsciiSanitizeShort(bytes, 0)); case 1: return(hash * HashCodeC1 + HashCodeAsciiSanitizsByte(bytes[0])); default: return(hash); } }
public void OnSelection(MaterialDialog p0, View p1, int itemId, ICharSequence itemString) { try { if (!Methods.CheckConnectivity()) { Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show(); return; } if (itemString.ToString() == GetText(Resource.String.Lbl_MakeAdmin)) { PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Group.MakeGroupAdmin(GroupId, ItemUser.UserId) }); var local = MAdapter?.UserList?.FirstOrDefault(a => a.UserId == ItemUser.UserId); if (local != null) { ItemUser.IsAdmin = "1"; MAdapter?.NotifyItemChanged(MAdapter.UserList.IndexOf(local)); } } else if (itemString.ToString() == GetText(Resource.String.Lbl_RemoveAdmin)) { PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Group.MakeGroupAdmin(GroupId, ItemUser.UserId) }); var local = MAdapter?.UserList?.FirstOrDefault(a => a.UserId == ItemUser.UserId); if (local != null) { MAdapter.UserList.Remove(local); MAdapter?.NotifyItemRemoved(MAdapter.UserList.IndexOf(local)); } } else if (itemString.ToString() == GetText(Resource.String.Lbl_RemoveMember)) { PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Group.RemoveGroupMembers(GroupId, ItemUser.UserId) }); var local = MAdapter?.UserList?.FirstOrDefault(a => a.UserId == ItemUser.UserId); if (local != null) { MAdapter.UserList.Remove(local); MAdapter?.NotifyItemRemoved(MAdapter.UserList.IndexOf(local)); } } else if (itemString.ToString() == GetText(Resource.String.Lbl_BlockMember)) { PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Group.RemoveGroupMembers(GroupId, ItemUser.UserId), () => RequestsAsync.Global.Block_User(GroupId, true) }); var local = MAdapter?.UserList?.FirstOrDefault(a => a.UserId == ItemUser.UserId); if (local != null) { MAdapter.UserList.Remove(local); MAdapter?.NotifyItemRemoved(MAdapter.UserList.IndexOf(local)); } } else if (itemString.ToString() == GetText(Resource.String.Lbl_ViewProfile)) { WoWonderTools.OpenProfile(this, ItemUser.UserId, ItemUser); } if (MAdapter?.UserList?.Count == 0) { ShowEmptyPage(); } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public override void OnAuthHelp(int helpMsgId, ICharSequence helpString) { Log.Info("OnAuthHelp", $"Authentication help. helpMsgId={helpMsgId},helpString={helpString}"); }
void ITextWatcher.BeforeTextChanged(ICharSequence s, int start, int count, int after) { }
public void DrawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, ICharSequence text, int start, int end, bool first, Layout layout) { }
public override bool TryGet(AsciiString name, out ICharSequence value) { value = default; return(false); }
public override int CodePointAt(ICharSequence seq, int offset) { return(Character.CodePointAt(seq, offset)); }
public async void OnSelection(MaterialDialog p0, View p1, int itemId, ICharSequence itemString) { try { if (itemString.ToString() == Context.GetText(Resource.String.Lbl_View_Profile)) { WoWonderTools.OpenProfile(Activity, DataUserChat.UserId, DataUserChat); } else if (itemString.ToString() == Context.GetText(Resource.String.Lbl_Block)) { if (Methods.CheckConnectivity()) { (int apiStatus, var respond) = await RequestsAsync.Global.Block_User(DataUserChat.UserId, true); //true >> "block" if (apiStatus == 200) { Methods.DisplayReportResultTrack(respond); var dbDatabase = new SqLiteDatabase(); dbDatabase.Insert_Or_Replace_OR_Delete_UsersContact(DataUserChat, "Delete"); dbDatabase.DeleteAllMessagesUser(UserDetails.UserId, DataUserChat.UserId); Methods.Path.DeleteAll_FolderUser(DataUserChat.UserId); Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_Blocked_successfully), ToastLength.Short)?.Show(); } } else { Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show(); } } else if (itemString.ToString() == Context.GetText(Resource.String.Lbl_Voice_call)) { string timeNow = DateTime.Now.ToString("hh:mm"); var unixTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); string time = Convert.ToString(unixTimestamp); Intent intentVideoCall = new Intent(Context, typeof(TwilioVideoCallActivity)); if (AppSettings.UseLibrary == SystemCall.Agora) { intentVideoCall = new Intent(Context, typeof(AgoraAudioCallActivity)); intentVideoCall.PutExtra("type", "Agora_audio_calling_start"); } else if (AppSettings.UseLibrary == SystemCall.Twilio) { intentVideoCall = new Intent(Context, typeof(TwilioAudioCallActivity)); intentVideoCall.PutExtra("type", "Twilio_audio_calling_start"); } intentVideoCall.PutExtra("UserID", DataUserChat.UserId); intentVideoCall.PutExtra("avatar", DataUserChat.Avatar); intentVideoCall.PutExtra("name", DataUserChat.Name); intentVideoCall.PutExtra("time", timeNow); intentVideoCall.PutExtra("CallID", time); StartActivity(intentVideoCall); } else if (itemString.ToString() == Context.GetText(Resource.String.Lbl_Video_call)) { string timeNow = DateTime.Now.ToString("hh:mm"); var unixTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); string time = Convert.ToString(unixTimestamp); Intent intentVideoCall = new Intent(Context, typeof(TwilioVideoCallActivity)); if (AppSettings.UseLibrary == SystemCall.Agora) { intentVideoCall = new Intent(Context, typeof(AgoraVideoCallActivity)); intentVideoCall.PutExtra("type", "Agora_video_calling_start"); } else if (AppSettings.UseLibrary == SystemCall.Twilio) { intentVideoCall = new Intent(Context, typeof(TwilioVideoCallActivity)); intentVideoCall.PutExtra("type", "Twilio_video_calling_start"); } intentVideoCall.PutExtra("UserID", DataUserChat.UserId); intentVideoCall.PutExtra("avatar", DataUserChat.Avatar); intentVideoCall.PutExtra("name", DataUserChat.Name); intentVideoCall.PutExtra("time", timeNow); intentVideoCall.PutExtra("CallID", time); intentVideoCall.PutExtra("access_token", "YOUR_TOKEN"); intentVideoCall.PutExtra("access_token_2", "YOUR_TOKEN"); intentVideoCall.PutExtra("from_id", "0"); intentVideoCall.PutExtra("active", "0"); intentVideoCall.PutExtra("status", "0"); intentVideoCall.PutExtra("room_name", "TestRoom"); StartActivity(intentVideoCall); } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
void ITextWatcher.OnTextChanged(ICharSequence s, int start, int before, int count) { Internals.TextTransformUtilites.SetPlainText(Element, s?.ToString()); }
/// <summary> /// Returns the plural form corresponding to the keyword, or <see cref="StandardPlural.Other"/>. /// </summary> /// <param name="keyword">Keyword for example "few" or "other".</param> /// <returns>The plural form corresponding to the keyword, or <see cref="StandardPlural.Other"/>.</returns> public static StandardPlural OrOtherFromString(ICharSequence keyword) { StandardPlural?p = OrNullFromString(keyword); return(p != null ? p.Value : StandardPlural.Other); }
/// <summary> /// Returns a property enum given one of its property names. /// If the property name is not known, this method returns /// <see cref="UPropertyConstants.Undefined"/>. /// </summary> public int GetPropertyEnum(ICharSequence alias) { return(GetPropertyOrValueEnum(0, alias)); }
/// <summary> /// Returns the index of the plural form corresponding to the keyword, or a negative value. /// </summary> /// <param name="keyword">Keyword for example "few" or "other".</param> /// <returns>The index of the plural form corresponding to the keyword, or a negative value.</returns> public static int IndexOrNegativeFromString(ICharSequence keyword) { StandardPlural?p = OrNullFromString(keyword); return(p != null ? (int)p.Value : -1); }
/// <summary> /// Returns the index of the plural form corresponding to the keyword, or <see cref="StandardPlural.Other"/>. /// </summary> /// <param name="keyword">Keyword for example "few" or "other".</param> /// <returns>The index of the plural form corresponding to the keyword, or <see cref="StandardPlural.Other"/>.</returns> public static int IndexOrOtherIndexFromString(ICharSequence keyword) { StandardPlural?p = OrNullFromString(keyword); return(p != null ? (int)p.Value : (int)StandardPlural.Other); }
public void BeforeTextChanged(ICharSequence s, int start, int count, int after) { }
public override void OnAuthError(int errMsgId, ICharSequence errString) { Log.Error("OnAuthError", $"Authentication error. errorCode={errMsgId},errorMessage={errString}"); }
public virtual int SetCharSequence(int index, ICharSequence sequence, Encoding encoding) => this.SetCharSequence0(index, sequence, encoding, false);
public override void OnAuthenticationHelp(FingerprintState helpCode, ICharSequence helpString) { base.OnAuthenticationHelp(helpCode, helpString); _listener?.OnHelp(FingerprintAuthenticationHelp.MovedTooFast, helpString?.ToString()); }
// Prefixes are reversed in the data structure. private void SetPrefix(ICharSequence pfx) { unreversedPrefix.Length = 0; unreversedPrefix.Append(pfx).Reverse(); }
public void OnTextChanged(ICharSequence s, int start, int before, int count) { }
public override void SetText(ICharSequence text, BufferType type) { base.SetText(Iconify.Compute(Context, text.ToString(), this), BufferType.Normal); }
public void OnText(ICharSequence text) { }
public override bool ContainsValue(AsciiString name, ICharSequence value, bool ignoreCase) => base.ContainsValue(name, TrimOws(value), ignoreCase);
/// <summary> /// Suppress a certain string from being the end of a segment. /// For example, suppressing "Mr.", then segments ending in "Mr." will not be returned /// by the iterator. /// </summary> /// <param name="str">The string to suppress, such as "Mr."</param> /// <returns>true if the string was not present and now added, /// false if the call was a no-op because the string was already being suppressed.</returns> /// <draft>ICU 60</draft> /// <provisional>This API might change or be removed in a future release.</provisional> internal abstract bool SuppressBreakAfter(ICharSequence str);
protected override void OnTitleChanged(ICharSequence title, Color color) { base.OnTitleChanged(title, color); Delegate.SetTitle(title); }
public override ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { // Borrowed heavily from the Android source ICharSequence filterFormatted = base.FilterFormatted(source, start, end, dest, dstart, dend); if (filterFormatted != null) { source = filterFormatted; start = 0; end = filterFormatted.Length(); } int sign = -1; int dec = -1; int dlen = dest.Length(); // Find out if the existing text has a sign or decimal point characters. for (var i = 0; i < dstart; i++) { char c = dest.CharAt(i); if (IsSignChar(c)) { sign = i; } else if (IsDecimalPointChar(c)) { dec = i; } } for (int i = dend; i < dlen; i++) { char c = dest.CharAt(i); if (IsSignChar(c)) { return(new Java.Lang.String("")); // Nothing can be inserted in front of a sign character. } if (IsDecimalPointChar(c)) { dec = i; } } // If it does, we must strip them out from the source. // In addition, a sign character must be the very first character, // and nothing can be inserted before an existing sign character. // Go in reverse order so the offsets are stable. SpannableStringBuilder stripped = null; for (int i = end - 1; i >= start; i--) { char c = source.CharAt(i); var strip = false; if (IsSignChar(c)) { if (i != start || dstart != 0) { strip = true; } else if (sign >= 0) { strip = true; } else { sign = i; } } else if (IsDecimalPointChar(c)) { if (dec >= 0) { strip = true; } else { dec = i; } } if (strip) { if (end == start + 1) { return(new Java.Lang.String("")); // Only one character, and it was stripped. } if (stripped == null) { stripped = new SpannableStringBuilder(source, start, end); } stripped.Delete(i - start, i + 1 - start); } } return(stripped ?? filterFormatted); }
private bool GetCEsFromContractionCE32(CollationData data, int ce32) { int trieIndex = Collation.IndexFromCE32(ce32); ce32 = data.GetCE32FromContexts(trieIndex); // Default if no suffix match. // Since the original ce32 is not a prefix mapping, // the default ce32 must not be another contraction. Debug.Assert(!Collation.IsContractionCE32(ce32)); int contractionIndex = contractionCEs.Count; if (GetCEsFromCE32(data, Collation.SENTINEL_CP, ce32)) { AddContractionEntry(CollationFastLatin.CONTR_CHAR_MASK, ce0, ce1); } else { // Bail out for c-without-contraction. AddContractionEntry(CollationFastLatin.CONTR_CHAR_MASK, Collation.NO_CE, 0); } // Handle an encodable contraction unless the next contraction is too long // and starts with the same character. int prevX = -1; bool addContraction = false; using (CharsTrie.Enumerator suffixes = CharsTrie.GetEnumerator(data.contexts, trieIndex + 2, 0)) { while (suffixes.MoveNext()) { CharsTrie.Entry entry = suffixes.Current; ICharSequence suffix = entry.Chars; int x = CollationFastLatin.GetCharIndex(suffix[0]); if (x < 0) { continue; } // ignore anything but fast Latin text if (x == prevX) { if (addContraction) { // Bail out for all contractions starting with this character. AddContractionEntry(x, Collation.NO_CE, 0); addContraction = false; } continue; } if (addContraction) { AddContractionEntry(prevX, ce0, ce1); } ce32 = entry.Value; if (suffix.Length == 1 && GetCEsFromCE32(data, Collation.SENTINEL_CP, ce32)) { addContraction = true; } else { AddContractionEntry(x, Collation.NO_CE, 0); addContraction = false; } prevX = x; } } if (addContraction) { AddContractionEntry(prevX, ce0, ce1); } // Note: There might not be any fast Latin contractions, but // we need to enter contraction handling anyway so that we can bail out // when there is a non-fast-Latin character following. // For example: Danish &Y<<u+umlaut, when we compare Y vs. u\u0308 we need to see the // following umlaut and bail out, rather than return the difference of Y vs. u. ce0 = (Collation.NO_CE_PRIMARY << 32) | CONTRACTION_FLAG | (uint)contractionIndex; ce1 = 0; return(true); }
/// <summary> /// Returns the code point at the given index of the <see cref="ICharSequence"/>. /// Depending on the <see cref="LuceneVersion"/> passed to /// <see cref="CharacterUtils.GetInstance(LuceneVersion)"/> this method mimics the behavior /// of <c>Character.CodePointAt(char[], int)</c> as it would have been /// available on a Java 1.4 JVM or on a later virtual machine version. /// </summary> /// <param name="seq"> /// a character sequence </param> /// <param name="offset"> /// the offset to the char values in the chars array to be converted /// </param> /// <returns> the Unicode code point at the given index </returns> /// <exception cref="NullReferenceException"> /// - if the sequence is null. </exception> /// <exception cref="ArgumentOutOfRangeException"> /// - if the value offset is negative or not less than the length of /// the character sequence. </exception> public abstract int CodePointAt(ICharSequence seq, int offset);
public void OnSelection(MaterialDialog p0, View p1, int itemId, ICharSequence itemString) { try { string text = itemString.ToString(); string getValue = SharedPref.SharedData.GetString("Night_Mode_key", string.Empty); if (text == GetString(Resource.String.Lbl_Light) && getValue != SharedPref.LightMode) { //Set Light Mode NightMode.Summary = ActivityContext.GetString(Resource.String.Lbl_Light); AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo; AppSettings.SetTabDarkTheme = false; SharedPref.SharedData.Edit().PutString("Night_Mode_key", SharedPref.LightMode).Commit(); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { ActivityContext.Window.ClearFlags(WindowManagerFlags.TranslucentStatus); ActivityContext.Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); } Intent intent = new Intent(ActivityContext, typeof(SplashScreenActivity)); intent.AddCategory(Intent.CategoryHome); intent.SetAction(Intent.ActionMain); intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask | ActivityFlags.ClearTask); ActivityContext.StartActivity(intent); ActivityContext.FinishAffinity(); } else if (text == GetString(Resource.String.Lbl_Dark) && getValue != SharedPref.DarkMode) { NightMode.Summary = ActivityContext.GetString(Resource.String.Lbl_Dark); AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightYes; AppSettings.SetTabDarkTheme = true; SharedPref.SharedData.Edit().PutString("Night_Mode_key", SharedPref.DarkMode).Commit(); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { ActivityContext.Window.ClearFlags(WindowManagerFlags.TranslucentStatus); ActivityContext.Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); } Intent intent = new Intent(ActivityContext, typeof(SplashScreenActivity)); intent.AddCategory(Intent.CategoryHome); intent.SetAction(Intent.ActionMain); intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask | ActivityFlags.ClearTask); ActivityContext.StartActivity(intent); ActivityContext.FinishAffinity(); } else if (text == GetString(Resource.String.Lbl_SetByBattery) && getValue != SharedPref.DefaultMode) { NightMode.Summary = ActivityContext.GetString(Resource.String.Lbl_SetByBattery); SharedPref.SharedData.Edit().PutString("Night_Mode_key", SharedPref.DefaultMode).Commit(); if ((int)Build.VERSION.SdkInt >= 29) { AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightFollowSystem; var currentNightMode = Resources.Configuration.UiMode & UiMode.NightMask; switch (currentNightMode) { case UiMode.NightNo: // Night mode is not active, we're using the light theme AppSettings.SetTabDarkTheme = false; break; case UiMode.NightYes: // Night mode is active, we're using dark theme AppSettings.SetTabDarkTheme = true; break; } } else { AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightAuto; var currentNightMode = Resources.Configuration.UiMode & UiMode.NightMask; switch (currentNightMode) { case UiMode.NightNo: // Night mode is not active, we're using the light theme AppSettings.SetTabDarkTheme = false; break; case UiMode.NightYes: // Night mode is active, we're using dark theme AppSettings.SetTabDarkTheme = true; break; } if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { ActivityContext.Window.ClearFlags(WindowManagerFlags.TranslucentStatus); ActivityContext.Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); } Intent intent = new Intent(ActivityContext, typeof(SplashScreenActivity)); intent.AddCategory(Intent.CategoryHome); intent.SetAction(Intent.ActionMain); intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask | ActivityFlags.ClearTask); ActivityContext.StartActivity(intent); ActivityContext.FinishAffinity(); } } } catch (Exception e) { Console.WriteLine(e); } }
public override int GetSize(Paint paint, ICharSequence text, int start, int end, Paint.FontMetricsInt fm) => (int)(margin + padding + paint.MeasureText(text.SubSequence(start, end)) + margin);
void ITextWatcher.OnTextChanged(ICharSequence s, int start, int before, int count) { }