public void Add(Classes.LibraryItem item) { try { var check = LibraryList.FirstOrDefault(a => a.SectionId == item.SectionId); if (check == null) { LibraryList.Add(item); NotifyItemInserted(LibraryList.IndexOf(LibraryList.Last())); } } catch (Exception exception) { Console.WriteLine(exception); } }
//Insert data LibraryItem public void InsertLibraryItem(Classes.LibraryItem libraryItem) { try { using (OpenConnection()) { if (Connection == null) { return; } if (libraryItem == null) { return; } var select = Connection.Table <DataTables.LibraryItemTb>().FirstOrDefault(a => a.SectionId == libraryItem.SectionId); if (select != null) { select.SongsCount = libraryItem.SongsCount; select.BackgroundImage = libraryItem.BackgroundImage; Connection.Update(select); } else { DataTables.LibraryItemTb item = new DataTables.LibraryItemTb { SectionId = libraryItem.SectionId, SectionText = libraryItem.SectionText, SongsCount = libraryItem.SongsCount, BackgroundImage = libraryItem.BackgroundImage }; Connection.Insert(item); } } } catch (Exception exception) { Console.WriteLine(exception); } }
public void Update(Classes.LibraryItem item) { try { var data = LibraryList.FirstOrDefault(a => a.SectionId == item.SectionId); if (data != null) { //if (data.BackgroundImage != item.BackgroundImage) //{ data.VideoCount = item.VideoCount; data.BackgroundImage = item.BackgroundImage; NotifyItemChanged(LibraryList.IndexOf(data)); //} } } catch (Exception exception) { Console.WriteLine(exception); } }
public void AddLibrarySectionViews() { try { var sqlEntity = new SqLiteDatabase(); var check = sqlEntity.Get_LibraryItem(); sqlEntity.Dispose(); if (check != null && check.Count > 0) { foreach (var all in check) { Classes.LibraryItem item = new Classes.LibraryItem { SectionId = all.SectionId, SectionText = all.SectionText, VideoCount = all.VideoCount, BackgroundImage = all.BackgroundImage }; Add(item); NotifyDataSetChanged(); } } else { //translate text in the adapter LibraryList.Add(new Classes.LibraryItem() { SectionId = "1", SectionText = ActivityContext.GetText(Resource.String.Lbl_Subscriptions), VideoCount = 0, BackgroundImage = "blackdefault" }); LibraryList.Add(new Classes.LibraryItem() { SectionId = "2", SectionText = ActivityContext.GetText(Resource.String.Lbl_WatchLater), VideoCount = 0, BackgroundImage = "blackdefault" }); LibraryList.Add(new Classes.LibraryItem() { SectionId = "3", SectionText = ActivityContext.GetText(Resource.String.Lbl_RecentlyWatched), VideoCount = 0, BackgroundImage = "blackdefault" }); if (AppSettings.AllowOfflineDownload) { LibraryList.Add(new Classes.LibraryItem() { SectionId = "4", SectionText = ActivityContext.GetText(Resource.String.Lbl_WatchOffline), VideoCount = 0, BackgroundImage = "blackdefault" }); } LibraryList.Add(new Classes.LibraryItem() { SectionId = "5", SectionText = ActivityContext.GetText(Resource.String.Lbl_PlayLists), VideoCount = 0, BackgroundImage = "blackdefault" }); LibraryList.Add(new Classes.LibraryItem() { SectionId = "6", SectionText = ActivityContext.GetText(Resource.String.Lbl_Liked), VideoCount = 0, BackgroundImage = "blackdefault" }); LibraryList.Add(new Classes.LibraryItem() { SectionId = "7", SectionText = ActivityContext.GetText(Resource.String.Lbl_Shared), VideoCount = 0, BackgroundImage = "blackdefault" }); LibraryList.Add(new Classes.LibraryItem() { SectionId = "8", SectionText = ActivityContext.GetText(Resource.String.Lbl_Paid), VideoCount = 0, BackgroundImage = "blackdefault" }); NotifyDataSetChanged(); sqlEntity.InsertLibraryItem(LibraryList); sqlEntity.Dispose(); } } catch (Exception exception) { Console.WriteLine(exception); } }
private void AddLibrarySectionViews() { try { var sqlEntity = new SqLiteDatabase(); var check = sqlEntity.Get_LibraryItem(); sqlEntity.Dispose(); if (check != null && check.Count > 0) { foreach (var all in check) { Classes.LibraryItem item = new Classes.LibraryItem { SectionId = all.SectionId, SectionText = all.SectionText, SongsCount = all.SongsCount, BackgroundImage = all.BackgroundImage }; Add(item); } NotifyDataSetChanged(); } else { LibraryList.Add(new Classes.LibraryItem { SectionId = "1", SectionText = ActivityContext.GetText(Resource.String.Lbl_Liked), SongsCount = 0, BackgroundImage = "blackdefault" }); LibraryList.Add(new Classes.LibraryItem { SectionId = "2", SectionText = ActivityContext.GetText(Resource.String.Lbl_RecentlyPlayed), SongsCount = 0, BackgroundImage = "blackdefault" }); LibraryList.Add(new Classes.LibraryItem { SectionId = "3", SectionText = ActivityContext.GetText(Resource.String.Lbl_Favorites), SongsCount = 0, BackgroundImage = "blackdefault" }); if (AppSettings.AllowOfflineDownload) { LibraryList.Add(new Classes.LibraryItem { SectionId = "4", SectionText = ActivityContext.GetText(Resource.String.Lbl_LatestDownloads), SongsCount = 0, BackgroundImage = "blackdefault" }); } LibraryList.Add(new Classes.LibraryItem { SectionId = "5", SectionText = ActivityContext.GetText(Resource.String.Lbl_Shared), SongsCount = 0, BackgroundImage = "blackdefault" }); LibraryList.Add(new Classes.LibraryItem { SectionId = "6", SectionText = ActivityContext.GetText(Resource.String.Lbl_Purchases), SongsCount = 0, BackgroundImage = "blackdefault" }); NotifyDataSetChanged(); sqlEntity.InsertLibraryItem(LibraryList); sqlEntity.Dispose(); } } catch (Exception exception) { Console.WriteLine(exception); } }