Skip to content

Instantly share code, notes, and snippets.

@migueldeicaza
Created February 19, 2010 17:01
Show Gist options
  • Save migueldeicaza/308903 to your computer and use it in GitHub Desktop.
Save migueldeicaza/308903 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.UIKit;
using MonoTouch.Dialog;
namespace MIX10
{
public class FavoritesViewController : DialogViewController
{
public FavoritesViewController () : base (null)
{
}
public override void LoadView ()
{
Root = new RootElement ("Favorites");
base.LoadView ();
}
public override void ViewWillAppear (bool animated)
{
// Refetch the data on View Will Appear.
Root = GenerateRoot ();
}
RootElement GenerateRoot ()
{
var favs = AppDelegate.UserData.GetFavoriteCodes();
return new RootElement ("Favorites") {
from s in AppDelegate.ConferenceData.Sessions
where favs.Contains(s.Code)
group s by s.Start.Ticks into g
select new Section (HomeViewController.MakeCaption ("", new DateTime (g.Key))) {
from hs in g
select (Element) new SessionElement (hs)
}};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment