Пример #1
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);


            /*
             * 1.	Locate the OnCreate method in MainActivity.cs.
             * 2.	Comment out the existing ListAdapter assignment.
             * 3.	Load the data using SongLoader.Load. This method uses the Task based Async pattern; you will need to await the call and decorate OnCreate with the async keyword.
             * 4.	Call ToList on the IEnumerable<Song> returned from SongLoader.Load - we'll use this in the next step. (This will require the System.Linq namespace.)
             * 5.	Create a new ListAdapter<Song> and assign the following properties:
             * 6.	Set the DataSource property to your new list.
             * 7.	Set the TextProc to a lambda that returns the song name: s => s.Name.
             * 8.	Set the DetailTextProc to a lambda that returns the artist and album: s => s.Artist + " - " + s.Album.
             * 9.	Assign the object to the ListAdapter property.
             */
            //ListAdapter = new ListAdapter<string>() {
            //	DataSource = new[] { "One", "Two", "Three" }
            //};

            // Load the data
            var data = await SongLoader.Load();

            ListAdapter = new ListAdapter <Song>()
            {
                DataSource     = data.ToList(),
                TextProc       = s => s.Name,
                DetailTextProc = s => s.Artist + " - " + s.Album
            };
        }
Пример #2
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            //SongLoader.Loader = new StreamLoader();
            //this.DataContext = await SongLoader.Load();

            this.DataContext = await SongLoader.ImprovedLoad();
        }
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            /*
             *          ListAdapter = new ListAdapter<string>() {
             *                  DataSource = new[] { "One", "Two", "Three" }
             *          };
             */

            var data = await SongLoader.Load();

            /*
             * you can't do ListAdapter.DataSource because ListAdapter is of type IListAdapter and not ListAdapter, so it can't access the properties of the subclass
             */

            ListAdapter = new ListAdapter <Song>()
            {
                DataSource = data.ToList(),

                // you are saying that whatever it gets as parameter, return the property Name (as it knows that is a Song object when you created the ListAdapter<Song>
                TextProc       = s => s.Name,
                DetailTextProc = s => s.Artist + " - " + s.Album
            };
        }
Пример #4
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            SongLoader.Loader = new StreamLoader();
            this.DataContext  = await SongLoader.Load();
        }
Пример #5
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            var data = await SongLoader.Load();

            ListAdapter = new ListAdapter <Song>()
            {
                DataSource     = data.ToList(),
                TextProc       = s => s.Name,
                DetailTextProc = s => s.Artist + " - " + s.Album
            };
        }
Пример #6
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            var songList = await SongLoader.Load();

            ListAdapter = new ListAdapter <Song>()
            {
                DataSource     = songList.ToList(),
                TextProc       = s => s.Name,
                DetailTextProc = s => $"{s.Artist}-{s.Album}",
            };
        }
Пример #7
0
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var data = await SongLoader.Load();

            TableView.Source = new ViewControllerSource <Song>(TableView)
            {
                DataSource     = data.ToList(),
                TextProc       = (s) => s.Name,
                DetailTextProc = s => $"{s.Artist} - {s.Album}"
            };
        }
Пример #8
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SongLoader.Loader = new StreamLoader(this);
            var data = await SongLoader.Load();

            ListAdapter = new ListAdapter <Song>()
            {
                DataSource     = data.ToList(),
                TextProc       = (arg) => arg.Name,
                DetailTextProc = (arg) => $"{arg.Artist} - {arg.Album}"
            };
        }
Пример #9
0
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var data = await SongLoader.Load();

            // Register the TableView's data source
            TableView.Source = new ViewControllerSource <Song>(TableView)
            {
                DataSource     = data.ToList(),
                TextProc       = s => s.Name,
                DetailTextProc = s => s.Artist + " - " + s.Album,
            };
        }
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SongLoader.StreamLoader = new StreamLoader(this.ApplicationContext);

            var data = await SongLoader.Load();

            this.ListAdapter = new ListAdapter <Song>
            {
                DataSource     = data.ToList(),
                TextProc       = s => s.Name,
                DetailTextProc = s => s.Artist + " - " + s.Album
            };
        }
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //TableView.Source = new ViewControllerSource<string>(TableView) {
            //	DataSource = new string[] { "One", "Two", "Three" },
            //};
            var data = await SongLoader.Load();

            TableView.Source = new ViewControllerSource <Song>(TableView)
            {
                DataSource     = data.ToList(),
                TextProc       = s => s.Name,
                DetailTextProc = s => s.Artist + " - " + s.Album
            };
        }
Пример #12
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // set the loader property before calling load song
            SongLoader.Loader = new StreamLoader(this);

            var data = await SongLoader.Load();

            ListAdapter = new ListAdapter <Song>()
            {
                DataSource     = data.ToList(),
                TextProc       = s => s.Name,
                DetailTextProc = s => s.Artist + " - " + s.Album
            };
        }
Пример #13
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            //ListAdapter = new ListAdapter<string>() {
            //	DataSource = new[] { "One", "Two", "Three" }
            //};
            var data = await SongLoader.Load();

            ListAdapter = new ListAdapter <Song>()
            {
                DataSource     = data.ToList(),
                TextProc       = s => s.Name,
                DetailTextProc = s => s.Artist + ' ' + s.Album
            };
        }
Пример #14
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            //ListAdapter = new ListAdapter<string>() {
            //	DataSource = new[] { "One", "Two", "Three" }
            //};
            var songList = await SongLoader.Load();

            ListAdapter = new ListAdapter <Song>
            {
                DataSource     = songList.ToList(),
                TextProc       = (arg) => arg.Name,
                DetailTextProc = (arg) => $"{arg.Artist} - {arg.Album}"
            };
        }
Пример #15
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            //ListAdapter = new ListAdapter<string>() {
            //	DataSource = new[] { "One", "Two", "Three" }
            //};

            SongLoader songLoader = new SongLoader(new StreamLoaderDroid());
            var        songList   = await songLoader.Load();

            ListAdapter = new ListAdapter <Song>()
            {
                DataSource     = songList.ToList(),
                TextProc       = song => song.Name,
                DetailTextProc = song => $"{song.Artist} - {song.Album}"
            };
        }
Пример #16
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            ////TableView.Source = new ViewControllerSource<string>(TableView) {
            ////	DataSource = new string[] { "One", "Two", "Three" },
            ////};
            var songs = await SongLoader.Load();

            ViewControllerSource <Song> viewSourceController = new ViewControllerSource <Song>(TableView)
            {
                DataSource     = songs.ToList(),
                TextProc       = (a) => a.Name,
                DetailTextProc = (a) => a.Artist + " - " + a.Album
            };

            TableView.Source = viewSourceController;
        }
Пример #17
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            ////ListAdapter = new ListAdapter<string>() {
            ////	DataSource = new[] { "One", "Two", "Three" }
            ////};
            var songs = await SongLoader.Load();

            ListAdapter <Song> adapter = new ListAdapter <Song>()
            {
                DataSource     = songs.ToList(),
                DetailTextProc = (a) => a.Artist + " - " + a.Album,
                TextProc       = (a) => a.Name
            };

            ListAdapter = adapter;
        }
Пример #18
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);


            // inject the dependency
            SongLoader.Loader = new StreamLoader(this);

            // Load Data
            var data = await SongLoader.Load();

            ListAdapter = new ListAdapter <Song>()
            {
                DataSource     = data.ToList(),
                TextProc       = s => s.Name,
                DetailTextProc = s => s.Artist + " - " + s.Album
            };
        }
Пример #19
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

//			ListAdapter = new ListAdapter<string>() {
//				DataSource = new[] { "One", "Two", "Three" }
//			};

            var data = await SongLoader.Load();

            var adapter = new ListAdapter <Song> ();

            adapter.DataSource     = data.ToList();
            adapter.TextProc       = s => s.Name;
            adapter.DetailTextProc = s => s.Artist + " - " + s.Album;

            this.ListAdapter = adapter;
        }
Пример #20
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var tempData = await SongLoader.Load();

            //var tempData = Enumerable.Range(1, 3).Select(i =>
            //{
            //    return new
            //    {
            //        Name = "Song" + i,
            //        Artist = "Artist" + i,
            //        Album = "Album" + i
            //    };
            //}).ToList();

            this.DataContext = tempData.ToList();
        }
Пример #21
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            //TableView.Source = new ViewControllerSource<string>(TableView) {
            //	DataSource = new string[] { "One", "Two", "Three" },
            //};

            SongLoader songLoader = new SongLoader(new StreamLoaderIOS());
            var        songList   = await songLoader.Load();

            TableView.Source = new ViewControllerSource <Song>(TableView)
            {
                DataSource     = songList.ToList(),
                TextProc       = song => song.Name,
                DetailTextProc = song => $"{song.Artist} - {song.Album}"
            };
        }
Пример #22
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            /* var tempData = Enumerable.Range(1, 3).Select(i =>
             * {
             *   return new
             *   {
             *       Name = "Song" + i,
             *       Artist = "Artist" + i,
             *       Album = "Album" + i
             *   };
             * }).ToList();
             *
             * this.DataContext = tempData;*/
            var data = await SongLoader.Load();

            DataContext = data.ToList();
        }
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            SongLoader.Loader = new StreamLoader();
            var data = await SongLoader.Load();

            // Register the TableView's data source
            TableView.Source = new ViewControllerSource <Song>(TableView)
            {
                DataSource     = data.ToList(),
                TextProc       = s => s.Name,
                DetailTextProc = s => s.Artist + " - " + s.Album,
            };

            //TableView.Source = new ViewControllerSource<string>(TableView) {
            //	DataSource = new string[] { "One", "Two", "Three" },
            //};
        }
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

//			TableView.Source = new ViewControllerSource<string>(TableView) {
//				DataSource = new string[] { "One", "Two", "Three" },
//			};

            var data = await SongLoader.Load();

            var viewControllerSource = new ViewControllerSource <Song> (this.TableView);

            viewControllerSource.DataSource = data.ToList();

            viewControllerSource.TextProc       = s => s.Name;
            viewControllerSource.DetailTextProc = s => s.Artist + " - " + s.Album;

            this.TableView.Source = viewControllerSource;
        }
Пример #25
0
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //TableView.Source = new ViewControllerSource<string>(TableView) {
            //	DataSource = new string[] { "One", "Two", "Three" },
            //};

            var songList = await SongLoader.Load();

            var viewControllerSource = new ViewControllerSource <Song>(TableView)
            {
                DataSource     = songList.ToList(),
                TextProc       = (arg) => arg.Name,
                DetailTextProc = (arg) => $"{arg.Artist} - {arg.Album}"
            };

            TableView.Source = viewControllerSource;
        }
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            var dataSource = await SongLoader.Load();

            //var source = dataSource.Select(c => c.Artist + " - " + c.Album).ToList();

            TableView.Source = new ViewControllerSource <Song>(TableView)
            {
                DataSource     = dataSource.ToList(),
                TextProc       = s => s.Name,
                DetailTextProc = c => c.Artist + " - " + c.Album,
            };


            //TableView.Source = new ViewControllerSource<string>(TableView) {
            //	DataSource = await SongLoader.Load(), // DataSource = new string[] { "One", "Two", "Three" },
            //};
        }
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            var data = await SongLoader.Load();

            //this.TableView.Source = new ViewControllerSource<string>(this.TableView)
            //{
            //    DataSource = new[]
            //    {
            //        "One",
            //        "Two",
            //        "Three"
            //    }
            //};
            this.TableView.Source = new ViewControllerSource <Song>(this.TableView)
            {
                DataSource     = data.ToList(),
                TextProc       = s => s.Name,
                DetailTextProc = s => $"{s.Artist} - {s.Album}"
            };
        }
Пример #28
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            var songList = await SongLoader.Load();

            this.ListAdapter = new ListAdapter <Song>()
            {
                DataSource     = songList.ToList(),
                TextProc       = s => s.Name,
                DetailTextProc = s => $"{s.Artist} - {s.Album}"
            };

            //this.ListAdapter = new ListAdapter<string>
            //{
            //    DataSource = new[]
            //    {
            //        "One",
            //        "Two",
            //        "Three"
            //    }
            //};
        }
Пример #29
0
 /// <summary>
 /// Invoked when this page is about to be displayed in a Frame.
 /// </summary>
 /// <param name="e">Event data that describes how this page was reached.
 /// This parameter is typically used to configure the page.</param>
 protected override async void OnNavigatedTo(NavigationEventArgs e)
 {
     DataContext = await SongLoader.Load();
 }
Пример #30
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            DataContext = await SongLoader.Load();
        }