Search in sources :

Example 1 with ReadingListPage

use of org.wikipedia.readinglist.database.ReadingListPage in project apps-android-wikipedia by wikimedia.

the class PageFragment method onPageLoadComplete.

public void onPageLoadComplete() {
    refreshView.setEnabled(true);
    if (callback() != null) {
        callback().onPageInvalidateOptionsMenu();
    }
    setupToC(model, pageFragmentLoadState.isFirstPage());
    editHandler.setPage(model.getPage());
    initPageScrollFunnel();
    bottomContentView.setPage(model.getPage());
    if (model.getReadingListPage() != null) {
        final ReadingListPage page = model.getReadingListPage();
        final PageTitle title = model.getTitle();
        CallbackTask.execute(() -> {
            if (!TextUtils.equals(page.thumbUrl(), title.getThumbUrl()) || !TextUtils.equals(page.description(), title.getDescription())) {
                page.thumbUrl(title.getThumbUrl());
                page.description(title.getDescription());
                ReadingListDbHelper.instance().updatePage(page);
            }
        });
    }
    checkAndShowSelectTextOnboarding();
}
Also used : ReadingListPage(org.wikipedia.readinglist.database.ReadingListPage)

Example 2 with ReadingListPage

use of org.wikipedia.readinglist.database.ReadingListPage in project apps-android-wikipedia by wikimedia.

the class RandomFragment method onSaveShareClick.

@OnClick(R.id.random_save_button)
void onSaveShareClick() {
    PageTitle title = getTopTitle();
    if (title == null) {
        return;
    }
    if (saveButtonState) {
        new ReadingListBookmarkMenu(saveButton, new ReadingListBookmarkMenu.Callback() {

            @Override
            public void onAddRequest(@Nullable ReadingListPage page) {
                onAddPageToList(title);
            }

            @Override
            public void onDeleted(@Nullable ReadingListPage page) {
                FeedbackUtil.showMessage(getActivity(), getString(R.string.reading_list_item_deleted, title.getDisplayText()));
                updateSaveShareButton(title);
            }
        }).show(title);
    } else {
        onAddPageToList(title);
    }
}
Also used : ReadingListBookmarkMenu(org.wikipedia.readinglist.ReadingListBookmarkMenu) PageTitle(org.wikipedia.page.PageTitle) ReadingListPage(org.wikipedia.readinglist.database.ReadingListPage) Nullable(android.support.annotation.Nullable) OnClick(butterknife.OnClick)

Example 3 with ReadingListPage

use of org.wikipedia.readinglist.database.ReadingListPage in project apps-android-wikipedia by wikimedia.

the class ReadingListFragment method getSelectedPages.

@NonNull
private List<ReadingListPage> getSelectedPages() {
    List<ReadingListPage> result = new ArrayList<>();
    if (readingList == null) {
        return result;
    }
    for (ReadingListPage page : displayedPages) {
        if (page.selected()) {
            result.add(page);
            page.selected(false);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ReadingListPage(org.wikipedia.readinglist.database.ReadingListPage) NonNull(android.support.annotation.NonNull)

Example 4 with ReadingListPage

use of org.wikipedia.readinglist.database.ReadingListPage in project apps-android-wikipedia by wikimedia.

the class ReadingListFragment method onDeleteItem.

@Override
public void onDeleteItem(int pageIndex) {
    ReadingListPage page = readingList == null ? null : readingList.pages().get(pageIndex);
    deleteSinglePage(page);
}
Also used : ReadingListPage(org.wikipedia.readinglist.database.ReadingListPage)

Example 5 with ReadingListPage

use of org.wikipedia.readinglist.database.ReadingListPage in project apps-android-wikipedia by wikimedia.

the class ReadingListFragment method addSelectedPagesToList.

private void addSelectedPagesToList() {
    List<ReadingListPage> selectedPages = getSelectedPages();
    if (!selectedPages.isEmpty()) {
        List<PageTitle> titles = new ArrayList<>();
        for (ReadingListPage page : selectedPages) {
            titles.add(ReadingListPage.toPageTitle(page));
        }
        bottomSheetPresenter.show(getChildFragmentManager(), AddToReadingListDialog.newInstance(titles, AddToReadingListDialog.InvokeSource.READING_LIST_ACTIVITY));
        update();
    }
}
Also used : PageTitle(org.wikipedia.page.PageTitle) ArrayList(java.util.ArrayList) ReadingListPage(org.wikipedia.readinglist.database.ReadingListPage)

Aggregations

ReadingListPage (org.wikipedia.readinglist.database.ReadingListPage)18 ArrayList (java.util.ArrayList)8 PageTitle (org.wikipedia.page.PageTitle)5 ReadingList (org.wikipedia.readinglist.database.ReadingList)3 Snackbar (android.support.design.widget.Snackbar)2 IOException (java.io.IOException)2 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 OnClick (butterknife.OnClick)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 CallbackTask (org.wikipedia.concurrency.CallbackTask)1 WikiSite (org.wikipedia.dataclient.WikiSite)1 ReadingListsEnableDialogEvent (org.wikipedia.events.ReadingListsEnableDialogEvent)1 ReadingListsEnabledStatusEvent (org.wikipedia.events.ReadingListsEnabledStatusEvent)1 ReadingListsMergeLocalDialogEvent (org.wikipedia.events.ReadingListsMergeLocalDialogEvent)1 ReadingListsNoLongerSyncedEvent (org.wikipedia.events.ReadingListsNoLongerSyncedEvent)1 ReadingListBookmarkMenu (org.wikipedia.readinglist.ReadingListBookmarkMenu)1 RemoteReadingList (org.wikipedia.readinglist.sync.SyncedReadingLists.RemoteReadingList)1