use of io.github.izzyleung.zhihudailypurify.bean.DailyNews 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.DailyNews in project ZhihuDailyPurify by izzyleung.
the class NewsAdapter method share.
private void share(Context context, int position) {
DailyNews dailyNews = newsList.get(position);
if (dailyNews.hasMultipleQuestions()) {
AlertDialog dialog = createDialog(context, dailyNews, makeShareQuestionDialogClickListener(context, dailyNews));
dialog.show();
} else {
shareQuestion(context, dailyNews.getQuestions().get(0).getTitle(), dailyNews.getQuestions().get(0).getUrl());
}
}
use of io.github.izzyleung.zhihudailypurify.bean.DailyNews in project ZhihuDailyPurify by izzyleung.
the class NewsAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(CardViewHolder holder, int position) {
DailyNews dailyNews = newsList.get(position);
imageLoader.displayImage(dailyNews.getThumbnailUrl(), holder.newsImage, options, animateFirstListener);
if (dailyNews.getQuestions().size() > 1) {
holder.questionTitle.setText(dailyNews.getDailyTitle());
holder.dailyTitle.setText(Constants.Strings.MULTIPLE_DISCUSSION);
} else {
holder.questionTitle.setText(dailyNews.getQuestions().get(0).getTitle());
holder.dailyTitle.setText(dailyNews.getDailyTitle());
}
}
use of io.github.izzyleung.zhihudailypurify.bean.DailyNews in project ZhihuDailyPurify by izzyleung.
the class NewsAdapter method browse.
private void browse(Context context, int position) {
DailyNews dailyNews = newsList.get(position);
if (dailyNews.hasMultipleQuestions()) {
AlertDialog dialog = createDialog(context, dailyNews, makeGoToZhihuDialogClickListener(context, dailyNews));
dialog.show();
} else {
goToZhihu(context, dailyNews.getQuestions().get(0).getUrl());
}
}
use of io.github.izzyleung.zhihudailypurify.bean.DailyNews in project ZhihuDailyPurify by izzyleung.
the class DailyNewsDataSource method insertDailyNewsList.
public List<DailyNews> insertDailyNewsList(String date, String content) {
ContentValues values = new ContentValues();
values.put(DBHelper.COLUMN_DATE, date);
values.put(DBHelper.COLUMN_CONTENT, content);
long insertId = database.insert(DBHelper.TABLE_NAME, null, values);
Cursor cursor = database.query(DBHelper.TABLE_NAME, allColumns, DBHelper.COLUMN_ID + " = " + insertId, null, null, null, null);
cursor.moveToFirst();
List<DailyNews> newsList = cursorToNewsList(cursor);
cursor.close();
return newsList;
}
Aggregations