Example #1
0
        public async Task <bool> GetMyFavorite()
        {
            if (IsBusy)
            {
                return(false);
            }
            IsBusy = true;
            try
            {
                if (IsFavoriteView)
                {
                    var myimages = new List <DerpImage>();
                    var mylist   = await derpibooru.GetDerpFavoriteImages(UserAPIKey);

                    foreach (var image in mylist)
                    {
                        if (!MyImages.Any(i => i.Id == image.Id))
                        {
                            image.IsFavorite = true;
                            myimages.Add(image);
                        }
                    }
                    foreach (var img in myimages)
                    {
                        await DerpImageDb.InsertDerpImageAsync(img);
                    }
                    await ExecuteLoadItemsCommand();
                }
            }
            catch
            {
            }
            IsBusy = false;
            return(true);
        }
Example #2
0
        public async Task <bool> GetMyFiles()
        {
            bool res = false;

            if (IsBusy)
            {
                return(false);
            }
            if (IsFavoriteView)
            {
                IsBusy               = true;
                Downloading          = true;
                ProgressBarIsVisible = true;
                ProgressBarHeight    = 8;
                try
                {
                    int    index     = 0;
                    string directory = await fileService.CreateDirectory("");

                    var filelist = (await fileService.GetSubList("")).FindAll(i => i.Name.Contains("__"));
                    var myimages = new List <DerpImage>();
                    foreach (var file in filelist)
                    {
                        var name = file.Name;
                        if (name.Contains("__"))
                        {
                            int    d;
                            string id = name.Substring(0, name.IndexOf('_'));
                            if (int.TryParse(id, out d))
                            {
                                if (!MyImages.Any(i => i.Id == id))
                                {
                                    var image = await derpibooru.GetDerpImage(id);

                                    if (image != null)
                                    {
                                        image.IsFavorite = true;
                                        myimages.Add(image);
                                    }
                                }
                            }
                        }
                        index++;
                        Progress2 = (float)index / filelist.Count;
                    }
                    foreach (var img in myimages)
                    {
                        await DerpImageDb.InsertDerpImageAsync(img);
                    }
                    res = true;
                }
                catch
                {
                    res = false;
                }
                await ExecuteLoadItemsCommand();

                Progress2            = 0;
                ProgressBarHeight    = 0;
                ProgressBarIsVisible = false;
                Downloading          = false;
                IsBusy = false;
            }
            return(res);
        }