protected override Filter.FilterResults PerformFiltering (Java.Lang.ICharSequence constraint) { FilterResults results = new FilterResults(); if (constraint != null) { var searchFor = constraint.ToString (); Console.WriteLine ("searchFor:" + searchFor); var matchList = new List<string>(); // find matches, IndexOf means look for the input anywhere in the items // but it isn't case-sensitive by default! var matches = from i in customAdapter.AllItems where i.IndexOf(searchFor) >= 0 select i; foreach (var match in matches) { matchList.Add (match); } customAdapter.MatchItems = matchList.ToArray (); Console.WriteLine ("resultCount:" + matchList.Count); // not sure if the Java array/FilterResults are used Java.Lang.Object[] matchObjects; matchObjects = new Java.Lang.Object[matchList.Count]; for (int i = 0; i < matchList.Count; i++) { matchObjects[i] = new Java.Lang.String(matchList[i]); } results.Values = matchObjects; results.Count = matchList.Count; } return results; }
public Java.Lang.ICharSequence FilterFormatted(Java.Lang.ICharSequence source, int start, int end, global::Android.Text.ISpanned dest, int dstart, int dend) { var s = source.ToString(); var d = dest.ToString(); var proposal = d.Remove(dstart, dend - dstart).Insert(dstart, s.Substring(start, end - start)); if (_onChangeDelegate(proposal)) return null; else { var r = new Java.Lang.String(d.Substring(dstart, dend - dstart)); if (source is ISpanned) { // This spannable thing here, is needed to copy information about which part of // the string is being under composition by the keyboard (or other spans). A // spannable string has support for extra information to the string, besides // its characters and that information must not be lost! var ssb = new SpannableString(r); var spannableEnd = (end <= ssb.Length()) ? end : ssb.Length(); global::Android.Text.TextUtils.CopySpansFrom((ISpanned)source, start, spannableEnd, null, ssb, 0); return ssb; } else return r; } }
public static Java.Lang.ICharSequence Parse(Context context, IList<IIconModule> modules, Java.Lang.ICharSequence text, View target = null) { context = context.ApplicationContext; // Analyse the text and replace {} blocks with the appropriate character // Retain all transformations in the accumulator var builder = new SpannableStringBuilder(text); RecursivePrepareSpannableIndexes(context, text.ToString(), builder, modules, 0); var isAnimated = HasAnimatedSpans(builder); // 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 View."); if (!(target is IHasOnViewAttachListener)) throw new ArgumentException(target.Class.SimpleName + " does not implement " + "HasOnViewAttachListener. Please use IconTextView, IconButton or IconToggleButton."); ((IHasOnViewAttachListener)target).SetOnViewAttachListener(new MyListener(target)); } else if (target is IHasOnViewAttachListener) { ((IHasOnViewAttachListener)target).SetOnViewAttachListener(null); } return builder; }
protected override void ApplyEntityValueToEditor(Java.Lang.Object o) { if(o == null) { this.editorButton.Text = "Tap to select."; return; } this.editorButton.Text = o.ToString(); //type = (EmployeeType)Enum.Parse(typeof(EmployeeType), o.ToString()); type = (EmployeeType)Enum.Parse(type.GetType(), o.ToString()); }
protected override void ApplyEntityValueToEditor(Java.Lang.Object o) { if(o == null) { this.editorButton.Text = "Tap to select."; return; } this.editorButton.Text = o.ToString(); type = (EmployeeType)o; }
public Java.Lang.Object Apply(Java.Lang.Object context, Java.Lang.Object groupName) { // Developers can create a special group layout for any given group name. if(groupName.Equals("Group 2")) { EditorGroup group = new EditorGroup((Context)context, groupName.ToString(), Resource.Layout.dataform_custom_group); // Each group can have a specific layout manager, be it a table layout, a linear layout, a placeholder layout or even something completely custom. group.LayoutManager = new DataFormPlaceholderLayoutManager((Context)context, Resource.Layout.dataform_group_placeholder_layout); return group; } return null; }
public void Validate(Java.Lang.Object o, IValidationCompletedCallback validationCompletedCallback) { ValidationInfo info; if(o == null || o.ToString().Equals("")) { info = new ValidationInfo(false, "This field can not be empty.", o); } else { info = new ValidationInfo(true, "The entered value is valid.", o); } validationCompletedCallback.ValidationCompleted(info); }
protected override FilterResults PerformFiltering (Java.Lang.ICharSequence constraint) { if (constraint == null) return new FilterResults () { Count = 0, Values = null }; var search = constraint.ToString (); var addresses = geocoder.GetFromLocationName (search, 7, LowerLeftLat, LowerLeftLon, UpperRightLat, UpperRightLon); return new FilterResults () { Count = addresses.Count, Values = (Java.Lang.Object)addresses }; }
protected override void PerformFiltering(Java.Lang.ICharSequence text, int keyCode) { string textToFilter = text.ToString(); if (!string.IsNullOrEmpty(textToFilter) && textToFilter.StartsWith(_lastCompletionPrefix)) { textToFilter = textToFilter.Substring(_lastCompletionPrefix.Length); base.PerformFiltering(new Java.Lang.String(textToFilter), keyCode); } else { DismissDropDown(); } }
//this method is called async (not from UI thread!) so making network request is possible here protected override FilterResults PerformFiltering(Java.Lang.ICharSequence constraint) { FilterResults filterResults = new FilterResults(); if (constraint != null) { nn_adapter.resultlist=AutoFillManager.RetrieveInfo (constraint.ToString ()); var tempcountry=(nn_adapter.nn_context!=null)? nn_adapter.nn_context.listcountry: nn_adapter.nn_context1.listcountry; var tempprovince=(nn_adapter.nn_context!=null)? nn_adapter.nn_context.liststateandprovince: nn_adapter.nn_context1.liststateandprovince; RetrievedInfo[] flag = new RetrievedInfo[nn_adapter.resultlist.Count]; for(int i=0;i<nn_adapter.resultlist.Count;i++){ var tempobj = nn_adapter.resultlist [i]; bool countryflag=false; bool provinceflag=false; foreach(var country in tempcountry){ if(country.country_name.Equals(tempobj.country)){ countryflag = true; } } foreach(var province in tempprovince){ if(province.state_province_name.Equals(tempobj.state)){ provinceflag = true; } } if(!(countryflag&&provinceflag)){ flag [i] = tempobj; } } for (int i = 0; i < flag.Length; i++) { if (flag [i]!=null) { nn_adapter.resultlist.Remove(flag[i]); } } nn_adapter.resultarraylist=new ArrayList(nn_adapter.resultlist); filterResults.Values = nn_adapter.resultarraylist; filterResults.Count = nn_adapter.resultarraylist.Size(); } return filterResults; }
public void Call (Java.Lang.Object content) { Console.WriteLine (content.ToString()); }
public void OnPropertyChanged(String s, Java.Lang.Object o) { if(o.ToString() == type.ToString()) { return; } ApplyEntityValueToEditor(o); // Remember to call value changed, otherwise the object being edited will not be updated. OnEditorValueChanged(o); }
public void UncaughtException(Java.Lang.Thread thread, Java.Lang.Throwable ex) { WriteException(ex != null ? ex.ToString() : "Java uncaught exception is null"); }
public override void OnBindGroupViewHolder(ListViewHolder holder, Java.Lang.Object groupKey) { GroupItemViewHolder vh = (GroupItemViewHolder) holder; vh.txtGroupHeader.Text = groupKey.ToString().ToUpper(); }
public Java.Lang.ICharSequence FilterFormatted(Java.Lang.ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { var replacement = source.ToString(); var ok = this.MayInsertTextAt(this.currencyEdit.Text, replacement, dstart, this.currencyEdit.DecimalPlaces); if (ok) { return source; } else { return new Java.Lang.String(string.Empty); } }
/// <summary> /// decode这个图片并且按比例缩放以减少内存消耗,虚拟机对每张图片的缓存大小也是有限制的 /// </summary> /// <returns>The file.</returns> /// <param name="f">F.</param> private Bitmap DecodeFile(Java.IO.File f){ try { //decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.InJustDecodeBounds = true; //FileInputStream stream1=new FileInputStream(f); FileStream stream1 = new FileStream(f.ToString(),FileMode.OpenOrCreate); BitmapFactory.DecodeStream(stream1,null,o); stream1.Close(); //Find the correct scale value. It should be the power of 2. int REQUIRED_SIZE=60; int width_tmp=o.OutWidth, height_tmp=o.OutHeight; int scale=1; while(true){ if(width_tmp/2<REQUIRED_SIZE || height_tmp/2<REQUIRED_SIZE) break; width_tmp/=2; height_tmp/=2; scale*=2; } //decode with inSampleSize BitmapFactory.Options o2 = new BitmapFactory.Options(); o2.InSampleSize=scale; //FileInputStream stream2=new FileInputStream(f); FileStream stream2 = new FileStream(f.ToString(),FileMode.OpenOrCreate); Bitmap bitmap=BitmapFactory.DecodeStream(stream2, null, o2); stream2.Close(); return bitmap; } catch (Java.IO.FileNotFoundException e) { e.PrintStackTrace (); } catch (Java.IO.IOException e) { e.PrintStackTrace(); } return null; }
public override void Notify(Java.Lang.String securityTokenResponse) { Exception ex = null; var response = ""; if (securityTokenResponse == null || securityTokenResponse.IsEmpty) ex = new ArgumentNullException("securityTokenResponse", "Did not recieve a Token Response"); else response = securityTokenResponse.ToString(); if (GotSecurityTokenResponse != null) GotSecurityTokenResponse(this, new RequestSecurityTokenResponseEventArgs(response, ex)); }
public void UpdateCardViewImage (Java.Net.URI uri) //FIXME prob this version, maybe don't work with either { Picasso.With (mContext) .Load (uri.ToString ()) .Resize (Utils.dpToPx (CardPresenter.CARD_WIDTH, mContext), Utils.dpToPx (CardPresenter.CARD_HEIGHT, mContext)) .Error (mDefaultCardImage) .Into (mImageCardViewTarget); }
public override void OnAuthenticationHelp (int helpMsgId, Java.Lang.ICharSequence helpString) { ShowError (helpString.ToString ()); }
protected override int SizeOf (Java.Lang.Object key, Java.Lang.Object value) { return GetSizeOf(key.ToString(), (Bitmap[])value); }
// to become consistent with Java/JS interop convention, the argument cannot be System.String. public void handle (Java.Lang.String message) { LoginActivity outer = (LoginActivity)context; outer.OnMessageFromInner (message.ToString ()); }
public int CompareTo (Java.Lang.Object obj) { if (obj is Question) return this.questionIndex - (obj as Question).questionIndex; return this.ToString ().CompareTo (obj.ToString ()); }
protected override void OnSetInitialValue(bool restorePersistedValue, Java.Lang.Object defaultValue) { if (restorePersistedValue) { currentValue = GetPersistedInt (currentValue); } else { int temp = 0; try { temp = ((Java.Lang.Integer)defaultValue).IntValue (); } catch { Console.WriteLine ("Invalid default value: " + defaultValue.ToString()); } PersistInt (temp); currentValue = temp; } }
public override Android.Database.ICursor RunQueryOnBackgroundThread (Java.Lang.ICharSequence constraint) { IFilterQueryProvider filter = FilterQueryProvider; if (filter != null) { return filter.RunQuery (constraint); } Android.Net.Uri uri = Android.Net.Uri.WithAppendedPath ( ContactsContract.Contacts.ContentFilterUri, Android.Net.Uri.Encode ("")); if (constraint != null) { uri = Android.Net.Uri.WithAppendedPath ( ContactsContract.Contacts.ContentFilterUri, Android.Net.Uri.Encode (constraint.ToString ())); } return mContent.Query (uri, AutoComplete4.CONTACT_PROJECTION, null, null, null); }
public void OnTextChanged(Java.Lang.ICharSequence s, int start, int before, int count) { if (Owner != null) Owner.OnTextChanged(s.ToString()); }
public override void OnAuthenticationError (int errMsgId, Java.Lang.ICharSequence errString) { if (!mSelfCancelled) { ShowError (errString.ToString ()); mIcon.PostDelayed (() => { mCallback.OnError (); }, ERROR_TIMEOUT_MILLIS); } }
public void OnTextChanged(Java.Lang.ICharSequence s, int start, int before, int count) { Value = s.ToString(); }
/** * Only call this method from the main (UI) thread. The {@link OnFetchCompleteListener} callback * be invoked on the UI thread, but image fetching will be done in an {@link AsyncTask}. * * @param cookie An arbitrary object that will be passed to the callback. */ public static void FetchImage(Context context, Java.Lang.String url, BitmapFactory.Options decodeOptions, Java.Lang.Object cookie, Action<Bitmap> callback) { Task.Factory.StartNew(() => { if(TextUtils.IsEmpty(url)) { result = null; return; } File cacheFile = null; try { MessageDigest mDigest = MessageDigest.GetInstance("SHA-1"); mDigest.Update(url.GetBytes()); string cacheKey = BytesToHexString(mDigest.Digest()); if(Environment.MediaMounted.Equals(Environment.ExternalStorageState)) { cacheFile = new File(Environment.ExternalStorageDirectory + File.Separator + "Android " + File.Separator + "data" + File.Separator + context.PackageName + File.Separator + "cache" + File.Separator + "bitmap_" + cacheKey + ".tmp"); } } catch (Exception e) { // NoSuchAlgorithmException // Oh well, SHA-1 not available (weird), don't cache bitmaps. } if (cacheFile != null && cacheFile.Exists()) { Bitmap cachedBitmap = BitmapFactory.DecodeFile(cacheFile.ToString(), decodeOptions); if (cachedBitmap != null) { result = cachedBitmap; return; } } try { // TODO: check for HTTP caching headers var client = new System.Net.WebClient(); var image = client.DownloadData(new Uri(url.ToString())); if (image != null) { result = null; return; } // Write response bytes to cache. if (cacheFile != null) { try { cacheFile.ParentFile.Mkdirs(); cacheFile.CreateNewFile(); FileOutputStream fos = new FileOutputStream(cacheFile); fos.Write(image); fos.Close(); } catch (FileNotFoundException e) { Log.Warn(TAG, "Error writing to bitmap cache: " + cacheFile.ToString(), e); } catch (IOException e) { Log.Warn(TAG, "Error writing to bitmap cache: " + cacheFile.ToString(), e); } } // Decode the bytes and return the bitmap. result = (BitmapFactory.DecodeByteArray(image, 0, image.Length, decodeOptions)); return; } catch (Exception e) { Log.Warn(TAG, "Problem while loading image: " + e.ToString(), e); } result = null; }) .ContinueWith(task => callback(result) ); }
protected override void OnTextChanged(Java.Lang.ICharSequence text, int start, int before, int after) { base.OnTextChanged(text, start, before, after); RefitText(text.ToString(), Width); }
protected override Filter.FilterResults PerformFiltering(Java.Lang.ICharSequence constraint) { FilterResults results = new FilterResults(); if (!String.IsNullOrEmpty (constraint.ToString ())) { var searchFor = constraint.ToString (); Console.WriteLine ("searchFor:" + searchFor); var matchList = new List<string> (); var matches = from i in _adapter.AllItems where i.IndexOf (searchFor, StringComparison.InvariantCultureIgnoreCase) >= 0 select i; foreach (var match in matches) { matchList.Add (match); } _adapter.MatchItems = matchList.ToArray (); Console.WriteLine ("resultCount:" + matchList.Count); Java.Lang.Object[] matchObjects; matchObjects = new Java.Lang.Object[matchList.Count]; for (int i = 0; i < matchList.Count; i++) { matchObjects [i] = new Java.Lang.String (matchList [i]); } results.Values = matchObjects; results.Count = matchList.Count; } else { _adapter.ResetSearch (); } return results; }