use of com.looklook.xinghongfei.looklook.bean.zhihu.ZhihuDaily in project LookLook by xinghongfei.
the class ZhihuPresenterImpl method getLastZhihuNews.
@Override
public void getLastZhihuNews() {
mZhihuFragment.showProgressDialog();
Subscription subscription = ApiManage.getInstence().getZhihuApiService().getLastDaily().map(new Func1<ZhihuDaily, ZhihuDaily>() {
@Override
public ZhihuDaily call(ZhihuDaily zhihuDaily) {
String date = zhihuDaily.getDate();
for (ZhihuDailyItem zhihuDailyItem : zhihuDaily.getStories()) {
zhihuDailyItem.setDate(date);
}
return zhihuDaily;
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<ZhihuDaily>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
mZhihuFragment.hidProgressDialog();
mZhihuFragment.showError(e.getMessage());
}
@Override
public void onNext(ZhihuDaily zhihuDaily) {
mZhihuFragment.hidProgressDialog();
mCacheUtil.put(Config.ZHIHU, gson.toJson(zhihuDaily));
mZhihuFragment.updateList(zhihuDaily);
}
});
addSubscription(subscription);
}
use of com.looklook.xinghongfei.looklook.bean.zhihu.ZhihuDaily in project LookLook by xinghongfei.
the class ZhihuPresenterImpl method getTheDaily.
@Override
public void getTheDaily(String date) {
Subscription subscription = ApiManage.getInstence().getZhihuApiService().getTheDaily(date).map(new Func1<ZhihuDaily, ZhihuDaily>() {
@Override
public ZhihuDaily call(ZhihuDaily zhihuDaily) {
String date = zhihuDaily.getDate();
for (ZhihuDailyItem zhihuDailyItem : zhihuDaily.getStories()) {
zhihuDailyItem.setDate(date);
}
return zhihuDaily;
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<ZhihuDaily>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
mZhihuFragment.hidProgressDialog();
mZhihuFragment.showError(e.getMessage());
}
@Override
public void onNext(ZhihuDaily zhihuDaily) {
mZhihuFragment.hidProgressDialog();
mZhihuFragment.updateList(zhihuDaily);
}
});
addSubscription(subscription);
}
use of com.looklook.xinghongfei.looklook.bean.zhihu.ZhihuDaily in project LookLook by xinghongfei.
the class ZhihuPresenterImpl method getLastFromCache.
@Override
public void getLastFromCache() {
if (mCacheUtil.getAsJSONObject(Config.ZHIHU) != null) {
ZhihuDaily zhihuDaily = gson.fromJson(mCacheUtil.getAsJSONObject(Config.ZHIHU).toString(), ZhihuDaily.class);
mZhihuFragment.updateList(zhihuDaily);
}
}
Aggregations