新增贵族特权:1.麦位昵称颜色 2.麦位svga声波

This commit is contained in:
huangjian
2022-01-04 17:20:43 +08:00
parent 4c81ca3f6f
commit 87b6668413
22 changed files with 130 additions and 58 deletions

View File

@@ -6,6 +6,7 @@ import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.RecyclerView;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.text.TextUtils;
import android.view.View;
@@ -17,6 +18,7 @@ import android.widget.TextView;
import com.coorchice.library.SuperTextView;
import com.netease.nim.uikit.common.util.string.StringUtil;
import com.opensource.svgaplayer.SVGAImageView;
import com.yizhuan.erban.R;
import com.yizhuan.erban.common.widget.CircleImageView;
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
@@ -37,6 +39,7 @@ import com.yizhuan.xchat_android_core.room.pk.bean.PKTeamInfo;
import com.yizhuan.xchat_android_core.room.queue.bean.MicMemberInfo;
import com.yizhuan.xchat_android_core.user.UserModel;
import com.yizhuan.xchat_android_core.utils.ActivityUtil;
import com.yizhuan.xchat_android_core.utils.StringExtensionKt;
import com.yizhuan.xchat_android_library.utils.config.BasicConfig;
/**
@@ -127,7 +130,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
ImageView ivLockImage;
ImageView ivMuteImage;
CircleImageView ivAvatar;
ImageView ivHalo;
SVGAImageView ivHalo;
@Nullable
ImageView ivHeadWear;
@@ -161,6 +164,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
position = TYPE_INVALID;
ivHalo.setBackground(null);
ivHalo.clearAnimation();
ivHalo.clear();
clearHeadWear();
ivUpImage.setVisibility(View.VISIBLE);
ivLockImage.setVisibility(View.GONE);
@@ -205,6 +209,8 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
ImageLoadUtils.loadAvatar(BasicConfig.INSTANCE.getAppContext(), chatRoomMember.getAvatar(), ivAvatar);
// 加载贵族
updateNobleView(chatRoomMember);
//增加贵族昵称颜色
tvNick.setTextColor(StringExtensionKt.toColorInt(chatRoomMember.getMicNickColor(),"#FFFFFF"));
} else {
clearHeadWear();
ivUpImage.setVisibility(View.VISIBLE);

View File

@@ -5,6 +5,7 @@ import android.content.Context;
import android.graphics.Point;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
@@ -12,8 +13,13 @@ import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.yizhuan.erban.R;
import com.yizhuan.erban.avroom.adapter.BaseMicroViewAdapter;
import com.yizhuan.erban.avroom.adapter.CpMicroViewAdapter;
@@ -40,6 +46,8 @@ import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import io.reactivex.disposables.Disposable;
@@ -222,6 +230,7 @@ public class MicroView extends FrameLayout implements View.OnLayoutChangeListene
private void init(final Context context) {
this.mContext = context;
inflate(mContext, R.layout.layout_micro_view, this);
setClipChildren(false);
recyclerView = findViewById(R.id.recycler_view);
recyclerView.addOnLayoutChangeListener(this);
if (AvRoomDataManager.get().isCpRoom()) {
@@ -245,7 +254,7 @@ public class MicroView extends FrameLayout implements View.OnLayoutChangeListene
int pos = positions.get(i) + 1;
if (pos >= count && pos != AvRoomDataManager.POSITION_VIP_MIC + 1) continue;
final View speakState;
final SVGAImageView speakState;
//相亲模式VIP位置光圈
if (pos == AvRoomDataManager.POSITION_VIP_MIC + 1) {
speakState = ((RecyclerView) recyclerView.getChildAt(0).findViewById(R.id.rv_vip))
@@ -256,32 +265,56 @@ public class MicroView extends FrameLayout implements View.OnLayoutChangeListene
if (speakState != null) {
RoomQueueInfo roomQueueInfo = AvRoomDataManager.get().getRoomQueueMemberInfoByMicPosition(positions.get(i));
if (roomQueueInfo == null) continue;
if (roomQueueInfo == null || roomQueueInfo.mChatRoomMember == null) continue;
String halo = (String) NobleUtil.getResource(NobleResourceType.KEY_HALO, roomQueueInfo.mChatRoomMember);
//光圈的起始位置应该是头像边界,终止位置是头饰边界,头像:头饰=3:4
AnimFactory.getSpeakingAnimation(mContext, speakState.getWidth(), speakState.getHeight(),
NobleUtil.getColor(halo), speakState.getWidth() * 3 / 4)
.subscribe((animationDrawable, throwable) -> {
boolean isNeedSetBackground = false;
if (speakState.getBackground() != null) {
if (speakState.getBackground() instanceof AnimationDrawable) {
AnimationDrawable oldAnimationDrawable = (AnimationDrawable) speakState.getBackground();
//因为设置了setOneShot属性这里判断动画是否完成。
if (oldAnimationDrawable.getCurrent() ==
oldAnimationDrawable.getFrame(oldAnimationDrawable.getNumberOfFrames() - 1)) {
String micCircle = roomQueueInfo.mChatRoomMember.getMicCircle();
if (TextUtils.isEmpty(micCircle)) {
//光圈的起始位置应该是头像边界,终止位置是头饰边界,头像:头饰=3:4
AnimFactory.getSpeakingAnimation(mContext, speakState.getWidth(), speakState.getHeight(),
NobleUtil.getColor(halo), speakState.getWidth() * 3 / 4)
.subscribe((animationDrawable, throwable) -> {
boolean isNeedSetBackground = false;
if (speakState.getBackground() != null) {
if (speakState.getBackground() instanceof AnimationDrawable) {
AnimationDrawable oldAnimationDrawable = (AnimationDrawable) speakState.getBackground();
//因为设置了setOneShot属性这里判断动画是否完成。
if (oldAnimationDrawable.getCurrent() ==
oldAnimationDrawable.getFrame(oldAnimationDrawable.getNumberOfFrames() - 1)) {
isNeedSetBackground = true;
}
} else {
isNeedSetBackground = true;
}
} else {
isNeedSetBackground = true;
}
} else {
isNeedSetBackground = true;
if (isNeedSetBackground && animationDrawable != null) {
speakState.setBackground(animationDrawable);
animationDrawable.start();
}
});
} else {
if (speakState.isAnimating()) continue;
try {
speakState.setLoops(1);
SVGAParser.Companion.shareParser().decodeFromURL(new URL(micCircle), new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@NonNull SVGAVideoEntity svgaVideoEntity) {
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity);
speakState.setImageDrawable(drawable);
speakState.startAnimation();
}
if (isNeedSetBackground && animationDrawable != null) {
speakState.setBackground(animationDrawable);
animationDrawable.start();
@Override
public void onError() {
}
});
}, null);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
}
}

View File

@@ -27,6 +27,7 @@ import com.yizhuan.xchat_android_library.annatation.ActLayoutRes;
import com.yizhuan.xchat_android_library.utils.ListUtils;
import java.util.List;
import java.util.Objects;
/**
* Created by huangmeng1 on 2018/5/7.
@@ -94,17 +95,18 @@ public class MyUserCardWearFragment extends BaseBindingFragment<FrgMyDecorationC
private void setUsedStatus(int position) {
UserCardWearInfo headWearInfo = shopAdapter.getData().get(position);
// id == 0标识不使用头饰
wearVm.userHeadWear(headWearInfo.isUsed() ? null : headWearInfo.getCardId())
String cardId = headWearInfo.isUsed() ? null : headWearInfo.getCardId();
wearVm.userHeadWear(cardId)
.compose(bindUntilEvent(FragmentEvent.DESTROY))
.doOnError(throwable -> {
toast(throwable.getMessage());
})
.subscribe(s -> {
for (int i = 0; i < shopAdapter.getData().size(); i++) {
shopAdapter.getData().get(i).setUsed(headWearInfo.getCardId().equals(shopAdapter.getData().get(i).getCardId()));
shopAdapter.getData().get(i).setUsed(Objects.equals(cardId,shopAdapter.getData().get(i).getCardId()));
}
shopAdapter.notifyDataSetChanged();
//更新用户信息

View File

@@ -17,7 +17,7 @@ public class UserCardWearVm extends BaseListViewModel<UserCardWearInfo> {
@Override
public Single<ServiceResult<List<UserCardWearInfo>>> getSingle() {
return HeadwearModel.get().getUserCardWearList(page , pageSize );
return HeadwearModel.get().getUserCardWearList(page, pageSize);
}
public Single<String> userHeadWear(String wearId) {

View File

@@ -12,11 +12,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/iv_user_card_wear"
android:layout_width="match_parent"
android:layout_height="180dp"
tools:background="@drawable/bg_user_card_wear" />
<RelativeLayout
android:id="@+id/layout_userinfo"
@@ -305,6 +300,12 @@
</RelativeLayout>
<ImageView
android:id="@+id/iv_user_card_wear"
android:layout_width="match_parent"
android:layout_height="180dp"
tools:background="@drawable/bg_user_card_wear" />
</FrameLayout>
<TextView

View File

@@ -12,7 +12,7 @@
android:layout_centerHorizontal="true"
tools:background="#000">
<ImageView
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/iv_halo"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@@ -21,7 +21,7 @@
android:layout_gravity="center"
tools:background="#3c3c3c">
<ImageView
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/iv_halo"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@@ -16,7 +16,7 @@
android:layout_centerHorizontal="true"
tools:background="#000">
<ImageView
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/iv_halo"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@@ -16,7 +16,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/iv_halo"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@@ -15,7 +15,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/iv_halo"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@@ -15,7 +15,7 @@
app:layout_constraintTop_toTopOf="parent"
tools:background="@color/red">
<ImageView
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/iv_halo"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@@ -16,7 +16,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/iv_halo"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@@ -18,7 +18,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/iv_halo"
android:visibility="gone"
android:layout_width="match_parent"

View File

@@ -15,7 +15,7 @@
android:layout_height="60dp"
tools:background="#000">
<ImageView
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/iv_halo"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@@ -6,7 +6,6 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:id="@+id/micro_layout"
android:layout_width="@dimen/dp_room_normal_mic_header_wear_radius"
@@ -14,14 +13,12 @@
android:layout_centerHorizontal="true"
tools:background="#3c3c3c">
<ImageView
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/iv_halo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
<com.yizhuan.erban.common.widget.CircleImageView
android:id="@+id/avatar"
android:layout_width="@dimen/dp_room_normal_mic_radius"
@@ -82,8 +79,6 @@
tools:visibility="gone" />
</RelativeLayout>
</FrameLayout>
<TextView

View File

@@ -13,7 +13,7 @@
android:layout_height="@dimen/dp_room_normal_mic_header_wear_radius"
tools:background="#3c3c3c">
<ImageView
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/iv_halo"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@@ -22,9 +22,10 @@
</data>
<RelativeLayout
android:layout_marginTop="75dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:layout_marginTop="75dp"
android:clipChildren="false">
<!-- ktv模式下的房间排行榜入口 -->
<LinearLayout
@@ -90,7 +91,8 @@
android:id="@+id/micro_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/ll_ktv_top" />
android:layout_below="@id/ll_ktv_top"
android:clipChildren="false" />
<LinearLayout
android:id="@+id/ll_dating_step"

View File

@@ -17,7 +17,7 @@
android:layout_gravity="center"
tools:background="#3c3c3c">
<ImageView
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/iv_halo"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@@ -617,6 +617,14 @@ public class RoomBaseModel extends BaseModel implements IRoomBaseModel {
contentJsonObj.put("vipMic", true);
}
if (!TextUtils.isEmpty(userInfo.getMicNickColor())){
contentJsonObj.put("micNickColor", userInfo.getMicNickColor());
}
if (!TextUtils.isEmpty(userInfo.getMicCircle())){
contentJsonObj.put("micCircle", userInfo.getMicCircle());
}
NIMChatRoomSDK.getChatRoomService()
.updateQueueEx(roomId, String.valueOf(micPosition), contentJsonObj.toJSONString(), true)
.setCallback(new RequestCallback<Void>() {

View File

@@ -19,16 +19,9 @@ public class MicMemberInfo {
private String account;
private String avatar;
private String nick;
private int micPosition;
private String micNickColor;
private String micCircle;
private String headWearUrl;
private boolean isRoomOwnner;
private boolean isAllMember = false;
//添加性别信息,在礼物面板显示
private int gender;
private boolean inPkMode = false;
private int teamId = 0;
private boolean isSelected = false;
private Map<String, Object> extension;
/**
* 相亲模式使用
@@ -55,6 +48,17 @@ public class MicMemberInfo {
*/
private int gameStatus;
//非麦序队列字段 start
private Map<String, Object> extension;
private int micPosition;
private boolean isRoomOwnner;
private boolean isAllMember = false;
private int gender;
private boolean inPkMode = false;
private int teamId = 0;
private boolean isSelected = false;
//非麦序队列字段 end
public MicMemberInfo() {
}

View File

@@ -212,6 +212,14 @@ public class UserInfo implements Serializable {
@Setter
private String userInfoCardPic;
@Getter
@Setter
private String micNickColor;
@Getter
@Setter
private String micCircle;
public Location getUserExpand() {
return userExpand;
}

View File

@@ -1,5 +1,6 @@
package com.yizhuan.xchat_android_core.utils
import android.graphics.Color
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
@@ -16,6 +17,18 @@ fun String?.toDoubleOrDef(def: Double = 0.0): Double {
return this?.toDoubleOrNull() ?: def
}
/**
* 主要用于将服务器返回的RGB值转换为ColorInt
*/
fun String?.toColorInt(defaultValue: String): Int {
if (this.isNullOrBlank()) return Color.parseColor(defaultValue)
return try {
Color.parseColor(this)
} catch (t: Throwable) {
Color.parseColor(defaultValue)
}
}
fun String?.toast() {
SingleToastUtil.showToast(this)
}