use of io.github.izzyleung.zhihudailypurify.bean.Story in project ZhihuDailyPurify by izzyleung.
the class NewsListFromZhihuObservable method convertToDailyNews.
private static Optional<DailyNews> convertToDailyNews(Pair<Story, Document> pair) {
DailyNews result = null;
Story story = pair.first;
Document document = pair.second;
String dailyTitle = story.getDailyTitle();
List<Question> questions = getQuestions(document, dailyTitle);
if (Stream.of(questions).allMatch(Question::isValidZhihuQuestion)) {
result = new DailyNews();
result.setDailyTitle(dailyTitle);
result.setThumbnailUrl(story.getThumbnailUrl());
result.setQuestions(questions);
}
return Optional.ofNullable(result);
}
use of io.github.izzyleung.zhihudailypurify.bean.Story in project ZhihuDailyPurify by izzyleung.
the class NewsListFromZhihuObservable method getStoryFromJSON.
private static Story getStoryFromJSON(JSONObject jsonStory) throws JSONException {
Story story = new Story();
story.setStoryId(jsonStory.getInt("id"));
story.setDailyTitle(jsonStory.getString("title"));
story.setThumbnailUrl(getThumbnailUrlForStory(jsonStory));
return story;
}