Skip to content

Commit

Permalink
修复聊天室管理员头像加载问题 IM-5312
Browse files Browse the repository at this point in the history
  • Loading branch information
jinfeng committed May 15, 2019
1 parent b949d00 commit 7e72038
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void gotResult(int i, String s, List<UserInfo> userInfos) {
}
}
mGvChatRoomKeeper.setNumColumns(keeperListDisplay.size());
mGridAdapter = new ChatRoomKeeperGridAdapter(ChatRoomInfoActivity.this, keeperListDisplay, mAvatarSize);
mGridAdapter = new ChatRoomKeeperGridAdapter(ChatRoomInfoActivity.this, keeperListDisplay);
mGvChatRoomKeeper.setAdapter(mGridAdapter);
if (taskCount.decrementAndGet() == 0) {
loadingDialog.dismiss();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,37 @@
import android.widget.BaseAdapter;
import android.widget.ImageView;

import java.io.File;
import java.util.List;

import cn.jpush.im.android.api.callback.GetAvatarBitmapCallback;
import cn.jpush.im.android.api.model.UserInfo;
import jiguang.chat.R;
import jiguang.chat.utils.BitmapLoader;

public class ChatRoomKeeperGridAdapter extends BaseAdapter {
private Context context;
private List<UserInfo> keeperList;
private int avatarSize;

public ChatRoomKeeperGridAdapter(Context context, List<UserInfo> keeperList, int avatarSize) {
public ChatRoomKeeperGridAdapter(Context context, List<UserInfo> keeperList) {
this.context = context;
this.keeperList = keeperList;
this.avatarSize = avatarSize;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView avatar;
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.item_chatroom_avatar, null);
}
avatar = ((ImageView) convertView.findViewById(R.id.grid_avatar));
UserInfo userInfo = keeperList.get(position);
if (userInfo != null) {
File file = userInfo.getAvatarFile();
if (file != null && file.exists()) {
Bitmap bitmap = BitmapLoader.getBitmapFromFile(file.getAbsolutePath(), avatarSize, avatarSize);
((ImageView) convertView.findViewById(R.id.grid_avatar)).setImageBitmap(bitmap);
}
userInfo.getAvatarBitmap(new GetAvatarBitmapCallback() {
@Override
public void gotResult(int i, String s, Bitmap bitmap) {
if (i == 0) {
avatar.setImageBitmap(bitmap);
}
}
});
}
return convertView;
}
Expand Down

0 comments on commit 7e72038

Please sign in to comment.