protected void updateView(Object object, int mode) { if (loadingDialog != null) { if (loadingDialog.isShowing()) { loadingDialog.dismiss(); } } if (mode == LOAD_MODE || mode == REFRESH_MODE) { listView.stopRefresh(); } else if (mode == MORE_MODE) { listView.stopLoadMore(); } if (object == null) { errorData(mode); return; } if (object instanceof ErrorModel) { // 网络连接失败 ErrorModel errorModel = (ErrorModel) object; errorData(mode); // TODO 提示出网络错误 Toast.makeText( CourseListActivity.this, ErrorCodeUtil.convertErrorCode(CourseListActivity.this, errorModel.getErrorCode()), Toast.LENGTH_SHORT) .show(); return; } BaseModel m = (BaseModel) object; // 服务器返回错误 if (m.getResult() > 0) { // TODO 提示出服务器端错误。 errorData(mode); Toast.makeText(CourseListActivity.this, m.getMessage(), Toast.LENGTH_SHORT).show(); return; } CourseListModel model = (CourseListModel) object; if (mode == REFRESH_MODE || mode == LOAD_MODE) { onRefreshPostExecute(model.getDataList(), mode, model.isHasNext()); pageNum = 1; } else { onMorePostExecute(model.getDataList(), mode, model.isHasNext()); pageNum = pageNum + 1; } }
package com.dns.taxchina.ui.fragment;