feat:完成全服福袋通知样式调整
This commit is contained in:
@@ -20,9 +20,14 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
|
||||
@@ -35,6 +40,7 @@ import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
|
||||
import com.yizhuan.erban.common.svga.SimpleSvgaCallback;
|
||||
import com.yizhuan.erban.databinding.DialogAllPlayEffectBinding;
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2;
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
|
||||
import com.yizhuan.erban.utils.RegexUtil;
|
||||
import com.yizhuan.erban.utils.SpannableBuilder;
|
||||
@@ -49,11 +55,18 @@ import com.yizhuan.xchat_android_core.treasurefairy.FairyMsgInfoBean;
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.StringUtils;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
|
||||
public class AllPlayEffectDialog extends BaseDialog {
|
||||
|
||||
private final PlayEffectInfo playEffectInfo;
|
||||
private DialogAllPlayEffectBinding binding;
|
||||
|
||||
private CompositeDisposable disposable = null;
|
||||
|
||||
public AllPlayEffectDialog(Context context, @NonNull PlayEffectInfo playEffectInfo) {
|
||||
super(context, R.style.FullScreenDialog);
|
||||
this.playEffectInfo = playEffectInfo;
|
||||
@@ -61,6 +74,7 @@ public class AllPlayEffectDialog extends BaseDialog {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
disposable = new CompositeDisposable();
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
binding = DialogAllPlayEffectBinding.inflate(LayoutInflater.from(getContext()));
|
||||
setContentView(binding.getRoot());
|
||||
@@ -260,22 +274,30 @@ public class AllPlayEffectDialog extends BaseDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private void showLuckyBagNotify(LuckyBagNoticeInfo luckyBagNoticeInfo) {
|
||||
private void showLuckyBagNotify(LuckyBagNoticeInfo noticeInfo) {
|
||||
View roomView = LayoutInflater.from(getContext())
|
||||
.inflate(R.layout.layout_room_lucky_bag_notify, null);
|
||||
roomView.setOnClickListener(view -> AVRoomActivity.start(getContext(), noticeInfo.getRoomUid()));
|
||||
ImageView bagImageView = roomView.findViewById(R.id.iv_bag);
|
||||
ImageLoadUtilsV2.loadImage(bagImageView, noticeInfo.getLuckyBagGiftPic());
|
||||
ImageView giftImageView = roomView.findViewById(R.id.iv_gift);
|
||||
ImageLoadUtilsV2.loadImage(giftImageView, noticeInfo.getGiftPic());
|
||||
TextView messageTextView = roomView.findViewById(R.id.tv_message);
|
||||
SpannableBuilder text = new SpannableBuilder()
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_04),
|
||||
new ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
subAndReplaceDot(luckyBagNoticeInfo.getNick(), 6) + " ",
|
||||
new ForegroundColorSpan(ContextCompat.getColor(getContext(),R.color.notice_nick))
|
||||
subAndReplaceDot(noticeInfo.getNick(), 6) + " ",
|
||||
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_05),
|
||||
new ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
luckyBagNoticeInfo.getLuckyBagName() + " ",
|
||||
noticeInfo.getLuckyBagName() + " ",
|
||||
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
@@ -283,7 +305,7 @@ public class AllPlayEffectDialog extends BaseDialog {
|
||||
new ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
luckyBagNoticeInfo.getGoldPrice() + " ",
|
||||
noticeInfo.getGoldPrice() + " ",
|
||||
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
@@ -291,62 +313,22 @@ public class AllPlayEffectDialog extends BaseDialog {
|
||||
new ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
luckyBagNoticeInfo.getGiftName(),
|
||||
noticeInfo.getGiftName(),
|
||||
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.notice_nick))
|
||||
);
|
||||
SVGAImageView svgaImageView = new SVGAImageView(getContext());
|
||||
svgaImageView.setLoops(1);
|
||||
svgaImageView.setClearsAfterDetached(true);
|
||||
messageTextView.setText(text.build());
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
||||
svgaImageView.setLayoutParams(params);
|
||||
svgaImageView.setCallback(new SimpleSvgaCallback() {
|
||||
@Override
|
||||
public void onFinished() {
|
||||
closeSelf();
|
||||
}
|
||||
});
|
||||
binding.flSvgaNotify.addView(svgaImageView);
|
||||
try {
|
||||
SVGAParser.Companion.shareParser().decodeFromAssets("svga/lucky_gift_notify.svga", new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(@NonNull SVGAVideoEntity svgaVideoEntity) {
|
||||
SVGADynamicEntity dynamicEntity = new SVGADynamicEntity();
|
||||
TextPaint textPaint = new TextPaint();
|
||||
textPaint.setColor(Color.WHITE);//字体颜色
|
||||
textPaint.setTextSize(24);//字体大小
|
||||
dynamicEntity.setDynamicText(new StaticLayout(
|
||||
text.build(),
|
||||
0,
|
||||
text.build().length(),
|
||||
textPaint,
|
||||
0,
|
||||
Layout.Alignment.ALIGN_CENTER,
|
||||
1.0f,
|
||||
0.0f,
|
||||
false
|
||||
), "fdpp_copywriting");
|
||||
svgaImageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//跳轉房間要移除監聽,不然可能NPE
|
||||
svgaImageView.setCallback(null);
|
||||
AVRoomActivity.start(getContext(), luckyBagNoticeInfo.getRoomUid());
|
||||
}
|
||||
});
|
||||
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity, dynamicEntity);
|
||||
svgaImageView.setImageDrawable(drawable);
|
||||
svgaImageView.stepToFrame(0, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
closeSelf();
|
||||
}
|
||||
}, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
closeSelf();
|
||||
}
|
||||
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) binding.flSvgaNotify.getLayoutParams();
|
||||
layoutParams.dimensionRatio = "375:71";
|
||||
binding.flSvgaNotify.setLayoutParams(layoutParams);
|
||||
binding.flSvgaNotify.addView(roomView,params);
|
||||
Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.anim_box_notify);
|
||||
roomView.startAnimation(animation);
|
||||
disposable.add(Observable.timer(4500, TimeUnit.MILLISECONDS).subscribe(aLong -> {
|
||||
Animation animation1 = AnimationUtils.loadAnimation(getContext(), R.anim.anim_box_notify_close);
|
||||
roomView.startAnimation(animation1);
|
||||
}));
|
||||
disposable.add(Observable.timer(5000, TimeUnit.MILLISECONDS).subscribe(aLong -> closeSelf()));
|
||||
}
|
||||
|
||||
private void showNotifyH5BySvga(NotifyH5Info info) {
|
||||
@@ -510,15 +492,18 @@ public class AllPlayEffectDialog extends BaseDialog {
|
||||
}
|
||||
|
||||
private String subAndReplaceDot(String nick, int maxLength) {
|
||||
if(nick.length() > maxLength){
|
||||
return nick.substring(0,maxLength)+"...";
|
||||
}else {
|
||||
if (nick.length() > maxLength) {
|
||||
return nick.substring(0, maxLength) + "...";
|
||||
} else {
|
||||
return nick;
|
||||
}
|
||||
}
|
||||
|
||||
private void closeSelf() {
|
||||
try {
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
dismiss();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
Reference in New Issue
Block a user