Search in sources :

Example 1 with WikipediaApp

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

the class ShareHandler method createFunnel.

private void createFunnel() {
    WikipediaApp app = WikipediaApp.getInstance();
    final Page page = fragment.getPage();
    final PageProperties pageProperties = page.getPageProperties();
    funnel = new ShareAFactFunnel(app, page.getTitle(), pageProperties.getPageId(), pageProperties.getRevisionId());
}
Also used : PageProperties(org.wikipedia.page.PageProperties) WikipediaApp(org.wikipedia.WikipediaApp) Page(org.wikipedia.page.Page) ShareAFactFunnel(org.wikipedia.analytics.ShareAFactFunnel)

Example 2 with WikipediaApp

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

the class EditSummaryHandler method persistSummary.

public void persistSummary() {
    WikipediaApp app = (WikipediaApp) container.getContext().getApplicationContext();
    EditSummary summary = new EditSummary(summaryEdit.getText().toString(), new Date());
    app.getDatabaseClient(EditSummary.class).upsert(summary, EditHistoryContract.Summary.SELECTION);
}
Also used : WikipediaApp(org.wikipedia.WikipediaApp) Date(java.util.Date)

Example 3 with WikipediaApp

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

the class MainPageClient method getMainPageTitle.

@NonNull
public static PageTitle getMainPageTitle() {
    WikipediaApp app = WikipediaApp.getInstance();
    PageTitle title = new PageTitle(SiteInfoClient.getMainPageForLang(app.getAppOrSystemLanguageCode()), app.getWikiSite());
    if (OfflineManager.hasCompilation() && !DeviceUtil.isOnline()) {
        try {
            title = new PageTitle(OfflineManager.instance().getMainPageTitle(), app.getWikiSite());
        } catch (IOException e) {
            L.e(e);
        }
    }
    return title;
}
Also used : WikipediaApp(org.wikipedia.WikipediaApp) PageTitle(org.wikipedia.page.PageTitle) IOException(java.io.IOException) NonNull(android.support.annotation.NonNull)

Example 4 with WikipediaApp

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

the class WidgetProviderFeaturedPage method getMainPageLead.

private void getMainPageLead(final Callback cb) {
    WikipediaApp app = WikipediaApp.getInstance();
    final PageTitle title = new PageTitle(MainPageNameData.valueFor(app.getAppOrSystemLanguageCode()), app.getWikiSite());
    getApiService(title).lead(null, null, title.getPrefixedText(), DimenUtil.calculateLeadImageWidth()).enqueue(new retrofit2.Callback<PageLead>() {

        @Override
        public void onResponse(Call<PageLead> call, Response<PageLead> rsp) {
            PageLead lead = rsp.body();
            if (lead.hasError()) {
                lead.logError("Error while updating widget");
                return;
            }
            L.d("Downloaded page " + title.getDisplayText());
            String titleText = findFeaturedArticleTitle(lead.getLeadSectionContent());
            cb.onFeaturedArticleReceived(titleText);
        }

        @Override
        public void onFailure(Call<PageLead> call, Throwable t) {
            L.e(t);
        }
    });
}
Also used : WikipediaApp(org.wikipedia.WikipediaApp) PageTitle(org.wikipedia.page.PageTitle) PageLead(org.wikipedia.dataclient.page.PageLead)

Example 5 with WikipediaApp

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

the class CommonHeaderRequestInterceptor method intercept.

@Override
public Response intercept(Chain chain) throws IOException {
    WikipediaApp app = WikipediaApp.getInstance();
    Request request = chain.request().newBuilder().header("User-Agent", app.getUserAgent()).header(isEventLoggingEnabled() ? "X-WMF-UUID" : "DNT", isEventLoggingEnabled() ? app.getAppInstallID() : "1").build();
    return chain.proceed(request);
}
Also used : WikipediaApp(org.wikipedia.WikipediaApp) Request(okhttp3.Request)

Aggregations

WikipediaApp (org.wikipedia.WikipediaApp)7 PageTitle (org.wikipedia.page.PageTitle)2 NonNull (android.support.annotation.NonNull)1 PopupMenu (android.support.v7.widget.PopupMenu)1 View (android.view.View)1 TextView (android.widget.TextView)1 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)1 IOException (java.io.IOException)1 Date (java.util.Date)1 Map (java.util.Map)1 Request (okhttp3.Request)1 LinkPreviewFunnel (org.wikipedia.analytics.LinkPreviewFunnel)1 ShareAFactFunnel (org.wikipedia.analytics.ShareAFactFunnel)1 CallbackTask (org.wikipedia.concurrency.CallbackTask)1 PageClient (org.wikipedia.dataclient.page.PageClient)1 PageLead (org.wikipedia.dataclient.page.PageLead)1 GalleryThumbnailScrollView (org.wikipedia.gallery.GalleryThumbnailScrollView)1 ImageInfo (org.wikipedia.gallery.ImageInfo)1 ImageTagParser (org.wikipedia.html.ImageTagParser)1 PixelDensityDescriptorParser (org.wikipedia.html.PixelDensityDescriptorParser)1