use of org.wikipedia.dataclient.page.PageClient in project apps-android-wikipedia by wikimedia.
the class WiktionaryDialog method loadDefinitions.
private void loadDefinitions() {
if (selectedText.trim().isEmpty()) {
displayNoDefinitionsFound();
return;
}
// TODO: centralize the Wiktionary domain better. Maybe a SharedPreference that defaults to
// https://wiktionary.org.
PageClient pageClient = PageClientFactory.create(new WikiSite(pageTitle.getWikiSite().subdomain() + WIKTIONARY_DOMAIN), Namespace.MAIN);
if (pageClient instanceof RbPageClient) {
((RbPageClient) pageClient).define(addUnderscores(selectedText), definitionOnLoadCallback);
} else {
L.i("Wiktionary definitions require mobile content service loading!");
displayNoDefinitionsFound();
}
}
use of org.wikipedia.dataclient.page.PageClient in project apps-android-wikipedia by wikimedia.
the class SavedPageSyncService method reqPageLead.
@NonNull
private Observable<retrofit2.Response<PageLead>> reqPageLead(@Nullable CacheControl cacheControl, @Nullable String saveOfflineHeader, @NonNull PageTitle pageTitle) {
PageClient client = newPageClient(pageTitle);
String title = pageTitle.getPrefixedText();
int thumbnailWidth = DimenUtil.calculateLeadImageWidth();
return client.lead(pageTitle.getWikiSite(), cacheControl, saveOfflineHeader, null, title, thumbnailWidth);
}
use of org.wikipedia.dataclient.page.PageClient in project apps-android-wikipedia by wikimedia.
the class SavedPageSyncService method reqPageSections.
@NonNull
private Observable<retrofit2.Response<PageRemaining>> reqPageSections(@Nullable CacheControl cacheControl, @Nullable String saveOfflineHeader, @NonNull PageTitle pageTitle) {
PageClient client = newPageClient(pageTitle);
String title = pageTitle.getPrefixedText();
return client.sections(pageTitle.getWikiSite(), cacheControl, saveOfflineHeader, title);
}
use of org.wikipedia.dataclient.page.PageClient in project apps-android-wikipedia by wikimedia.
the class PageCacher method loadIntoCache.
@SuppressLint("CheckResult")
static void loadIntoCache(@NonNull PageTitle title) {
L.d("Loading page into cache: " + title.getPrefixedText());
PageClient client = PageClientFactory.create(title.getWikiSite(), title.namespace());
Observable.zip(leadReq(client, title), remainingReq(client, title), (leadRsp, sectionsRsp) -> leadRsp).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(leadRsp -> {
for (int i = WikipediaApp.getInstance().getTabCount() - 1; i >= 0; i--) {
PageTitle pageTitle = WikipediaApp.getInstance().getTabList().get(i).getBackStackPositionTitle();
if (pageTitle.equals(title)) {
pageTitle.setThumbUrl(leadRsp.body().getThumbUrl());
break;
}
}
}, L::e);
}
Aggregations