Search in sources :

Example 1 with Banner

use of com.itculturalfestival.smartcampus.entity.db.Banner in project SmartCampus by Vegen.

the class HomePresenter method getBanner.

@Override
public void getBanner() {
    BmobQuery<Banner> query = new BmobQuery<Banner>();
    // 先从缓存获取数据,如果没有,再从网络获取。
    query.setCachePolicy(BmobQuery.CachePolicy.CACHE_THEN_NETWORK);
    // 按照时间降序
    query.order("-createdAt");
    Subscription subscription = query.findObjects(new FindListener<Banner>() {

        @Override
        public void done(List<Banner> list, BmobException e) {
            if (mView != null) {
                if (e == null) {
                    // 请求成功
                    mView.showBanner(list);
                    mView.hideLoading(false);
                } else {
                    mView.showMessage(HttpError.getErrorMessage(e));
                    mView.hideLoading(true);
                }
            }
        }
    });
    mHttpLinkers.add(new SubscriptionHolder(subscription));
}
Also used : BmobException(cn.bmob.v3.exception.BmobException) BmobQuery(cn.bmob.v3.BmobQuery) Banner(com.itculturalfestival.smartcampus.entity.db.Banner) SubscriptionHolder(com.itculturalfestival.smartcampus.network.SubscriptionHolder) Subscription(rx.Subscription)

Aggregations

BmobQuery (cn.bmob.v3.BmobQuery)1 BmobException (cn.bmob.v3.exception.BmobException)1 Banner (com.itculturalfestival.smartcampus.entity.db.Banner)1 SubscriptionHolder (com.itculturalfestival.smartcampus.network.SubscriptionHolder)1 Subscription (rx.Subscription)1