public MainViewModel()
        {
            FooterLoadingVisibility = Visibility.Collapsed;
            NoItemHintVisibility    = Visibility.Collapsed;
            NoNetworkHintVisibility = Visibility.Collapsed;
            FooterReloadVisibility  = Visibility.Collapsed;
            EndVisibility           = Visibility.Collapsed;
            IsRefreshing            = true;
            ShowDownloadsUC         = false;

            SelectedIndex = -1;

            DataVM = new ImageDataViewModel(this,
                                            new ImageService(Request.GetNewImages, NormalFactory));
        }
Esempio n. 2
0
        private async Task RestoreMainListDataAsync()
        {
            var file = await CacheUtil.GetCachedFileFolder().TryGetFileAsync(CachedFileNames.MainListFileName);

            if (file != null)
            {
                var list = await SerializerHelper.DeserializeFromJsonByFile <IncrementalLoadingCollection <UnsplashImage> >(CachedFileNames.MainListFileName, CacheUtil.GetCachedFileFolder());

                if (list != null)
                {
                    this.MainDataVM = new ImageDataViewModel(this, UrlHelper.GetFeaturedImages);
                    list.ToList().ForEach(s => MainDataVM.DataList.Add(s));

                    for (int i = 0; i < MainDataVM.DataList.Count; i++)
                    {
                        var item = MainDataVM.DataList[i];
                        if (i % 2 == 0)
                        {
                            item.BackColor = new SolidColorBrush(ColorConverter.HexToColor("#FF2E2E2E").Value);
                        }
                        else
                        {
                            item.BackColor = new SolidColorBrush(ColorConverter.HexToColor("#FF383838").Value);
                        }
                        var task = item.RestoreAsync();
                    }
                    await UpdateLiveTileAsync();
                }
                else
                {
                    MainDataVM = new ImageDataViewModel(this, UrlHelper.GetFeaturedImages);
                }
            }
            else
            {
                MainDataVM = new ImageDataViewModel(this, UrlHelper.GetFeaturedImages);
            }
        }
Esempio n. 3
0
        private async Task RestoreMainListDataAsync()
        {
            var file = await CacheUtil.GetCachedFileFolder().TryGetFileAsync(CachedFileNames.MainListFileName);

            if (file != null)
            {
                var list = await SerializerHelper.DeserializeFromJsonByFile <IncrementalLoadingCollection <UnsplashImageBase> >(CachedFileNames.MainListFileName, CacheUtil.GetCachedFileFolder());

                if (list != null)
                {
                    this.MainDataVM = new ImageDataViewModel(this, UrlHelper.GetNewImages, true);
                    list.ToList().ForEach(s => MainDataVM.DataList.Add(s));

                    for (int i = 0; i < MainDataVM.DataList.Count; i++)
                    {
                        var item = MainDataVM.DataList[i];
                        if (i % 2 == 0)
                        {
                            item.BackColor = App.Current.Resources["ImageBackBrush1"] as SolidColorBrush;
                        }
                        else
                        {
                            item.BackColor = App.Current.Resources["ImageBackBrush2"] as SolidColorBrush;
                        }
                        var task = item.RestoreDataAsync();
                    }
                }
                else
                {
                    MainDataVM = new ImageDataViewModel(this, UrlHelper.GetNewImages, true);
                }
            }
            else
            {
                MainDataVM = new ImageDataViewModel(this, UrlHelper.GetNewImages, true);
            }
        }
Esempio n. 4
0
        private async Task RestoreMainListDataAsync()
        {
            DataVM = new ImageDataViewModel(UrlHelper.GetNewImages, false);

            if (AppSettings.Instance.DefaultCategory == 0)
            {
                return;
            }
            var file = await CacheUtil.GetCachedFileFolder().TryGetFileAsync(CachedFileNames.MainListFileName);

            if (file != null)
            {
                var str = await FileIO.ReadTextAsync(file);

                var list = JsonConvert.DeserializeObject <List <UnsplashImage> >(str);
                if (list != null)
                {
                    list.ForEach(s => DataVM.DataList.Add(s));

                    for (int i = 0; i < DataVM.DataList.Count; i++)
                    {
                        var item = DataVM.DataList[i];
                        if (i % 2 == 0)
                        {
                            item.BackColor = Application.Current.Resources["ImageBackBrush1"] as SolidColorBrush;
                        }
                        else
                        {
                            item.BackColor = Application.Current.Resources["ImageBackBrush2"] as SolidColorBrush;
                        }
                        var task = item.RestoreDataAsync();
                    }

                    return;
                }
            }
        }