public void ScrollToTop() { if (TimelineItems.Items.Count > 0) { TimelineItems.ScrollIntoView(TimelineItems.Items[0]); } }
async Task ExecuteRefreshCommandAsync() { if (IsBusy) { return; } IsBusy = true; try { var client = DependencyService.Get <IDataService>() as AzureService; var table = client.MobileService.GetSyncTable <TimelineItem>(); var items = await table.Where((item) => item.Id == Settings.UserId).ToListAsync(); TimelineItems.Clear(); foreach (var item in items) { TimelineItems.Add(item); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"ERROR: {ex.Message}"); } finally { IsBusy = false; } }
private void SelectItemCommandHandler(object sender, ExecutedRoutedEventArgs ea) { var updated = false; var down = Convert.ToBoolean(ea.Parameter); if (down) { if (TimelineItems.SelectedIndex < TimelineItems.Items.Count - 1) { TimelineItems.SelectedIndex += 1; updated = true; } } else { if (TimelineItems.SelectedIndex > 0) { TimelineItems.SelectedIndex -= 1; updated = true; } } if (updated) { var listboxItem = TimelineItems.ItemContainerGenerator.ContainerFromIndex(TimelineItems.SelectedIndex) as ListBoxItem; Keyboard.Focus(listboxItem); TimelineItems.ScrollIntoView(TimelineItems.SelectedItem); } }
protected override async Task <IAsyncEnumerable <HohoemaListingPageItemBase> > GetPagedItemsImpl(int head, int count) { var tail = head + count; var prevCount = TimelineItems.Count; if (TimelineItems.Count < tail) { while (prevCount == TimelineItems.Count) { var nicoRepoResponse = await LoginUserNicoRepoProvider.GetLoginUserNicoRepo(NicoRepoTimelineType.all, _LastItem?.Id); if (nicoRepoResponse.IsStatusOK) { foreach (var item in nicoRepoResponse.TimelineItems) { if (CheckCanDisplayTimelineItem(item)) { TimelineItems.Add(item); } } _LastItem = nicoRepoResponse.LastTimelineItem; if (nicoRepoResponse.TimelineItems.Count == 0) { break; } } else { break; } } } var list = new List <HohoemaListingPageItemBase>(); return(TimelineItems.Skip(head).Take(count).ToArray() .Select <NicoRepoTimelineItem, HohoemaListingPageItemBase>(item => { var topicType = NicoRepoItemTopicExtension.ToNicoRepoTopicType(item.Topic); if (topicType == NicoRepoItemTopic.Live_User_Program_OnAirs || topicType == NicoRepoItemTopic.Live_User_Program_Reserve || topicType == NicoRepoItemTopic.Live_Channel_Program_Onairs || topicType == NicoRepoItemTopic.Live_Channel_Program_Reserve) { return new NicoRepoLiveTimeline(item, topicType); } else if (topicType == NicoRepoItemTopic.NicoVideo_User_Video_Upload || topicType == NicoRepoItemTopic.NicoVideo_User_Mylist_Add_Video || topicType == NicoRepoItemTopic.NicoVideo_Channel_Video_Upload) { return new NicoRepoVideoTimeline(item, topicType); } else { throw new NotSupportedException(topicType.ToString()); } }) .ToAsyncEnumerable()); }
async Task ExecuteRefreshCommandAsync() { if (IsBusy) { return; } IsBusy = true; try { if (TimelineItems == null) { TimelineItems = new ObservableCollection <TimelineItem>(); } var items = await DependencyService.Get <IDataService>().GetItems <TimelineItem>(); TimelineItems.Clear(); foreach (var item in items) { TimelineItems.Add(item); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"ERROR: {ex.Message}"); } finally { IsBusy = false; } }
public void AddItemToTimeline() { TimelineItems.Add(new TimelineItem() { Datestamp = DateTime.Now, Description = "New Item" }); }
async Task ExecutePostTimelineItemCommandAsync() { if (IsBusy) { return; } IsBusy = true; try { await CrossMedia.Current.Initialize(); MediaFile file; if (CrossMedia.Current.IsCameraAvailable) { file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions { Directory = "TimelineItems", Name = "photo.jpg" }); } else { file = await CrossMedia.Current.PickPhotoAsync(); } var client = DependencyService.Get <IDataService>() as AzureService; var author = await client.GetItem <Employee>(Settings.UserId); var url = await client.StoreBlob(file.GetStream()); var text = "Having a blast at this Azure workshop!"; var timelineItem = new TimelineItem { Author = author, Text = text, PhotoUrl = url }; TimelineItems.Add(timelineItem); await client.AddItem <TimelineItem>(timelineItem); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"ERROR: {ex.Message}"); } finally { IsBusy = false; } }
protected override async Task <int> ResetSourceImpl() { TimelineItems.Clear(); var nicoRepoResponse = await LoginUserNicoRepoProvider.GetLoginUserNicoRepo(NicoRepoTimelineType.all); if (nicoRepoResponse.IsStatusOK) { foreach (var item in nicoRepoResponse.TimelineItems) { if (CheckCanDisplayTimelineItem(item)) { TimelineItems.Add(item); } } _LastItem = nicoRepoResponse.LastTimelineItem; return(nicoRepoResponse.Meta.Limit); } else { return(0); } }