Exemplo n.º 1
0
        public static bool ProcessTableFeedsToList(ObservableCollection <Feeds> AddList, List <TableFeeds> LoadTableFeeds)
        {
            try
            {
                foreach (TableFeeds Feed in LoadTableFeeds)
                {
                    //Load and check feed id
                    string FeedId = Feed.feed_id;
                    if (!AddList.Any(x => x.feed_id == FeedId))
                    {
                        bool IgnoreStatus = Feed.feed_ignore_status ? true : false;

                        //Load feed folder
                        string FeedFolder = Feed.feed_folder;
                        if (string.IsNullOrWhiteSpace(FeedFolder))
                        {
                            FeedFolder = "No folder";
                        }

                        //Load feed icon
                        ImageSource FeedIcon = null;
                        if (FeedId.StartsWith("user/"))
                        {
                            FeedIcon = ImageSource.FromResource("NewsScroll.Assets.iconUser-Dark.png");
                        }
                        else
                        {
                            FeedIcon = AVFiles.File_LoadImage(FeedId + ".png", true);
                        }
                        if (FeedIcon == null)
                        {
                            FeedIcon = ImageSource.FromResource("NewsScroll.Assets.iconRSS-Dark.png");
                        }

                        //Add feed to list
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            try
                            {
                                AddList.Add(new Feeds()
                                {
                                    feed_id = FeedId, feed_title = Feed.feed_title, feed_icon = FeedIcon, feed_link = Feed.feed_link, feed_folder_title = FeedFolder, feed_ignore_status = IgnoreStatus
                                });
                            }
                            catch { }
                        });
                    }

                    //Update the added item count
                    AppVariables.CurrentFeedsLoaded++;

                    //Request information update
                    if (AppVariables.CurrentFeedsLoaded == 1)
                    {
                        EventHideProgressionStatus();
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed processing multiple feeds from database: " + ex.Message);
                return(false);
            }
        }
Exemplo n.º 2
0
        //Update the item image content
        public static void ItemUpdateImages(object itemObject, bool resetContent)
        {
            try
            {
                Items updateItem = (Items)itemObject;
                if (resetContent)
                {
                    //Debug.WriteLine("Disappearing item: " + updateItem.item_title);
                    //Unload feed icon
                    if (updateItem.feed_icon != null)
                    {
                        updateItem.feed_icon = null;
                    }

                    //Unload status image
                    if (updateItem.item_read_icon != null)
                    {
                        updateItem.item_read_icon = null;
                    }
                    if (updateItem.item_star_icon != null)
                    {
                        updateItem.item_star_icon = null;
                    }

                    //Unload item image
                    if (updateItem.item_image != null)
                    {
                        updateItem.item_image = null;
                    }
                }
                else
                {
                    //Debug.WriteLine("Appearing item: " + updateItem.item_title);
                    //Load feed icon
                    if (updateItem.feed_icon == null)
                    {
                        if (updateItem.feed_id.StartsWith("user/"))
                        {
                            updateItem.feed_icon = ImageSource.FromResource("NewsScroll.Assets.iconUser-Dark.png");
                        }
                        else
                        {
                            updateItem.feed_icon = AVFiles.File_LoadImage(updateItem.feed_id + ".png", true);
                        }
                        if (updateItem.feed_icon == null)
                        {
                            updateItem.feed_icon = ImageSource.FromResource("NewsScroll.Assets.iconRSS-Dark.png");
                        }
                    }

                    //Load status image
                    if (updateItem.item_read_icon == null && updateItem.item_read_status)
                    {
                        updateItem.item_read_icon = ImageSource.FromResource("NewsScroll.Assets.iconRead-Dark.png");
                    }
                    if (updateItem.item_star_icon == null && updateItem.item_star_status)
                    {
                        updateItem.item_star_icon = ImageSource.FromResource("NewsScroll.Assets.iconStar-Dark.png");
                    }

                    //Load item image
                    string itemImageLink = updateItem.item_image_link;
                    if (updateItem.item_image == null && !string.IsNullOrWhiteSpace(itemImageLink) && updateItem.item_image_visibility == true && AppVariables.LoadMedia)
                    {
                        updateItem.item_image = itemImageLink;
                    }
                }
            }
            catch { }
        }
Exemplo n.º 3
0
        //Load feeds in selection
        async Task LoadSelectionFeeds(List <TableFeeds> LoadTableFeeds, List <TableItems> LoadTableItems, bool Silent, bool EnableUI)
        {
            try
            {
                if (!Silent)
                {
                    ProgressDisableUI("Loading selection feeds...", true);
                }
                Debug.WriteLine("Loading selection feeds, silent: " + Silent);

                combobox_FeedSelection.IsEnabled = false;
                combobox_FeedSelection.Opacity   = 0.30;
                await ClearObservableCollection(List_FeedSelect);

                //Check if received lists are empty
                if (LoadTableFeeds == null)
                {
                    LoadTableFeeds = await vSQLConnection.Table <TableFeeds>().OrderBy(x => x.feed_folder).ToListAsync();
                }
                if (LoadTableItems == null)
                {
                    LoadTableItems = await vSQLConnection.Table <TableItems>().ToListAsync();
                }

                //Filter un/ignored feeds
                List <string>     IgnoredFeedList   = LoadTableFeeds.Where(x => x.feed_ignore_status == true).Select(x => x.feed_id).ToList();
                List <TableFeeds> UnignoredFeedList = LoadTableFeeds.Where(x => x.feed_ignore_status == false).ToList();
                Feeds             TempFeed          = new Feeds();

                //Add all feeds selection
                TempFeed.feed_id = "0";
                int   TotalItemsAll = ProcessItemLoad.FilterNewsItems(IgnoredFeedList, LoadTableItems, TempFeed, 0, AppVariables.ItemsToLoadMax).Count();
                Feeds FeedItemAll   = new Feeds();
                FeedItemAll.feed_icon              = ImageSource.FromResource("NewsScroll.Assets.iconRSS-Dark.png");
                FeedItemAll.feed_title             = "All news items";
                FeedItemAll.feed_item_count        = TotalItemsAll;
                FeedItemAll.feed_collection_status = true;
                FeedItemAll.feed_id = "0";
                List_FeedSelect.Add(FeedItemAll);

                //Add unread feeds selection
                TempFeed.feed_id = "2";
                int   TotalItemsUnread = ProcessItemLoad.FilterNewsItems(IgnoredFeedList, LoadTableItems, TempFeed, 0, AppVariables.ItemsToLoadMax).Count();
                Feeds FeedItemUnread   = new Feeds();
                FeedItemUnread.feed_icon              = ImageSource.FromResource("NewsScroll.Assets.iconRSS-Dark.png");
                FeedItemUnread.feed_title             = "Unread news items";
                FeedItemUnread.feed_item_count        = TotalItemsUnread;
                FeedItemUnread.feed_collection_status = true;
                FeedItemUnread.feed_id = "2";
                List_FeedSelect.Add(FeedItemUnread);

                //Add read feeds selection
                TempFeed.feed_id = "1";
                int   TotalItemsRead = ProcessItemLoad.FilterNewsItems(IgnoredFeedList, LoadTableItems, TempFeed, 0, AppVariables.ItemsToLoadMax).Count();
                Feeds FeedItemRead   = new Feeds();
                FeedItemRead.feed_icon              = ImageSource.FromResource("NewsScroll.Assets.iconRSS-Dark.png");
                FeedItemRead.feed_title             = "Read news items";
                FeedItemRead.feed_item_count        = TotalItemsRead;
                FeedItemRead.feed_collection_status = true;
                FeedItemRead.feed_id = "1";
                List_FeedSelect.Add(FeedItemRead);

                //Feeds that are not ignored and contain items
                foreach (TableFeeds Feed in UnignoredFeedList)
                {
                    TempFeed.feed_id = Feed.feed_id;
                    int TotalItems = ProcessItemLoad.FilterNewsItems(IgnoredFeedList, LoadTableItems, TempFeed, 0, AppVariables.ItemsToLoadMax).Count();
                    if (TotalItems > 0)
                    {
                        //Add folder
                        string FeedFolder = Feed.feed_folder;
                        if (string.IsNullOrWhiteSpace(FeedFolder))
                        {
                            FeedFolder = "No folder";
                        }
                        Feeds FolderUpdate = List_FeedSelect.Where(x => x.feed_folder_title == FeedFolder && x.feed_folder_status).FirstOrDefault();
                        if (FolderUpdate == null)
                        {
                            //Load folder icon
                            ImageSource FolderIcon = ImageSource.FromResource("NewsScroll.Assets.iconFolder-Dark.png");

                            //Add folder
                            Feeds FolderItem = new Feeds();
                            FolderItem.feed_icon          = FolderIcon;
                            FolderItem.feed_title         = "(Folder) " + FeedFolder;
                            FolderItem.feed_folder_title  = FeedFolder;
                            FolderItem.feed_folder_status = true;
                            List_FeedSelect.Add(FolderItem);
                            //Debug.WriteLine("Added folder...");
                        }

                        //Add feed
                        //Load feed icon
                        ImageSource FeedIcon = null;
                        if (Feed.feed_id.StartsWith("user/"))
                        {
                            FeedIcon = ImageSource.FromResource("NewsScroll.Assets.iconUser-Dark.png");
                        }
                        else
                        {
                            FeedIcon = AVFiles.File_LoadImage(Feed.feed_id + ".png", true);
                        }
                        if (FeedIcon == null)
                        {
                            FeedIcon = ImageSource.FromResource("NewsScroll.Assets.iconRSS-Dark.png");
                        }

                        //Get the current feed item count
                        Feeds FeedItem = new Feeds();
                        FeedItem.feed_icon       = FeedIcon;
                        FeedItem.feed_title      = Feed.feed_title;
                        FeedItem.feed_item_count = TotalItems;
                        FeedItem.feed_id         = Feed.feed_id;
                        List_FeedSelect.Add(FeedItem);

                        //Update folder
                        FolderUpdate = List_FeedSelect.Where(x => x.feed_folder_title == FeedFolder && x.feed_folder_status).FirstOrDefault();
                        if (FolderUpdate != null)
                        {
                            FolderUpdate.feed_folder_ids.Add(Feed.feed_id);
                            FolderUpdate.feed_item_count = FolderUpdate.feed_item_count + FeedItem.feed_item_count;
                            //Debug.WriteLine("Updated folder...");
                        }
                    }
                }

                combobox_FeedSelection.IsEnabled = true;
                combobox_FeedSelection.Opacity   = 1;
            }
            catch { }
            if (EnableUI)
            {
                ProgressEnableUI();
            }
        }
Exemplo n.º 4
0
        //Open the popup
        public async void OpenPopup(Items Source)
        {
            try
            {
                //Adjust the swiping direction
                SwipeBarAdjust();

                //Check if the header is hidden
                if (AppVariables.HeaderHidden)
                {
                    HideShowHeader(true);
                }

                //Update the status message
                ProgressDisableUI("Loading the item...");

                //Set item source
                vItemViewerItem  = Source;
                txt_AppInfo.Text = ApiMessageError + Source.feed_title;

                //Load feed icon
                if (vItemViewerItem.feed_id.StartsWith("user/"))
                {
                    image_feed_icon.Source = ImageSource.FromResource("NewsScroll.Assets.iconUser-Dark.png");
                }
                else
                {
                    image_feed_icon.Source = AVFiles.File_LoadImage(vItemViewerItem.feed_id + ".png", true);
                }
                if (image_feed_icon.Source == null)
                {
                    image_feed_icon.Source = ImageSource.FromResource("NewsScroll.Assets.iconRSS-Dark.png");
                }

                //Check if internet is available
                if (Connectivity.NetworkAccess == NetworkAccess.Internet)
                {
                    iconItem.IsVisible             = true;
                    iconBrowser.IsVisible          = true;
                    button_LoadFullItem.IsVisible  = true;
                    button_OpenInBrowser.IsVisible = true;
                }
                else
                {
                    iconItem.IsVisible             = false;
                    iconBrowser.IsVisible          = false;
                    button_LoadFullItem.IsVisible  = false;
                    button_OpenInBrowser.IsVisible = false;
                }

                //Update the star status
                if (Source.item_star_status == false)
                {
                    iconStar.Source = ImageSource.FromResource("NewsScroll.Assets.iconStarAdd.png");
                }
                else
                {
                    iconStar.Source = ImageSource.FromResource("NewsScroll.Assets.iconStarRemove.png");
                }
                iconStar.IsVisible = true;

                //Load item into the viewer
                await LoadItem(string.Empty);

                //Register page events
                RegisterPageEvents();

                //Update the status message
                ProgressEnableUI();
            }
            catch
            {
                Debug.WriteLine("Failed loading item.");
                await ClosePopup();
            }
        }