use of org.wikipedia.feed.model.UtcDate in project apps-android-wikipedia by wikimedia.
the class AggregatedFeedContentClient method requestAggregated.
void requestAggregated(@NonNull WikiSite wiki, int age, @NonNull retrofit2.Callback<AggregatedFeedContent> cb) {
cancel();
UtcDate date = DateUtil.getUtcRequestDateFor(age);
String endpoint = String.format(Locale.ROOT, Prefs.getRestbaseUriFormat(), wiki.scheme(), wiki.authority());
Retrofit retrofit = RetrofitFactory.newInstance(endpoint, wiki);
AggregatedFeedContentClient.Service service = retrofit.create(Service.class);
call = service.get(date.year(), date.month(), date.date());
call.enqueue(cb);
}
use of org.wikipedia.feed.model.UtcDate in project apps-android-wikipedia by wikimedia.
the class WidgetProviderFeaturedPage method getFeaturedArticleInformation.
@SuppressLint("CheckResult")
private void getFeaturedArticleInformation(final Callback cb) {
WikipediaApp app = WikipediaApp.getInstance();
final PageTitle mainPageTitle = new PageTitle(MainPageNameData.valueFor(app.getAppOrSystemLanguageCode()), app.getWikiSite());
UtcDate date = DateUtil.getUtcRequestDateFor(0);
ServiceFactory.getRest(WikipediaApp.getInstance().getWikiSite()).getAggregatedFeed(date.year(), date.month(), date.date()).flatMap(response -> {
if (response.tfa() != null) {
return Observable.just(response.tfa());
} else {
// TODO: this logic can be removed if the feed API can return the featured article for all languages.
return getApiService(mainPageTitle).lead(mainPageTitle.getWikiSite(), null, null, null, mainPageTitle.getPrefixedText(), DimenUtil.calculateLeadImageWidth());
}
}).subscribeOn(Schedulers.io()).subscribe(response -> {
CharSequence widgetText = mainPageTitle.getText();
PageTitle pageTitle = mainPageTitle;
if (response instanceof retrofit2.Response) {
PageLead lead = (PageLead) ((retrofit2.Response) response).body();
L.d("Downloaded page " + mainPageTitle.getDisplayText());
widgetText = findFeaturedArticleTitle(lead.getLeadSectionContent());
} else if (response instanceof RbPageSummary) {
widgetText = StringUtil.fromHtml(((RbPageSummary) response).getDisplayTitle());
pageTitle = ((RbPageSummary) response).getPageTitle(app.getWikiSite());
}
cb.onFeaturedArticleReceived(pageTitle, widgetText);
}, L::e);
}
Aggregations