/** * 获取用户信息个人专页(包含该用户的动态信息以及个人信息) * * @param uid 自己的uid * @param hisuid 被查看用户的uid * @param hisname 被查看用户的用户名 * @param pageIndex 页面索引 * @return * @throws AppException */ public UserInformation getInformation( int uid, int hisuid, String hisname, int pageIndex, boolean isRefresh) throws AppException { String _hisname = ""; if (!StringUtils.isEmpty(hisname)) { _hisname = hisname; } UserInformation userinfo = null; String key = "userinfo_" + uid + "_" + hisuid + "_" + (URLEncoder.encode(hisname)) + "_" + pageIndex + "_" + PAGE_SIZE; if (isNetworkConnected() && (!isReadDataCache(key) || isRefresh)) { try { userinfo = ApiClient.information(this, uid, hisuid, _hisname, pageIndex, PAGE_SIZE); if (userinfo != null && pageIndex == 0) { Notice notice = userinfo.getNotice(); userinfo.setNotice(null); userinfo.setCacheKey(key); saveObject(userinfo, key); userinfo.setNotice(notice); } } catch (AppException e) { userinfo = (UserInformation) readObject(key); if (userinfo == null) throw e; } } else { userinfo = (UserInformation) readObject(key); if (userinfo == null) userinfo = new UserInformation(); } return userinfo; }
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); } }