Skip to content

Commit

Permalink
Merge pull request #155 from jinfengf/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jinfengf authored May 24, 2019
2 parents 83d60d3 + 9d1dd7e commit cc60d8f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class GroupMemberGridAdapter extends BaseAdapter {
private int mCurrentNum;
//用群成员项数余4得到,作为下标查找mRestArray,得到空白项
private int mRestNum;
private static final int MAX_GRID_ITEM = 40;
private int maxGridItem;
private boolean mIsGroup;
private String mTargetId;
private Context mContext;
Expand All @@ -53,6 +53,7 @@ public GroupMemberGridAdapter(Context context, List<UserInfo> memberList, boolea
this.mMemberList = memberList;
mCurrentNum = mMemberList.size();
this.mIsCreator = isCreator;
maxGridItem = isCreator ? 13 : 14;
this.mAvatarSize = size;
initBlankItem(mCurrentNum);
}
Expand All @@ -66,17 +67,17 @@ public GroupMemberGridAdapter(Context context, String targetId, String appKey) {
}

public void initBlankItem(int size) {
if (mMemberList.size() > MAX_GRID_ITEM) {
mCurrentNum = MAX_GRID_ITEM - 1;
if (mMemberList.size() > maxGridItem) {
mCurrentNum = maxGridItem;
} else {
mCurrentNum = mMemberList.size();
}
mRestNum = mRestArray[mCurrentNum % 5];
}

public void refreshMemberList() {
if (mMemberList.size() > MAX_GRID_ITEM) {
mCurrentNum = MAX_GRID_ITEM - 1;
if (mMemberList.size() > maxGridItem) {
mCurrentNum = maxGridItem;
} else {
mCurrentNum = mMemberList.size();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class ChatDetailController implements OnClickListener, OnItemClickListene
private Dialog mLoadingDialog = null;
private static final int ADD_MEMBERS_TO_GRIDVIEW = 2048;
private static final int ADD_A_MEMBER_TO_GRIDVIEW = 2049;
private static final int MAX_GRID_ITEM = 40;
private int maxGridItem = 40;
private String mGroupName;
private String mGroupDesc;
private final MyHandler myHandler = new MyHandler(this);
Expand Down Expand Up @@ -161,6 +161,7 @@ public void initData() {
if (mGroupOwnerId != null && mGroupOwnerId.equals(mMyUsername)) {
mIsCreator = true;
}
maxGridItem = mIsCreator ? 13 : 14;
mChatDetailView.setMyName(mMyUsername);
mChatDetailView.showBlockView(mGroupInfo.isGroupBlocked());
initAdapter();
Expand Down Expand Up @@ -213,8 +214,8 @@ public void gotResult(int i, String s, UserInfo userInfo) {
private void initAdapter() {
// 初始化头像
mGridAdapter = new GroupMemberGridAdapter(mContext, mMemberInfoList, mIsCreator, mAvatarSize);
if (mMemberInfoList.size() > MAX_GRID_ITEM) {
mCurrentNum = MAX_GRID_ITEM - 1;
if (mMemberInfoList.size() > maxGridItem) {
mCurrentNum = maxGridItem;
} else {
mCurrentNum = mMemberInfoList.size();
}
Expand Down Expand Up @@ -637,7 +638,7 @@ public void gotResult(final int status, final String desc) {

//添加或者删除成员后重新获得MemberInfoList
public void refreshMemberList() {
mCurrentNum = mMemberInfoList.size() > MAX_GRID_ITEM ? MAX_GRID_ITEM - 1 : mMemberInfoList.size();
mCurrentNum = mMemberInfoList.size() > maxGridItem ? maxGridItem : mMemberInfoList.size();
mGridAdapter.refreshMemberList();
}

Expand Down Expand Up @@ -912,7 +913,10 @@ public GroupMemberGridAdapter getAdapter() {
*/
public void refresh(long groupId) {
//当前群聊
if (mGroupId == groupId) {
if (mGroupId == groupId && mGroupInfo != null) {
mMemberInfoList.clear();
mMemberInfoList.addAll(mGroupInfo.getGroupMembers());
mChatDetailView.setMemberCount(" " + mMemberInfoList.size() + " 人");
refreshMemberList();
}
}
Expand Down

0 comments on commit cc60d8f

Please sign in to comment.