This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"kind": "youtube#searchListResponse", | |
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/tXySRT-f4qSG4YdRv0YhL_k79fE\"", | |
"nextPageToken": "CBQQAA", | |
"regionCode": "NL", | |
"pageInfo": { | |
"totalResults": 587, | |
"resultsPerPage": 20 | |
}, | |
"items": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var httpClient = new HttpClient()) | |
{ | |
var videoIds = new List<string>(); | |
var json = await httpClient.GetStringAsync(channelUrl); | |
// Deserialize our data, this is in a simple List format | |
var response = JsonConvert.DeserializeObject<YouTubeApiListRoot>(json); | |
// Add all the video id's we've found to our list. | |
videoIds.AddRange(response.items.Select(item => item.id.videoId)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var videoIdString = string.Join(",", videoIds); | |
var youtubeItems = new List<YouTubeItem>(); | |
using (var httpClient = new HttpClient()) | |
{ | |
var json = await httpClient.GetStringAsync(string.Format(detailsUrl, videoIdString)); | |
var response = JsonConvert.DeserializeObject<YouTubeApiDetailsRoot>(json); | |
foreach (var item in response.items) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ListView ItemsSource="{Binding Items}" HasUnevenRows="True"> | |
<ListView.ItemTemplate> | |
<DataTemplate> | |
<ViewCell> | |
<StackLayout Orientation="Vertical" Padding="15,20,15,20"> | |
<Image Source="{Binding HighThumbnailUrl}" Aspect="AspectFill" /> | |
<Label Text="{Binding Title}" TextColor="Black" Margin="0,5,0,0" FontSize="15"/> | |
<Label Text="{Binding ChannelTitle}" Margin="0,-5,0,0" TextColor="#767676" FontSize="13"/> | |
<StackLayout Orientation="Horizontal"> | |
<Label Text="{Binding ViewCount, StringFormat='{0:n0} views'}" TextColor="#767676" FontSize="13"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private readonly ObservableRangeCollection<Grouping<string, MyItem>> _myItems = new ObservableRangeCollection<Grouping<string, MyItem>>(); | |
public ObservableCollection<Grouping<string, MyItem>> MyItems => _myItems; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sorted = from item in myItems | |
orderby item.Name | |
group item by item.Name[0].ToString().ToUpperInvariant() into itemGroup | |
select new Grouping<string, MyItem>(itemGroup.Key, itemGroup); | |
_myItems.ReplaceRange(sorted); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[assembly: ExportRenderer(typeof(ListView), typeof(ColoredListViewIndexRenderer))] | |
namespace MyApp.iOS.Renderers | |
{ | |
public class ColoredListViewIndexRenderer : ListViewRenderer | |
{ | |
protected override void OnElementChanged(ElementChangedEventArgs e) | |
{ | |
base.OnElementChanged(e); | |
if (Control == null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ListView ItemsSource="{Binding MyItems}" GroupDisplayBinding="{Binding Key}" GroupShortNameBinding="{Binding Key}"> | |
.... | |
</ListView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ListView ItemsSource="{Binding MyItems}" GroupDisplayBinding="{Binding Key}"> | |
.... | |
</ListView> |