全站喇叭

This commit is contained in:
18401019693
2022-09-14 18:29:14 +08:00
parent ad1599ccce
commit 169bf74f31
2 changed files with 82 additions and 10 deletions

View File

@@ -43,6 +43,7 @@ public class FullServiceNotificationView extends FrameLayout {
private RelativeLayout contextLayout;
private long animationTime = 8600;
private String userName = "熱度卡如何獲得?", userText = "前往「個人中心」-「我的包裹」中,即可使用熱度卡。";
private String anchorId = "";
public FullServiceNotificationView(@NonNull Context context) {
super(context);
@@ -64,6 +65,12 @@ public class FullServiceNotificationView extends FrameLayout {
this.userText = userText;
rcUserText.setText(":" + userText);
rcUserName.setGradientColor(Color.parseColor("#FFFFFF"), Color.parseColor("#FFEF00"));
rcUserName.setText(userName);
return this;
}
public FullServiceNotificationView setAnchorId(String anchorId) {
this.anchorId = anchorId;
return this;
}
@@ -79,6 +86,16 @@ public class FullServiceNotificationView extends FrameLayout {
contextLayout = rootView.findViewById(R.id.context_layout);
gotoRoomView.setVisibility(GONE);
contextLayout.setVisibility(GONE);
//点击跳转直播间
gotoRoomView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (callBack != null) {
callBack.goToLive();
}
}
});
}
@@ -156,15 +173,18 @@ public class FullServiceNotificationView extends FrameLayout {
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 ((userName.length()+userText.length())>13){
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);
@@ -235,4 +255,15 @@ public class FullServiceNotificationView extends FrameLayout {
return this;
}
}
private FullServiceNotificationViewCallBack callBack;
public FullServiceNotificationView setCallBack(FullServiceNotificationViewCallBack callBack) {
this.callBack = callBack;
return this;
}
public interface FullServiceNotificationViewCallBack {
void goToLive();
}
}