Example #1
0
  @SuppressWarnings({"unchecked", "deprecation"})
  public void success(Object object) {

    PagerResponse response = (PagerResponse) object;
    if (null == requestAction.pageBean) {
      return;
    }

    int allCount = response.pageBean.getAllCount();
    if (allCount == 0) {}
    requestAction.pageBean.setAllCount(allCount);
    int count = 0;

    /** 没有记录或记录为空的时候 */
    if (response.pageBean.getPageDatas() != null) {
      count = ((List<T>) response.pageBean.getPageDatas()).size();
    }
    if (action == UIHelper.LISTVIEW_ACTION_REFRESH) {
      tableBodyAdapter.removeAll();
    }
    if (count == 0 || allCount == 0) {
      Toast tost = Toast.makeText(context, "没有更多记录!", Toast.LENGTH_LONG);
      tost.setGravity(Gravity.CENTER, 0, 0);
      tost.show();

      lv_page_body.setTag(UIHelper.LISTVIEW_DATA_EMPTY);
      lvNews_foot_more.setText(R.string.load_empty);
    }
    if (count < RequestParamConfig.pagesize && count > -1) { // 末页返还
      lv_page_body.setTag(UIHelper.LISTVIEW_DATA_FULL);
      tableBodyAdapter.add((List<T>) response.pageBean.getPageDatas());

      tableBodyAdapter.notifyDataSetChanged();
      lvNews_foot_more.setText(R.string.load_full); // 已加载全部
    } else if (count == RequestParamConfig.pagesize) {
      lv_page_body.setTag(UIHelper.LISTVIEW_DATA_MORE);
      tableBodyAdapter.add((List<T>) response.pageBean.getPageDatas());
      tableBodyAdapter.notifyDataSetChanged();
      lvNews_foot_more.setText(R.string.load_more);
    }
    lvNews_foot_progress.setVisibility(ProgressBar.GONE);

    if (action == UIHelper.LISTVIEW_ACTION_REFRESH) {
      lv_page_body.onRefreshComplete("最近更新:" + new Date().toLocaleString());
      lv_page_body.setSelection(0);
    } else if (action == UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG) {
      lv_page_body.onRefreshComplete();
      lv_page_body.setSelection(0);
    }
  }
Example #2
0
 private void initData(ArrayList<T> arraylist) {
   tableBodyAdapter = new CommonAdapter<T>(context, viewCreator, arraylist);
   lv_page_body.setAdapter(tableBodyAdapter);
   // add
   lv_page_body.setOnPositionChangedListener((OnPositionChangedListener) context);
   // new
   if (arraylist.size() < 5) {
     lv_page_body.setTag(UIHelper.LISTVIEW_DATA_FULL);
     lvNews_foot_more.setText(R.string.load_full); // 已加载全部
     lvNews_foot_progress.setVisibility(ProgressBar.GONE);
   }
 }