public static DateTime?FromUnixTime(this Java.Lang.Long unixTimeMillis) { if (unixTimeMillis == null) { return(null); } return(FromUnixTime(unixTimeMillis.LongValue())); }
private void updateLocations(int buttonId) { switch (buttonId) { case Resource.Id.radioFoursquare: service = new Foursquare( this, "[Foursquare Client ID]", "[Foursquare Client Secret]" ); break; case Resource.Id.radioGoogleplaces: service = new GooglePlaces( this, "[Google Places Client ID]" ); break; case Resource.Id.radioYelp: service = new Yelp( this, "[Yelp Client ID]", "[Yelp Client Secret]" ); break; } Java.Lang.Long range = new Java.Lang.Long(2000); new System.Threading.Thread(new System.Threading.ThreadStart(() => { // run in background IList <POI> pois = service.GetNearbyPOIs( (Java.Lang.Double)lat, (Java.Lang.Double)lng, range, "Pizza", null ); POI[] poiArray = new POI[pois.Count]; pois.CopyTo(poiArray, 0); Array.Sort(poiArray, (x, y) => (dist(x).CompareTo(dist(y)))); RunOnUiThread(() => { // manipulate UI controls ListView lv = FindViewById <ListView>(Resource.Id.listView1); //lv.Adapter = new ArrayAdapter<POI>(this, Android.Resource.Layout.SimpleListItem1, pois); lv.Adapter = new POIAdapter(this, poiArray, lat, lng); }); })).Start(); }
public void Put(string key, long value) { if (id_put_Ljava_lang_String_Ljava_lang_Long_ == IntPtr.Zero) { id_put_Ljava_lang_String_Ljava_lang_Long_ = JNIEnv.GetMethodID(class_ref, "put", "(Ljava/lang/String;Ljava/lang/Long;)V"); } IntPtr jkey = JNIEnv.NewString(key); try { using (var val = new Java.Lang.Long(value)) JNIEnv.CallVoidMethod(Handle, id_put_Ljava_lang_String_Ljava_lang_Long_, new JValue(jkey), new JValue(val)); } finally { JNIEnv.DeleteLocalRef(jkey); } }
public long GetAsLong(string key) { if (id_getAsLong_Ljava_lang_String_ == IntPtr.Zero) { id_getAsLong_Ljava_lang_String_ = JNIEnv.GetMethodID(class_ref, "getAsLong", "(Ljava/lang/String;)Ljava/lang/Long;"); } IntPtr jkey = JNIEnv.NewString(key); try { using (var ret = new Java.Lang.Long(JNIEnv.CallObjectMethod(Handle, id_getAsLong_Ljava_lang_String_, new JValue(jkey)), JniHandleOwnership.TransferLocalRef | JniHandleOwnership.DoNotRegister)) return((long)ret); } finally { JNIEnv.DeleteLocalRef(jkey); } }
internal static Notification ToNotification(this Huawei.Hms.Push.RemoteMessage.Notification notification) { Notification result = new Notification(); PropertyInfo[] properties = typeof(Notification).GetProperties(); foreach (PropertyInfo property in properties) { PropertyInfo notificationProperty = notification.GetType().GetProperty(property.Name); if (notificationProperty != null) { if (property.PropertyType == notificationProperty.PropertyType) { property.SetValue(result, notificationProperty.GetValue(notification, null)); } else if (notificationProperty.PropertyType == typeof(Java.Lang.Integer) && property.PropertyType == typeof(int?))//Java.Lang.Integer to int? { object valueToSet = notificationProperty.GetValue(notification, null); Java.Lang.Integer javaInt = valueToSet as Java.Lang.Integer; if (javaInt != null) { property.SetValue(result, javaInt.IntValue()); } else { Log.Error("ToNotification", $"({property.PropertyType.FullName}){property.Name} is null"); } } else if (notificationProperty.PropertyType == typeof(Java.Lang.Long) && property.PropertyType == typeof(long?))//Java.Lang.Long to long? { object valueToSet = notificationProperty.GetValue(notification, null); Java.Lang.Long javaLong = valueToSet as Java.Lang.Long; if (javaLong != null) { property.SetValue(result, javaLong.IntValue()); } else { Log.Error("ToNotification", $"({property.PropertyType.FullName}){property.Name} is null"); } } else if (notificationProperty.PropertyType == typeof(Android.Net.Uri) && property.PropertyType == typeof(System.Uri))//Android.Net to System.Uri { object valueToSet = notificationProperty.GetValue(notification, null); Android.Net.Uri androidUri = valueToSet as Android.Net.Uri; if (androidUri != null) { property.SetValue(result, new System.Uri(androidUri.ToString())); } else { Log.Error("ToNotification", $"({property.PropertyType.FullName}){property.Name} is null"); } } else { Log.Error("ToNotification", $"[{property.Name}]{property.PropertyType} is not equal to {notificationProperty.PropertyType}"); } } else { Log.Error("ToNotification", $"{property.Name} is null"); } } return(result); }
public static long longValue(this Java.Lang.Long value) { return(value.LongValue()); }
public void Put(string key, long value) { if (id_put_Ljava_lang_String_Ljava_lang_Long_ == IntPtr.Zero) id_put_Ljava_lang_String_Ljava_lang_Long_ = JNIEnv.GetMethodID (class_ref, "put", "(Ljava/lang/String;Ljava/lang/Long;)V"); IntPtr jkey = JNIEnv.NewString (key); try { using (var val = new Java.Lang.Long (value)) JNIEnv.CallVoidMethod (Handle, id_put_Ljava_lang_String_Ljava_lang_Long_, new JValue (jkey), new JValue (val)); } finally { JNIEnv.DeleteLocalRef (jkey); } }
public long GetAsLong(string key) { if (id_getAsLong_Ljava_lang_String_ == IntPtr.Zero) id_getAsLong_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "getAsLong", "(Ljava/lang/String;)Ljava/lang/Long;"); IntPtr jkey = JNIEnv.NewString (key); try { using (var ret = new Java.Lang.Long (JNIEnv.CallObjectMethod (Handle, id_getAsLong_Ljava_lang_String_, new JValue (jkey)), JniHandleOwnership.TransferLocalRef | JniHandleOwnership.DoNotRegister)) return (long) ret; } finally { JNIEnv.DeleteLocalRef (jkey); } }