private void init() { BitmapManager.getInstance().registerBitmapChangedListener(listener); service = new V2CrowdGroupRequest(); deleteMemberList = new ArrayList<User>(); long cid = getIntent().getLongExtra("cid", 0); if (activityType == GROUP_MEMBER_TYPE_CROWD) { memberGroup = GlobalHolder.getInstance().getGroupById(GroupType.CHATING.intValue(), cid); if (memberGroup.getOwnerUser().getmUserId() != GlobalHolder.getInstance().getCurrentUserId()) { mInvitationButton.setVisibility(View.INVISIBLE); } } else { mTitleTV.setText(getResources().getString(R.string.discussion_board_detail_members)); memberGroup = GlobalHolder.getInstance().getGroupById(GroupType.DISCUSSION.intValue(), cid); } mMembers = memberGroup.getUsers(); if (activityType == GROUP_MEMBER_TYPE_DISCUSSION) { sortMembers(); } adapter = new MembersAdapter(); mMembersContainer.setAdapter(adapter); }
private void sortMembers() { long ownerID = memberGroup.getOwnerUser().getmUserId(); long loginUserID = GlobalHolder.getInstance().getCurrentUserId(); User loginUser = GlobalHolder.getInstance().getCurrentUser(); int ownerPos = -1; int loginPos = -1; boolean isExistCreater = false; for (int i = 0; i < mMembers.size(); i++) { if (ownerPos != -1 && loginPos != -1) break; if (ownerID == mMembers.get(i).getmUserId()) { ownerPos = i; } else if (loginUserID == mMembers.get(i).getmUserId()) { loginPos = i; } } if (ownerPos != -1) { isExistCreater = true; User user = mMembers.get(ownerPos); mMembers.remove(user); mMembers.add(0, user); } if (loginPos != -1) { mMembers.remove(loginUser); if (isExistCreater) { mMembers.add(1, loginUser); } else { if (loginPos != 0) { mMembers.add(0, loginUser); } } } }