|
@@ -1,8 +1,10 @@
|
|
|
package com.rong.io.live.widget;
|
|
|
|
|
|
import android.content.Context;
|
|
|
+import android.net.Uri;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.AttributeSet;
|
|
|
+import android.util.Log;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
@@ -10,6 +12,7 @@ import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
+import com.cooleshow.base.utils.GlideUtils;
|
|
|
import com.cooleshow.usercenter.helper.UserHelper;
|
|
|
import com.rong.io.live.R;
|
|
|
import com.rong.io.live.bean.User;
|
|
@@ -17,6 +20,7 @@ import com.rong.io.live.bean.User;
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
+import de.hdodenhof.circleimageview.CircleImageView;
|
|
|
import io.rong.imlib.model.UserInfo;
|
|
|
|
|
|
/**
|
|
@@ -28,6 +32,7 @@ public class LiveRoomMicIconView extends LinearLayout {
|
|
|
public static final String DEFAULT_NICK = "连麦用户";
|
|
|
public OnEventListener mEventListener;
|
|
|
private String mCurrentUserName;
|
|
|
+ private String mCurrentUserAvatar;
|
|
|
|
|
|
public LiveRoomMicIconView(Context context) {
|
|
|
this(context, null);
|
|
@@ -48,6 +53,7 @@ public class LiveRoomMicIconView extends LinearLayout {
|
|
|
mMicUserInfos = new ArrayList<>();
|
|
|
mCurrentUserId = UserHelper.getUserId();
|
|
|
mCurrentUserName = UserHelper.getUserName();
|
|
|
+ mCurrentUserAvatar = UserHelper.getUserAvatar();
|
|
|
}
|
|
|
|
|
|
public void delAll() {
|
|
@@ -80,7 +86,7 @@ public class LiveRoomMicIconView extends LinearLayout {
|
|
|
for (int i = 0; i < mMicUserInfos.size(); i++) {
|
|
|
UserInfo userInfo = mMicUserInfos.get(i);
|
|
|
View view = LayoutInflater.from(getContext()).inflate(R.layout.item_live_room_mic_user_layout, this, false);
|
|
|
- ImageView iv_icon = view.findViewById(R.id.iv_icon);
|
|
|
+ CircleImageView iv_icon = view.findViewById(R.id.iv_icon);
|
|
|
TextView tv_name = view.findViewById(R.id.tv_name);
|
|
|
String nickName = DEFAULT_NICK;
|
|
|
if (!TextUtils.isEmpty(userInfo.getName())) {
|
|
@@ -88,12 +94,19 @@ public class LiveRoomMicIconView extends LinearLayout {
|
|
|
}
|
|
|
userInfo.setName(nickName);
|
|
|
tv_name.setText(nickName);
|
|
|
+ //头像
|
|
|
+ String avatarPath = "";
|
|
|
+ if(userInfo.getPortraitUri()!=null){
|
|
|
+ Log.i("pq","userInfo.getPortraitUri().getPath():"+userInfo.getPortraitUri().toString());
|
|
|
+ avatarPath = userInfo.getPortraitUri().toString();
|
|
|
+ }
|
|
|
+ GlideUtils.INSTANCE.loadImage(getContext(), avatarPath, iv_icon, R.drawable.icon_live_room_mic_other);
|
|
|
if (userInfo != null && TextUtils.equals(userInfo.getUserId(), mCurrentUserId)) {
|
|
|
//自己
|
|
|
- iv_icon.setImageResource(R.drawable.icon_live_room_mic_own);
|
|
|
+ iv_icon.setBorderColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_f37c17));
|
|
|
tv_name.setBackgroundResource(R.drawable.shape_live_room_mic_nickname_bg);
|
|
|
} else {
|
|
|
- iv_icon.setImageResource(R.drawable.icon_live_room_mic_other);
|
|
|
+ iv_icon.setBorderColor(getContext().getResources().getColor(com.cooleshow.base.R.color.transparent));
|
|
|
tv_name.setBackgroundResource(R.drawable.shape_live_room_mic_nickname_bg_normal);
|
|
|
}
|
|
|
this.addView(view);
|
|
@@ -133,7 +146,7 @@ public class LiveRoomMicIconView extends LinearLayout {
|
|
|
mMicUserInfos.clear();
|
|
|
for (int i = 0; i < users.size(); i++) {
|
|
|
User user = users.get(i);
|
|
|
- UserInfo userInfo = new UserInfo(user.getUserId(), user.getUserName(), null);
|
|
|
+ UserInfo userInfo = new UserInfo(user.getUserId(), user.getUserName(), user.getPortraitUri());
|
|
|
mMicUserInfos.add(userInfo);
|
|
|
}
|
|
|
refreshAllUser();
|
|
@@ -167,6 +180,7 @@ public class LiveRoomMicIconView extends LinearLayout {
|
|
|
if (TextUtils.equals(targetUser.getUserId(), mCurrentUserId)) {
|
|
|
//如果是自身则不需要查询,直接取缓存名称
|
|
|
targetUser.setName(mCurrentUserName);
|
|
|
+ targetUser.setPortraitUri(Uri.parse(mCurrentUserAvatar));
|
|
|
}
|
|
|
String lastName = targetUser.getName();
|
|
|
if (TextUtils.isEmpty(lastName) || TextUtils.equals(lastName, DEFAULT_NICK)) {
|