Exemplo n.º 1
0
  private void loaddate() {
    isLoading = true;
    MyUser myUser = BmobUser.getCurrentUser(MessageActivity.this, MyUser.class);
    BmobQuery<ReplyBean> Query = new BmobQuery<ReplyBean>();
    Query.order("-createdAt");
    Query.setSkip(page);
    Query.addWhereEqualTo("userid", new BmobPointer(myUser));
    Query.include("userid,replyid,detailsid");
    Query.findObjects(
        MessageActivity.this,
        new FindListener<ReplyBean>() {
          @Override
          public void onSuccess(List<ReplyBean> object) {
            replyBeans.addAll(object);
            if (object.size() == endpage) {
              page = page + endpage;
            } else {
              flag = false;
            }
            messageAdapter.notifyDataSetChanged();
            isLoading = false;
          }

          @Override
          public void onError(int code, String msg) {
            // TODO Auto-generated method stub
            ErrorReport.RrrorCode(code, MessageActivity.this);
            isLoading = false;
          }
        });
  }
Exemplo n.º 2
0
  private void loadData() {
    // data.clear();
    isLoading = true;
    BmobQuery<CommunityItem> query = new BmobQuery<CommunityItem>();
    // query.addWhereEqualTo("CommunityItem", "");
    BmobDate date = new BmobDate(new Date(System.currentTimeMillis()));
    query.addWhereLessThan("createdAt", date);
    query.order("-createdAt");
    query.include("author");
    // 返回50条数据,如果不加上这条语句,默认返回10条数据
    query.setLimit(Constant.NUMBERS_PER_PAGE);
    query.setSkip(Constant.NUMBERS_PER_PAGE * (pageNum++));
    // 执行查询方法
    query.findObjects(
        getContext(),
        new FindListener<CommunityItem>() {
          @Override
          public void onSuccess(List<CommunityItem> list) {
            LogUtil.d(LogUtil.TAG, "onSuccess list size--> " + list.size());
            if (list.size() != 0 && list.get(list.size() - 1) != null) {
              if (isCleared == false) {
                data.clear();
                isCleared = true;
              }
              if (list.size() < Constant.NUMBERS_PER_PAGE) {
                isAllLoaded = true;
                // ToastUtil.show(getContext(), "已加载完所有数据~");
              }
              data.addAll(list);
              putImgData(data);
              mImageLoader.setImgUrls(imgUrls);
              mImageLoader.setAvatarImgUrls(imgUrlsAvatar);
              if (BmobUtil.getCurrentUser(getContext()) != null) {
                data = DatabaseManager.getInstance(getContext()).setFav(data);
              }
              communityListAdapter.setData(data);
              mListView.setOnScrollListener(myScrollListener);
            } else {
              isAllLoaded = true;
              // ToastUtil.show(getContext(), "暂无更多数据~");
              if (list.size() == 0 && data.size() == 0) {
                pageNum--;
                return;
              }
              pageNum--;
            }
            swipeView.setRefreshing(false);
            progressBar.setVisibility(View.GONE);
            isLoading = false;
          }

          @Override
          public void onError(int code, String msg) {
            LogUtil.d(LogUtil.TAG, "onError --> msg -->" + msg + " code -->" + code);
            pageNum--;
            swipeView.setRefreshing(false);
            isLoading = false;
          }
        });
  }