Exemplo n.º 1
0
 private void update(IQueryExhibitionPageBean mGoodsBean) {
   if (mGoodsBean == null || mGoodsBean.getData() == null) return;
   if (productList == null) {
     productList = new ArrayList<ExhibitionBean>();
   }
   if (pageIndex == 1) {
     productList.clear();
     sv_exhibition.setMode(PullToRefreshBase.Mode.BOTH);
   }
   productList.addAll(mGoodsBean.getData());
   if (adapterLv == null) {
     adapterLv = new ExhibitionTextListAdapter(mContext, productList);
     listView.setAdapter(adapterLv);
   } else {
     adapterLv.setData(productList);
     adapterLv.notifyDataSetChanged();
   }
   if (mGoodsBean.getData().size() < pageSize) {
     Toast.makeText(mContext, "数据加载完成", Toast.LENGTH_SHORT).show();
     sv_exhibition.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
   }
 }
Exemplo n.º 2
0
  private void setPullRefreshView() {
    sv_exhibition.setEnabled(false);
    // 设定上下拉刷新
    // lv_exhibition.setMode(Mode.BOTH);
    sv_exhibition.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
    sv_exhibition.getLoadingLayoutProxy().setLastUpdatedLabel(Utils.getCurrTiem());
    sv_exhibition.getLoadingLayoutProxy().setPullLabel("往下拉更新数据...");
    sv_exhibition.getLoadingLayoutProxy().setRefreshingLabel("正在载入中...");
    sv_exhibition.getLoadingLayoutProxy().setReleaseLabel("放开更新数据...");

    // 下拉刷新数据
    sv_exhibition.setOnRefreshListener(
        new PullToRefreshBase.OnRefreshListener2<ScrollView>() {
          // 下拉刷新
          @Override
          public void onPullDownToRefresh(PullToRefreshBase refreshView) {
            sv_exhibition
                .getLoadingLayoutProxy(true, false)
                .setLastUpdatedLabel(
                    "最近更新: " + Utils.Long2DateStr_detail(System.currentTimeMillis()));
            pageIndex = 1;
            if (bean != null) {
              productList.clear();
            }
            getIQueryExhibitionPage();
          }

          // 加载更多
          @Override
          public void onPullUpToRefresh(PullToRefreshBase refreshView) {
            // 加载更多
            if (bean != null && bean.getData().size() == pageSize) {
              pageIndex++;
              getIQueryExhibitionPage();
            }
          }
        });
  }