Пример #1
0
        async void iconApi_Tap(object sender, RoutedEventArgs e)
        {
            try
            {
                //Check username and password
                if (!String.IsNullOrWhiteSpace(AppVariables.ApplicationSettings["ApiAccount"].ToString()) && !String.IsNullOrWhiteSpace(AppVariables.ApplicationSettings["ApiPassword"].ToString()))
                {
                    HideShowMenu(true);

                    //Check if account has changed
                    await CheckAccountChange();

                    //Wait for busy application
                    await ApiUpdate.WaitForBusyApplication();

                    App.vApplicationFrame.Navigate(typeof(ApiPage));
                    App.vApplicationFrame.BackStack.Clear();
                    return;
                }
                else
                {
                    HideShowMenu(true);
                    await NoAccountPrompt();
                }
            }
            catch { }
        }
Пример #2
0
        //Add search history to database
        private async Task AddSearchHistory(string SearchTerm)
        {
            try
            {
                Debug.WriteLine("Adding " + SearchTerm + " to the search list and database...");

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

                //Clear search history from database
                await SQLConnection.ExecuteAsync("DELETE FROM TableSearchHistory WHERE lower(search_term) = ('" + SearchTerm.ToLower() + "')");

                //Add search term to database
                await SQLConnection.ExecuteAsync("INSERT INTO TableSearchHistory(search_term) VALUES ('" + SearchTerm + "')");

                //Count the current search terms
                Int32 CountItems = await SQLConnection.ExecuteScalarAsync <Int32>("SELECT count(search_term) FROM TableSearchHistory");

                //Cleanup older search terms
                if (CountItems > 20)
                {
                    Int32 DeletedItems = await SQLConnection.ExecuteAsync("DELETE FROM TableSearchHistory WHERE search_term IN(SELECT search_term FROM TableSearchHistory LIMIT 1)");

                    Debug.WriteLine("Removed " + DeletedItems + " older search history...");
                }

                //Update the search history
                await LoadSearchHistory();
            }
            catch { }
        }
Пример #3
0
        async void iconApi_Tap(object sender, EventArgs e)
        {
            try
            {
                //Check username and password
                if (!string.IsNullOrWhiteSpace(AppSettingLoad("ApiAccount").ToString()) && !string.IsNullOrWhiteSpace(AppSettingLoad("ApiPassword").ToString()))
                {
                    HideShowMenu(true);

                    //Check if account has changed
                    await CheckAccountChange();

                    //Wait for busy application
                    await ApiUpdate.WaitForBusyApplication();

                    App.NavigateToPage(new ApiPage(), true, false);
                    return;
                }
                else
                {
                    HideShowMenu(true);
                    await NoAccountPrompt();
                }
            }
            catch { }
        }
Пример #4
0
        //Ignore feeds in database
        async void btn_IgnoreFeeds_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Check for selected items
                if (ListView_Items.SelectedItems.Count == 0)
                {
                    await AVMessageBox.Popup("No feeds selected", "Please select some feeds that you want to un/ignore first.", "Ok", "", "", "", "", false);

                    return;
                }
                else
                {
                    try
                    {
                        //Wait for busy application
                        await ApiUpdate.WaitForBusyApplication();

                        await ProgressDisableUI("Un/ignoring selected feeds...", true);

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

                        List <TableFeeds> TableEditFeeds = await SQLConnection.Table <TableFeeds>().ToListAsync();

                        foreach (Feeds SelectedItem in ListView_Items.SelectedItems)
                        {
                            TableFeeds TableResult = TableEditFeeds.Where(x => x.feed_id == SelectedItem.feed_id).FirstOrDefault();
                            if (SelectedItem.feed_ignore_status == Visibility.Visible)
                            {
                                TableResult.feed_ignore_status  = false;
                                SelectedItem.feed_ignore_status = Visibility.Collapsed;
                            }
                            else
                            {
                                TableResult.feed_ignore_status  = true;
                                SelectedItem.feed_ignore_status = Visibility.Visible;
                            }
                        }

                        //Update the items in database
                        await SQLConnection.UpdateAllAsync(TableEditFeeds);

                        //Reset the list selection
                        ListView_Items.SelectedIndex = -1;
                        await AVMessageBox.Popup("Feeds have been un/ignored", "Their items will be hidden or shown again on the next news item refresh.", "Ok", "", "", "", "", false);
                    }
                    catch
                    {
                        await AVMessageBox.Popup("Failed to un/ignore feeds", "Please try to un/ignored the feeds again.", "Ok", "", "", "", "", false);
                    }

                    await ProgressEnableUI();
                }
            }
            catch { }
        }
Пример #5
0
        async void iconHelp_Tap(object sender, EventArgs e)
        {
            try
            {
                HideShowMenu(true);

                //Wait for busy application
                await ApiUpdate.WaitForBusyApplication();

                App.NavigateToPage(new HelpPage(), true, false);
            }
            catch { }
        }
Пример #6
0
        //Delete feeds from The Old Reader/Database
        async void btn_DeleteFeeds_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Check for internet connection
                if (!NetworkInterface.GetIsNetworkAvailable())
                {
                    await AVMessageBox.Popup("No internet connection", "Deleting a feed can only be done when there is an internet connection available.", "Ok", "", "", "", "", false);

                    return;
                }

                //Check for selected items
                if (ListView_Items.SelectedItems.Count == 0)
                {
                    await AVMessageBox.Popup("No feeds selected", "Please select some feeds that you want to delete first.", "Ok", "", "", "", "", false);

                    return;
                }
                else
                {
                    //Wait for busy application
                    await ApiUpdate.WaitForBusyApplication();

                    await ProgressDisableUI("Deleting the selected feeds...", true);

                    try
                    {
                        foreach (Feeds SelectedItem in ListView_Items.SelectedItems)
                        {
                            await DeleteFeed(SelectedItem.feed_id);
                        }
                        await AVMessageBox.Popup("Feeds have been deleted", "The feeds and it's items will disappear on the next refresh.", "Ok", "", "", "", "", false);
                    }
                    catch
                    {
                        await AVMessageBox.Popup("Failed to delete feeds", "Please check your account settings, internet connection and try again.", "Ok", "", "", "", "", false);
                    }

                    //Reset the online status
                    OnlineUpdateFeeds = true;
                    ApiMessageError   = String.Empty;

                    //Load all the feeds
                    await LoadFeeds();

                    await ProgressEnableUI();
                }
            }
            catch { }
        }
Пример #7
0
        async void iconHelp_Tap(object sender, RoutedEventArgs e)
        {
            try
            {
                HideShowMenu(true);

                //Wait for busy application
                await ApiUpdate.WaitForBusyApplication();

                App.vApplicationFrame.Navigate(typeof(HelpPage));
                App.vApplicationFrame.BackStack.Clear();
            }
            catch { }
        }
Пример #8
0
        async void iconSettings_Tap(object sender, EventArgs e)
        {
            try
            {
                HideShowMenu(true);

                //Wait for busy application
                await ApiUpdate.WaitForBusyApplication();

                await CleanupPageResources();

                App.NavigateToPage(new SettingsPage(), true, false);
            }
            catch { }
        }
Пример #9
0
        //Load the search history
        private async Task LoadSearchHistory()
        {
            try
            {
                //Wait for busy database
                await ApiUpdate.WaitForBusyDatabase();

                //Load and add search history
                txtbox_Search.ItemsSource = (await SQLConnection.Table <TableSearchHistory>().ToListAsync()).Select(x => x.search_term).Reverse();

                //Set the autosuggestbox list height
                txtbox_Search.MaxSuggestionListHeight = 140;
            }
            catch { }
        }
Пример #10
0
        async void iconSettings_Tap(object sender, RoutedEventArgs e)
        {
            try
            {
                HideShowMenu(true);

                //Wait for busy application
                await ApiUpdate.WaitForBusyApplication();

                await CleanupPageResources();

                App.vApplicationFrame.Navigate(typeof(SettingsPage));
                //FixApp.vApplicationFrame.BackStack.Clear();
            }
            catch { }
        }
Пример #11
0
        //Load and set database size
        async Task UpdateSizeInformation()
        {
            try
            {
                //Wait for busy database
                await ApiUpdate.WaitForBusyDatabase();

                string DatabaseSize = await GetDatabaseSize();

                Int32 TotalItems = await SQLConnection.Table <TableItems>().CountAsync();

                Int32 TotalFeeds = await SQLConnection.Table <TableFeeds>().CountAsync();

                txt_OfflineStoredSize.Text = "Offline stored database is " + DatabaseSize + "\nin size and contains a total of " + TotalItems + "\nstored items and has " + TotalFeeds + " feeds in it.";
            }
            catch { }
        }
Пример #12
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 { }
        }
Пример #13
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 { }
        }
Пример #14
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 { }
        }
Пример #15
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 { }
        }
Пример #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
        //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 { }
        }
Пример #18
0
        //Load items from database to list
        public static async Task DatabaseToList(List <TableFeeds> LoadTableFeeds, List <TableItems> LoadTableItems, Int32 SkipItems, Int32 NumberOfItems, bool Silent, bool EnableUI)
        {
            try
            {
                //Wait for busy database
                await ApiUpdate.WaitForBusyDatabase();

                //Load items from the table
                if (AppVariables.LoadNews)
                {
                    if (!Silent)
                    {
                        await EventProgressDisableUI("Checking news items...", true);
                    }
                    Debug.WriteLine("Checking news items...");

                    //Check if received lists are empty
                    if (LoadTableFeeds == null)
                    {
                        LoadTableFeeds = await SQLConnection.Table <TableFeeds>().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();
                    LoadTableItems = FilterNewsItems(IgnoredFeedList, LoadTableItems, NewsPage.vCurrentLoadingFeedFolder, SkipItems, NumberOfItems);

                    if (!Silent)
                    {
                        await EventProgressDisableUI("Loading " + LoadTableItems.Count() + " news items...", true);
                    }
                    Debug.WriteLine("Loading " + LoadTableItems.Count() + ", skipped " + SkipItems + " loaded news items...");

                    await Process.ProcessTableItemsToList(List_NewsItems, LoadTableItems, false, false, false);
                }
                else if (AppVariables.LoadStarred)
                {
                    if (!Silent)
                    {
                        await EventProgressDisableUI("Checking starred items...", true);
                    }
                    Debug.WriteLine("Checking starred items...");

                    //Check if received lists are empty
                    if (LoadTableItems == null)
                    {
                        LoadTableItems = await SQLConnection.Table <TableItems>().ToListAsync();
                    }

                    //Filter starred items
                    LoadTableItems = LoadTableItems.Where(x => x.item_star_status == true).OrderByDescending(x => x.item_datetime).Skip(SkipItems).Take(NumberOfItems).ToList();

                    if (!Silent)
                    {
                        await EventProgressDisableUI("Loading " + LoadTableItems.Count() + " starred items...", true);
                    }
                    Debug.WriteLine("Loading " + LoadTableItems.Count() + ", skipped " + SkipItems + " loaded starred items...");

                    await Process.ProcessTableItemsToList(List_StarredItems, LoadTableItems, false, false, false);
                }
                else if (AppVariables.LoadSearch)
                {
                    if (!Silent)
                    {
                        await EventProgressDisableUI("Searching for: " + SearchPage.vSearchTerm, true);
                    }
                    Debug.WriteLine("Searching for: " + SearchPage.vSearchTerm);

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

                    //Filter un/ignored feeds
                    List <String> UnignoredFeedList = LoadTableFeeds.Where(x => x.feed_ignore_status == false).Select(x => x.feed_id).ToList();

                    //Get the search items by feed or folder
                    if (SearchPage.vSearchFeed.feed_folder_status)
                    {
                        List <String> SearchFolders = SearchPage.vSearchFeed.feed_folder_ids;
                        Debug.WriteLine("Search in folders: " + String.Join(", ", SearchFolders));
                        LoadTableItems = LoadTableItems.Where(x => x.item_title.ToLower().Contains(SearchPage.vSearchTerm.ToLower()) && SearchFolders.Any(y => y == x.item_feed_id) && UnignoredFeedList.Any(y => y == x.item_feed_id)).ToList();
                    }
                    else
                    {
                        string FeedId = SearchPage.vSearchFeed.feed_id;
                        if (FeedId != "0")
                        {
                            Debug.WriteLine("Search in feed: " + FeedId);
                            LoadTableItems = LoadTableItems.Where(x => x.item_title.ToLower().Contains(SearchPage.vSearchTerm.ToLower()) && x.item_feed_id == FeedId && UnignoredFeedList.Any(y => y == x.item_feed_id)).ToList();
                        }
                        else
                        {
                            Debug.WriteLine("Search in all items.");
                            LoadTableItems = LoadTableItems.Where(x => x.item_title.ToLower().Contains(SearchPage.vSearchTerm.ToLower()) && UnignoredFeedList.Any(y => y == x.item_feed_id)).ToList();
                        }
                    }

                    //Search items in table
                    LoadTableItems = LoadTableItems.OrderByDescending(x => x.item_datetime).Skip(SkipItems).Take(NumberOfItems).ToList();

                    //if (!Silent) { await EventProgressDisableUI("Loading " + LoadTableItems.Count() + " found items...", true); }
                    Debug.WriteLine("Loading " + LoadTableItems.Count() + ", skipped " + SkipItems + " found items...");

                    await Process.ProcessTableItemsToList(List_SearchItems, LoadTableItems, false, false, false);
                }
                else if (AppVariables.LoadFeeds)
                {
                    if (!Silent)
                    {
                        await EventProgressDisableUI("Checking feeds...", true);
                    }
                    Debug.WriteLine("Checking feeds...");

                    //Check if received lists are empty
                    if (LoadTableFeeds == null)
                    {
                        LoadTableFeeds = await SQLConnection.Table <TableFeeds>().ToListAsync();
                    }

                    if (!Silent)
                    {
                        await EventProgressDisableUI("Loading " + LoadTableFeeds.Count() + " feeds...", true);
                    }
                    Debug.WriteLine("Loading " + LoadTableFeeds.Count() + " feeds...");

                    await Process.ProcessTableFeedsToList(List_Feeds, LoadTableFeeds);
                }

                if (EnableUI)
                {
                    await EventProgressEnableUI();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed loading items: " + ex.Message);
                await EventProgressEnableUI();
            }
        }
Пример #19
0
        //Count items from database
        public static async Task <Int32> DatabaseToCount(List <TableFeeds> LoadTableFeeds, List <TableItems> LoadTableItems, bool Silent, bool EnableUI)
        {
            Int32 FoundItems = 0;

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

                //Load items from the table
                if (AppVariables.LoadNews)
                {
                    if (!Silent)
                    {
                        await EventProgressDisableUI("Counting news items...", true);
                    }
                    Debug.WriteLine("Counting news items...");

                    //Check if received lists are empty
                    if (LoadTableFeeds == null)
                    {
                        LoadTableFeeds = await SQLConnection.Table <TableFeeds>().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();
                    FoundItems = FilterNewsItems(IgnoredFeedList, LoadTableItems, NewsPage.vCurrentLoadingFeedFolder, 0, AppVariables.ItemsMaximumLoad).Count();
                }
                else if (AppVariables.LoadStarred)
                {
                    if (!Silent)
                    {
                        await EventProgressDisableUI("Counting starred items...", true);
                    }
                    Debug.WriteLine("Counting starred items...");

                    //Check if received lists are empty
                    if (LoadTableItems == null)
                    {
                        LoadTableItems = await SQLConnection.Table <TableItems>().ToListAsync();
                    }

                    //Filter starred items
                    FoundItems = LoadTableItems.Where(x => x.item_star_status == true).Count();
                }
                else if (AppVariables.LoadSearch)
                {
                    if (!Silent)
                    {
                        await EventProgressDisableUI("Counting search items...", true);
                    }
                    Debug.WriteLine("Counting search items...");

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

                    //Filter un/ignored feeds
                    List <String> UnignoredFeedList = LoadTableFeeds.Where(x => x.feed_ignore_status == false).Select(x => x.feed_id).ToList();

                    //Get the search items by feed or folder
                    if (SearchPage.vSearchFeed.feed_folder_status)
                    {
                        List <String> SearchFolders = SearchPage.vSearchFeed.feed_folder_ids;
                        Debug.WriteLine("Search in folders: " + String.Join(", ", SearchFolders));
                        LoadTableItems = LoadTableItems.Where(x => x.item_title.ToLower().Contains(SearchPage.vSearchTerm.ToLower()) && SearchFolders.Any(y => y == x.item_feed_id) && UnignoredFeedList.Any(y => y == x.item_feed_id)).ToList();
                    }
                    else
                    {
                        string FeedId = SearchPage.vSearchFeed.feed_id;
                        if (FeedId != "0")
                        {
                            Debug.WriteLine("Search in feed: " + FeedId);
                            LoadTableItems = LoadTableItems.Where(x => x.item_title.ToLower().Contains(SearchPage.vSearchTerm.ToLower()) && x.item_feed_id == FeedId && UnignoredFeedList.Any(y => y == x.item_feed_id)).ToList();
                        }
                        else
                        {
                            Debug.WriteLine("Search in all items.");
                            LoadTableItems = LoadTableItems.Where(x => x.item_title.ToLower().Contains(SearchPage.vSearchTerm.ToLower()) && UnignoredFeedList.Any(y => y == x.item_feed_id)).ToList();
                        }
                    }

                    //Count items in table
                    FoundItems = LoadTableItems.Count();
                }
                else if (AppVariables.LoadFeeds)
                {
                    if (!Silent)
                    {
                        await EventProgressDisableUI("Counting your feeds...", true);
                    }
                    Debug.WriteLine("Counting your feeds...");

                    //Check if received lists are empty
                    if (LoadTableFeeds == null)
                    {
                        LoadTableFeeds = await SQLConnection.Table <TableFeeds>().ToListAsync();
                    }

                    //Load feeds from table
                    FoundItems = LoadTableFeeds.Count();
                }

                if (EnableUI)
                {
                    await EventProgressEnableUI();
                }
                return(FoundItems);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed counting items: " + ex.Message);
                await EventProgressEnableUI();

                return(FoundItems);
            }
        }
Пример #20
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 { }
        }
Пример #21
0
        //Delete feeds from The Old Reader/Database
        async void btn_DeleteFeeds_Click(object sender, EventArgs e)
        {
            try
            {
                //Check for internet connection
                if (Connectivity.NetworkAccess != NetworkAccess.Internet)
                {
                    List <string> messageAnswers = new List <string>();
                    messageAnswers.Add("Ok");

                    await MessagePopup.Popup("No internet connection", "Deleting a feed can only be done when there is an internet connection available.", messageAnswers);

                    return;
                }

                //Check for selected items
                if (listview_Items.SelectedItem == null)
                {
                    List <string> messageAnswers = new List <string>();
                    messageAnswers.Add("Ok");

                    await MessagePopup.Popup("No feeds selected", "Please select some feeds that you want to delete first.", messageAnswers);

                    return;
                }
                else
                {
                    //Wait for busy application
                    await ApiUpdate.WaitForBusyApplication();

                    ProgressDisableUI("Deleting the selected feeds...", true);

                    try
                    {
                        Feeds SelectedItem = (Feeds)listview_Items.SelectedItem;
                        await DeleteFeed(SelectedItem.feed_id);

                        List <string> messageAnswers = new List <string>();
                        messageAnswers.Add("Ok");

                        await MessagePopup.Popup("Feeds have been deleted", "The feeds and it's items will disappear on the next refresh.", messageAnswers);
                    }
                    catch
                    {
                        List <string> messageAnswers = new List <string>();
                        messageAnswers.Add("Ok");

                        await MessagePopup.Popup("Failed to delete feeds", "Please check your account settings, internet connection and try again.", messageAnswers);
                    }

                    //Reset the online status
                    OnlineUpdateFeeds = true;
                    ApiMessageError   = string.Empty;

                    //Load all the feeds
                    await LoadFeeds();

                    ProgressEnableUI();
                }
            }
            catch { }
        }
Пример #22
0
        //Ignore feeds in database
        async void btn_IgnoreFeeds_Click(object sender, EventArgs e)
        {
            try
            {
                //Check for selected items
                if (listview_Items.SelectedItem == null)
                {
                    List <string> messageAnswers = new List <string>();
                    messageAnswers.Add("Ok");

                    await MessagePopup.Popup("No feeds selected", "Please select some feeds that you want to un/ignore first.", messageAnswers);

                    return;
                }
                else
                {
                    try
                    {
                        //Wait for busy application
                        await ApiUpdate.WaitForBusyApplication();

                        ProgressDisableUI("Un/ignoring selected feeds...", true);

                        List <TableFeeds> TableEditFeeds = await vSQLConnection.Table <TableFeeds>().ToListAsync();

                        Feeds      SelectedItem = (Feeds)listview_Items.SelectedItem;
                        TableFeeds TableResult  = TableEditFeeds.Where(x => x.feed_id == SelectedItem.feed_id).FirstOrDefault();
                        if (SelectedItem.feed_ignore_status == true)
                        {
                            TableResult.feed_ignore_status  = false;
                            SelectedItem.feed_ignore_status = false;
                        }
                        else
                        {
                            TableResult.feed_ignore_status  = true;
                            SelectedItem.feed_ignore_status = true;
                        }

                        //Update the items in database
                        await vSQLConnection.UpdateAllAsync(TableEditFeeds);

                        //Reset the list selection
                        listview_Items.SelectedItem = -1;

                        List <string> messageAnswers = new List <string>();
                        messageAnswers.Add("Ok");

                        await MessagePopup.Popup("Feeds have been un/ignored", "Their items will be hidden or shown again on the next news item refresh.", messageAnswers);
                    }
                    catch
                    {
                        List <string> messageAnswers = new List <string>();
                        messageAnswers.Add("Ok");

                        await MessagePopup.Popup("Failed to un/ignore feeds", "Please try to un/ignored the feeds again.", messageAnswers);
                    }

                    ProgressEnableUI();
                }
            }
            catch { }
        }
Пример #23
0
        //Update feeds in selection
        async Task UpdateSelectionFeeds(List <TableFeeds> LoadTableFeeds, List <TableItems> LoadTableItems, bool Silent, bool EnableUI)
        {
            try
            {
                if (!Silent)
                {
                    await ProgressDisableUI("Updating selection feeds...", true);
                }
                Debug.WriteLine("Updating selection feeds, silent: " + Silent);

                combobox_FeedSelection.IsHitTestVisible = false;
                combobox_FeedSelection.Opacity          = 0.30;

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

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

                //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.ItemsMaximumLoad).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)AppVariables.ApplicationSettings["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 && vCurrentLoadingFeedFolder.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.IsHitTestVisible = true;
                combobox_FeedSelection.Opacity          = 1;
            }
            catch { }
            if (EnableUI)
            {
                await ProgressEnableUI();
            }
        }
Пример #24
0
        public static async Task <bool> ProcessTableItemsToList(ObservableCollection <Items> AddList, List <TableItems> LoadTableItems, bool AddFromTop, bool HideReadStatus, bool HideStarStatus)
        {
            try
            {
                //Check if media needs to load
                AppVariables.LoadMedia = true;
                if (!NetworkInterface.GetIsNetworkAvailable() && !(bool)AppVariables.ApplicationSettings["DisplayImagesOffline"])
                {
                    AppVariables.LoadMedia = false;
                }

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

                List <TableFeeds> FeedList = await SQLConnection.Table <TableFeeds>().ToListAsync();

                foreach (TableItems LoadTable in LoadTableItems)
                {
                    //Load and check item id
                    string ItemId = LoadTable.item_id;
                    if (!AddList.Any(x => x.item_id == ItemId))
                    {
                        //Load feed id and title
                        string FeedId    = LoadTable.item_feed_id;
                        string FeedTitle = "Unknown feed";

                        TableFeeds TableResult = FeedList.Where(x => x.feed_id == FeedId).FirstOrDefault();
                        if (TableResult == null)
                        {
                            //Debug.WriteLine("Feed not found: " + FeedId);
                            if (LoadTable.item_feed_title != null && !String.IsNullOrWhiteSpace(LoadTable.item_feed_title))
                            {
                                Debug.WriteLine("Backup feed title: " + LoadTable.item_feed_title);
                                FeedTitle = LoadTable.item_feed_title;
                            }
                            else if (FeedId.StartsWith("user/"))
                            {
                                Debug.WriteLine("Detected an user feed.");
                                FeedTitle = "User feed";
                            }
                        }
                        else
                        {
                            //Set the feed item title
                            FeedTitle = TableResult.feed_title;
                        }

                        //Load item image
                        BitmapImage ItemImage           = null;
                        Visibility  ItemImageVisibility = Visibility.Collapsed;
                        string      ItemImageLink       = LoadTable.item_image;
                        if (!String.IsNullOrWhiteSpace(ItemImageLink) && AppVariables.LoadMedia)
                        {
                            ItemImageVisibility = Visibility.Visible;
                            if (AppVariables.CurrentItemsLoaded < AppVariables.ContentToScrollLoad)
                            {
                                ItemImage = await AVImage.LoadBitmapImage(ItemImageLink, false);
                            }
                        }

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

                        //Set the date time string
                        DateTime convertedDate    = DateTime.SpecifyKind(LoadTable.item_datetime, DateTimeKind.Utc).ToLocalTime();
                        string   DateAuthorString = convertedDate.ToString(AppVariables.CultureInfoFormat.LongDatePattern, AppVariables.CultureInfoFormat) + ", " + convertedDate.ToString(AppVariables.CultureInfoFormat.ShortTimePattern, AppVariables.CultureInfoFormat);

                        //Add the author to date time
                        if ((bool)AppVariables.ApplicationSettings["DisplayItemsAuthor"] && !String.IsNullOrWhiteSpace(LoadTable.item_author))
                        {
                            DateAuthorString += " by " + LoadTable.item_author;
                        }

                        //Check item read or star status
                        Visibility ReadVisibility = Visibility.Collapsed;
                        if (!HideReadStatus)
                        {
                            ReadVisibility = LoadTable.item_read_status ? Visibility.Visible : Visibility.Collapsed;
                        }
                        Visibility StarredVisibility = Visibility.Collapsed;
                        if (!HideStarStatus)
                        {
                            StarredVisibility = LoadTable.item_star_status ? Visibility.Visible : Visibility.Collapsed;
                        }

                        //Load item content
                        string item_content = String.Empty;
                        if ((bool)AppVariables.ApplicationSettings["ContentCutting"])
                        {
                            item_content = AVFunctions.StringCut(LoadTable.item_content, Convert.ToInt32(AppVariables.ApplicationSettings["ContentCuttingLength"]), "...");
                        }
                        else
                        {
                            item_content = AVFunctions.StringCut(LoadTable.item_content, AppVariables.MaximumItemTextLength, "...");
                        }

                        //Add item to the ListView
                        Items NewItem = new Items()
                        {
                            feed_id = FeedId, feed_title = FeedTitle, feed_icon = FeedIcon, item_id = ItemId, item_read_status = ReadVisibility, item_star_status = StarredVisibility, item_title = LoadTable.item_title, item_image = ItemImage, item_image_visibility = ItemImageVisibility, item_image_link = ItemImageLink, item_content = item_content, item_link = LoadTable.item_link, item_datestring = DateAuthorString, item_datetime = LoadTable.item_datetime
                        };
                        await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            try
                            {
                                if (AddFromTop)
                                {
                                    AddList.Insert(0, NewItem);
                                }
                                else
                                {
                                    AddList.Add(NewItem);
                                }
                            }
                            catch { }
                        });

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

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

                return(true);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed processing multiple items from database: " + ex.Message);
                return(false);
            }
        }
Пример #25
0
        //Load item into the viewer
        private async Task LoadItem(string CustomItemContent)
        {
            try
            {
                //Wait for busy database
                await ApiUpdate.WaitForBusyDatabase();

                //Load the full item
                TableItems LoadTable = await SQLConnection.Table <TableItems>().Where(x => x.item_id == vCurrentWebSource.item_id).FirstOrDefaultAsync();

                if (LoadTable != null)
                {
                    //Check if media needs to load
                    AppVariables.LoadMedia = true;
                    if (!NetworkInterface.GetIsNetworkAvailable() && !(bool)AppVariables.ApplicationSettings["DisplayImagesOffline"])
                    {
                        AppVariables.LoadMedia = false;
                    }

                    //Set the date time string
                    DateTime convertedDate    = DateTime.SpecifyKind(LoadTable.item_datetime, DateTimeKind.Utc).ToLocalTime();
                    string   DateAuthorString = convertedDate.ToString(AppVariables.CultureInfoFormat.LongDatePattern, AppVariables.CultureInfoFormat) + ", " + convertedDate.ToString(AppVariables.CultureInfoFormat.ShortTimePattern, AppVariables.CultureInfoFormat);

                    //Add the author to date time
                    if (!string.IsNullOrWhiteSpace(LoadTable.item_author))
                    {
                        DateAuthorString += " by " + LoadTable.item_author;
                    }
                    tb_ItemDateString.Text = DateAuthorString;

                    //Enable or disable text selection
                    if ((bool)AppVariables.ApplicationSettings["ItemTextSelection"])
                    {
                        tb_ItemTitle.IsTextSelectionEnabled      = true;
                        tb_ItemDateString.IsTextSelectionEnabled = true;
                        rtb_ItemContent.IsTextSelectionEnabled   = true;
                    }
                    else
                    {
                        tb_ItemTitle.IsTextSelectionEnabled      = false;
                        tb_ItemDateString.IsTextSelectionEnabled = false;
                        rtb_ItemContent.IsTextSelectionEnabled   = false;
                    }

                    //Load the item content
                    bool SetHtmlToRichTextBlock = false;
                    if (!string.IsNullOrWhiteSpace(CustomItemContent))
                    {
                        await HtmlToRichTextBlock(rtb_ItemContent, CustomItemContent, string.Empty);

                        SetHtmlToRichTextBlock = true;
                    }
                    else if (!string.IsNullOrWhiteSpace(LoadTable.item_content_full))
                    {
                        SetHtmlToRichTextBlock = await HtmlToRichTextBlock(rtb_ItemContent, LoadTable.item_content_full, string.Empty);
                    }

                    //Check if html to xaml has failed
                    if (!SetHtmlToRichTextBlock || !rtb_ItemContent.Blocks.Any())
                    {
                        //Load summary text
                        Paragraph paragraph = new Paragraph();
                        paragraph.Inlines.Add(new Run()
                        {
                            Text = AVFunctions.StringCut(LoadTable.item_content, AppVariables.MaximumItemTextLength, "...")
                        });

                        //Add paragraph to rich text block
                        rtb_ItemContent.Blocks.Clear();
                        rtb_ItemContent.Blocks.Add(paragraph);
                    }

                    //Wait for item content is loaded
                    await AppAdjust.FinishLayoutUpdateAsync(rtb_ItemContent);

                    //Check if item content contains preview image
                    await CheckItemContentContainsPreviewImage(LoadTable);

                    //Adjust the itemviewer size
                    await AdjustItemViewerSize();
                }
            }
            catch { }
        }
Пример #26
0
        //Clear Database Thread
        async Task ClearDatabase()
        {
            await ProgressDisableUI("Clearing stored items...");

            try
            {
                //Reset the online status
                OnlineUpdateFeeds   = true;
                OnlineUpdateNews    = true;
                OnlineUpdateStarred = true;
                ApiMessageError     = String.Empty;

                //Reset the last update setting
                AppVariables.ApplicationSettings["LastItemsUpdate"] = "Never";

                await ClearObservableCollection(List_Feeds);
                await ClearObservableCollection(List_FeedSelect);
                await ClearObservableCollection(List_NewsItems);
                await ClearObservableCollection(List_SearchItems);
                await ClearObservableCollection(List_StarredItems);

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

                await SQLConnection.DeleteAllAsync <TableFeeds>();

                await SQLConnection.DropTableAsync <TableFeeds>();

                await SQLConnection.CreateTableAsync <TableFeeds>();

                await SQLConnection.DeleteAllAsync <TableOffline>();

                await SQLConnection.DropTableAsync <TableOffline>();

                await SQLConnection.CreateTableAsync <TableOffline>();

                await SQLConnection.DeleteAllAsync <TableItems>();

                await SQLConnection.DropTableAsync <TableItems>();

                await SQLConnection.CreateTableAsync <TableItems>();

                await SQLConnection.DeleteAllAsync <TableSearchHistory>();

                await SQLConnection.DropTableAsync <TableSearchHistory>();

                await SQLConnection.CreateTableAsync <TableSearchHistory>();

                //Delete all feed icons from local storage
                foreach (IStorageItem LocalFile in await ApplicationData.Current.LocalFolder.GetItemsAsync())
                {
                    try
                    {
                        if (LocalFile.Name.EndsWith(".png"))
                        {
                            await LocalFile.DeleteAsync(StorageDeleteOption.PermanentDelete);
                        }
                    }
                    catch { }
                }

                //Load and set database size
                await UpdateSizeInformation();
            }
            catch { }
            await ProgressEnableUI();
        }
Пример #27
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 { }
        }