Search in sources :

Example 21 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class PageFragmentLoadState method pageLoadLeadSectionComplete.

private void pageLoadLeadSectionComplete(PageLead pageLead, int startSequenceNum) {
    if (!fragment.isAdded() || !sequenceNumber.inSync(startSequenceNum)) {
        return;
    }
    if (pageLead.hasError()) {
        ServiceError error = pageLead.getError();
        if (error != null) {
            commonSectionFetchOnCatch(new MwException((MwServiceError) error), startSequenceNum);
        } else {
            commonSectionFetchOnCatch(new IOException(getResources().getString(R.string.error_unknown)), startSequenceNum);
        }
        return;
    }
    Page page = pageLead.toPage(model.getTitle());
    model.setPage(page);
    model.setTitle(page.getTitle());
    editHandler.setPage(model.getPage());
    if (page.getTitle().getDescription() == null) {
        app.getSessionFunnel().noDescription();
    }
    layoutLeadImage(() -> {
        if (!fragment.isAdded()) {
            return;
        }
        fragment.callback().onPageInvalidateOptionsMenu();
        pageLoadRemainingSections(sequenceNumber.get());
    });
    // Update our history entry, in case the Title was changed (i.e. normalized)
    final HistoryEntry curEntry = model.getCurEntry();
    model.setCurEntry(new HistoryEntry(model.getTitle(), curEntry.getTimestamp(), curEntry.getSource()));
    // Fetch larger thumbnail URL from the network, and save it to our DB.
    new PageImagesClient().request(model.getTitle().getWikiSite(), Collections.singletonList(model.getTitle()), new PageImagesClient.Callback() {

        @Override
        public void success(@NonNull Call<MwQueryResponse> call, @NonNull Map<PageTitle, PageImage> results) {
            if (results.containsKey(model.getTitle())) {
                PageImage pageImage = results.get(model.getTitle());
                app.getDatabaseClient(PageImage.class).upsert(pageImage, PageImageHistoryContract.Image.SELECTION);
                updateThumbnail(pageImage.getImageName());
            }
        }

        @Override
        public void failure(@NonNull Call<MwQueryResponse> call, @NonNull Throwable caught) {
            L.w(caught);
        }
    });
}
Also used : MwServiceError(org.wikipedia.dataclient.mwapi.MwServiceError) ServiceError(org.wikipedia.dataclient.ServiceError) MwQueryResponse(org.wikipedia.dataclient.mwapi.MwQueryResponse) MwException(org.wikipedia.dataclient.mwapi.MwException) ReadingListPage(org.wikipedia.readinglist.database.ReadingListPage) IOException(java.io.IOException) PageImage(org.wikipedia.pageimages.PageImage) MwServiceError(org.wikipedia.dataclient.mwapi.MwServiceError) PageImagesClient(org.wikipedia.pageimages.PageImagesClient) HistoryEntry(org.wikipedia.history.HistoryEntry)

Example 22 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class LinkPreviewDialog method goToLinkedPage.

public void goToLinkedPage() {
    navigateSuccess = true;
    funnel.logNavigate();
    if (getDialog() != null) {
        getDialog().dismiss();
    }
    HistoryEntry newEntry = new HistoryEntry(pageTitle, entrySource);
    loadPage(pageTitle, newEntry, false);
}
Also used : HistoryEntry(org.wikipedia.history.HistoryEntry)

Aggregations

HistoryEntry (org.wikipedia.history.HistoryEntry)22 PageTitle (org.wikipedia.page.PageTitle)11 WikiSite (org.wikipedia.dataclient.WikiSite)5 Date (java.util.Date)4 Test (org.junit.Test)4 PageBackStackItem (org.wikipedia.page.PageBackStackItem)3 Tab (org.wikipedia.page.tabs.Tab)3 Intent (android.content.Intent)2 Uri (android.net.Uri)2 NonNull (android.support.annotation.NonNull)2 View (android.view.View)2 WebView (android.webkit.WebView)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 OnClick (butterknife.OnClick)2 IOException (java.io.IOException)2 ObservableWebView (org.wikipedia.views.ObservableWebView)2 ProgressDialog (android.app.ProgressDialog)1 Context (android.content.Context)1 AssetManager (android.content.res.AssetManager)1