using System; using System.Collections.Generic; using System.Linq; using Android.Content; using Android.Widget; namespace GUTSchedule.Droid { public static class Extensions { /// /// Sets array as Spinner dropdown list content /// /// Array items type /// Spinner on which array will be assigned to /// Current activity context. In most common cases this will do /// Array of items to be displayed public static void SetList(this Spinner spinner, Context context, IEnumerable array) { ArrayAdapter adapter = new ArrayAdapter(context, Resource.Layout.support_simple_spinner_dropdown_item, array.ToList()); spinner.Adapter = adapter; } /// /// Converts to milliseconds count /// /// In the nearest future we will be fucked because of that shit /// which is to be converted to UNIX time /// which is represented by total milliseconds count passed since 1970 public static long ToUnixTime(this DateTime dt) => (long)dt.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds; } }