Пример #1
0
        //Update the total items count
        private async Task UpdateTotalItemsCount(List <TableFeeds> LoadTableFeeds, List <TableItems> LoadTableItems, bool Silent, bool EnableUI)
        {
            try
            {
                //Set the total item count
                AppVariables.CurrentTotalItemsCount = await ProcessItemLoad.DatabaseToCount(LoadTableFeeds, LoadTableItems, Silent, EnableUI);

                Device.BeginInvokeOnMainThread(() =>
                {
                    try
                    {
                        //Check the total item count
                        if (AppVariables.CurrentTotalItemsCount > 0)
                        {
                            txt_AppInfo.Text             = ApiMessageError + AppVariables.CurrentTotalItemsCount + " feeds";
                            txt_NewsScrollInfo.IsVisible = false;
                        }
                        else
                        {
                            txt_AppInfo.Text             = ApiMessageError + "No feeds";
                            txt_NewsScrollInfo.Text      = "It seems like you don't have any feeds added to your account, please add some feeds to start loading your feeds and click on the refresh button above.";
                            txt_NewsScrollInfo.IsVisible = true;
                        }
                    }
                    catch { }
                });
            }
            catch { }
        }
Пример #2
0
        //Update the total items count
        private async Task UpdateTotalItemsCount(List <TableFeeds> LoadTableFeeds, List <TableItems> LoadTableItems, bool Silent, bool EnableUI)
        {
            try
            {
                //Set the total item count
                AppVariables.CurrentTotalItemsCount = await ProcessItemLoad.DatabaseToCount(LoadTableFeeds, LoadTableItems, Silent, EnableUI);

                await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    try
                    {
                        //Check the total item count
                        if (AppVariables.CurrentTotalItemsCount > 0)
                        {
                            txt_AppInfo.Text = ApiMessageError + AppVariables.CurrentTotalItemsCount + " feeds";
                            txt_NewsScrollInfo.Visibility = Visibility.Collapsed;
                        }
                        else
                        {
                            txt_AppInfo.Text              = ApiMessageError + "No feeds";
                            txt_NewsScrollInfo.Text       = "It seems like you don't have any feeds added to your account, please add some feeds to start loading your feeds and click on the refresh button above.";
                            txt_NewsScrollInfo.Visibility = Visibility.Visible;
                        }
                    }
                    catch { }
                });
            }
            catch { }
        }
Пример #3
0
        //Update the total items count
        private async Task UpdateTotalItemsCount(List <TableFeeds> LoadTableFeeds, List <TableItems> LoadTableItems, bool Silent, bool EnableUI)
        {
            try
            {
                //Set the total item count
                AppVariables.CurrentTotalItemsCount = await ProcessItemLoad.DatabaseToCount(LoadTableFeeds, LoadTableItems, Silent, EnableUI);

                await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    try
                    {
                        //Check the total item count
                        if (AppVariables.CurrentTotalItemsCount > 0)
                        {
                            txt_AppInfo.Text = ApiMessageError + AppVariables.CurrentTotalItemsCount + " items";
                            txt_NewsScrollInfo.Visibility = Visibility.Collapsed;

                            button_StatusCurrentItem.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            txt_AppInfo.Text              = ApiMessageError + "No items";
                            txt_NewsScrollInfo.Text       = "It seems like you don't have any starred items added to your account, please add some starred items to start loading your items and click on the refresh button above.";
                            txt_NewsScrollInfo.Visibility = Visibility.Visible;

                            button_StatusCurrentItem.Visibility = Visibility.Collapsed;
                        }

                        //Update the current item count
                        Int32 HeaderTargetSize  = Convert.ToInt32(stackpanel_Header.Tag);
                        Int32 HeaderCurrentSize = Convert.ToInt32(stackpanel_Header.Height);
                        if (HeaderCurrentSize == HeaderTargetSize || AppVariables.CurrentTotalItemsCount == 0)
                        {
                            textblock_StatusCurrentItem.Text = textblock_StatusCurrentItem.Tag.ToString();
                        }
                        else
                        {
                            textblock_StatusCurrentItem.Text = textblock_StatusCurrentItem.Tag.ToString() + "/" + AppVariables.CurrentTotalItemsCount;
                        }
                    }
                    catch { }
                });
            }
            catch { }
        }
Пример #4
0
        //Update Api Start
        async Task LoadItems()
        {
            try
            {
                //Clear all items and reset load count
                await ClearObservableCollection(List_StarredItems);

                //Update the loading information
                txt_AppInfo.Text              = "Loading items";
                txt_NewsScrollInfo.Text       = "Your starred items will be shown here shortly...";
                txt_NewsScrollInfo.Visibility = Visibility.Visible;

                //Load items from api/database
                AppVariables.LoadNews    = false;
                AppVariables.LoadStarred = true;
                AppVariables.LoadSearch  = false;
                AppVariables.LoadFeeds   = true;
                Int32 Result = await ApiUpdate.PageApiUpdate();

                //Check the api update result
                if (Result == 2)
                {
                    await CleanupPageResources();

                    App.vApplicationFrame.Navigate(typeof(SettingsPage));
                    App.vApplicationFrame.BackStack.Clear();
                    return;
                }

                //Wait for busy database
                await ApiUpdate.WaitForBusyDatabase();

                //Set all items to list
                List <TableItems> LoadTableItems = await SQLConnection.Table <TableItems>().ToListAsync();

                //Load items into the list
                await ProcessItemLoad.DatabaseToList(null, LoadTableItems, AppVariables.CurrentItemsLoaded, AppVariables.ItemsToScrollLoad, false, false);

                //Update the total items count
                await UpdateTotalItemsCount(null, LoadTableItems, false, true);
            }
            catch { }
        }
Пример #5
0
        //Update the total items count
        private async Task UpdateTotalItemsCount(List <TableFeeds> LoadTableFeeds, List <TableItems> LoadTableItems, bool Silent, bool EnableUI)
        {
            try
            {
                //Set the total item count
                AppVariables.CurrentTotalItemsCount = await ProcessItemLoad.DatabaseToCount(LoadTableFeeds, LoadTableItems, Silent, EnableUI);

                Device.BeginInvokeOnMainThread(() =>
                {
                    try
                    {
                        //Check the total item count
                        if (AppVariables.CurrentTotalItemsCount > 0)
                        {
                            txt_AppInfo.Text             = ApiMessageError + AppVariables.CurrentTotalItemsCount + " items";
                            txt_NewsScrollInfo.IsVisible = false;

                            button_StatusCurrentItem.IsVisible = true;
                        }
                        else
                        {
                            txt_AppInfo.Text             = ApiMessageError + "No items";
                            txt_NewsScrollInfo.Text      = "It seems like you don't have any starred items added to your account, please add some starred items to start loading your items and click on the refresh button above.";
                            txt_NewsScrollInfo.IsVisible = true;

                            button_StatusCurrentItem.IsVisible = false;
                        }

                        //Update the current item count
                        if (stackpanel_Header.IsVisible || AppVariables.CurrentTotalItemsCount == 0)
                        {
                            label_StatusCurrentItem.Text = AppVariables.CurrentViewItemsCount.ToString();
                        }
                        else
                        {
                            label_StatusCurrentItem.Text = AppVariables.CurrentViewItemsCount + "/" + AppVariables.CurrentTotalItemsCount;
                        }
                    }
                    catch { }
                });
            }
            catch { }
        }
Пример #6
0
        //Check if new items need to be loaded
        public static async Task ScrollViewerAddItems(ListView TargetListView, Int32 CurrentOffsetId)
        {
            try
            {
                if (!(bool)AppVariables.ApplicationSettings["LoadAllItems"])
                {
                    Int32 LoadedListCount = TargetListView.Items.Count();
                    if (!AppVariables.BusyApplication && (LoadedListCount - CurrentOffsetId) < AppVariables.ItemsToScrollLoad && LoadedListCount < AppVariables.CurrentTotalItemsCount)
                    {
                        AppVariables.BusyApplication = true;

                        //Debug.WriteLine("ItemsLoaded" + AppVariables.CurrentItemsLoaded + "/" + AppVariables.TotalItemsCount);
                        //Debug.WriteLine("Time to load new items because there are only " + AppVariables.ItemsToScrollLoad + " left.");
                        await ProcessItemLoad.DatabaseToList(null, null, LoadedListCount, AppVariables.ItemsToScrollLoad, true, false);

                        AppVariables.BusyApplication = false;
                    }
                }
            }
            catch { AppVariables.BusyApplication = false; }
        }
Пример #7
0
        //Load feeds from Api
        async Task LoadFeeds()
        {
            try
            {
                //Clear all items
                await ClearObservableCollection(List_Feeds);

                //Update the loading information
                txt_AppInfo.Text              = "Loading feeds";
                txt_NewsScrollInfo.Text       = "Your feeds will be shown here shortly...";
                txt_NewsScrollInfo.Visibility = Visibility.Visible;

                //Load feeds from api/database
                AppVariables.LoadNews    = false;
                AppVariables.LoadStarred = false;
                AppVariables.LoadSearch  = false;
                AppVariables.LoadFeeds   = true;
                int Result = await ApiUpdate.PageApiUpdate();

                //Check the api update result
                if (Result == 2)
                {
                    await CleanupPageResources();

                    App.vApplicationFrame.Navigate(typeof(SettingsPage));
                    //FixApp.vApplicationFrame.BackStack.Clear();
                    return;
                }

                //Set all items to list
                List <TableFeeds> LoadTableFeeds = await SQLConnection.Table <TableFeeds>().OrderBy(x => x.feed_folder).ToListAsync();

                //Load items into the list
                await ProcessItemLoad.DatabaseToList(LoadTableFeeds, null, AppVariables.CurrentItemsLoaded, AppVariables.ItemsToScrollLoad, false, false);

                //Update the total items count
                await UpdateTotalItemsCount(LoadTableFeeds, null, false, true);
            }
            catch { }
        }
Пример #8
0
        //Update Api Start
        async Task LoadItems()
        {
            try
            {
                //Clear all items and reset load count
                await ClearObservableCollection(List_StarredItems);

                //Update the loading information
                txt_AppInfo.Text             = "Loading items";
                txt_NewsScrollInfo.Text      = "Your starred items will be shown here shortly...";
                txt_NewsScrollInfo.IsVisible = true;

                //Load items from api/database
                AppVariables.LoadNews    = false;
                AppVariables.LoadStarred = true;
                AppVariables.LoadSearch  = false;
                AppVariables.LoadFeeds   = true;
                int Result = await ApiUpdate.PageApiUpdate();

                //Check the api update result
                if (Result == 2)
                {
                    await CleanupPageResources();

                    App.NavigateToPage(new SettingsPage(), true, false);
                    return;
                }

                //Set all items to list
                List <TableItems> LoadTableItems = await vSQLConnection.Table <TableItems>().ToListAsync();

                //Load items into the list
                await ProcessItemLoad.DatabaseToList(null, LoadTableItems, AppVariables.CurrentItemsLoaded, AppVariables.ItemsToLoadMax, false, false);

                //Update the total items count
                await UpdateTotalItemsCount(null, LoadTableItems, false, true);
            }
            catch { }
        }
Пример #9
0
        //Update Api Start
        async Task LoadItems(bool LoadSelectFeeds, bool UpdateSelectFeeds)
        {
            try
            {
                //Clear all items and reset load count
                await ClearObservableCollection(List_NewsItems);

                //Get the currently selected feed
                string SelectedFeedTitle = "All news items";
                if (!(bool)AppSettingLoad("DisplayReadMarkedItems"))
                {
                    SelectedFeedTitle = "Unread news items";
                }
                if (vNewsFeed != null)
                {
                    if (vNewsFeed.feed_title != null)
                    {
                        SelectedFeedTitle = vNewsFeed.feed_title;
                    }
                    if (vNewsFeed.feed_folder_title != null)
                    {
                        SelectedFeedTitle = vNewsFeed.feed_folder_title;
                    }
                }

                //Update the loading information
                txt_AppInfo.Text = "Loading items";

                Span text1 = new Span {
                    Text = "Your news items from "
                };
                Span text2 = new Span {
                    Text = SelectedFeedTitle
                };
                text2.SetDynamicResource(Span.TextColorProperty, "ApplicationAccentLightColor");
                Span text3 = new Span {
                    Text = " will be shown here shortly..."
                };

                FormattedString formattedString = new FormattedString();
                formattedString.Spans.Add(text1);
                formattedString.Spans.Add(text2);
                formattedString.Spans.Add(text3);
                txt_NewsScrollInfo.FormattedText = formattedString;
                txt_NewsScrollInfo.IsVisible     = true;

                //Check the loading feed
                if (LoadSelectFeeds)
                {
                    if ((bool)AppSettingLoad("DisplayReadMarkedItems"))
                    {
                        Feeds TempFeed = new Feeds();
                        TempFeed.feed_id    = "0";
                        vNewsFeed           = TempFeed;
                        vPreviousScrollItem = 0;
                    }
                    else
                    {
                        Feeds TempFeed = new Feeds();
                        TempFeed.feed_id    = "2";
                        vNewsFeed           = TempFeed;
                        vPreviousScrollItem = 0;
                    }
                }

                //Load items from api/database
                AppVariables.LoadNews    = true;
                AppVariables.LoadStarred = false;
                AppVariables.LoadSearch  = false;
                AppVariables.LoadFeeds   = true;
                int Result = await ApiUpdate.PageApiUpdate();

                //Check the api update result
                if (Result == 2)
                {
                    await CleanupPageResources();

                    App.NavigateToPage(new SettingsPage(), true, false);
                    return;
                }

                //Set all items to list
                List <TableFeeds> LoadTableFeeds = await vSQLConnection.Table <TableFeeds>().OrderBy(x => x.feed_folder).ToListAsync();

                List <TableItems> LoadTableItems = await vSQLConnection.Table <TableItems>().ToListAsync();

                //Load items into the list
                await ProcessItemLoad.DatabaseToList(LoadTableFeeds, LoadTableItems, AppVariables.CurrentItemsLoaded, AppVariables.ItemsToLoadMax, false, false);

                //Load feeds into selector
                if (LoadSelectFeeds)
                {
                    await LoadSelectionFeeds(LoadTableFeeds, LoadTableItems, false, true);
                }

                //Update feeds in selector
                if (UpdateSelectFeeds)
                {
                    await UpdateSelectionFeeds(LoadTableFeeds, LoadTableItems, false, true);
                }

                //Change the selection feed
                ChangeSelectionFeed(vNewsFeed, false);

                //Update the total item count
                UpdateTotalItemsCount();

                //Enable the interface manually
                if (!LoadSelectFeeds && !UpdateSelectFeeds)
                {
                    ProgressEnableUI();
                }
            }
            catch { }
        }
Пример #10
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();
            }
        }
Пример #11
0
        //Update feeds in selection
        async Task UpdateSelectionFeeds(List <TableFeeds> LoadTableFeeds, List <TableItems> LoadTableItems, bool Silent, bool EnableUI)
        {
            try
            {
                if (!Silent)
                {
                    ProgressDisableUI("Updating selection feeds...", true);
                }
                Debug.WriteLine("Updating selection feeds, silent: " + Silent);

                combobox_FeedSelection.IsEnabled = false;
                combobox_FeedSelection.Opacity   = 0.30;

                //Check if received lists are empty
                if (LoadTableFeeds == null)
                {
                    LoadTableFeeds = await vSQLConnection.Table <TableFeeds>().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();

                //Update the currently loaded feeds
                foreach (Feeds FeedUpdate in List_FeedSelect.Where(x => !x.feed_folder_status))
                {
                    Feeds TempFeed = new Feeds();
                    TempFeed.feed_id = FeedUpdate.feed_id;

                    FeedUpdate.feed_item_count = ProcessItemLoad.FilterNewsItems(IgnoredFeedList, LoadTableItems, TempFeed, 0, AppVariables.ItemsToLoadMax).Count();
                }

                //Reset the loaded folders item count
                foreach (Feeds FolderReset in List_FeedSelect.Where(x => x.feed_folder_status))
                {
                    FolderReset.feed_item_count = 0;
                }

                //Update the currently loaded folders
                foreach (Feeds FolderUpdate in List_FeedSelect.Where(x => x.feed_folder_status))
                {
                    foreach (string FeedId in FolderUpdate.feed_folder_ids)
                    {
                        Feeds Feed = List_FeedSelect.Where(x => x.feed_id == FeedId).FirstOrDefault();
                        if (Feed != null && Feed.feed_item_count > 0)
                        {
                            FolderUpdate.feed_item_count = FolderUpdate.feed_item_count + Feed.feed_item_count;
                            //Debug.WriteLine("Added folder count: " + Feed.feed_item_count);
                        }
                    }
                }

                //Remove empty feeds and folders from combobox
                bool FeedFolderRemoved = false;
                if (!(bool)AppSettingLoad("DisplayReadMarkedItems"))
                {
                    foreach (Feeds Feed in List_FeedSelect.ToList())
                    {
                        if (Feed.feed_item_count == 0 && !Feed.feed_collection_status)
                        {
                            Debug.WriteLine("Removing feed or folder: " + Feed.feed_title + Feed.feed_folder_title + " from the list.");
                            List_FeedSelect.Remove(Feed);
                            FeedFolderRemoved = true;
                        }
                    }
                }

                //Check if selected feed has been removed and set to read items feed
                if (FeedFolderRemoved && combobox_FeedSelection.SelectedIndex == -1 || (combobox_FeedSelection.SelectedIndex == 0 && vNewsFeed.feed_item_count == 0))
                {
                    Feeds TempFeed = new Feeds();
                    TempFeed.feed_id = "1";

                    //Change the selection feed
                    ChangeSelectionFeed(TempFeed, false);

                    //Load all the items
                    await LoadItems(false, false);
                }
                else
                {
                    //Update the total item count
                    UpdateTotalItemsCount();
                }

                combobox_FeedSelection.IsEnabled = true;
                combobox_FeedSelection.Opacity   = 1;
            }
            catch { }
            if (EnableUI)
            {
                ProgressEnableUI();
            }
        }
Пример #12
0
        //Update Api Start
        async Task LoadItems(bool LoadSelectFeeds, bool UpdateSelectFeeds)
        {
            try
            {
                //Clear all items and reset load count
                await ClearObservableCollection(List_NewsItems);

                //Get the currently selected feed
                string SelectedFeedTitle = "All items";
                if (!(bool)AppVariables.ApplicationSettings["DisplayReadMarkedItems"])
                {
                    SelectedFeedTitle = "Unread items";
                }
                if (vCurrentLoadingFeedFolder != null)
                {
                    if (vCurrentLoadingFeedFolder.feed_title != null)
                    {
                        SelectedFeedTitle = vCurrentLoadingFeedFolder.feed_title;
                    }
                    if (vCurrentLoadingFeedFolder.feed_folder_title != null)
                    {
                        SelectedFeedTitle = vCurrentLoadingFeedFolder.feed_folder_title;
                    }
                }

                //Update the loading information
                txt_AppInfo.Text = "Loading items";
                txt_NewsScrollInfo.Inlines.Clear();
                txt_NewsScrollInfo.Inlines.Add(new Run()
                {
                    Text = "Your news items from "
                });
                txt_NewsScrollInfo.Inlines.Add(new Run()
                {
                    Text = SelectedFeedTitle, Foreground = new SolidColorBrush((Color)Application.Current.Resources["ApplicationAccentLightColor"])
                });
                txt_NewsScrollInfo.Inlines.Add(new Run()
                {
                    Text = " will be shown here shortly..."
                });
                txt_NewsScrollInfo.Visibility = Visibility.Visible;

                //Check the loading feed
                if (LoadSelectFeeds)
                {
                    if ((bool)AppVariables.ApplicationSettings["DisplayReadMarkedItems"])
                    {
                        Feeds TempFeed = new Feeds();
                        TempFeed.feed_id          = "0";
                        vCurrentLoadingFeedFolder = TempFeed;
                        vPreviousScrollItem       = 0;
                    }
                    else
                    {
                        Feeds TempFeed = new Feeds();
                        TempFeed.feed_id          = "2";
                        vCurrentLoadingFeedFolder = TempFeed;
                        vPreviousScrollItem       = 0;
                    }
                }

                //Load items from api/database
                AppVariables.LoadNews    = true;
                AppVariables.LoadStarred = false;
                AppVariables.LoadSearch  = false;
                AppVariables.LoadFeeds   = true;
                int Result = await ApiUpdate.PageApiUpdate();

                //Check the api update result
                if (Result == 2)
                {
                    await CleanupPageResources();

                    App.vApplicationFrame.Navigate(typeof(SettingsPage));
                    //FixApp.vApplicationFrame.BackStack.Clear();
                    return;
                }

                //Set all items to list
                List <TableFeeds> LoadTableFeeds = await SQLConnection.Table <TableFeeds>().OrderBy(x => x.feed_folder).ToListAsync();

                List <TableItems> LoadTableItems = await SQLConnection.Table <TableItems>().ToListAsync();

                //Load items into the list
                await ProcessItemLoad.DatabaseToList(LoadTableFeeds, LoadTableItems, AppVariables.CurrentItemsLoaded, AppVariables.ItemsToScrollLoad, false, false);

                //Load feeds into selector
                if (LoadSelectFeeds)
                {
                    await LoadSelectionFeeds(LoadTableFeeds, LoadTableItems, false, true);
                }

                //Update feeds in selector
                if (UpdateSelectFeeds)
                {
                    await UpdateSelectionFeeds(LoadTableFeeds, LoadTableItems, false, true);
                }

                //Change the selection feed
                ChangeSelectionFeed(vCurrentLoadingFeedFolder, false);

                //Update the total item count
                UpdateTotalItemsCount();

                //Enable the interface manually
                if (!LoadSelectFeeds && !UpdateSelectFeeds)
                {
                    await ProgressEnableUI();
                }
            }
            catch { }
        }
Пример #13
0
        //Update the total items count
        private async Task UpdateTotalItemsCount(List <TableFeeds> LoadTableFeeds, List <TableItems> LoadTableItems, bool Silent, bool EnableUI)
        {
            try
            {
                //Set the total item count
                AppVariables.CurrentTotalItemsCount = await ProcessItemLoad.DatabaseToCount(LoadTableFeeds, LoadTableItems, Silent, EnableUI);

                await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    try
                    {
                        //Check the total item count
                        if (AppVariables.CurrentTotalItemsCount > 0)
                        {
                            txt_AppInfo.Text = AppVariables.CurrentTotalItemsCount + " results";
                            txt_NewsScrollInfo.Visibility = Visibility.Collapsed;

                            button_StatusCurrentItem.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            txt_AppInfo.Text = "No results";
                            txt_NewsScrollInfo.Inlines.Clear();
                            txt_NewsScrollInfo.Inlines.Add(new Run()
                            {
                                Text = "No search results could be found for "
                            });
                            txt_NewsScrollInfo.Inlines.Add(new Run()
                            {
                                Text = vSearchTerm, Foreground = new SolidColorBrush((Color)Application.Current.Resources["SystemAccentColor"])
                            });
                            txt_NewsScrollInfo.Inlines.Add(new Run()
                            {
                                Text = " in "
                            });
                            txt_NewsScrollInfo.Inlines.Add(new Run()
                            {
                                Text = vSearchFeedTitle, Foreground = new SolidColorBrush((Color)Application.Current.Resources["SystemAccentColor"])
                            });
                            txt_NewsScrollInfo.Visibility = Visibility.Visible;

                            button_StatusCurrentItem.Visibility = Visibility.Collapsed;

                            //Focus on the text box to open keyboard
                            txtbox_Search.IsEnabled = false;
                            txtbox_Search.IsEnabled = true;
                            txtbox_Search.Focus(FocusState.Programmatic);
                        }

                        //Update the current item count
                        Int32 HeaderTargetSize  = Convert.ToInt32(stackpanel_Header.Tag);
                        Int32 HeaderCurrentSize = Convert.ToInt32(stackpanel_Header.Height);
                        if (HeaderCurrentSize == HeaderTargetSize || AppVariables.CurrentTotalItemsCount == 0)
                        {
                            textblock_StatusCurrentItem.Text = textblock_StatusCurrentItem.Tag.ToString();
                        }
                        else
                        {
                            textblock_StatusCurrentItem.Text = textblock_StatusCurrentItem.Tag.ToString() + "/" + AppVariables.CurrentTotalItemsCount;
                        }
                    }
                    catch { }
                });
            }
            catch { }
        }
Пример #14
0
        //Search items from database
        async Task LoadItems()
        {
            try
            {
                //Clear all items and reset load count
                await ClearObservableCollection(List_SearchItems);

                //Get the currently selected feed
                vSearchFeed = combobox_FeedSelection.SelectedItem as Feeds;
                if (vSearchFeed.feed_title != null)
                {
                    vSearchFeedTitle = vSearchFeed.feed_title;
                }
                if (vSearchFeed.feed_folder_title != null)
                {
                    vSearchFeedTitle = vSearchFeed.feed_folder_title;
                }

                //Update the items count placer
                txt_AppInfo.Text = "Searching items";
                txt_NewsScrollInfo.Inlines.Clear();
                txt_NewsScrollInfo.Inlines.Add(new Run()
                {
                    Text = "Your search results for "
                });
                txt_NewsScrollInfo.Inlines.Add(new Run()
                {
                    Text = vSearchTerm, Foreground = new SolidColorBrush((Color)Application.Current.Resources["SystemAccentColor"])
                });
                txt_NewsScrollInfo.Inlines.Add(new Run()
                {
                    Text = " in "
                });
                txt_NewsScrollInfo.Inlines.Add(new Run()
                {
                    Text = vSearchFeedTitle, Foreground = new SolidColorBrush((Color)Application.Current.Resources["SystemAccentColor"])
                });
                txt_NewsScrollInfo.Inlines.Add(new Run()
                {
                    Text = " will be shown here shortly..."
                });
                txt_NewsScrollInfo.Visibility = Visibility.Visible;

                await EventProgressDisableUI("Searching for: " + vSearchTerm, true);

                Debug.WriteLine("Searching for: " + vSearchTerm);

                //Add search history to database
                await AddSearchHistory(vSearchTerm);

                //Load items from api/database
                AppVariables.LoadNews    = false;
                AppVariables.LoadStarred = false;
                AppVariables.LoadSearch  = true;
                AppVariables.LoadFeeds   = false;
                Int32 Result = await ApiUpdate.PageApiUpdate();

                //Check the api update result
                if (Result == 2)
                {
                    await CleanupPageResources();

                    App.vApplicationFrame.Navigate(typeof(SettingsPage));
                    App.vApplicationFrame.BackStack.Clear();
                    return;
                }

                //Wait for busy database
                await ApiUpdate.WaitForBusyDatabase();

                //Set all items to list
                List <TableItems> LoadTableItems = await SQLConnection.Table <TableItems>().ToListAsync();

                //Load items into the list
                await ProcessItemLoad.DatabaseToList(null, LoadTableItems, AppVariables.CurrentItemsLoaded, AppVariables.ItemsToScrollLoad, false, false);

                //Update the total items count
                await UpdateTotalItemsCount(null, LoadTableItems, false, true);
            }
            catch { }
        }
Пример #15
0
        //Update the total item count
        private async Task UpdateTotalItemsCount(List <TableFeeds> LoadTableFeeds, List <TableItems> LoadTableItems, bool Silent, bool EnableUI)
        {
            try
            {
                //Set the total item count
                AppVariables.CurrentTotalItemsCount = await ProcessItemLoad.DatabaseToCount(LoadTableFeeds, LoadTableItems, Silent, EnableUI);

                if (AppVariables.CurrentTotalItemsCount > 0)
                {
                    txt_AppInfo.Text             = ApiMessageError + AppVariables.CurrentTotalItemsCount + " items";
                    txt_NewsScrollInfo.IsVisible = false;

                    button_StatusCurrentItem.IsVisible = true;
                }
                else
                {
                    txt_AppInfo.Text = "No results";

                    Span text1 = new Span {
                        Text = "No search results could be found for "
                    };
                    Span text2 = new Span {
                        Text = vSearchTerm
                    };
                    text2.SetDynamicResource(Span.TextColorProperty, "ApplicationAccentLightColor");
                    Span text3 = new Span {
                        Text = " in "
                    };
                    Span text4 = new Span {
                        Text = vSearchFeedTitle
                    };
                    text4.SetDynamicResource(Span.TextColorProperty, "ApplicationAccentLightColor");

                    FormattedString formattedString = new FormattedString();
                    formattedString.Spans.Add(text1);
                    formattedString.Spans.Add(text2);
                    formattedString.Spans.Add(text3);
                    formattedString.Spans.Add(text4);
                    txt_NewsScrollInfo.FormattedText = formattedString;
                    txt_NewsScrollInfo.IsVisible     = true;

                    button_StatusCurrentItem.IsVisible = false;

                    //Focus on the text box to open keyboard
                    txtbox_Search.IsEnabled = false;
                    txtbox_Search.IsEnabled = true;
                    txtbox_Search.Focus();
                }

                //Update the current item count
                if (stackpanel_Header.IsVisible || AppVariables.CurrentTotalItemsCount == 0)
                {
                    label_StatusCurrentItem.Text = AppVariables.CurrentViewItemsCount.ToString();
                }
                else
                {
                    label_StatusCurrentItem.Text = AppVariables.CurrentViewItemsCount + "/" + AppVariables.CurrentTotalItemsCount;
                }
            }
            catch { }
        }
Пример #16
0
        //Load feeds in selection
        async Task LoadSelectionFeeds(List <TableFeeds> LoadTableFeeds, List <TableItems> LoadTableItems, bool Silent, bool EnableUI)
        {
            try
            {
                if (!Silent)
                {
                    await ProgressDisableUI("Loading selection feeds...", true);
                }
                Debug.WriteLine("Loading selection feeds, silent: " + Silent);

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

                //Wait for busy database
                await ApiUpdate.WaitForBusyDatabase();

                //Check if received lists are empty
                if (LoadTableFeeds == null)
                {
                    LoadTableFeeds = await SQLConnection.Table <TableFeeds>().OrderBy(x => x.feed_folder).ToListAsync();
                }
                if (LoadTableItems == null)
                {
                    LoadTableItems = await SQLConnection.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();

                if (!(bool)AppVariables.ApplicationSettings["DisplayReadMarkedItems"])
                {
                    //Add unread feeds selection
                    Feeds TempFeed = new Feeds();
                    TempFeed.feed_id = "2";

                    Int32 TotalItemsUnread = ProcessItemLoad.FilterNewsItems(IgnoredFeedList, LoadTableItems, TempFeed, 0, AppVariables.ItemsMaximumLoad).Count();
                    Feeds FeedItemUnread   = new Feeds();
                    FeedItemUnread.feed_icon = await AVImage.LoadBitmapImage("ms-appx:///Assets/iconRSS-Dark.png", false);

                    FeedItemUnread.feed_title             = "All unread 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";

                    Int32 TotalItemsRead = ProcessItemLoad.FilterNewsItems(IgnoredFeedList, LoadTableItems, TempFeed, 0, AppVariables.ItemsMaximumLoad).Count();
                    Feeds FeedItemRead   = new Feeds();
                    FeedItemRead.feed_icon = await AVImage.LoadBitmapImage("ms-appx:///Assets/iconRSS-Dark.png", false);

                    FeedItemRead.feed_title             = "Already read items";
                    FeedItemRead.feed_item_count        = TotalItemsRead;
                    FeedItemRead.feed_collection_status = true;
                    FeedItemRead.feed_id = "1";
                    List_FeedSelect.Add(FeedItemRead);
                }
                else
                {
                    //Add all feeds selection
                    Feeds TempFeed = new Feeds();
                    TempFeed.feed_id = "0";

                    Int32 TotalItemsAll = ProcessItemLoad.FilterNewsItems(IgnoredFeedList, LoadTableItems, TempFeed, 0, AppVariables.ItemsMaximumLoad).Count();
                    Feeds FeedItemAll   = new Feeds();
                    FeedItemAll.feed_icon = await AVImage.LoadBitmapImage("ms-appx:///Assets/iconRSS-Dark.png", false);

                    FeedItemAll.feed_title             = "All feed items";
                    FeedItemAll.feed_item_count        = TotalItemsAll;
                    FeedItemAll.feed_collection_status = true;
                    FeedItemAll.feed_id = "0";
                    List_FeedSelect.Add(FeedItemAll);
                }

                //Feeds that are not ignored and contain items
                foreach (TableFeeds Feed in UnignoredFeedList)
                {
                    Feeds TempFeed = new Feeds();
                    TempFeed.feed_id = Feed.feed_id;

                    Int32 TotalItems = ProcessItemLoad.FilterNewsItems(IgnoredFeedList, LoadTableItems, TempFeed, 0, AppVariables.ItemsMaximumLoad).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
                            BitmapImage FolderIcon = await AVImage.LoadBitmapImage("ms-appx:///Assets/iconFolder-Dark.png", false);

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

                        //Add feed
                        //Load feed icon
                        BitmapImage FeedIcon = null;
                        if (Feed.feed_id.StartsWith("user/"))
                        {
                            FeedIcon = await AVImage.LoadBitmapImage("ms-appx:///Assets/iconUser-Dark.png", false);
                        }
                        else
                        {
                            FeedIcon = await AVImage.LoadBitmapImage("ms-appdata:///local/" + Feed.feed_id + ".png", false);
                        }
                        if (FeedIcon == null)
                        {
                            FeedIcon = await AVImage.LoadBitmapImage("ms-appx:///Assets/iconRSS-Dark.png", false);
                        }

                        //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.IsHitTestVisible = true;
                combobox_FeedSelection.Opacity          = 1;
            }
            catch { }
            if (EnableUI)
            {
                await ProgressEnableUI();
            }
        }
Пример #17
0
        //Search items from database
        async Task LoadItems()
        {
            try
            {
                //Clear all items and reset load count
                await ClearObservableCollection(List_SearchItems);

                //Get the currently selected feed
                vSearchFeed = combobox_FeedSelection.SelectedItem as Feeds;
                if (vSearchFeed.feed_title != null)
                {
                    vSearchFeedTitle = vSearchFeed.feed_title;
                }
                if (vSearchFeed.feed_folder_title != null)
                {
                    vSearchFeedTitle = vSearchFeed.feed_folder_title;
                }

                //Update the items count placer
                txt_AppInfo.Text = "Searching items";

                Span text1 = new Span {
                    Text = "Your search results for "
                };
                Span text2 = new Span {
                    Text = vSearchTerm
                };
                text2.SetDynamicResource(Span.TextColorProperty, "ApplicationAccentLightColor");
                Span text3 = new Span {
                    Text = " in "
                };
                Span text4 = new Span {
                    Text = vSearchFeedTitle
                };
                text4.SetDynamicResource(Span.TextColorProperty, "ApplicationAccentLightColor");
                Span text5 = new Span {
                    Text = " will be shown here shortly..."
                };

                FormattedString formattedString = new FormattedString();
                formattedString.Spans.Add(text1);
                formattedString.Spans.Add(text2);
                formattedString.Spans.Add(text3);
                formattedString.Spans.Add(text4);
                formattedString.Spans.Add(text5);
                txt_NewsScrollInfo.FormattedText = formattedString;
                txt_NewsScrollInfo.IsVisible     = true;

                EventProgressDisableUI("Searching for: " + vSearchTerm, true);
                Debug.WriteLine("Searching for: " + vSearchTerm);

                //Add search history to database
                await AddSearchHistory(vSearchTerm);

                //Load items from api/database
                AppVariables.LoadNews    = false;
                AppVariables.LoadStarred = false;
                AppVariables.LoadSearch  = true;
                AppVariables.LoadFeeds   = false;
                int Result = await ApiUpdate.PageApiUpdate();

                //Check the api update result
                if (Result == 2)
                {
                    await CleanupPageResources();

                    App.NavigateToPage(new SettingsPage(), true, false);
                    return;
                }

                //Set all items to list
                List <TableItems> LoadTableItems = await vSQLConnection.Table <TableItems>().ToListAsync();

                //Load items into the list
                await ProcessItemLoad.DatabaseToList(null, LoadTableItems, AppVariables.CurrentItemsLoaded, AppVariables.ItemsToLoadMax, false, false);

                //Update the total items count
                await UpdateTotalItemsCount(null, LoadTableItems, false, true);
            }
            catch { }
        }