public void AddNewItem(IVideoItem item, bool isIncrease = true, bool isUpdateCount = true) { if (item == null) { throw new ArgumentException("item"); } if (item.ParentTitle == null) { item.ParentTitle = item.ParentID; } if (ChannelItems.Select(x => x.ID).Contains(item.ID)) { ChannelItems.Remove(ChannelItems.First(x => x.ID == item.ID)); } item.FileState = ItemState.LocalNo; if (item.SyncState == SyncState.Added) { ChannelItems.Insert(0, item); } else { ChannelItems.Add(item); } }
public void RestoreFullChannelItems() { if (isHasScrolled) { return; } if (ChannelItemsCount != 0 && ChannelItemsCount <= ChannelItems.Count) { return; } isHasScrolled = true; ChannelFactory.SetChannelCountAsync(this); ChannelFactory.FillChannelItemsFromDbAsync(this, 0, ChannelItems.Select(x => x.ID).ToList()); }
public void AddToStateList(object state, IVideoItem item) { if (state is WatchState) { var st = (WatchState)state; switch (st) { case WatchState.Watched: if (!watchedList.Select(x => x.ID).Contains(item.ID)) { watchedList.Add(item); if (SelectedState != null && SelectedState.State as WatchState? == st) { AddNewItem(item); } if (!watchedListIds.Contains(item.ID)) { watchedListIds.Add(item.ID); } } break; case WatchState.Planned: if (!plannedList.Select(x => x.ID).Contains(item.ID)) { plannedList.Add(item); if (SelectedState != null && SelectedState.State as WatchState? == st) { AddNewItem(item); } if (!plannedListIds.Contains(item.ID)) { plannedListIds.Add(item.ID); } IVideoItem vi = watchedList.FirstOrDefault(x => x.ID == item.ID); if (vi != null) { watchedList.Remove(vi); if (watchedListIds.Contains(item.ID)) { watchedListIds.Remove(item.ID); } } if (SelectedState != null && SelectedState.State as WatchState? == WatchState.Watched) { DeleteItem(item); } } break; case WatchState.Notset: IVideoItem vim = plannedList.FirstOrDefault(x => x.ID == item.ID); if (vim != null) { plannedList.Remove(vim); if (plannedListIds.Contains(item.ID)) { plannedListIds.Remove(item.ID); } } // if (SelectedState != null && SelectedState.State as WatchState? == WatchState.Planned) // { // DeleteItem(item); // } break; } } else if (state is SyncState) { var st = (SyncState)state; switch (st) { case SyncState.Added: if (!addedList.Select(x => x.ID).Contains(item.ID)) { addedList.Add(item); if (!addedListIds.Contains(item.ID)) { addedListIds.Add(item.ID); if (SelectedState != null && SelectedState.State as SyncState? == st) { if (!ChannelItems.Select(x => x.ID).Contains(item.ID)) { ChannelItems.Add(item); } } } } break; case SyncState.Notset: IVideoItem vi = addedList.FirstOrDefault(x => x.ID == item.ID); if (vi != null) { addedList.Remove(vi); if (addedListIds.Contains(item.ID)) { addedListIds.Remove(item.ID); if (SelectedState != null && SelectedState.State as SyncState? == SyncState.Added) { IVideoItem ite = ChannelItems.FirstOrDefault(x => x.ID == item.ID); if (ite != null) { ChannelItems.Remove(ite); } } } } break; } } }