private void AddEPCToList(String epc, String rssi) { if (!string.IsNullOrEmpty(epc)) { int index = checkIsExist(epc); if (index == -1) { JavaDictionary <string, object> map = new JavaDictionary <string, object> (); map.Add("tagUii", epc); map.Add("tagCount", "1"); map.Add("tagRssi", rssi); tagList.Add(map); adapter = new SimpleAdapter(mContext, tagList, Resource.Layout.listtag_items, new String[] { "tagUii", "tagLen", "tagCount", "tagRssi" }, new int[] { Resource.Id.TvTagUii, Resource.Id.TvTagLen, Resource.Id.TvTagCount, Resource.Id.TvTagRssi }); LvTags.Adapter = adapter; } else { int tagcount = int.Parse(tagList [index] ["tagCount"].ToString()) + 1; tagList [index]["tagCount"] = tagcount.ToString(); adapter.NotifyDataSetChanged(); } Sound(); tvTotal.Text = adapter.Count.ToString(); } }
//LOAD LISTA E PÁGINA public async void LoadContent() { aeho = await Get(); List <Models.Restaurante> list = JsonConvert.DeserializeObject <List <Models.Restaurante> >(aeho); IList <IDictionary <string, object> > dados = new List <IDictionary <string, object> >(); foreach (Models.Restaurante r in list) { IDictionary <string, object> dado = new JavaDictionary <string, object>(); dado.Add("Id", r.Id.ToString()); dado.Add("Descricao", r.Descricao); dados.Add(dado); } string[] from = new String[] { "Id", "Descricao" }; int[] to = new int[] { Resource.Id.idRest, Resource.Id.descRest }; int layout = Resource.Layout.ListItem; EditText txtid = FindViewById <EditText>(Resource.Id.txtId); EditText txtdesc = FindViewById <EditText>(Resource.Id.txtDescricao); // ArrayList for data row // SimpleAdapter mapping static data to views in xml file SimpleAdapter adapter = new SimpleAdapter(this, dados, layout, from, to); ListView.Adapter = adapter; }
protected void AddItem(List <IDictionary <String, Object> > data, String name, Intent intent) { IDictionary <String, Object> temp = new JavaDictionary <String, Object> (); temp.Add("title", name); temp.Add("intent", intent); data.Add(temp); }
public async System.Threading.Tasks.Task Register(string email, string fullname, string password) { var user = await Firebase.FirebaseAuth.CreateUserWithEmailAndPasswordAsync(email, password); var dictionary = new JavaDictionary <string, object>(); dictionary.Add("email", email); dictionary.Add("uid", user.User.Uid); dictionary.Add("fullname", fullname); dictionary.Add("phone", ""); Firebase.FirebaseFirestore.Document($"users/{user.User.Uid}/").Set(dictionary); }
public async System.Threading.Tasks.Task UpdateProject(string key, Projet projet) { projet.ProjectId = key; var data = new JavaDictionary(); data.Add("ProjectId", projet.ProjectId); data.Add("OwnerUId", projet.OwnerUId); data.Add("Date", projet.Date.ToString()); data.Add("Description", projet.Description); data.Add("Categories", new JavaList(projet.Categories)); await Firebase.FirebaseFirestore.Document($"projects/{key}").Set((ProjetJava)((IProjet)projet)); }
public void FromNativeToBridgeCustomJSON() { CustomJSON customJSON = new CustomJSON(); JavaDictionary jsonMap = new JavaDictionary(); jsonMap.Add("nome", "stefano"); jsonMap.Add("numero", 4.6); Java.Util.ArrayList lista = new Java.Util.ArrayList(); lista.Add(3.0); lista.Add(4.0); jsonMap.Add("lista", lista); JavaDictionary innerDict = new JavaDictionary(); innerDict.Add("nome", "martin"); innerDict.Add("cognome", "scorsese"); jsonMap.Add("inner_object", innerDict); customJSON.Content = jsonMap; customJSON.NotificationMessage = "messaggio"; XCCustomJSONNotification jSONNotification = AdapterCustom.GetCommonType(customJSON); Assert.True(jSONNotification.Content is Dictionary <string, object>); jSONNotification.Content.TryGetValue("nome", out object stringValue); Assert.True(stringValue is string); Assert.True(stringValue.Equals("stefano")); jSONNotification.Content.TryGetValue("numero", out object doubleValue); Assert.True(doubleValue is double); Assert.True(doubleValue.Equals(4.6)); jSONNotification.Content.TryGetValue("lista", out object listValue); Assert.True(listValue is List <object>); Assert.True((listValue as List <object>)[0] is double); Assert.True((double)(listValue as List <object>)[0] == 3.0); Assert.True((listValue as List <object>)[1] is double); Assert.True((double)(listValue as List <object>)[1] == 4.0); jSONNotification.Content.TryGetValue("inner_object", out object innerObj); Assert.True(innerObj is Dictionary <string, object>); Dictionary <string, object> castedDic = innerObj as Dictionary <string, object>; castedDic.TryGetValue("nome", out object name); Assert.True(name is string); Assert.True(((string)name).Equals("martin")); castedDic.TryGetValue("cognome", out object cognome); Assert.True(cognome is string); Assert.True(((string)cognome).Equals("scorsese")); }
private IList <IDictionary <string, object> > GetListValues() { IList <IDictionary <string, object> > values = new List <IDictionary <string, object> >(); int length = mMenuText.Length; for (int i = 0; i < length; i++) { IDictionary <string, object> v = new JavaDictionary <string, object>(); v.Add("name", mMenuText[i]); v.Add("desc", mMenuSummary[i]); values.Add(v); } return(values); }
public async System.Threading.Tasks.Task UpdateUser(User user) { if (user.Email.Trim() != CurrentUser.Email) { await Firebase.FirebaseAuth.CurrentUser.UpdateEmailAsync(user.Email); } var dictionary = new JavaDictionary <string, object>(); dictionary.Add("email", user.Email.Trim()); dictionary.Add("uid", user.UId); dictionary.Add("fullname", user.Fullname.Trim()); dictionary.Add("phone", user.Phone.Trim()); await Firebase.FirebaseFirestore.Document($"users/{user.UId}").Set(dictionary); }
public async void LoadContent() { eae = await Get(); List <Models.Cardapio> list = JsonConvert.DeserializeObject <List <Models.Cardapio> >(eae); IList <IDictionary <string, object> > dados = new List <IDictionary <string, object> >(); foreach (Models.Cardapio r in list) { IDictionary <string, object> dado = new JavaDictionary <string, object>(); //dado.Add("Id", r.Id.ToString()); dado.Add("Descricao", r.Descricao); dados.Add(dado); } string[] from = new String[] { "Descricao" }; //string[] from = new String[] { "Id", "Descricao" }; int[] to = new int[] { Resource.Id.descRest }; int layout = Resource.Layout.listRest; // ArrayList for data row // SimpleAdapter mapping static data to views in xml file SimpleAdapter adapter = new SimpleAdapter(this, dados, layout, from, to); ListView.Adapter = adapter; }
public static JavaDictionary <string, Java.Lang.Object> ToNativeFieldValues(this object fieldValues) { if (fieldValues == null) { return(null); } if (fieldValues is IDictionary dictionary) { var resultDictionary = new JavaDictionary <string, Java.Lang.Object>(); foreach (var key in dictionary.Keys) { resultDictionary.Add(key.ToString(), dictionary[key].ToNativeFieldValue()); } return(resultDictionary); } var properties = fieldValues.GetType().GetProperties(); var values = new JavaDictionary <string, Java.Lang.Object>(); foreach (var property in properties) { var(key, @object) = GetKeyAndObject(fieldValues, property); if (key != null) { values.Add(key, @object); } } return(values); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.activity_autocomplete); // Highlight sample XuniAutoCompleteTextView highLightAutoComplete = (XuniAutoCompleteTextView)this.FindViewById(Resource.Id.autocomplete_highlight); //highLightAutoComplete.SetItemsSource(DropDownItem.country); highLightAutoComplete.DisplayMemberPath = "Name"; highLightAutoComplete.ItemsSource = DropDownItem.getList(); highLightAutoComplete.MatchType = MatchType.Contains; highLightAutoComplete.Threshold = 1; // Delay sample XuniAutoCompleteTextView delayAutoComplete = (XuniAutoCompleteTextView)this.FindViewById(Resource.Id.autocomplete_delay); delayAutoComplete.DisplayMemberPath = "Name"; delayAutoComplete.ItemsSource = DropDownItem.getList(); delayAutoComplete.MatchType = MatchType.Contains; delayAutoComplete.Threshold = 1; delayAutoComplete.Delay = 1500; // Delay 1500 milliseconds. delayAutoComplete.SetWidth(20); // Custom sample System.Collections.Generic.IDictionary <Integer, string> viewToDataMap = new JavaDictionary <Integer, string>(); viewToDataMap.Add(Integer.ValueOf(Resource.Id.imageView1), "flag"); viewToDataMap.Add(Integer.ValueOf(Resource.Id.textView1), "Name"); XuniAutoCompleteTextView customAutoComplete = (XuniAutoCompleteTextView)this.FindViewById(Resource.Id.autocomplete_custom); customAutoComplete.SetDropDownItemLayoutId(Resource.Layout.custom_item); // Custom drop down item. customAutoComplete.SetDropDownItemTextViewId(Resource.Id.textView1); customAutoComplete.ViewDataBinderMap = viewToDataMap; IList <object> list = DropDownItem.getList(); customAutoComplete.ItemsSource = list; customAutoComplete.DisplayMemberPath = "Name"; customAutoComplete.MatchType = MatchType.Contains; customAutoComplete.Threshold = 1; // custom filter sample filterAutoComplete = (XuniAutoCompleteTextView)this.FindViewById(Resource.Id.autocomplete_filter); filterAutoComplete.ItemsSource = DropDownItem.getList(); filterAutoComplete.DisplayMemberPath = "Name"; filterAutoComplete.Threshold = 1; filterAutoComplete.FilteringEvent += filterAutoComplete_FilteringEvent; }
public static Java.Lang.Object ToNative(Type type, object data) { var dataType = data.GetType(); if (dataType.IsPrimitive || data is string) { if (data is bool b) { return(new Java.Lang.Boolean(b)); } else if (data is float f) { return(new Java.Lang.Float(f)); } else if (data is double d) { return(new Java.Lang.Double(d)); } else if (data is long l) { return(new Java.Lang.Long(l)); } else if (data is int i) { return(new Java.Lang.Integer(i)); } else if (data is string s) { return(new Java.Lang.String(s)); } return((Java.Lang.Object)data); } else if (data is IDictionary dict) { var ret = new JavaDictionary <string, Java.Lang.Object>(); var valueType = DataConverter.GetItemType(dict.GetType(), 1); foreach (var key in dict.Keys) { ret.Add(key as string, ToNative(valueType, dict[key])); } return(ret); } else { var ret = new JavaDictionary <string, Java.Lang.Object>(); foreach (var item in TypePropertyHelper.GetFirebaseProperties(type)) { var prp = item.Value.Property; var key = item.Key; var objData = prp.GetValue(data); if (objData != null) { ret.Add(key, ToNative(prp.PropertyType, objData)); } } return(ret); } //return (Java.Lang.Object) data; }
public static void PopulateListView(Context context, ListView listview, int resource, string[] header, int[] image, string[] info, int[] to) { var aList = new JavaList <IDictionary <string, object> >(); for (int i = 0; i < header.Length; i++) { var hm = new JavaDictionary <string, object>(); hm.Add("header", header[i].ToString()); hm.Add("info", info[i].ToString()); hm.Add("image", image[i].ToString()); aList.Add(hm); } //to=id // Keys used in Hashmap String[] from = { "header", "info", "image" }; SimpleAdapter adapter = new SimpleAdapter(context, aList, resource, from, to); listview.Adapter = adapter; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); stopProcesB(); int id = Intent.GetIntExtra("id", 0); ((TextView)FindViewById(Resource.Id.text)).Text = "Список оценок по дисцеплине \"" + MainActivity.mylesson[id].PredmetName + "\":"; var list1 = new List <IDictionary <string, object> >(); foreach (var itemz in MainActivity.mylesson[id].Zanatie) { foreach (var itemd in itemz.Dost) { if (itemd.Student_id == MainActivity.myperson.Id) { var item1 = new JavaDictionary <string, object>(); item1.Add("namez", itemz.Name); item1.Add("ocenka", itemd.Ocenka); item1.Add("date", itemz.Data.ToLongDateString()); list1.Add(item1); } } } string[] from = { "namez", "ocenka", "date" }; int[] to = { Resource.Id.name, Resource.Id.ocenka, Resource.Id.date }; SimpleAdapter newslistAdapter = new SimpleAdapter(this, list1, Resource.Layout.item, from, to); ListView newsList = (ListView)FindViewById(Resource.Id.listView1); LayoutParams lpView = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); TextView tv = new TextView(this); tv.Text = "Пусто"; tv.LayoutParameters = lpView; newsList.EmptyView = tv; newsList.Adapter = newslistAdapter; }
private void RegisterResources(Type layoutClassType, JavaDictionary <string, int> container) { foreach (var field in layoutClassType.GetFields()) { var name = CreateName(field.Name); if (container.ContainsKey(name)) { container.Remove(name); } container.Add(name, field.GetValue(null)); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment // return inflater.Inflate(Resource.Layout.YourFragment, container, false); View view = inflater.Inflate(Resource.Layout.fragment_menu_list, container, false); ListView lvMenu = view.FindViewById <ListView>(Resource.Id.lvMenu); var menuList = new JavaList <IDictionary <string, object> >(); JavaDictionary <string, object> menu = new JavaDictionary <string, object>(); menu.Add("name", "からあげ"); menu.Add("price", "300"); menuList.Add(menu); menu = new JavaDictionary <string, object>(); menu.Add("name", "バグった食べ物☆"); menu.Add("price", "28.8200"); menuList.Add(menu); menu = new JavaDictionary <string, object>(); menu.Add("name", "ごみ"); menu.Add("price", "3333300"); menuList.Add(menu); string[] from = { "name", "price" }; int[] to = { Android.Resource.Id.Text1, Android.Resource.Id.Text2 }; _adapter = new SimpleAdapter(_parentActivity, menuList, Android.Resource.Layout.SimpleListItem2, from, to); lvMenu.Adapter = _adapter; lvMenu.ItemClick += OnItemClick; return(view); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); using (var groupData = new JavaList <IDictionary <string, object> > ()) using (var childData = new JavaList <IList <IDictionary <string, object> > > ()) { for (int i = 0; i < 20; i++) { using (var curGroupMap = new JavaDictionary <string, object>()) { groupData.Add(curGroupMap); curGroupMap.Add(Name, "Group " + i); curGroupMap.Add(IsEven, (i % 2 == 0) ? "This group is even" : "This group is odd"); using (var children = new JavaList <IDictionary <string, object> > ()) { for (int j = 0; j < 15; j++) { using (var curChildMap = new JavaDictionary <string, object> ()) { children.Add(curChildMap); curChildMap.Add(Name, "Child " + j); curChildMap.Add(IsEven, (j % 2 == 0) ? "This child is even" : "This child is odd"); } } childData.Add(children); } } } // Set up our adapter mAdapter = new SimpleExpandableListAdapter( this, groupData, Android.Resource.Layout.SimpleExpandableListItem1, new string[] { Name, IsEven }, new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 }, childData, Android.Resource.Layout.SimpleExpandableListItem2, new string[] { Name, IsEven }, new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 } ); SetListAdapter(mAdapter); } }
public static List <IDictionary <string, object> > ReadFileName() { List <IDictionary <string, object> > map = new List <IDictionary <string, object> >(); Java.IO.File file = new Java.IO.File(PATH); if (file.Exists()) { Java.IO.File[] files = file.ListFiles(); for (int k = 0; k < files.Length; k++) { JavaDictionary <string, object> map2 = new JavaDictionary <string, object>(); /// String str1=files[k].getAbsolutePath(); // String str2=files[k].getPath(); map2.Add("fname", files[k].Name); map2.Add("fpath", files[k].AbsolutePath); map.Add(map2); } return(map); } return(map); }
/// <summary> /// Gets the ListView items. /// </summary> /// <returns> /// The get items. /// </returns> private IList <IDictionary <string, object> > _GetItems() { var item1 = new JavaDictionary <string, object>(); item1.Add(TitleKey, "FileExplorer"); item1.Add(DetailsKey, "12312"); var item2 = new JavaDictionary <string, object>(); item2.Add(TitleKey, "Author"); item2.Add(DetailsKey, "Alexander Matsibarov (macasun)"); var item3 = new JavaDictionary <string, object>(); item3.Add(TitleKey, "Email"); item3.Add(DetailsKey, "*****@*****.**"); var item4 = new JavaDictionary <string, object>(); item4.Add(TitleKey, "Copyrights"); item4.Add(DetailsKey, "2013"); var item5 = new JavaDictionary <string, object>(); item5.Add(TitleKey, "Application description"); item5.Add(DetailsKey, "FileExplorer application for iOS and Android"); var coll = new JavaList <IDictionary <string, object> >(); coll.Add(item1); coll.Add(item2); coll.Add(item3); coll.Add(item4); coll.Add(item5); return(coll); }
public JavaDictionary <string, Java.Lang.Object?> ConvertToFieldObject(object target) { var ret = new JavaDictionary <string, Java.Lang.Object?>(); var adapter = GetDictionaryAdapter(target); var enumerator = adapter.GetEnumerator(); while (enumerator.MoveNext()) { var entry = enumerator.Entry; ret.Add(entry.Key.ToString(), entry.Value.ToNativeFieldValue(_documentFieldInfo)); } return(ret); }
void TestNonJavaObjectGenerics(TextView textview) { var adapter = new Android.Widget.ArrayAdapter <NonJavaObject> (this, textview.Id); var item = new NonJavaObject(); adapter.Add(item); textview.Text += "\n\n" + adapter.GetItem(0).ToString(); var coll = new JavaDictionary <NonJavaObject, NonJavaObject> (); coll.Add(item, item); if (!object.ReferenceEquals(item, coll [item])) { throw new InvalidOperationException("Unable to lookup non-java.lang.Object item in JavaDictionary!"); } #if BXC_2147 Log.Info("*jonp*", "A1"); var jl1 = new Android.Runtime.JavaList <object>(); Log.Info("*jonp*", "A2"); var v1 = new Dictionary <string, object>(); Log.Info("*jonp*", "A3"); v1.Add("szLongName", "Bla.pdf"); Log.Info("*jonp*", "A4"); jl1.Add(v1); Log.Info("*jonp*", "A5"); var vo1 = jl1 [0]; Log.Info("*jonp*", "A6={0}", vo1); var jl2 = new Android.Runtime.JavaList(); Log.Info("*jonp*", "B2"); var v2 = new Dictionary <string, object>(); Log.Info("*jonp*", "B3"); v2.Add("szLongName", "Bla.pdf"); Log.Info("*jonp*", "B4"); jl2.Add(v2); Log.Info("*jonp*", "B5"); var _vo2 = jl2 [0]; // Exception Log.Info("*jonp*", "B6={0} [{1}]", _vo2, _vo2 != null ? _vo2.GetType().FullName : "<null>"); var vo2 = (Dictionary <string, object>)jl2 [0]; // Exception Log.Info("*jonp*", "B7={0}", vo2); #endif }
public async System.Threading.Tasks.Task NewProject(Projet projet) { var dictionary = new JavaDictionary <string, object>(); dictionary.Add("projectId", projet.ProjectId); dictionary.Add("ownerUId", projet.OwnerUId); dictionary.Add("name", projet.Name); dictionary.Add("date", projet.Date.ToString()); dictionary.Add("description", projet.Description); var lst = new JavaList(projet.Categories); dictionary.Add("categories", lst); await Firebase.FirebaseFirestore.Document($"projects/{projet.ProjectId}/").Set(dictionary); }
public static Java.Lang.Object ToNativeFieldValue(this object fieldValue) { if (fieldValue == null) { return(null); } switch (fieldValue) { case bool @bool: return(new Java.Lang.Boolean(@bool)); case byte @byte: return(new Java.Lang.Long(@byte)); case double @doble: return(new Java.Lang.Double(@doble)); case float @float: return(new Java.Lang.Double(@float)); case int @int: return(new Java.Lang.Long(@int)); case long @long: return(new Java.Lang.Long(@long)); case sbyte @sbyte: return(new Java.Lang.Long(@sbyte)); case short @short: return(new Java.Lang.Long(@short)); case uint @uint: return(new Java.Lang.Long(@uint)); case ulong @ulong: return(new Java.Lang.Double(@ulong)); case ushort @ushort: return(new Java.Lang.Long(@ushort)); case decimal @decimal: return(new Java.Lang.Double((double)@decimal)); case string @string: return(new Java.Lang.String(@string)); case DateTime dateTime: return(new Timestamp(dateTime).ToNative()); case DateTimeOffset dateTimeOffset: return(new Timestamp(dateTimeOffset).ToNative()); case Timestamp timestamp: return(timestamp.ToNative()); case GeoPoint geoPoint: return(geoPoint.ToNative()); case DocumentReferenceWrapper documentReference: return((Firebase.Firestore.DocumentReference)documentReference); case byte[] @byte: return(Firebase.Firestore.Blob.FromBytes(@byte)); case Stream stream: using (var ms = new MemoryStream()) { stream.CopyTo(ms); return(Firebase.Firestore.Blob.FromBytes(ms.ToArray())); } case IList list: { var javaList = new JavaList(); foreach (var val in list) { javaList.Add(val.ToNativeFieldValue()); } return(javaList); } case IDictionary dictionary: { var javaDictionary = new JavaDictionary(); foreach (var key in dictionary.Keys) { javaDictionary.Add(key.ToString(), dictionary[key].ToNativeFieldValue()); } return(javaDictionary); } case FieldValue firestoreFieldValue: return(firestoreFieldValue.ToNative()); case FieldPath fieldPath: return(fieldPath.ToNative()); default: { var type = fieldValue.GetType(); if (type.IsPrimitive) { throw new NotSupportedException($"{type.FullName} is not supported"); } var javaDictionary = new JavaDictionary(); var properties = type.GetProperties(); foreach (var property in properties) { var(key, @object) = GetKeyAndObject(fieldValue, property); if (key != null) { javaDictionary.Add(key, @object); } } return(javaDictionary); } } }
public XmlVocabFileParser(Stream xmlStream) { // SimpleAdapter requires a list of JavaDictionary<string,object> objects vocabList = new List <IDictionary <string, object> >(); /* * //for testing * var item1 = new JavaDictionary<string, object> (); * item1.Add (SPANISH, "mono"); * item1.Add (ENGLISH, "monkey"); * item1.Add ("partOfSpeech", "noun"); * vocabList.Add(item1); * var item2 = new JavaDictionary<string, object> (); * item2.Add (SPANISH, "agua"); * item2.Add (ENGLISH, "water"); * item2.Add (ENGLISH, "noun"); * vocabList.Add(item2); * var item3 = new JavaDictionary<string, object> (); * item3.Add (SPANISH, "saltar"); * item3.Add (ENGLISH, "to jump"); * item3.Add (ENGLISH, "verb"); * vocabList.Add(item3); */ // Parse the xml file and fill the list of JavaDictionary objects with vocabulary data using (XmlReader reader = XmlReader.Create(xmlStream)) { JavaDictionary <string, object> word = null; while (reader.Read()) { // Only detect start elements. if (reader.IsStartElement()) { // Get element name and switch on it. switch (reader.Name) { case WORD: // New word word = new JavaDictionary <string, object> (); break; case SPANISH: // Add spanish word if (reader.Read() && word != null) { word.Add(SPANISH, reader.Value.Trim()); } break; case ENGLISH: // Add english word if (reader.Read() && word != null) { word.Add(ENGLISH, reader.Value.Trim()); } break; case POS: // Add part of speech if (reader.Read() && word != null) { word.Add(POS, reader.Value.Trim()); } break; } } else if (reader.Name == WORD) { // reached </word> vocabList.Add(word); word = null; } } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.SoundFontDetails); var sf = Intent.GetStringExtra("soundfont"); var model = ApplicationModel.Instance; var mod = model.Database.Modules.First(m => m.Name == sf); var sfFile = model.Files.FirstOrDefault(p => p.Value == mod.Name).Key; if (!File.Exists(sfFile)) { Toast.MakeText(this, string.Format("SoundFont file '{0}' was not found. Details not shown", sfFile), ToastLength.Long).Show(); } else { var sf2 = new SoundFont(new MemoryStream(File.ReadAllBytes(sfFile))); var infoList = new JavaList <IDictionary <string, object> > (); var map = mod.Instrument.Maps.First(); var labels = new string [] { "BankName", "FileName", "Author", "Copyright", "Comments", "Created", "SFVersion", "ROMVersion", "WaveTableEngine", "Tools", "TargetProduct", "DataROM" }; var values = new string [] { mod.Name, sfFile, sf2.FileInfo.Author, sf2.FileInfo.Copyright, sf2.FileInfo.Comments, sf2.FileInfo.SoundFontVersion == null ? null : string.Format("{0}.{1}", sf2.FileInfo.SoundFontVersion.Major, sf2.FileInfo.SoundFontVersion.Minor), sf2.FileInfo.ROMVersion == null ? null : string.Format("{0}.{1}", sf2.FileInfo.ROMVersion.Major, sf2.FileInfo.ROMVersion.Minor), sf2.FileInfo.CreationDate, sf2.FileInfo.WaveTableSoundEngine, sf2.FileInfo.Tools, sf2.FileInfo.TargetProduct, sf2.FileInfo.DataROM, }; for (int i = 0; i < labels.Length; i++) { var items = new JavaDictionary <string, object> (); items.Add("text1", labels [i]); items.Add("text2", values [i]); infoList.Add(items); } var bankList = new JavaList <IDictionary <string, object> > (); foreach (var p in map.Programs) { foreach (var b in p.Banks) { var items = new JavaDictionary <string, object> (); items.Add("text1", string.Format("{0:D03}.{1:D03}.{2:D03}", p.Index, b.Msb, b.Lsb)); items.Add("text2", b.Name); bankList.Add(items); } } var fromKeys = new string [] { "text1", "text2" }; var toIds = new int [] { Resource.Id.soundFontDetailFileInfoLabel, Resource.Id.soundFontDetailFileInfoValue }; var lvfi = FindViewById <ListView> (Resource.Id.soundFontDetailsFileInfo); lvfi.Adapter = new SimpleAdapter(this, infoList, Resource.Layout.SoundFontFileInfoItem, fromKeys, toIds); var lvbanks = FindViewById <ListView> (Resource.Id.soundFontDetailsBankList); lvbanks.Adapter = new SimpleAdapter(this, bankList, Resource.Layout.SoundFontFileInfoItem, fromKeys, toIds); } }
public static Java.Lang.Object ToNativeFieldValue <T>(this T fieldValue) { if (fieldValue == null) { return(null); } switch (fieldValue) { case bool @bool: return(new Java.Lang.Boolean(@bool)); case byte @byte: return(new Java.Lang.Long(@byte)); case double @doble: return(new Java.Lang.Double(@doble)); case float @float: return(new Java.Lang.Double(@float)); case int @int: return(new Java.Lang.Long(@int)); case long @long: return(new Java.Lang.Long(@long)); case sbyte @sbyte: return(new Java.Lang.Long(@sbyte)); case short @short: return(new Java.Lang.Long(@short)); case uint @uint: return(new Java.Lang.Long(@uint)); case ulong @ulong: return(new Java.Lang.Double(@ulong)); case ushort @ushort: return(new Java.Lang.Long(@ushort)); case decimal @decimal: return(new Java.Lang.Double((double)@decimal)); case string @string: return(new Java.Lang.String(@string)); case DateTime dateTime: return(new Java.Util.Date((long)(dateTime - new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero)).TotalMilliseconds)); case DateTimeOffset dateTimeOffset: return(new Java.Util.Date((long)(dateTimeOffset - new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero)).TotalMilliseconds)); case GeoPoint geoPoint: return(new Firebase.Firestore.GeoPoint(geoPoint.Latitude, geoPoint.Longitude)); case DocumentReferenceWrapper documentReference: return(documentReference.DocumentReference); case byte[] @byte: return(Firebase.Firestore.Blob.FromBytes(@byte)); case Stream stream: using (var ms = new MemoryStream()) { stream.CopyTo(ms); return(Firebase.Firestore.Blob.FromBytes(ms.ToArray())); } case IList list: { var javaList = new JavaList(); foreach (var val in list) { javaList.Add(val.ToNativeFieldValue()); } return(javaList); } case IDictionary dictionary: { var javaDictionary = new JavaDictionary(); foreach (var key in dictionary.Keys) { javaDictionary.Add(key.ToString(), dictionary[key].ToNativeFieldValue()); } return(javaDictionary); } default: { var type = fieldValue.GetType(); if (type.IsPrimitive) { throw new NotSupportedException($"{type.FullName} is not supported"); } var javaDictionary = new JavaDictionary(); var properties = type.GetProperties(); foreach (var property in properties) { var idAttribute = Attribute.GetCustomAttribute(property, typeof(IdAttribute)); var igonoredAttribute = Attribute.GetCustomAttribute(property, typeof(IgnoredAttribute)); if (idAttribute == null && igonoredAttribute == null) { var mapToAttribute = (MapToAttribute)Attribute.GetCustomAttribute(property, typeof(MapToAttribute)); var key = mapToAttribute != null ? mapToAttribute.Mapping : property.Name; javaDictionary.Add(key, property.GetValue(fieldValue).ToNativeFieldValue()); } } return(javaDictionary); } } }
private static object ToFlutterObject(object value) { if (value == null) { return(null); } Type type = value.GetType(); Type properType = Nullable.GetUnderlyingType(type) ?? type; if (properType.IsPrimitive || properType == typeof(string)) { return(value); } if (properType.IsArray && properType.IsGenericType == false) { Type elementType = properType.GetElementType(); Type properElementType = Nullable.GetUnderlyingType(elementType) ?? elementType; if (properElementType == typeof(byte)) { // for performance reasons, we adopt Newtonsoft approach // and convert byte[] to a base-64 encoded string return(JsonConversionExtensions.ConvertByteArrayToBase64String(value)); } JavaList list = new JavaList(); foreach (object item in (IList)value) { list.Add(properElementType.IsPrimitive ? item : ToFlutterObject(item)); } return(list); } if (properType.IsGenericType) { Type[] interfaces = properType.IsInterface ? new[] { properType } : properType.GetInterfaces(); bool implementsDictionary = interfaces.Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IDictionary <,>)); if (implementsDictionary) { Type[] types = properType.GetGenericArguments(); Type valueType = Nullable.GetUnderlyingType(types[1]) ?? types[1]; JavaDictionary map = new JavaDictionary(); foreach (dynamic kvp in (IEnumerable)value) { map.Add(kvp.Key, valueType.IsPrimitive ? kvp.Value : ToFlutterObject(kvp.Value)); } return(map); } bool implementsEnumerable = interfaces.Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IEnumerable <>)); if (implementsEnumerable) { Type[] types = properType.GetGenericArguments(); Type itemType = Nullable.GetUnderlyingType(types[0]) ?? types[0]; JavaList list = new JavaList(); foreach (object item in (IEnumerable)value) { list.Add(itemType.IsPrimitive ? item : ToFlutterObject(item)); } return(list); } throw new InvalidOperationException(); } if (properType.GetCustomAttributes(typeof(PlatformDataAttribute), false).Length > 0) { return(JObject.FromObject(value).ToJavaDictionary()); } throw new InvalidOperationException(); }
public XmlTideFileParser(Stream xmlStream) { // SimpleAdapter requires a list of JavaDictionary<string,object> objects tideList = new List <IDictionary <string, object> >(); // Parse the xml file and fill the list of JavaDictionary objects with vocabulary data using (XmlReader reader = XmlReader.Create(xmlStream)) { JavaDictionary <string, object> prediction = null; while (reader.Read()) { // Only detect start elements. if (reader.IsStartElement()) { // Get element name and switch on it. switch (reader.Name) { case ITEM: // New word prediction = new JavaDictionary <string, object>(); break; case DATE: // Add date if (reader.Read() && prediction != null) { prediction.Add(DATE, reader.Value.Trim()); } break; case DAY: // Add day of the week if (reader.Read() && prediction != null) { prediction.Add(DAY, reader.Value.Trim()); } break; case TIME: // Add time of day if (reader.Read() && prediction != null) { prediction.Add(TIME, reader.Value.Trim()); } break; case HEIGHT: // Add tide height in inches if (reader.Read() && prediction != null) { prediction.Add(HEIGHT, reader.Value.Trim()); } break; case HI_LOW: // Add H or L for high or low tied if (reader.Read() && prediction != null) { prediction.Add(HI_LOW, reader.Value.Trim()); } break; } } else if (reader.Name == ITEM) { // reached </item> tideList.Add(prediction); prediction = null; } } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); ISharedPreferences prefs = Application.Context.GetSharedPreferences("TEST_PREF", FileCreationMode.Private); // Tracking Users EditText userIdEditText = FindViewById <EditText>(Resource.Id.userIdEditText); userId = prefs.GetString("userid", ""); userIdEditText.Text = userId; Button loginButton = FindViewById <Button>(Resource.Id.loginButton); if (userId.Equals("")) { loginButton.Text = "LOGIN"; } else { loginButton.Text = "LOGOUT"; } loginButton.Click += delegate { if (loginButton.Text.Equals("LOGIN")) { userId = userIdEditText.Text.ToString(); if (!userId.Equals("")) { ISharedPreferencesEditor editor = prefs.Edit(); editor.PutString("userid", userId); editor.Apply(); loginButton.Text = "LOGOUT"; // Login WebEngage.Get().User().Login(userId); } } else { ISharedPreferencesEditor editor = prefs.Edit(); editor.PutString("userid", ""); editor.Apply(); loginButton.Text = "LOGIN"; userIdEditText.Text = ""; // Logout WebEngage.Get().User().Logout(); } }; // System user attributes EditText emailEditText = FindViewById <EditText>(Resource.Id.emailEditText); Button emailButton = FindViewById <Button>(Resource.Id.emailButton); emailButton.Click += delegate { string email = emailEditText.Text.ToString(); if (!email.Equals("")) { WebEngage.Get().User().SetEmail(email); Toast.MakeText(this.ApplicationContext, "Email set successfully", ToastLength.Long).Show(); } }; Spinner genderSpinner = FindViewById <Spinner>(Resource.Id.genderSpinner); var adapter = ArrayAdapter.CreateFromResource( this, Resource.Array.gender_array, Android.Resource.Layout.SimpleSpinnerItem); adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); genderSpinner.Adapter = adapter; Button genderButton = FindViewById <Button>(Resource.Id.genderButton); genderButton.Click += delegate { int spinnerPosition = genderSpinner.SelectedItemPosition; Gender gender = Gender.Male; if (spinnerPosition == 0) { gender = Gender.Male; } else if (spinnerPosition == 1) { gender = Gender.Female; } else if (spinnerPosition == 2) { gender = Gender.Other; } WebEngage.Get().User().SetGender(gender); Toast.MakeText(this.BaseContext, "Gender set successfully", ToastLength.Long).Show(); }; //WebEngage.Get().User().SetBirthDate("1994-04-29"); //WebEngage.Get().User().SetFirstName("John"); //WebEngage.Get().User().SetLastName("Doe"); //WebEngage.Get().User().SetCompany("WebEngage"); //WebEngage.Get().User().SetPhoneNumber("+551155256325"); //WebEngage.Get().User().SetHashedPhoneNumber("e0ec043b3f9e198ec09041687e4d4e8d"); //WebEngage.Get().User().SetHashedEmail("144e0424883546e07dcd727057fd3b62"); // Channels //WebEngage.Get().User().SetOptIn(Channel.Whatsapp, true); //WebEngage.Get().User().SetOptIn(Channel.Email, true); //WebEngage.Get().User().SetOptIn(Channel.Sms, true); //WebEngage.Get().User().SetOptIn(Channel.Push, true); //WebEngage.Get().User().SetOptIn(Channel.InApp, true); // Custom user attributes //WebEngage.Get().User().SetAttribute("age", (Java.Lang.Integer)23); //WebEngage.Get().User().SetAttribute("premium", (Boolean)true); //WebEngage.Get().User().SetAttribute("last_seen", new Date("2018-12-25")); //IDictionary<string, Object> customAttributes = new Dictionary<string, Object>(); //customAttributes.Add("Twitter Email", "*****@*****.**"); //customAttributes.Add("Subscribed", true); //WebEngage.Get().User().SetAttributes(customAttributes); //WebEngage.Get().User().DeleteAttribute("age"); //WebEngage.Get().SetLocationTrackingStrategy(LocationTrackingStrategy.AccuracyCity); //WebEngage.Get().User().SetLocation(12.23, 12.45); //IList<Object> brandAffinity = new List<Object> //{ // "Hugo Boss", // "Armani Exchange", // "GAS", // "Brooks Brothers" //}; //WebEngage.Get().User().SetAttribute("Brand affinity", brandAffinity); //JavaDictionary<string, Object> address = new JavaDictionary<string, Object> //{ // { "Flat", "Z-62" }, // { "Building", "Pennant Court" }, // { "Locality", "Penn Road" }, // { "City", "Wolverhampton" }, // { "State", "West Midlands" }, // { "PIN", "WV30DT" } //}; //IDictionary<string, Object> customAttributes = new Dictionary<string, Object>(); //customAttributes.Add("Address", address); //WebEngage.Get().User().SetAttributes(customAttributes); // Tracking Events EditText eventEditText = FindViewById <EditText>(Resource.Id.eventEditText); Button trackButton = FindViewById <Button>(Resource.Id.trackButton); trackButton.Click += delegate { string eventName = eventEditText.Text; if (!eventName.Equals("")) { WebEngage.Get().Analytics().Track(eventName, new Analytics.Options().SetHighReportingPriority(false)); Toast.MakeText(this.BaseContext, "Event tracked successfully", ToastLength.Long).Show(); } }; // Tracking Event with Attributes //IDictionary<string, Object> attributes = new Dictionary<string, Object> //{ // { "id", "~123" }, // { "price", 100 }, // { "discount", true } //}; //WebEngage.Get().Analytics().Track("Product Viewed", attributes, new Analytics.Options().SetHighReportingPriority(false)); Button shopButton = FindViewById <Button>(Resource.Id.shopButton); shopButton.Click += delegate { // Tracking Complex Events IDictionary <string, Object> product1 = new JavaDictionary <string, Object>(); product1.Add("SKU Code", "UHUH799"); product1.Add("Product Name", "Armani Jeans"); product1.Add("Price", 300.49); JavaDictionary <string, Object> detailsProduct1 = new JavaDictionary <string, Object>(); detailsProduct1.Add("Size", "L"); product1.Add("Details", detailsProduct1); IDictionary <string, Object> product2 = new JavaDictionary <string, Object>(); product2.Add("SKU Code", "FBHG746"); product2.Add("Product Name", "Hugo Boss Jacket"); product2.Add("Price", 507.99); JavaDictionary <string, Object> detailsProduct2 = new JavaDictionary <string, Object>(); detailsProduct2.Add("Size", "L"); product2.Add("Details", detailsProduct2); IDictionary <string, Object> deliveryAddress = new JavaDictionary <string, Object>(); deliveryAddress.Add("City", "San Francisco"); deliveryAddress.Add("ZIP", "94121"); JavaDictionary <string, Object> orderPlacedAttributes = new JavaDictionary <string, Object>(); JavaList <Object> products = new JavaList <Object>(); products.Add(product1); products.Add(product2); JavaList <string> coupons = new JavaList <string>(); coupons.Add("BOGO17"); orderPlacedAttributes.Add("Products", products); orderPlacedAttributes.Add("Delivery Address", deliveryAddress); orderPlacedAttributes.Add("Coupons Applied", coupons); WebEngage.Get().Analytics().Track("Order Placed", orderPlacedAttributes, new Analytics.Options().SetHighReportingPriority(false)); Toast.MakeText(this.BaseContext, "Order Placed successfully", ToastLength.Long).Show(); }; Button locationButton = FindViewById <Button>(Resource.Id.locationButton); locationButton.Click += delegate { requestLocationPermission(); }; Button nextButton = FindViewById <Button>(Resource.Id.nextButton); nextButton.Click += delegate { StartActivity(typeof(NextActivity)); }; }
public JavaList <IDictionary <string, object> > getFoodList(string word, Context c = null) { //conn = new SQLiteConnection(GlobalFunction.dbPath); var sqlconn = new MySqlConnection(GlobalFunction.remoteaccess); sqlconn.Open(); var foodList = new JavaList <IDictionary <string, object> >(); var query = $@"SELECT * FROM Food where Food_NAME LIKE '%{word}%'"; var tickets = new DataSet(); var adapter = new MySqlDataAdapter(query, sqlconn); adapter.Fill(tickets, "Food"); foreach (DataRow x in tickets.Tables["Food"].Rows) { var food = new JavaDictionary <string, object>(); food.Add("food_id", GlobalFunction.stringValidation(x[0].ToString())); food.Add("food_name", GlobalFunction.stringValidation(x[1].ToString())); food.Add("food_calories", GlobalFunction.stringValidation(x[3].ToString())); food.Add("food_unit", GlobalFunction.stringValidation(x[4].ToString())); food.Add("food_netweight", GlobalFunction.stringValidation(x[5].ToString())); food.Add("food_netunit", GlobalFunction.stringValidation(x[6].ToString())); food.Add("food_protein", GlobalFunction.stringValidation(x[7].ToString())); food.Add("food_fat", GlobalFunction.stringValidation(x[8].ToString())); food.Add("food_carbyhydrate", GlobalFunction.stringValidation(x[9].ToString())); food.Add("food_sugars", GlobalFunction.stringValidation(x[10].ToString())); food.Add("food_sodium", GlobalFunction.stringValidation(x[11].ToString())); food.Add("food_detail", GlobalFunction.stringValidation(x[12].ToString())); foodList.Add(food); } #region SQLiteMethodology /* * var query = $@"SELECT * FROM FoodTABLE where Food_NAME LIKE '%{word}%'"; * var backFromSQL = conn.Query<FoodTABLE>(query); * backFromSQL.ForEach(x => * { * var food = new JavaDictionary<string, object>(); * food.Add("food_id", GlobalFunction.stringValidation(x.Food_ID)); * food.Add("food_name", GlobalFunction.stringValidation(x.Food_NAME)); * food.Add("food_calories", GlobalFunction.stringValidation(x.Food_CAL)); * food.Add("food_unit", GlobalFunction.stringValidation(x.Food_UNIT)); * food.Add("food_netweight", GlobalFunction.stringValidation(x.Food_NET_WEIGHT)); * food.Add("food_netunit", GlobalFunction.stringValidation(x.Food_NET_UNIT)); * food.Add("food_protein", GlobalFunction.stringValidation(x.Food_PROTEIN)); * food.Add("food_fat", GlobalFunction.stringValidation(x.Food_FAT)); * food.Add("food_carbyhydrate", GlobalFunction.stringValidation(x.Food_CARBOHYDRATE)); * food.Add("food_sugars", GlobalFunction.stringValidation(x.Food_SUGAR)); * food.Add("food_sodium", GlobalFunction.stringValidation(x.Food_SODIUM)); * food.Add("food_detail", GlobalFunction.stringValidation(x.Food_Detail)); * foodList.Add(food); * }); * conn.Close(); */ #endregion sqlconn.Close(); return(foodList); }