private void updateListView() { if (mAdapter != null) { mAdapter.notifyDataSetChanged(); } if (mWeiboList == null || mWeiboList.size() == 0) { return; } mListView.setVisibility(View.VISIBLE); if (mAdapter != null) { mAdapter.notifyDataSetChanged(); } mAdapter = new MyFavoriteListAdapter(mContext, mWeiboList); if (mListView.getFooterViewsCount() == 0) { mFootView = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.hometab_listview_footer, null); ProgressBar pb = (ProgressBar) mFootView.findViewById(R.id.hometab_addmore_progressbar); pb.setVisibility(View.GONE); mListView.addFooterView(mFootView); } mListView.setAdapter(mAdapter); }
@Override public void handleMessage(Message msg) { switch (msg.what) { case GlobalParam.SHOW_SCROLLREFRESH: if (mIsRefreshing) { mContainer.onRefreshComplete(); break; } mIsRefreshing = true; if (mWeibo != null) { mWeibo = null; } getPublishWeiboData(GlobalParam.LIST_LOAD_REFERSH); break; case GlobalParam.HIDE_SCROLLREFRESH: mIsRefreshing = false; mContainer.onRefreshComplete(); updateListView(); break; case GlobalParam.SHOW_PROGRESS_DIALOG: String dialogMsg = (String) msg.obj; showProgressDialog(dialogMsg); break; case GlobalParam.HIDE_PROGRESS_DIALOG: hideProgressDialog(); // updateListView(); break; case GlobalParam.MSG_CHECK_STATE: // mHandler.sendEmptyMessage(HIDE_PROGRESS_DIALOG); hideProgressDialog(); if (mFootView != null) { mListView.removeFooterView(mFootView); } if (mAdapter != null) { mAdapter.notifyDataSetChanged(); } // Toast.makeText(mContext, "没有更多数据了", Toast.LENGTH_LONG); break; case GlobalParam.MSG_SHOW_LISTVIEW_DATA: updateListView(); break; case GlobalParam.MSG_LOAD_ERROR: String error_Detail = (String) msg.obj; if (error_Detail != null && !error_Detail.equals("")) { Toast.makeText(mContext, error_Detail, Toast.LENGTH_LONG).show(); } else { Toast.makeText(mContext, R.string.load_error, Toast.LENGTH_LONG).show(); } break; case GlobalParam.MSG_NETWORK_ERROR: Toast.makeText(mContext, R.string.network_error, Toast.LENGTH_LONG).show(); break; case GlobalParam.MSG_TICE_OUT_EXCEPTION: String message = (String) msg.obj; if (message == null || message.equals("")) { message = mContext.getResources().getString(R.string.timeout); } Toast.makeText(mContext, message, Toast.LENGTH_LONG).show(); break; case GlobalParam.SHOW_LOADINGMORE_INDECATOR: LinearLayout footView = (LinearLayout) msg.obj; ProgressBar pb = (ProgressBar) footView.findViewById(R.id.hometab_addmore_progressbar); pb.setVisibility(View.VISIBLE); TextView more = (TextView) footView.findViewById(R.id.hometab_footer_text); more.setText(mContext.getString(R.string.add_more_loading)); // getLoveList(GlobalParam.LIST_LOAD_MORE); getPublishWeiboData(GlobalParam.LIST_LOAD_MORE); break; case GlobalParam.HIDE_LOADINGMORE_INDECATOR: if (mFootView != null) { ProgressBar pbar = (ProgressBar) mFootView.findViewById(R.id.hometab_addmore_progressbar); pbar.setVisibility(View.GONE); TextView moreView = (TextView) mFootView.findViewById(R.id.hometab_footer_text); moreView.setText(R.string.add_more); } if (mAdapter != null) { mAdapter.notifyDataSetChanged(); } break; case GlobalParam.MSG_CHECK_FAVORITE_STATUS: IMJiaState canclefavResult = (IMJiaState) msg.obj; if (canclefavResult == null) { Toast.makeText(mContext, R.string.commit_dataing, Toast.LENGTH_LONG).show(); return; } if (canclefavResult.code != 0) { Toast.makeText(mContext, canclefavResult.errorMsg, Toast.LENGTH_LONG).show(); return; } else { mWeiboList.remove(canclefavResult.positon); if (mAdapter != null) { mAdapter.notifyDataSetChanged(); } } break; default: break; } }