protected override async Task Archive(ReaderItem item) { await CacheService.DeleteArticle(item); Items.Remove(item); await CacheService.SaveLocalItems(Items); }
private async Task SaveItemFromExternal(UriSchemeMessage message, Action errorAction = null) { HomeButtonIsVisible = true; var allOk = true; ReaderItem item = null; try { IsSavingVisible = true; item = await _readerHelper.HandleProtocolMessage(message); } catch (Exception ex) { Log.ErrorException("ShareMessage", ex); allOk = false; } if (item != null) { await SetReaderItem(item, autostart : false); } IsSavingVisible = false; if (allOk && _canStart) { StartStopTimer(); } else { errorAction?.Invoke(); } }
protected override async Task <ReaderItem> GetArticle(ReaderItem item, bool isRefresh = false) { if (item == null) { return(null); } if (!isRefresh) { var article = await CacheService.GetArticle(item); if (article != null) { return(article); } } var text = await GetArticleText(item.Id); var result = new ReaderItem(); item.CopyItem(result); result.Text = text.StripHtmlTags(); item.Text = result.Text.ToExcerpt(); item.IsDownloaded = !string.IsNullOrEmpty(result.Text); await CacheService.SaveArticle(result).ConfigureAwait(false); return(result); }
protected override async Task <ReaderItem> GetArticle(ReaderItem item, bool isRefresh = false) { if (item == null) { return(null); } if (!isRefresh) { var article = await CacheService.GetArticle(item); if (article != null) { return(article); } } var response = await _readabilityClient.GetArticleAsync(item.Id); if (response != null) { var article = response.ToReaderItem(); item.IsDownloaded = !string.IsNullOrEmpty(article.Text); await CacheService.SaveArticle(article).ConfigureAwait(false); return(article); } return(null); }
protected override async Task Archive(ReaderItem item) { if (!AuthenticationService.IsLoggedIntoReadability) { return; } var id = int.Parse(item.Id); var failed = false; try { await _readabilityClient.SetBookmarkArchiveStateAsync(id, true); } catch (Exception ex) { Log.ErrorException("ArchiveArticle", ex); failed = true; } if (!failed) { var itemToRemove = Items.FirstOrDefault(x => x.Id == item.Id); if (itemToRemove != null) { Items.Remove(itemToRemove); } CacheService.SaveReadabilityItems(Items).ConfigureAwait(false); await CacheService.DeleteArticle(item); } }
protected override async Task Archive(ReaderItem item) { if (!AuthenticationService.IsLoggedInToPocket) { return; } var failed = false; try { if (!await _pocketClient.Archive(item.Id)) { failed = true; } } catch (Exception ex) { Log.ErrorException("PocketArchiveMessage", ex); failed = true; } if (!failed) { var itemToDelete = Items.FirstOrDefault(x => x.Id == item.Id); if (itemToDelete == null) { return; } Items.Remove(itemToDelete); CacheService.SavePocketItems(Items).ConfigureAwait(false); await CacheService.DeleteArticle(item); } }
protected override async Task<ReaderItem> GetArticle(ReaderItem item, bool isRefresh = false) { if (item == null) { return null; } if (!isRefresh) { var article = await CacheService.GetArticle(item); if (article != null) { return article; } } var text = await GetArticleText(item.Id); var result = new ReaderItem(); item.CopyItem(result); result.Text = text.StripHtmlTags(); item.Text = result.Text.ToExcerpt(); item.IsDownloaded = !string.IsNullOrEmpty(result.Text); await CacheService.SaveArticle(result).ConfigureAwait(false); return result; }
public async Task DeleteArticle(ReaderItem item) { var filename = GetFileName(item.InternalId); if (await _storage.Local.FileExistsAsync(filename)) { await _storage.Local.DeleteFileAsync(filename); } }
protected override async Task<ReaderItem> GetArticle(ReaderItem item, bool isRefresh = false) { if (item == null) { return null; } var article = await CacheService.GetArticle(item); return article; }
protected override async Task <ReaderItem> GetArticle(ReaderItem item, bool isRefresh = false) { if (item == null) { return(null); } var article = await CacheService.GetArticle(item); return(article); }
protected virtual async Task FullPage(ReaderItem item) { var article = await GetArticle(item); if (article == null) { return; } FullPageViewModel.ReaderItem = article; NavigationService.Navigate <FullPageView>(); }
public async Task SaveArticle(ReaderItem item) { var filename = GetFileName(item.InternalId); using (var file = await _storage.Local.CreateFileAsync(filename)) { using (var writer = new BinaryWriter(file)) { writer.Write(item); } } }
protected virtual async Task Reader(ReaderItem item) { var article = await GetArticle(item); if (article == null) { return; } ReaderViewModel.SetReaderItem(article); NavigationService.Navigate <ReaderView>(); }
private async Task Save(Action navigationAction = null) { var text = _loader.GetString("Saving.Text"); SetProgressBar(text); var copyItem = new ReaderItem(); ReaderItem.CopyItem(copyItem); await _readerHelper.SaveEditedArticle(copyItem); SetProgressBar(); navigationAction?.Invoke(); }
public static ReaderItem ToReaderItem(this Bookmark article) { var result = new ReaderItem { Id = article.Id.ToString(), Source = SourceProvider.Instapaper, Author = string.Empty, Title = article.Title ?? string.Empty, Url = article.Url ?? string.Empty, Excerpt = article.Description ?? string.Empty, Text= string.Empty, CreatedDate = article.Time ?? DateTime.Now }; return result; }
public static ReaderItem ToReaderItem(this Bookmark article) { var result = new ReaderItem { Id = article.Id.ToString(), Source = SourceProvider.Instapaper, Author = string.Empty, Title = article.Title ?? string.Empty, Url = article.Url ?? string.Empty, Excerpt = article.Description ?? string.Empty, Text = string.Empty, CreatedDate = article.Time ?? DateTime.Now }; return(result); }
public static ReaderItem ToReaderItem(this PocketArticle article) { var result = new ReaderItem { Id = article.ID ?? string.Empty, Source= SourceProvider.Pocket, Author = article.Authors == null ? string.Empty : string.Join(", ", article.Authors) ?? string.Empty, Title = article.Title ?? string.Empty, Url = article.Uri.AbsoluteUri ?? string.Empty, Excerpt = string.Empty, Text = article.Content.StripHtmlTags() ?? string.Empty, CreatedDate = article.PublishedTime ?? DateTime.Now }; result.WordCount = string.IsNullOrEmpty(result.Text) ? 0 : result.Text.Split(new[] {' '}).Length; return result; }
public static ReaderItem ToReaderItem(this PocketArticle article) { var result = new ReaderItem { Id = article.ID ?? string.Empty, Source = SourceProvider.Pocket, Author = article.Authors == null ? string.Empty : string.Join(", ", article.Authors) ?? string.Empty, Title = article.Title ?? string.Empty, Url = article.Uri.AbsoluteUri ?? string.Empty, Excerpt = string.Empty, Text = article.Content.StripHtmlTags() ?? string.Empty, CreatedDate = article.PublishedTime ?? DateTime.Now }; result.WordCount = string.IsNullOrEmpty(result.Text) ? 0 : result.Text.Split(new[] { ' ' }).Length; return(result); }
public static ReaderItem ToReaderItem(this Article article) { var result = new ReaderItem { Id = article.Id ?? string.Empty, Source = SourceProvider.Readability, Author = article.Author ?? string.Empty, Title = article.Title ?? string.Empty, Url = article.Url ?? string.Empty, Excerpt = article.Excerpt ?? string.Empty, WordCount = article.WordCount, CreatedDate = article.DatePublished ?? DateTime.Now, Text = string.IsNullOrEmpty(article.Content) ? string.Empty : article.Content.StripHtmlTags() }; return result; }
public static ReaderItem ToReaderItem(this ExtendedPocketItem article) { var result = new ReaderItem { Id = article.ResolvedId ?? string.Empty, Source = SourceProvider.Pocket, Author = article.Authors == null ? string.Empty : string.Join(", ", article.Authors) ?? string.Empty, Title = article.DisplayTitle ?? string.Empty, Text = string.Empty, Url = article.Uri.ToString() ?? string.Empty, Excerpt = article.Excerpt ?? string.Empty, CreatedDate = article.UpdateTime ?? DateTime.Now }; result.WordCount = string.IsNullOrEmpty(result.Text) ? 0 : result.Text.Split(new[] { ' ' }).Length; return(result); }
public static ReaderItem ToReaderItem(this ExtendedPocketItem article) { var result = new ReaderItem { Id = article.ResolvedId ?? string.Empty, Source = SourceProvider.Pocket, Author = article.Authors == null ? string.Empty : string.Join(", ", article.Authors) ?? string.Empty, Title = article.DisplayTitle ?? string.Empty, Text = string.Empty, Url = article.Uri.ToString() ?? string.Empty, Excerpt = article.Excerpt ?? string.Empty, CreatedDate = article.UpdateTime ?? DateTime.Now }; result.WordCount = string.IsNullOrEmpty(result.Text) ? 0 : result.Text.Split(new[] { ' ' }).Length; return result; }
public static ReaderItem ToReaderItem(this Article article) { var result = new ReaderItem { Id = article.Id ?? string.Empty, Source = SourceProvider.Readability, Author = article.Author ?? string.Empty, Title = article.Title ?? string.Empty, Url = article.Url ?? string.Empty, Excerpt = article.Excerpt ?? string.Empty, WordCount = article.WordCount, CreatedDate = article.DatePublished ?? DateTime.Now, Text = string.IsNullOrEmpty(article.Content) ? string.Empty : article.Content.StripHtmlTags() }; return(result); }
private ReaderItem CopyReaderItem(int?wordsRead = null) { var readerItem = new ReaderItem(); SelectedItem.CopyItem(readerItem); if (wordsRead.HasValue) { readerItem.WordsRead = wordsRead.Value; } if (string.IsNullOrEmpty(readerItem.Excerpt)) { readerItem.Excerpt = readerItem.Text.ToExcerpt(); } readerItem.Text = string.Empty; return(readerItem); }
public async Task <ReaderItem> GetArticle(ReaderItem item) { var filename = GetFileName(item.InternalId); if (!await _storage.Local.FileExistsAsync(filename)) { return(null); } using (var file = await _storage.Local.OpenFileForReadAsync(filename)) { using (var reader = new BinaryReader(file)) { var cachedItem = reader.ReadGeneric <ReaderItem>(); return(cachedItem); } } }
public async Task SetReaderItem(ReaderItem item, bool isRestarting = false, bool autostart = true) { ReaderFont = _settingsService.ReaderFont; SelectedItem = item; GetInProgressItems().ConfigureAwait(false); AddToRecent().ConfigureAwait(false); IsPaused = false; if (!isRestarting) { _canStart = false; } WordsList = null; TimeRemaining = null; _readerTimer = null; WordsPerMinute = _settingsService.WordsPerMin; SelectedIndex = -1; SetProgressBar("Preparing article..."); SelectedItem.WordsRead = GetWordsRead(); var words = item.Text.Clean().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (_settingsService.WordsAtATime == 1) { WordsList = words.ToList(); SetTimings(); SetProgressBar(); } else { var list = words.ToWordList(_settingsService.WordsAtATime); WordsList = list; SetTimings(); SetProgressBar(); } if (_canStart && autostart) { StartStopTimer(); return; } _canStart = true; }
protected override async Task Archive(ReaderItem item) { if (!AuthenticationService.IsLoggedIntoInstapaper) { return; } var id = int.Parse(item.Id); var failed = false; try { var archivedItem = await _instapaperClient.ArchiveBookmarkAsync(id); if (archivedItem == null || archivedItem.Response == null) { failed = true; } } catch (Exception ex) { Log.ErrorException("ArchiveArticle", ex); failed = true; } if (!failed) { var itemToRemove = Items.FirstOrDefault(x => x.Id == item.Id); if (itemToRemove == null) { return; } Items.Remove(itemToRemove); CacheService.SaveInstapaperItems(Items).ConfigureAwait(false); await CacheService.DeleteArticle(item); } }
public async Task SaveEditedArticle(ReaderItem copyItem) { var response = await _cacheService.GetLocalItemsFromCache(); var isAdd = false; var existingItem = response.ReaderItems.FirstOrDefault(x => x.Id == copyItem.Id); if (existingItem == null) { isAdd = true; copyItem.Text = copyItem.Text.Clean(); var title = copyItem.Text.Length > 150 ? copyItem.Text.Substring(0, 150).Trim() : copyItem.Text; copyItem.Title = title; copyItem.CreatedDate = DateTime.Now; copyItem.Url = copyItem.Author = string.Empty; existingItem = copyItem; } else { existingItem.Text = copyItem.Text.Clean(); } existingItem.Excerpt = copyItem.Text.ToExcerpt(); existingItem.WordCount = copyItem.Text.Split(' ').Length; await _cacheService.SaveArticle(existingItem); existingItem.Text = string.Empty; if (isAdd) { response.ReaderItems.Insert(0, existingItem); } await _cacheService.SaveLocalItems(response.ReaderItems); }
public async Task <ReaderItem> HandleProtocolMessage(UriSchemeMessage m) { if (m.IsUri) { var item = await SaveArticle(new Uri(m.Content)); if (item != null) { var fullItem = await _cacheService.GetArticle(item); return(fullItem); } } else { var item = ReaderItem.NewLocalItem(m.Content); await SaveEditedArticle(item); return(item); } return(null); }
protected override async Task <ReaderItem> GetArticle(ReaderItem item, bool isRefresh = false) { if (item == null) { return(null); } if (!isRefresh) { var article = await CacheService.GetArticle(item); if (article != null) { return(article); } } try { var response = await _pocketClient.GetArticle(new Uri(item.Url, UriKind.Absolute), forceRefresh : isRefresh); if (response != null) { var article = response.ToReaderItem(); item.IsDownloaded = true; await CacheService.SaveArticle(article).ConfigureAwait(false); return(article); } } catch (Exception ex) { Log.ErrorException("GetArticle", ex); } return(null); }
private ReaderItem CopyReaderItem(int? wordsRead = null) { var readerItem = new ReaderItem(); SelectedItem.CopyItem(readerItem); if (wordsRead.HasValue) { readerItem.WordsRead = wordsRead.Value; } if (string.IsNullOrEmpty(readerItem.Excerpt)) { readerItem.Excerpt = readerItem.Text.ToExcerpt(); } readerItem.Text = string.Empty; return readerItem; }
public async Task SaveEditedArticle(ReaderItem copyItem) { }
protected override async Task Archive(ReaderItem item) { if (!AuthenticationService.IsLoggedIntoInstapaper) return; var id = int.Parse(item.Id); var failed = false; try { var archivedItem = await _instapaperClient.ArchiveBookmarkAsync(id); if (archivedItem == null || archivedItem.Response == null) { failed = true; } } catch (Exception ex) { Log.ErrorException("ArchiveArticle", ex); failed = true; } if (!failed) { var itemToRemove = Items.FirstOrDefault(x => x.Id == item.Id); if (itemToRemove == null) return; Items.Remove(itemToRemove); CacheService.SaveInstapaperItems(Items).ConfigureAwait(false); await CacheService.DeleteArticle(item); } }
protected virtual Task<ReaderItem> GetArticle(ReaderItem item, bool isRefresh = false) { return null; }
protected virtual Task <ReaderItem> GetArticle(ReaderItem item, bool isRefresh = false) { return(null); }
protected override async Task<ReaderItem> GetArticle(ReaderItem item, bool isRefresh = false) { if (item == null) { return null; } if (!isRefresh) { var article = await CacheService.GetArticle(item); if (article != null) { return article; } } var response = await _readabilityClient.GetArticleAsync(item.Id); if (response != null) { var article = response.ToReaderItem(); item.IsDownloaded = !string.IsNullOrEmpty(article.Text); await CacheService.SaveArticle(article).ConfigureAwait(false); return article; } return null; }
protected virtual async Task Reader(ReaderItem item) { var article = await GetArticle(item); if (article == null) { return; } ReaderViewModel.SetReaderItem(article); NavigationService.Navigate<ReaderView>(); }
public Task<ReaderItem> GetArticle(ReaderItem item) { throw new NotImplementedException(); }
public Task DeleteArticle(ReaderItem item) { throw new NotImplementedException(); }
protected override async Task<ReaderItem> GetArticle(ReaderItem item, bool isRefresh = false) { if (item == null) { return null; } if (!isRefresh) { var article = await CacheService.GetArticle(item); if (article != null) { return article; } } try { var response = await _pocketClient.GetArticle(new Uri(item.Url, UriKind.Absolute), forceRefresh: isRefresh); if (response != null) { var article = response.ToReaderItem(); item.IsDownloaded = true; await CacheService.SaveArticle(article).ConfigureAwait(false); return article; } } catch (Exception ex) { Log.ErrorException("GetArticle", ex); } return null; }
protected override async Task Archive(ReaderItem item) { if (!AuthenticationService.IsLoggedInToPocket) return; var failed = false; try { if (!await _pocketClient.Archive(item.Id)) { failed = true; } } catch (Exception ex) { Log.ErrorException("PocketArchiveMessage", ex); failed = true; } if (!failed) { var itemToDelete = Items.FirstOrDefault(x => x.Id == item.Id); if (itemToDelete == null) return; Items.Remove(itemToDelete); CacheService.SavePocketItems(Items).ConfigureAwait(false); await CacheService.DeleteArticle(item); } }
protected override async Task Archive(ReaderItem item) { if (!AuthenticationService.IsLoggedIntoReadability) return; var id = int.Parse(item.Id); var failed = false; try { await _readabilityClient.SetBookmarkArchiveStateAsync(id, true); } catch (Exception ex) { Log.ErrorException("ArchiveArticle", ex); failed = true; } if (!failed) { var itemToRemove = Items.FirstOrDefault(x => x.Id == item.Id); if (itemToRemove != null) { Items.Remove(itemToRemove); } CacheService.SaveReadabilityItems(Items).ConfigureAwait(false); await CacheService.DeleteArticle(item); } }
protected virtual Task Archive(ReaderItem item) { return null; }
protected virtual async Task FullPage(ReaderItem item) { var article = await GetArticle(item); if (article == null) { return; } FullPageViewModel.ReaderItem = article; NavigationService.Navigate<FullPageView>(); }
public async Task<ReaderItem> GetArticle(ReaderItem item) { var filename = GetFileName(item.InternalId); if (!await _storage.Local.FileExistsAsync(filename)) { return null; } using (var file = await _storage.Local.OpenFileForReadAsync(filename)) { using (var reader = new BinaryReader(file)) { var cachedItem = reader.ReadGeneric<ReaderItem>(); return cachedItem; } } }
public ArchiveMessage(SourceProvider source, ReaderItem item, Action action) { SourceProvider = source; Item = item; Action = action; }
public Task <ReaderItem> GetArticle(ReaderItem item) { throw new NotImplementedException(); }
protected virtual Task Archive(ReaderItem item) { return(null); }