private void fillData(String result) { DealData dealData = null; try { dealData = GsonUtil.json2bean(result, DealData.class); ArrayList<Deal> deals = dealData.getData().getDeals(); if (isRefresh) { mAllDeals.clear(); convenientBanner.setcurrentitem(0); } mAllDeals.addAll(deals); if (newsListAdapter == null) { newsListAdapter = new TabListAdapter(mContext, mAllDeals); home_Xlistview.setAdapter(newsListAdapter); } else { newsListAdapter.setData(mAllDeals); newsListAdapter.notifyDataSetChanged(); } mHandler.sendEmptyMessage(MSG_STOP_REFRESH); home_Xlistview.setVisibility(View.VISIBLE); hideBaseLoading(); } catch (Exception e) { hideBaseLoading(); if (mAllDeals.size() == 0 && !isRefresh) { showLoadingError(); } else { mHandler.sendEmptyMessage(MSG_STOP_REFRESH); ToastUtil.showToast(mContext, "亲,加载错误啦,请重试."); } e.printStackTrace(); } }
@Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { case MSG_STOP_REFRESH: stopRefresh(); break; case MSG_GET_DATA_OVER: ToastUtil.showToast(mContext, "亲,没有更多数据了哦."); stopRefresh(); home_Xlistview.setPullLoadEnable(false); break; default: break; } }