private void Load() { try { // Get all items inside the database reference Query myQuery = databaseReference.OrderByChild("place"); OnValueEventListener OnValueEvent = new OnValueEventListener(); OnValueEvent.Raised += (s, e) => { if (e.snapshot == null) { return; } // Load finished, reload things lists and refresh UI thingsList.Clear(); thingsQuery.Clear(); if (e.snapshot.HasChildren) { Java.Util.IIterator iterator = e.snapshot.Children.Iterator(); while (iterator.HasNext) { thingsList.Add(new Thing((DataSnapshot)iterator.Next())); } } else { thingsList.Add(new Thing(e.snapshot)); } thingsQuery.AddRange(thingsList); // Refresh UI list view RefreshUI(); }; // Add listener that raises when load finish myQuery.AddValueEventListener(OnValueEvent); } catch (Exception ex) { Console.WriteLine(ex.Message); Toast.MakeText(Application.Context, ex.Message, ToastLength.Long).Show(); } }
public void OnGpsStatusChanged(GpsEvent e) // GpsStatus.IListener { if (locationManager != null) { gpsStatus = locationManager.GetGpsStatus(gpsStatus); switch (e) { case GpsEvent.FirstFix: status = IDeviceGpsStatus.FirstFix; DeviceDebugAndroid.LogToFileMethodStatic("gps: " + status.ToString()); break; case GpsEvent.SatelliteStatus: if (gpsStatus != null) { gpsSatellitesVisible = 0; gpsSatellitesUsedInFix = 0; gpsSatellitesWithEphemeris = 0; gpsSatellitesWithAlmanac = 0; var satellites = gpsStatus.Satellites; if (satellites != null) { Java.Util.IIterator iterator = satellites.Iterator(); { while (iterator.HasNext) { gpsSatellitesVisible++; var s = (GpsSatellite)iterator.Next(); if (s.UsedInFix()) { gpsSatellitesUsedInFix++; } if (s.HasEphemeris) { gpsSatellitesWithEphemeris++; } if (s.HasAlmanac) { gpsSatellitesWithAlmanac++; } } } if (gpsSatellitesUsedInFix > 3) { status = IDeviceGpsStatus.Connected; } } } break; case GpsEvent.Started: status = IDeviceGpsStatus.Started; DeviceDebugAndroid.LogToFileMethodStatic("gps: " + status.ToString()); break; case GpsEvent.Stopped: status = IDeviceGpsStatus.Stopped; DeviceDebugAndroid.LogToFileMethodStatic("gps: " + status.ToString()); break; } if (listener != null) { listener.OnGpsStatusUpdate(); } } }
public static void SendEvent(BranchEvent e, Context c) { IO.Branch.Referral.Util.BranchEvent branchEvent = null; JSONObject parameters = new JSONObject(e.ToJsonString()); if (parameters.Has("event_name")) { // try to create standart event foreach (IO.Branch.Referral.Util.BRANCH_STANDARD_EVENT type in IO.Branch.Referral.Util.BRANCH_STANDARD_EVENT.Values()) { if (type.Name.Equals(parameters.GetString("event_name"))) { branchEvent = new IO.Branch.Referral.Util.BranchEvent(type); break; } } // if standart event can't be created, let's create custom event if (branchEvent == null) { branchEvent = new IO.Branch.Referral.Util.BranchEvent(parameters.GetString("event_name")); } } else { return; } if (parameters.Has("transaction_id")) { branchEvent.SetTransactionID(parameters.GetString("transaction_id")); } if (parameters.Has("customer_event_alias")) { branchEvent.SetCustomerEventAlias(parameters.GetString("customer_event_alias")); } if (parameters.Has("affiliation")) { branchEvent.SetAffiliation(parameters.GetString("affiliation")); } if (parameters.Has("coupon")) { branchEvent.SetCoupon(parameters.GetString("coupon")); } if (parameters.Has("currency")) { branchEvent.SetCurrency(IO.Branch.Referral.Util.CurrencyType.GetValue(parameters.GetString("currency"))); } if (parameters.Has("tax")) { branchEvent.SetTax(parameters.GetDouble("tax")); } if (parameters.Has("revenue")) { branchEvent.SetRevenue(parameters.GetDouble("revenue")); } if (parameters.Has("description")) { branchEvent.SetDescription(parameters.GetString("description")); } if (parameters.Has("shipping")) { branchEvent.SetRevenue(parameters.GetDouble("shipping")); } if (parameters.Has("search_query")) { branchEvent.SetSearchQuery(parameters.GetString("search_query")); } if (parameters.Has("custom_data")) { JSONObject dict = parameters.GetJSONObject("custom_data"); Java.Util.IIterator keys = dict.Keys(); while (keys.HasNext) { String key = keys.Next().ToString(); branchEvent.AddCustomDataProperty(key, dict.GetString(key)); } } if (parameters.Has("content_items")) { JSONArray array = parameters.GetJSONArray("content_items"); for (int i = 0; i < array.Length(); i++) { branchEvent.AddContentItems(ToNativeBUO(new BranchUniversalObject(array.Get(i).ToString()))); } } // log event branchEvent.LogEvent(c); }