Search in sources :

Example 1 with DailyNewsDataSource

use of io.github.izzyleung.zhihudailypurify.db.DailyNewsDataSource in project ZhihuDailyPurify by izzyleung.

the class ZhihuDailyPurifyApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    applicationContext = this;
    initImageLoader(getApplicationContext());
    dataSource = new DailyNewsDataSource(getApplicationContext());
    dataSource.open();
}
Also used : DailyNewsDataSource(io.github.izzyleung.zhihudailypurify.db.DailyNewsDataSource)

Example 2 with DailyNewsDataSource

use of io.github.izzyleung.zhihudailypurify.db.DailyNewsDataSource 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

DailyNewsDataSource (io.github.izzyleung.zhihudailypurify.db.DailyNewsDataSource)2 GsonBuilder (com.google.gson.GsonBuilder)1 DailyNews (io.github.izzyleung.zhihudailypurify.bean.DailyNews)1