use of com.itculturalfestival.smartcampus.entity.NewsList in project SmartCampus by Vegen.
the class HomePresenter method getNewsList.
@Override
public void getNewsList(String url) {
Disposable disposable = Observable.create((ObservableOnSubscribe<Document>) e -> {
Document document = Jsoup.connect(url).get();
e.onNext(document);
e.onComplete();
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(document -> {
Element body = document.body();
Element photoList = body.getElementById("ListNews").getElementById("leftbox").getElementById("photolist");
// 新闻列表
List<NewsList> newsListList = new ArrayList<>();
// NEWS_TYPE_FOCUS 要闻
newsListList.add(new NewsList(NEWS_TYPE_FOCUS, getTagNews(photoList, "xxyw", NEWS_TYPE_FOCUS)));
// NEWS_TYPE_COMPREHENSIVE 综合
newsListList.add(new NewsList(NEWS_TYPE_COMPREHENSIVE, getTagNews(photoList, "zhxw", NEWS_TYPE_COMPREHENSIVE)));
// NEWS_TYPE_FLASH 快讯
newsListList.add(new NewsList(NEWS_TYPE_FLASH, getTagNews(photoList, "xykx", NEWS_TYPE_FLASH)));
// NEWS_TYPE_OTHER 其他
newsListList.add(new NewsList(NEWS_TYPE_OTHER, getTagNews(photoList, "otherPic", NEWS_TYPE_OTHER)));
List<String> strings = new ArrayList<>();
Elements elements = photoList.select("div.more");
for (Element element : elements) {
String id = element.getElementsByTag("a").attr("href");
strings.add(id);
}
if (mView != null) {
mView.showNewsList(newsListList);
mView.moreNewsClassId(strings);
mView.hideLoading(false);
}
}, throwable -> {
if (mView != null) {
mView.showMessage(HttpError.getErrorMessage(throwable));
mView.hideLoading(true);
}
});
mHttpLinkers.add(new DisposableHolder(disposable));
}
Aggregations