static int ComparisonLocalNotifications(LocalNotificationDesc one, LocalNotificationDesc two) { if (one.fireDate < two.fireDate) { return(-1); } else { return(1); } }
private static List <LocalNotificationDesc> GetSortedEvents() { List <LocalNotificationDesc> arrEvents = new List <LocalNotificationDesc>(mInstance._allEvents); int countNightEvents = 0; foreach (LocalNotificationDesc desc in arrEvents) { if (IsNight(desc.fireDate)) { ++countNightEvents; } } if (countNightEvents > 0) { LocalNotificationDesc newDesc = new LocalNotificationDesc(); if (countNightEvents > 1) { newDesc.message = GameStrings.GetLocalizedString(GameStrings.LocalNotifications_CommonText); } bool isFound = false; do { isFound = false; foreach (LocalNotificationDesc desc in arrEvents) { if (IsNight(desc.fireDate)) { newDesc.fireDate = CreateDateByMorning(desc.fireDate); if (countNightEvents == 1) { newDesc.message = desc.message; } isFound = true; arrEvents.Remove(desc); break; } } } while (isFound); arrEvents.Add(newDesc); } arrEvents.Sort(ComparisonLocalNotifications); return(arrEvents); }