Search in sources :

Example 1 with Story

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);
}
Also used : Question(io.github.izzyleung.zhihudailypurify.bean.Question) DailyNews(io.github.izzyleung.zhihudailypurify.bean.DailyNews) Document(org.jsoup.nodes.Document) Story(io.github.izzyleung.zhihudailypurify.bean.Story)

Example 2 with Story

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;
}
Also used : Story(io.github.izzyleung.zhihudailypurify.bean.Story)

Aggregations

Story (io.github.izzyleung.zhihudailypurify.bean.Story)2 DailyNews (io.github.izzyleung.zhihudailypurify.bean.DailyNews)1 Question (io.github.izzyleung.zhihudailypurify.bean.Question)1 Document (org.jsoup.nodes.Document)1