protected String getCacheKey() { return new StringBuffer(getCacheKeyPrefix()) .append(mCatalog) .append("_") .append(mCurrentPage) .append("_") .append(TDevice.getPageSize()) .toString(); }
protected void executeOnLoadDataSuccess(List<?> data) { if (mState == STATE_REFRESH) { mAdapter.clear(); } mAdapter.addData(data); mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); if (data.size() == 0 && mState == STATE_REFRESH) { mErrorLayout.setErrorType(EmptyLayout.NODATA); } else if (data.size() < TDevice.getPageSize()) { if (mState == STATE_REFRESH) { mAdapter.setState(RecycleBaseAdapter.STATE_LESS_ONE_PAGE); } else mAdapter.setState(RecycleBaseAdapter.STATE_NO_MORE); } else { mAdapter.setState(RecycleBaseAdapter.STATE_LOAD_MORE); } }
/** * 获取数据失败时候调用的代码 * * @param error */ protected void executeOnLoadDataError(String error) { if (mCurrentPage == 0) { if (mAdapter.getDataSize() == 0) { mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR); } else { mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); String message = error; if (TextUtils.isEmpty(error)) { if (TDevice.hasInternet()) { message = getString(R.string.tip_load_date_error); } else { message = getString(R.string.tip_network_error); } } AppContext.showToashShort(message); } } else { mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); mAdapter.setState(RecycleBaseAdapter.STATE_NETWORK_ERROR); } mAdapter.notifyDataSetChanged(); }