private async Task RestoreState(IDictionary <string, object> state) { string imagesJson = (string)state["images"]; string type = (string)state["type"]; int index = state["index"] is int?(int)state["index"] : int.Parse((string)state["index"]); IEnumerable <IGalleryItem> collection = null; if (type == typeof(IncrementalGallery).Name) { collection = IncrementalGallery.fromJson(imagesJson); } if (type == typeof(IncrementalSubredditGallery).Name) { collection = (IEnumerable <IGalleryItem>)IncrementalSubredditGallery.FromJson(imagesJson); } if (collection != null && collection is ISupportIncrementalLoading) { var im = (ISupportIncrementalLoading)collection; while (collection.Count() < index + 1) { await im.LoadMoreItemsAsync(60); } } Images = collection; FlipViewIndex = index; state.Clear(); }
private async Task RestoreState(IDictionary <string, object> state) { if (state["subredditUrl"] == null) { Sub = JsonConvert.DeserializeObject <SubredditItem>((string)state["sub"]); Images = IncrementalSubredditGallery.FromJson((string)state["images"]); state.Clear(); } else { string subUrl = (string)state["subredditUrl"]; var sub = await Initializer.Reddits.GetSubreddit(subUrl); Sub = new SubredditItem(sub); Images = new IncrementalSubredditGallery(subUrl, Enums.Sort.Time); } }
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { if (state.Any()) { // restore state state.Clear(); } else { if (mode == NavigationMode.Back) { ImageSelectedIndex = galleryMetaInfo?.SelectedIndex ?? 0; } else { var sub = BootStrapper.Current.SessionState[(string)parameter] as SubredditItem; Images = new IncrementalSubredditGallery(sub.Url); } } await Task.CompletedTask; }