全站喇叭

This commit is contained in:
18401019693
2022-09-14 18:05:42 +08:00
parent 5bd0f455bb
commit ad1599ccce
28 changed files with 546 additions and 247 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,6 +1,9 @@
package com.yunbao.common.bean;
import android.text.TextUtils;
import com.google.gson.annotations.SerializedName;
import com.yunbao.common.views.weight.FullServiceNotificationView;
public class MsgModel extends BaseModel {
/**
@@ -19,7 +22,7 @@ public class MsgModel extends BaseModel {
@SerializedName("user_name")
private String userName = "";
@SerializedName("noble_id")
private long nobleId = 0;
private String nobleId = "";
@SerializedName("trumpet_msg")
private String trumpetMsg = "";
@SerializedName("anchor_id")
@@ -52,11 +55,11 @@ public class MsgModel extends BaseModel {
return this;
}
public long getNobleId() {
public String getNobleId() {
return nobleId;
}
public MsgModel setNobleId(long nobleId) {
public MsgModel setNobleId(String nobleId) {
this.nobleId = nobleId;
return this;
}
@@ -78,4 +81,27 @@ public class MsgModel extends BaseModel {
this.anchorId = anchorId;
return this;
}
/**
* 获取贵族等级
*
* @return
*/
public FullServiceNotificationView.RoleType getRoleType() {
if (TextUtils.isEmpty(nobleId)) {
return null;
} else {
FullServiceNotificationView.RoleType roleType = null;
if (TextUtils.equals(nobleId, "5")) {
roleType = FullServiceNotificationView.RoleType.KING;
} else if (TextUtils.equals(nobleId, "6")) {
roleType = FullServiceNotificationView.RoleType.EMPEROR;
} else if (TextUtils.equals(nobleId, "7")) {
roleType = FullServiceNotificationView.RoleType.BETTER_EMPEROR;
} else {
}
return roleType;
}
}
}

View File

@@ -35,9 +35,9 @@ import static com.yunbao.common.CommonAppContext.isReady;
*/
public class RongcloudIMManager {
//融云开发者平台注册app唯一识别符
public static final String RONG_IM_KEY = "uwd1c0sxu1p71";
// public static final String RONG_IM_KEY = "uwd1c0sxu1p71";
//测试环境
// public static final String RONG_IM_KEY = "pvxdm17jpd3hr";
public static final String RONG_IM_KEY = "pvxdm17jpd3hr";
private static final String CLASSNAME = "RongcloudIMManager";

View File

@@ -0,0 +1,238 @@
package com.yunbao.common.views.weight;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.TranslateAnimation;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.opensource.svgaplayer.SVGACallback;
import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.yunbao.common.R;
import com.yunbao.common.glide.ImgLoader;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field;
/**
* 全服通知
*/
public class FullServiceNotificationView extends FrameLayout {
private Context mContext;
private View rootView;
private SVGAImageView svagaBc;
private ImageView iconImg;
private TextView gotoRoomView, rcUserText;
private GradientColorTextView rcUserName;
private RoleType type;
private RelativeLayout contextLayout;
private long animationTime = 8600;
private String userName = "熱度卡如何獲得?", userText = "前往「個人中心」-「我的包裹」中,即可使用熱度卡。";
public FullServiceNotificationView(@NonNull Context context) {
super(context);
init(context);
}
public FullServiceNotificationView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context);
}
public FullServiceNotificationView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
public FullServiceNotificationView setUserNameAndUserText(String userName, String userText) {
this.userName = userName;
this.userText = userText;
rcUserText.setText(":" + userText);
rcUserName.setGradientColor(Color.parseColor("#FFFFFF"), Color.parseColor("#FFEF00"));
return this;
}
private void init(Context context) {
mContext = context;
rootView = LayoutInflater.from(mContext).inflate(R.layout.view_full_service_notification, this, true);
svagaBc = rootView.findViewById(R.id.svaga_bc);
iconImg = rootView.findViewById(R.id.icon_img);
gotoRoomView = rootView.findViewById(R.id.goto_room_view);
iconImg = rootView.findViewById(R.id.icon_img);
rcUserName = rootView.findViewById(R.id.rc_user_name);
rcUserText = rootView.findViewById(R.id.rc_user_text);
contextLayout = rootView.findViewById(R.id.context_layout);
gotoRoomView.setVisibility(GONE);
contextLayout.setVisibility(GONE);
}
public FullServiceNotificationView setType(RoleType type) {
this.type = type;
switch (type) {
case KING:
ImgLoader.display(mContext, R.mipmap.imng_guowang, iconImg);
setFullServiceStart("icon_livemsgbg_guowang.svga");
break;
case EMPEROR:
ImgLoader.display(mContext, R.mipmap.img_huangdi, iconImg);
setFullServiceStart("icon_livemsgbg_huangdi.svga");
break;
case BETTER_EMPEROR:
ImgLoader.display(mContext, R.mipmap.img_chaohuang, iconImg);
setFullServiceStart("icon_livemsgbg_chaohuang.svga");
break;
}
return this;
}
private void setFullServiceStart(String svgaName) {
svagaBc.setCallback(svgaCallback);
svagaBc.setLoops(1);
svagaBc.startAnimation();
new SVGAParser(mContext)
.decodeFromAssets(svgaName, new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@NotNull SVGAVideoEntity svgaVideoEntity) {
svagaBc.setVisibility(VISIBLE);
SVGADrawable imageView = new SVGADrawable(svgaVideoEntity);
svagaBc.setImageDrawable(imageView);
try {
Field mAnimator = svagaBc.getClass().getDeclaredField("mAnimator");
mAnimator.setAccessible(true);
ValueAnimator animator = (ValueAnimator) mAnimator.get(svagaBc);
animationTime = animator.getDuration();
System.out.println("播放时间 = " + animator.getDuration());
} catch (Exception e) {
e.printStackTrace();
}
svagaBc.startAnimation();
}
@Override
public void onError() {
}
}, null);
}
private SVGACallback svgaCallback = new SVGACallback() {
@Override
public void onPause() {
}
@Override
public void onFinished() {
svagaBc.clear();
svagaBc.setVisibility(GONE);
gotoRoomView.setVisibility(GONE);
}
@Override
public void onRepeat() {
}
@Override
public void onStep(int frame, double v) {
System.out.println("frame = " + frame);
if (frame == 12) {
gotoRoomView.setVisibility(VISIBLE);
contextLayout.setVisibility(VISIBLE);
contextLayout.post(() -> {
TranslateAnimation animationTranslate = new TranslateAnimation(0, -contextLayout.getMeasuredWidth(), 0, 0);
AnimationSet animationSet1 = new AnimationSet(true);
animationSet1.addAnimation(animationTranslate);
animationSet1.setFillAfter(true);
animationSet1.setDuration((animationTime - 800) / 2);
animationSet1.setAnimationListener(animationListener);
contextLayout.startAnimation(animationSet1);
});
}
if (frame == 165) {
gotoRoomView.setVisibility(GONE);
contextLayout.setVisibility(GONE);
}
}
};
Animation.AnimationListener animationListener = new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
contextLayout.clearAnimation();
if (svagaBc.isAnimating()) {
TranslateAnimation animationTranslate = new TranslateAnimation(0, -contextLayout.getMeasuredWidth(), 0, 0);
AnimationSet animationSet1 = new AnimationSet(true);
animationSet1.addAnimation(animationTranslate);
animationSet1.setFillAfter(true);
animationSet1.setDuration((animationTime - 800) / 2);
animationSet1.setAnimationListener(animationListener);
contextLayout.startAnimation(animationSet1);
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
};
/**
* 角色类型
*/
public enum RoleType {
KING("国王", 5),
EMPEROR("皇帝", 6),
BETTER_EMPEROR("超皇", 7);
private String name;
private int type;
RoleType(String name, int type) {
this.name = name;
this.type = type;
}
public String getName() {
return name;
}
public RoleType setName(String name) {
this.name = name;
return this;
}
public int getType() {
return type;
}
public RoleType setType(int type) {
this.type = type;
return this;
}
}
}

View File

@@ -0,0 +1,55 @@
package com.yunbao.common.views.weight;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Shader;
import android.util.AttributeSet;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;
/**
* 文字渐变
*/
public class GradientColorTextView extends AppCompatTextView {
private LinearGradient mLinearGradient;
private Paint mPaint;
private int mViewWidth = 0;
private Rect mTextBound = new Rect();
private int fromColor, toColor;
public GradientColorTextView(@NonNull Context context) {
super(context);
}
public GradientColorTextView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public GradientColorTextView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void setGradientColor(int fromColor, int toColor) {
this.fromColor = fromColor;
this.toColor = toColor;
}
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas) {
mViewWidth = getMeasuredHeight();
mPaint = getPaint();
String mTipText = getText().toString();
mPaint.getTextBounds(mTipText, 0, mTipText.length(), mTextBound);
mLinearGradient = new LinearGradient(0, 0, 0, mViewWidth,
new int[]{fromColor, toColor},
null, Shader.TileMode.REPEAT);
mPaint.setShader(mLinearGradient);
canvas.drawText(mTipText, getMeasuredWidth() / 2 - mTextBound.width() / 2, getMeasuredHeight() / 2 + mTextBound.height() / 2, mPaint);
}
}

View File

@@ -1,6 +1,7 @@
package com.yunbao.common.views.weight;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import androidx.annotation.NonNull;
@@ -24,4 +25,6 @@ public class MarqueeTextView extends AppCompatTextView {
public boolean isFocused() {
return true;
}
}

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromXDelta="100%p"
android:toXDelta="0%p" />
<translate
android:fromXDelta="100%p"
android:toXDelta="0%p" />
</set>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:radius="11dp" />
<gradient android:angle="360" android:endColor="#FFFBD040" android:startColor="#FFFF5655" />
</shape>
</item>
</selector>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="ring">
<gradient android:angle="90" android:endColor="#FFFFFF" android:startColor="#FFEF00" />
</shape>
</item>
</selector>

View File

@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp">
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/svaga_bc"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/goto_room_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="42dp"
android:layout_marginEnd="19dp"
android:background="@drawable/background_whole_station_horn"
android:paddingLeft="7dp"
android:paddingTop="3dp"
android:paddingRight="7dp"
android:paddingBottom="3dp"
android:text="@string/use_live"
android:textColor="#FFFEFEFE"
android:textSize="10dp" />
<ViewFlipper
android:id="@+id/viewflipper_banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="19dp"
android:layout_marginTop="42dp"
android:layout_marginEnd="20dp"
android:layout_toStartOf="@+id/goto_room_view"
android:inAnimation="@anim/vice_screen_come_in"
android:outAnimation="@anim/vice_screen_come_out"
android:visibility="gone" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="19dp"
android:layout_marginTop="42dp"
android:layout_marginEnd="20dp"
android:layout_toStartOf="@+id/goto_room_view"
android:animateLayoutChanges="true"
android:gravity="center_vertical"
android:visibility="visible">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<RelativeLayout
android:id="@+id/context_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/icon_img"
android:layout_width="52dp"
android:layout_height="20.5dp"
android:layout_centerVertical="true"
android:layout_marginStart="7dp"
android:src="@mipmap/img_chaohuang" />
<com.yunbao.common.views.weight.GradientColorTextView
android:id="@+id/rc_user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="7dp"
android:layout_toEndOf="@id/icon_img"
android:lines="1"
android:text="@string/live_hot_ruletext2"
android:textSize="12sp" />
<TextView
android:id="@+id/rc_user_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="3dp"
android:layout_toEndOf="@id/rc_user_name"
android:lines="1"
android:text="@string/live_hot_ruletext22"
android:textColor="#FFFFFFFF"
android:textSize="12sp" />
</RelativeLayout>
</HorizontalScrollView>
</RelativeLayout>
</RelativeLayout>

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="19dp"
android:layout_marginTop="42dp"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/context_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:gravity="center_vertical"
android:visibility="visible">
<ImageView
android:id="@+id/icon_img"
android:layout_width="52dp"
android:layout_height="20.5dp"
android:layout_marginStart="7dp"
android:src="@mipmap/img_chaohuang" />
<TextView
android:id="@+id/rc_user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="7dp"
android:lines="1"
android:text="@string/live_hot_ruletext2"
android:textColor="#FFEF00"
android:textSize="12sp" />
<TextView
android:id="@+id/rc_user_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:lines="1"
android:text="@string/live_hot_ruletext22"
android:textColor="#FFFFFFFF"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB