@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != RESULT_OK) return; if (data == null) return; if (requestCode == UIHelper.REQUEST_CODE_FOR_RESULT) { Comment comm = (Comment) data.getSerializableExtra("COMMENT_SERIALIZABLE"); lvCommentData.add(0, comm); lvCommentAdapter.notifyDataSetChanged(); mLvComment.setSelection(0); } }
private void lvBlogHandleMessage(Message msg) { if (msg.what >= 0) { BlogList bloglist = (BlogList) msg.obj; Notice notice = bloglist.getNotice(); // 显示用户博客数量 String tabBlogText = String.format("博客(%d)", bloglist.getBlogsCount()); mTabBlog.setText(tabBlogText); // 处理listview数据 switch (msg.arg1) { case UIHelper.LISTVIEW_ACTION_INIT: case UIHelper.LISTVIEW_ACTION_REFRESH: case UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG: lvBlogSumData = msg.what; lvBlogData.clear(); // 先清除原有数据 lvBlogData.addAll(bloglist.getBloglist()); break; case UIHelper.LISTVIEW_ACTION_SCROLL: lvBlogSumData += msg.what; if (lvBlogData.size() > 0) { for (Blog blog1 : bloglist.getBloglist()) { boolean b = false; for (Blog blog2 : lvBlogData) { if (blog1.getId() == blog2.getId()) { b = true; break; } } if (!b) lvBlogData.add(blog1); } } else { lvBlogData.addAll(bloglist.getBloglist()); } break; } if (msg.what < _pageSize) { curLvBlogDataState = UIHelper.LISTVIEW_DATA_FULL; lvBlogAdapter.notifyDataSetChanged(); lvBlog_foot_more.setText(R.string.load_full); } else if (msg.what == _pageSize) { curLvBlogDataState = UIHelper.LISTVIEW_DATA_MORE; lvBlogAdapter.notifyDataSetChanged(); lvBlog_foot_more.setText(R.string.load_more); } // 发送通知广播 if (msg.obj != null) { UIHelper.sendBroadCast(UserCenter.this, notice); } } else if (msg.what == -1) { // 有异常--显示加载出错 & 弹出错误消息 curLvBlogDataState = UIHelper.LISTVIEW_DATA_MORE; lvBlog_foot_more.setText(R.string.load_error); ((AppException) msg.obj).makeToast(UserCenter.this); } if (lvBlogData.size() == 0) { curLvBlogDataState = UIHelper.LISTVIEW_DATA_EMPTY; lvBlog_foot_more.setText(R.string.load_empty); } lvBlog_foot_progress.setVisibility(View.GONE); if (msg.arg1 == UIHelper.LISTVIEW_ACTION_REFRESH) { mLvBlog.onRefreshComplete( getString(R.string.pull_to_refresh_update) + new Date().toLocaleString()); mLvBlog.setSelection(0); } else if (msg.arg1 == UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG) { mLvBlog.setSelection(0); } }
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); } }