protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_section_uer); SetBackBtn(); SetTitle("Section Use"); _recyclerView = FindViewById <RecyclerView>(Resource.Id.rv_list); _recyclerView.SetLayoutManager(new GridLayoutManager(this, 2)); _data = DataServer.GetSampleData(); var sectionAdapter = new SectionAdapter(Resource.Layout.item_section_content, Resource.Layout.def_section_head, _data); sectionAdapter.ItemClick += (s, e) => { var mySection = _data[e.Position]; if (mySection.IsHeader) { Toast.MakeText(this, mySection.Header, ToastLength.Long).Show(); } else { Toast.MakeText(this, (mySection.T as Video).Name, ToastLength.Long).Show(); } }; sectionAdapter.ItemChildClick += (s, e) => { Toast.MakeText(this, "onItemChildClick" + e.Position, ToastLength.Long).Show(); }; _recyclerView.SetAdapter(sectionAdapter); }
async Task PopulateList() { sections.Clear(); try { var request = YoutubeManager.YoutubeService.ChannelSections.List("snippet,contentDetails"); request.ChannelId = item.YoutubeID; var response = await request.ExecuteAsync(); for (int i = 0; i < response.Items.Count; i++) { if (response.Items[i].ContentDetails?.Playlists?.Count == 1) { sections.Add(new Section(null, SectionType.SinglePlaylist)); LoadPlaylist(sections.Count - 1, response.Items[i].ContentDetails.Playlists[0]); } else if (response.Items[i].ContentDetails?.Playlists?.Count > 1) { sections.Add(new Section(response.Items[i].Snippet.Title, SectionType.PlaylistList)); LoadMulitplePlaylists(sections.Count - 1, response.Items[i].ContentDetails.Playlists); } else if (response.Items[i].ContentDetails?.Channels?.Count > 1) { sections.Add(new Section(response.Items[i].Snippet.Title, SectionType.ChannelList)); LoadChannels(sections.Count - 1, response.Items[i].ContentDetails.Channels); } } adapter = new SectionAdapter(sections); ListView.SetAdapter(adapter); } catch (System.Net.Http.HttpRequestException) { System.Console.WriteLine("&Channel section list time out"); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.SectionLayout); _sectionRecyclerView = FindViewById <RecyclerView>(Resource.Id.sectionRecyclerView); var layoutManager = new LinearLayoutManager(BaseContext); _sectionRecyclerView.SetLayoutManager(layoutManager); _toast = Toast.MakeText(BaseContext, "Action invoked", ToastLength.Short); var defaultModel = new SectionModel() { SectionAction = () => { _toast.Show(); }, HasBorder = (bool)EOSThemeProvider.Instance.GetCurrentTheme().ThemeValues[EOSConstants.HasSectionBorder], HasButton = (bool)EOSThemeProvider.Instance.GetCurrentTheme().ThemeValues[EOSConstants.HasSectionAction] }; _dataSource = new List <object>() { defaultModel, "Terms of Use", "Privacy Policy", "About Us" }; var adapter = new SectionAdapter(_dataSource); _sectionRecyclerView.SetAdapter(adapter); _themeDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.themeDropDown); _sectionNameDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.sectionNameDropDown); _buttonTextDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.buttonTextDropDown); _sectionFontDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.sectionNameFontDropDown); _buttonFontDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.buttonTextFontDropDown); _sectionNameLetterSpacingDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.sectionNameLetterSpacingDropDown); _buttonTextLetterSpacingDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.buttonTextLetterSpacingDropDown); _sectionTextSizeDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.sectionTextSizeDropDown); _buttonTextSizeDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.buttonTextSizeDropDown); _sectionTextColorDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.sectionTextColorDropDown); _buttonTextColorDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.buttonTextColorDropDown); _backgroundColorDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.backgroundColorDropDown); _borderColorDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.borderColorDropDown); _borderWidthDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.borderWidthDropDown); _paddingTopDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.paddingTopDropDown); _paddingBottomDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.paddingBottomDropDown); _paddingLeftDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.paddingLeftDropDown); _paddingRightDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.paddingRightDropDown); _hasBorderSwitch = FindViewById <Switch>(Resource.Id.switchHasBorder); _hasButtonSwitch = FindViewById <Switch>(Resource.Id.switchHasButton); _resetCustomizationButton = FindViewById <Button>(Resource.Id.buttonResetCustomization); _themeDropDown.Name = Fields.Theme; _themeDropDown.SetupAdapter(ThemeTypes.ThemeCollection.Select(item => item.Key).ToList()); _themeDropDown.ItemSelected += ThemeItemSelected; _sectionNameDropDown.Name = Fields.SectionName; _sectionNameDropDown.SetupAdapter(Titles.TitleCollection.Select(item => item.Key).ToList()); _sectionNameDropDown.ItemSelected += SectionNameItemSelected; _buttonTextDropDown.Name = Fields.ButtonText; _buttonTextDropDown.SetupAdapter(Titles.TitleCollection.Select(item => item.Key).ToList()); _buttonTextDropDown.ItemSelected += ButtonTextItemSelected; _sectionNameLetterSpacingDropDown.Name = Fields.SectionNameLetterSpacing; _sectionNameLetterSpacingDropDown.SetupAdapter(SectionConstants.SectionLetterSpacings.Select(item => item.Key).ToList()); _sectionNameLetterSpacingDropDown.ItemSelected += SectionNameLetterSpacingItemSelected; _buttonTextLetterSpacingDropDown.Name = Fields.ButtonTextLetterSpacing; _buttonTextLetterSpacingDropDown.SetupAdapter(SectionConstants.ButtonLetterSpacings.Select(item => item.Key).ToList()); _buttonTextLetterSpacingDropDown.ItemSelected += ButtonTextLetterSpacingItemSelected; _sectionTextSizeDropDown.Name = Fields.SectionTextSize; _sectionTextSizeDropDown.SetupAdapter(SectionConstants.SectionTextSizes.Select(item => item.Key).ToList()); _sectionTextSizeDropDown.ItemSelected += SectionTextSizeItemSelected; _buttonTextSizeDropDown.Name = Fields.ButtonTextSize; _buttonTextSizeDropDown.SetupAdapter(SectionConstants.ButtonTextSizes.Select(item => item.Key).ToList()); _buttonTextSizeDropDown.ItemSelected += ButtonTextSizeItemSelected; _sectionTextColorDropDown.Name = Fields.SectionTextColor; _sectionTextColorDropDown.SetupAdapter(SectionConstants.SectionTextColors.Select(item => item.Key).ToList()); _sectionTextColorDropDown.ItemSelected += SectionTextColorItemSelected; _buttonTextColorDropDown.Name = Fields.ButtonTextColor; _buttonTextColorDropDown.SetupAdapter(SectionConstants.ButtonTextColors.Select(item => item.Key).ToList()); _buttonTextColorDropDown.ItemSelected += ButtonTextColorItemSelected; _backgroundColorDropDown.Name = Fields.BackgroundColor; _backgroundColorDropDown.SetupAdapter(SectionConstants.BackgroundsColors.Select(item => item.Key).ToList()); _backgroundColorDropDown.ItemSelected += BackgroundColorItemSelected; _borderColorDropDown.Name = Fields.BorderColor; _borderColorDropDown.SetupAdapter(SectionConstants.BorderColors.Select(item => item.Key).ToList()); _borderColorDropDown.ItemSelected += BorderColorItemSelected; _borderWidthDropDown.Name = Fields.BorderWidth; _borderWidthDropDown.SetupAdapter(SectionConstants.BorderWidth.Select(item => item.Key).ToList()); _borderWidthDropDown.ItemSelected += BorderWidthItemSelected; _paddingTopDropDown.Name = Fields.PaddingTop; _paddingTopDropDown.SetupAdapter(SectionConstants.TopPaddings.Select(item => item.Key).ToList()); _paddingTopDropDown.ItemSelected += PaddingTopItemSelected; _paddingBottomDropDown.Name = Fields.PaddingBottom; _paddingBottomDropDown.SetupAdapter(SectionConstants.BottomPaddings.Select(item => item.Key).ToList()); _paddingBottomDropDown.ItemSelected += PaddingBottomItemSelected; _paddingLeftDropDown.Name = Fields.PaddingLeft; _paddingLeftDropDown.SetupAdapter(SectionConstants.LeftPaddings.Select(item => item.Key).ToList()); _paddingLeftDropDown.ItemSelected += PaddingLeftItemSelected; _paddingRightDropDown.Name = Fields.PaddingRight; _paddingRightDropDown.SetupAdapter(SectionConstants.RightPaddings.Select(item => item.Key).ToList()); _paddingRightDropDown.ItemSelected += PaddingRightItemSelected; _sectionFontDropDown.Name = Fields.SectionNameFont; _sectionFontDropDown.SetupAdapter(SectionConstants.SectionFonts.Select(item => item.Key).ToList()); _sectionFontDropDown.ItemSelected += SectionFontItemSelected; _buttonFontDropDown.Name = Fields.ButtonTextFont; _buttonFontDropDown.SetupAdapter(SectionConstants.ButtonFonts.Select(item => item.Key).ToList()); _buttonFontDropDown.ItemSelected += ButtonFontItemSelected; _hasBorderSwitch.CheckedChange += HasBorderSwitch_CheckedChange; _hasButtonSwitch.CheckedChange += HasButtonSwitch_CheckedChange; _resetCustomizationButton.Click += ResetCustomizationClick; SetCurrenTheme(EOSThemeProvider.Instance.GetCurrentTheme()); }
/// <summary> /// Constructs a Section with the specified header /// </summary> /// <param name="caption"> /// The header to display /// </param> public Section(string caption) : base(caption) { Adapter = new SectionAdapter(this); }
/// <summary> /// Constructs a Section without header or footers. /// </summary> public Section() : this("") { Adapter = new SectionAdapter(this); }
private async Task PopulateView() { if (!populating) { populating = true; sections = new List <Section>(); if (MusicPlayer.UseCastPlayer || (MusicPlayer.queue != null && MusicPlayer.queue?.Count > 0)) { Section queue = new Section("Queue", SectionType.SinglePlaylist, MusicPlayer.queue); sections.Add(queue); } Section shuffle = new Section(Resources.GetString(Resource.String.shuffle), SectionType.Shuffle); sections.Add(shuffle); await Task.Run(() => { if (MainActivity.instance.HasReadPermission()) { if (Looper.MyLooper() == null) { Looper.Prepare(); } Android.Net.Uri musicUri = MediaStore.Audio.Media.ExternalContentUri; List <Song> allSongs = new List <Song>(); CursorLoader cursorLoader = new CursorLoader(MainActivity.instance, musicUri, null, null, null, null); ICursor musicCursor = (ICursor)cursorLoader.LoadInBackground(); if (musicCursor != null && musicCursor.MoveToFirst()) { int titleID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Title); int artistID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Artist); int albumID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Album); int thisID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Id); int pathID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Data); do { string Artist = musicCursor.GetString(artistID); string Title = musicCursor.GetString(titleID); string Album = musicCursor.GetString(albumID); long AlbumArt = musicCursor.GetLong(musicCursor.GetColumnIndex(MediaStore.Audio.Albums.InterfaceConsts.AlbumId)); long id = musicCursor.GetLong(thisID); string path = musicCursor.GetString(pathID); if (Title == null) { Title = "Unknown Title"; } if (Artist == null) { Artist = "Unknow Artist"; } if (Album == null) { Album = "Unknow Album"; } allSongs.Add(new Song(Title, Artist, Album, null, AlbumArt, id, path)); }while (musicCursor.MoveToNext()); musicCursor.Close(); } Random r = new Random(); List <Song> songList = allSongs.OrderBy(x => r.Next()).ToList(); if (songList.Count > 0) { Section featured = new Section(Resources.GetString(Resource.String.featured), SectionType.SinglePlaylist, songList.GetRange(0, songList.Count > 50 ? 50 : songList.Count)); sections.Add(featured); } } }); List <Song> favorites = await SongManager.GetFavorites(); if (favorites.Count > 0) { sections.Add(new Section("Fav", SectionType.SinglePlaylist, favorites)); } view.FindViewById(Resource.Id.loading).Visibility = ViewStates.Gone; adapter = new SectionAdapter(sections); ListView.SetAdapter(adapter); adapter.ItemClick += ListView_ItemClick; ListView.SetItemAnimator(new DefaultItemAnimator()); (List <PlaylistItem> playlists, string error) = await PlaylistManager.GetLocalPlaylists(false); if (playlists != null) { (List <PlaylistItem> pl, List <PlaylistItem> sp) = await PlaylistManager.ProcessSyncedPlaylists(playlists); List <PlaylistItem> saved = await PlaylistManager.GetSavedYoutubePlaylists(sp, null); sp.AddRange(saved); sp.AddRange(pl); sections.Add(new Section(GetString(Resource.String.playlists), SectionType.PlaylistList, sp)); adapter.NotifyItemInserted(sections.Count - 1); } else { List <PlaylistItem> saved = await PlaylistManager.GetSavedYoutubePlaylists(null, null); if (saved != null && saved.Count > 0) { sections.Add(new Section(GetString(Resource.String.playlists), SectionType.PlaylistList, saved)); adapter.NotifyItemInserted(sections.Count - 1); } } populating = false; } }