修改交友布局
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
package com.xscm.moduleutil.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.blankj.utilcode.util.ConvertUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.room.RoomUserJoinModel;
|
||||
import com.xscm.moduleutil.databinding.RoomViewWelcomeAnimViewBinding;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/9
|
||||
*@description: 进场公屏
|
||||
*/
|
||||
public class WelcomeAnimView extends ConstraintLayout implements Animation.AnimationListener {
|
||||
|
||||
|
||||
private Animation mAnimation;
|
||||
public boolean animEnded = true;
|
||||
private RoomViewWelcomeAnimViewBinding mBinding;
|
||||
|
||||
public WelcomeAnimView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public WelcomeAnimView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mBinding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.room_view_welcome_anim_view, this, true);
|
||||
setVisibility(GONE);
|
||||
mAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.room_anim_set_welcome);
|
||||
mAnimation.setFillAfter(true);
|
||||
mAnimation.setAnimationListener(this);
|
||||
}
|
||||
|
||||
public void showAnim() {
|
||||
if (SpUtil.getOpenEffect() == 0) {
|
||||
return;
|
||||
}
|
||||
if (queue == null || queue.size() == 0) {
|
||||
return;
|
||||
}
|
||||
if (animEnded) {
|
||||
RoomUserJoinModel animBean = queue.poll();
|
||||
if (animBean != null) {
|
||||
// mIvRole.setRole(animBean.getRole());
|
||||
// mIvNew.setVisibility(animBean.getUser_is_new() == 1 ? VISIBLE : GONE);
|
||||
mBinding.tvName.setText(animBean.getNickname());
|
||||
// mIvNobility.setVisibility(TextUtils.isEmpty(animBean.getNobility_icon()) ? GONE : VISIBLE);
|
||||
// ImageUtils.loadImageView(animBean.getNobility_icon(), mIvNobility);
|
||||
mBinding.ivRank.setVisibility(TextUtils.isEmpty(animBean.getRank_icon()) ? GONE : VISIBLE);
|
||||
ImageUtils.loadImageView(animBean.getRank_icon(), mBinding.ivRank);
|
||||
}
|
||||
setVisibility(VISIBLE);
|
||||
//加入房间背景 和 字体颜色
|
||||
LayoutParams infoParams = (LayoutParams) mBinding.llInfo.getLayoutParams();
|
||||
if (!TextUtils.isEmpty(animBean.getBackground())) {
|
||||
mBinding.ivUserInto.setVisibility(VISIBLE);
|
||||
mBinding.llInfo.setBackgroundResource(R.drawable.bg_r10_transparent);
|
||||
infoParams.leftMargin = ConvertUtils.dp2px(74);
|
||||
ImageUtils.loadImageView(animBean.getBackground(), mBinding.ivUserInto);
|
||||
} else {
|
||||
infoParams.leftMargin = 0;
|
||||
mBinding.llInfo.setBackgroundResource(R.drawable.room_bg_welcome_anim);
|
||||
mBinding.ivUserInto.setVisibility(INVISIBLE);
|
||||
}
|
||||
mBinding.llInfo.setLayoutParams(infoParams);
|
||||
if (!TextUtils.isEmpty(animBean.getColor())) {
|
||||
try {
|
||||
mBinding.tvEndTxt.setTextColor(Color.parseColor(animBean.getColor()));
|
||||
mBinding.tvName.setTextColor(Color.parseColor(animBean.getColor()));
|
||||
} catch (Exception e) {
|
||||
mBinding.tvEndTxt.setTextColor(Color.WHITE);
|
||||
mBinding.tvName.setTextColor(Color.WHITE);
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
mBinding.tvEndTxt.setTextColor(Color.WHITE);
|
||||
mBinding.tvName.setTextColor(Color.WHITE);
|
||||
}
|
||||
this.startAnimation(mAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
public void addAnim(RoomUserJoinModel bean) {
|
||||
if (SpUtil.getOpenEffect() == 0) {
|
||||
return;
|
||||
}
|
||||
if (queue.size() == 0) {
|
||||
queue.add(bean);
|
||||
showAnim();
|
||||
} else {
|
||||
queue.add(bean);
|
||||
}
|
||||
}
|
||||
|
||||
private Queue<RoomUserJoinModel> queue = new LinkedList<>();
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
animEnded = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
animEnded = true;
|
||||
showAnim();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭特效
|
||||
*/
|
||||
public void closeEffect() {
|
||||
//清空队列
|
||||
queue.clear();
|
||||
//关闭动画
|
||||
if (mAnimation != null && !animEnded) {
|
||||
animEnded = true;
|
||||
mAnimation.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user