コード例 #1
0
  private void getDataFromNet(String customerId, boolean showDialog, Context ctx) {
    this.customerId = customerId;
    HttpControl hControl = new HttpControl();
    hControl.getOrderList(
        page,
        Constants.PageSize,
        orderProductType,
        status,
        customerId,
        new HttpCallBackInterface() {

          @Override
          public void http_Success(Object obj) {
            rlv.postDelayed(
                new Runnable() {
                  @Override
                  public void run() {
                    rlv.onRefreshComplete();
                  }
                },
                100);
            OrderListBackBean bean = (OrderListBackBean) obj;
            if (isRefresh) {
              if (bean.getData() != null
                  && bean.getData().getOrderlist() != null
                  && bean.getData().getOrderlist().size() > 0) {
                tv_nodata.setVisibility(View.GONE);
                mList.clear();
                mList.addAll(bean.getData().getOrderlist());

                rlv.setAdapter(adapter);
              } else {
                tv_nodata.setVisibility(View.VISIBLE);
              }

            } else {
              if (bean.getData().getOrderlist() != null
                  && bean.getData().getOrderlist().size() > 0) {
                mList.addAll(bean.getData().getOrderlist());
              } else {
                Toast.makeText(getActivity(), "没有更多数据了...", 1000).show();
              }
              adapter.notifyDataSetChanged();
            }
          }

          @Override
          public void http_Fails(int error, String msg) {
            rlv.onRefreshComplete();
            Toast.makeText(getActivity(), msg, 1000).show();
          }
        },
        ctx,
        showDialog);
  }
コード例 #2
0
  /**
   * *** 请求数据
   *
   * @param page int 当前页
   * @param BrandId int 品牌id **
   */
  void sendHttp(final int page, final int type) {
    ToolsUtil.showNoDataView(BaijiaBrandListActivity.this, parenetView, false);
    httpControl.getBaijiaBrandDetails(
        page,
        pageSize,
        BrandId,
        TextName,
        showDialog,
        new HttpCallBackInterface() {

          @Override
          public void http_Success(Object obj) {
            ToolsUtil.pullResfresh(brandlist_layout_pullTorefreshgridview);
            currPage = page;
            showDialog = false;
            if (obj != null) {
              RequestBrandInfoInfoBean bean = (RequestBrandInfoInfoBean) obj;
              switch (type) {
                case 0:
                  falshData(bean);
                  break;
                case 1:
                  addData(bean);
                  break;
              }
              setPageStatus(bean, page);

            } else {
              http_Fails(
                  500,
                  BaijiaBrandListActivity.this
                      .getResources()
                      .getString(R.string.errorpagedata_str));
            }
          }

          @Override
          public void http_Fails(int error, String msg) {
            MyApplication.getInstance().showMessage(BaijiaBrandListActivity.this, msg);
            ToolsUtil.pullResfresh(brandlist_layout_pullTorefreshgridview);
          }
        },
        BaijiaBrandListActivity.this);
  }