use of org.wikipedia.readinglist.database.ReadingListPage in project apps-android-wikipedia by wikimedia.
the class ReadingListItemView method updateThumbnails.
private void updateThumbnails() {
if (readingList == null) {
return;
}
clearThumbnails();
List<String> thumbUrls = new ArrayList<>();
for (ReadingListPage page : readingList.pages()) {
if (!TextUtils.isEmpty(page.thumbUrl())) {
thumbUrls.add(page.thumbUrl());
}
if (thumbUrls.size() > imageViews.size()) {
break;
}
}
for (int i = thumbUrls.size(); i < imageViews.size() && i < readingList.pages().size(); i++) {
thumbUrls.add("");
}
for (int i = 0; i < thumbUrls.size() && i < imageViews.size(); ++i) {
loadThumbnail(imageViews.get(i), thumbUrls.get(i));
}
}
use of org.wikipedia.readinglist.database.ReadingListPage in project apps-android-wikipedia by wikimedia.
the class ReadingListsFragment method showDeleteListUndoSnackbar.
private void showDeleteListUndoSnackbar(final ReadingList readingList) {
Snackbar snackbar = FeedbackUtil.makeSnackbar(getActivity(), String.format(getString(R.string.reading_list_deleted), readingList.title()), FeedbackUtil.LENGTH_DEFAULT);
snackbar.setAction(R.string.reading_list_item_delete_undo, v -> {
ReadingList newList = ReadingListDbHelper.instance().createList(readingList.title(), readingList.description());
List<ReadingListPage> newPages = new ArrayList<>();
for (ReadingListPage page : readingList.pages()) {
newPages.add(new ReadingListPage(ReadingListPage.toPageTitle(page)));
}
ReadingListDbHelper.instance().addPagesToList(newList, newPages, true);
updateLists();
});
snackbar.show();
}
use of org.wikipedia.readinglist.database.ReadingListPage in project apps-android-wikipedia by wikimedia.
the class ReadingListSyncAdapter method manualSyncWithDeletePages.
public static void manualSyncWithDeletePages(@NonNull ReadingList list, @NonNull List<ReadingListPage> pages) {
if (list.remoteId() <= 0) {
return;
}
Set<String> ids = new HashSet<>();
for (ReadingListPage page : pages) {
if (page.remoteId() > 0) {
ids.add(Long.toString(list.remoteId()) + ":" + Long.toString(page.remoteId()));
}
}
if (!ids.isEmpty()) {
Prefs.addReadingListPagesDeletedIds(ids);
manualSync();
}
}
use of org.wikipedia.readinglist.database.ReadingListPage in project apps-android-wikipedia by wikimedia.
the class ReadingListSyncAdapter method deletePageByTitle.
private void deletePageByTitle(@NonNull ReadingList listForPage, @NonNull PageTitle title) {
ReadingListPage localPage = null;
for (ReadingListPage page : listForPage.pages()) {
if (ReadingListPage.toPageTitle(page).equals(title)) {
localPage = page;
break;
}
}
if (localPage == null) {
localPage = ReadingListDbHelper.instance().getPageByTitle(listForPage, title);
if (localPage == null) {
return;
}
}
L.d("Deleting local page " + localPage.title());
ReadingListDbHelper.instance().markPagesForDeletion(listForPage, Collections.singletonList(localPage), false);
}
use of org.wikipedia.readinglist.database.ReadingListPage in project apps-android-wikipedia by wikimedia.
the class FeaturedArticleCardView method footer.
private void footer(@NonNull FeaturedArticleCard card) {
PageTitle title = new PageTitle(card.articleTitle(), card.wikiSite());
CallbackTask.execute(() -> ReadingListDbHelper.instance().findPageInAnyList(title), new CallbackTask.DefaultCallback<ReadingListPage>() {
@Override
public void success(ReadingListPage page) {
boolean pageInList = page != null;
int actionIcon = pageInList ? R.drawable.ic_bookmark_white_24dp : R.drawable.ic_bookmark_border_black_24dp;
int actionText = pageInList ? R.string.view_featured_article_footer_saved_button_label : R.string.view_featured_article_footer_save_button_label;
footerView.actionIcon(actionIcon).actionText(actionText).onActionListener(pageInList ? new CardBookmarkMenuListener() : new CardAddToListListener()).onShareListener(new CardShareListener());
footerView.actionIconColor(ResourceUtil.getThemedAttributeId(getContext(), pageInList ? R.attr.colorAccent : R.attr.secondary_text_color));
footerView.actionTextColor(ResourceUtil.getThemedAttributeId(getContext(), pageInList ? R.attr.colorAccent : R.attr.secondary_text_color));
}
});
}
Aggregations