コード例 #1
0
  /**
   * 查询我发表的
   *
   * @param pageNo
   * @param adapter
   * @param pullToRefreshListview
   */
  private void queryMyAsk(
      final int pageNo,
      final ListAdapter adapter,
      final PullToRefreshListView pullToRefreshListview) {
    sendRequestWithNoDialog(
        RequestPool.requestMQannAns(pageNo),
        new RequestProxy() {

          @Override
          public void onSuccess(String msg, String result) {
            JSONObject js = JSON.parseObject(result);
            List<AskObj> items =
                JSON.parseArray(js.getJSONObject("page").getString("result"), AskObj.class);

            if (pageNo == 1) {
              if (items.size() == 0) {
                tv_mempty.setVisibility(View.VISIBLE);
              } else {
                tv_mempty.setVisibility(View.GONE);
              }
              adapter.list.clear();
            }
            if (items.size() > 0) {
              adapter.list.addAll(items);
            }
            adapter.notifyDataSetChanged();
            pullToRefreshListview.onRefreshComplete();
          }

          @Override
          public void onError(String code, String msg) {
            pullToRefreshListview.onRefreshComplete();
          }
        });
  }
コード例 #2
0
  /**
   * 查询全部
   *
   * @param pageNo
   * @param adapter
   * @param pullToRefreshListview
   */
  private void queryAllAsk(
      final int pageNo,
      final ListAdapter adapter,
      final PullToRefreshListView pullToRefreshListview) {

    sendRequestWithNoDialog(
        RequestPool.requestQannAns(pageNo),
        new RequestProxy() {

          @Override
          public void onSuccess(String msg, String result) {
            Log.e(TAG, "result:" + result + " \n pageNo:" + pageNo);
            JSONObject js = JSON.parseObject(result);
            List<AskObj> items =
                JSON.parseArray(js.getJSONObject("page").getString("result"), AskObj.class);

            if (pageNo == 1) {
              adapter.list.clear();
              pullToRefreshListview.setMode(PullToRefreshListView.MODE_BOTH);
            }
            if (items.size() > 0) {
              adapter.list.addAll(items);
            }

            if (items.size() < 8) {
              pullToRefreshListview.setMode(PullToRefreshListView.MODE_PULL_UP_TO_REFRESH);
            }
            adapter.notifyDataSetChanged();
            pullToRefreshListview.onRefreshComplete();
          }

          @Override
          public void onError(String code, String msg) {
            pullToRefreshListview.onRefreshComplete();
          }
        });
  }