private void lvActiveHandleMessage(Message msg) { if (msg.what >= 0) { UserInformation uinfo = (UserInformation) msg.obj; Notice notice = uinfo.getNotice(); // 处理listview数据 switch (msg.arg1) { case UIHelper.LISTVIEW_ACTION_INIT: case UIHelper.LISTVIEW_ACTION_REFRESH: case UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG: lvActiveSumData = msg.what; lvActiveData.clear(); // 先清除原有数据 lvActiveData.addAll(uinfo.getActivelist()); break; case UIHelper.LISTVIEW_ACTION_SCROLL: lvActiveSumData += msg.what; if (lvActiveData.size() > 0) { for (Active active1 : uinfo.getActivelist()) { boolean b = false; for (Active active2 : lvActiveData) { if (active1.getId() == active2.getId()) { b = true; break; } } if (!b) lvActiveData.add(active1); } } else { lvActiveData.addAll(uinfo.getActivelist()); } break; } if (msg.what < _pageSize) { curLvActiveDataState = UIHelper.LISTVIEW_DATA_FULL; lvActiveAdapter.notifyDataSetChanged(); lvActive_foot_more.setText(R.string.load_full); } else if (msg.what == _pageSize) { curLvActiveDataState = UIHelper.LISTVIEW_DATA_MORE; lvActiveAdapter.notifyDataSetChanged(); lvActive_foot_more.setText(R.string.load_more); } // 发送通知广播 if (msg.obj != null) { UIHelper.sendBroadCast(UserCenter.this, notice); } } else if (msg.what == -1) { // 有异常--显示加载出错 & 弹出错误消息 curLvActiveDataState = UIHelper.LISTVIEW_DATA_MORE; lvActive_foot_more.setText(R.string.load_error); ((AppException) msg.obj).makeToast(UserCenter.this); } if (lvActiveData.size() == 0) { curLvActiveDataState = UIHelper.LISTVIEW_DATA_EMPTY; lvActive_foot_more.setText(R.string.load_empty); } lvActive_foot_progress.setVisibility(View.GONE); if (msg.arg1 == UIHelper.LISTVIEW_ACTION_REFRESH) { mLvActive.onRefreshComplete( getString(R.string.pull_to_refresh_update) + new Date().toLocaleString()); mLvActive.setSelection(0); } else if (msg.arg1 == UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG) { mLvActive.setSelection(0); } }