Search in sources :

Example 6 with DailyNews

use of io.github.izzyleung.zhihudailypurify.bean.DailyNews in project ZhihuDailyPurify by izzyleung.

the class DailyNewsDataSource method newsOfTheDay.

// That reminds you of Queen, huh? ;-)
public List<DailyNews> newsOfTheDay(String date) {
    Cursor cursor = database.query(DBHelper.TABLE_NAME, allColumns, DBHelper.COLUMN_DATE + " = " + date, null, null, null, null);
    cursor.moveToFirst();
    List<DailyNews> newsList = cursorToNewsList(cursor);
    cursor.close();
    return newsList;
}
Also used : DailyNews(io.github.izzyleung.zhihudailypurify.bean.DailyNews) Cursor(android.database.Cursor)

Example 7 with DailyNews

use of io.github.izzyleung.zhihudailypurify.bean.DailyNews in project ZhihuDailyPurify by izzyleung.

the class SaveNewsListTask method saveNewsList.

private void saveNewsList(List<DailyNews> newsList) {
    DailyNewsDataSource dataSource = ZhihuDailyPurifyApplication.getDataSource();
    String date = newsList.get(0).getDate();
    List<DailyNews> originalData = dataSource.newsOfTheDay(date);
    if (originalData == null || !originalData.equals(newsList)) {
        dataSource.insertOrUpdateNewsList(date, new GsonBuilder().create().toJson(newsList));
    }
}
Also used : DailyNewsDataSource(io.github.izzyleung.zhihudailypurify.db.DailyNewsDataSource) GsonBuilder(com.google.gson.GsonBuilder) DailyNews(io.github.izzyleung.zhihudailypurify.bean.DailyNews)

Aggregations

DailyNews (io.github.izzyleung.zhihudailypurify.bean.DailyNews)7 Cursor (android.database.Cursor)2 AlertDialog (android.support.v7.app.AlertDialog)2 ContentValues (android.content.ContentValues)1 GsonBuilder (com.google.gson.GsonBuilder)1 Question (io.github.izzyleung.zhihudailypurify.bean.Question)1 Story (io.github.izzyleung.zhihudailypurify.bean.Story)1 DailyNewsDataSource (io.github.izzyleung.zhihudailypurify.db.DailyNewsDataSource)1 Document (org.jsoup.nodes.Document)1