feat:完成飘窗延时功能

This commit is contained in:
Max
2023-11-16 17:58:49 +08:00
parent ee28779a01
commit 7e05a6514f
2 changed files with 22 additions and 2 deletions

View File

@@ -220,5 +220,8 @@ class SettingActivity : BaseViewBindingActivity<ActivitySettingBinding>(), View.
// RedPackageOpenDialog2().show(this) // RedPackageOpenDialog2().show(this)
// val json = "{\"first\":3,\"second\":32,\"data\":{\"recvUserUid\":2735,\"recvUserAvatar\":\"https://img.pekolive.com/default_avatar.png\",\"recvUserNick\":\"66丢丢丢丢丢多多多的hhhh\",\"sendUserNick\":\"11的ass\",\"sendUserAvatar\":\"http://beta.img.pekolive.com/Fk7aur-1RBqKXC-qqBwMTjivZ3lV?imageslim\",\"sendUserUid\":2737,\"giftUrl\":\"http://beta.img.pekolive.com/Fn6h_gPFD5MwA-Ql_kcWqNpKp0JM?imageslim\",\"giftName\":\"幽靈糖果\",\"giftId\":2075,\"giftNum\":${Random.nextInt(1,1000)},\"giftGolds\":33440,\"notifyStaySecond\":5,\"isHomeShow\":true,\"isSkipRoom\":true,\"isFullScreen\":false,\"isSendMsg\":false,\"roomUid\":2737,\"roomErbanNo\":11,\"roomTitle\":\"11的工会\",\"levelNum\":${Random.nextInt(1,4)}}}" // val json = "{\"first\":3,\"second\":32,\"data\":{\"recvUserUid\":2735,\"recvUserAvatar\":\"https://img.pekolive.com/default_avatar.png\",\"recvUserNick\":\"66丢丢丢丢丢多多多的hhhh\",\"sendUserNick\":\"11的ass\",\"sendUserAvatar\":\"http://beta.img.pekolive.com/Fk7aur-1RBqKXC-qqBwMTjivZ3lV?imageslim\",\"sendUserUid\":2737,\"giftUrl\":\"http://beta.img.pekolive.com/Fn6h_gPFD5MwA-Ql_kcWqNpKp0JM?imageslim\",\"giftName\":\"幽靈糖果\",\"giftId\":2075,\"giftNum\":${Random.nextInt(1,1000)},\"giftGolds\":33440,\"notifyStaySecond\":5,\"isHomeShow\":true,\"isSkipRoom\":true,\"isFullScreen\":false,\"isSendMsg\":false,\"roomUid\":2737,\"roomErbanNo\":11,\"roomTitle\":\"11的工会\",\"levelNum\":${Random.nextInt(1,4)}}}"
// onReceivedNimBroadcastMessage(json) // onReceivedNimBroadcastMessage(json)
val json = "{\"first\":85,\"second\":855,\"data\":{\"nick\":\"66丢丢丢丢丢多多多的hhhh\",\"preVipName\":\"子爵\",\"floatPic\":\"https://image.hfighting.com/Fq3JtbK2acO3FN-3vWZo8ldtHfse\",\"uid\":2735,\"currVipName\":\"侯爵\",\"erbanNo\":66,\"roomUid\":2734,\"avatar\":\"https://img.pekolive.com/default_avatar.png\",\"currVipLevel\":5}}"
onReceivedNimBroadcastMessage(json)
// CommonWebViewActivity.start(this,"https://api.anan.chat/anan_vestBag/modules/myincome/index.html#/DiamondLog")
} }
} }

View File

@@ -16,6 +16,7 @@ import android.widget.FrameLayout;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.chuhai.utils.ServiceTime;
import com.opensource.svgaplayer.SVGADrawable; import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGADynamicEntity; import com.opensource.svgaplayer.SVGADynamicEntity;
import com.opensource.svgaplayer.SVGAImageView; import com.opensource.svgaplayer.SVGAImageView;
@@ -41,6 +42,8 @@ public class AllServiceVipLevelUPDialog extends BaseDialog {
private final VipMessageInfo vipMessageInfo; private final VipMessageInfo vipMessageInfo;
private DialogVipAllServiceLevelUpBinding binding; private DialogVipAllServiceLevelUpBinding binding;
private long startTime = 0;
private int frameCount = 0;
public AllServiceVipLevelUPDialog(Context context, @NonNull VipMessageInfo vipMessageInfo) { public AllServiceVipLevelUPDialog(Context context, @NonNull VipMessageInfo vipMessageInfo) {
super(context, R.style.FullScreenDialog); super(context, R.style.FullScreenDialog);
@@ -77,7 +80,7 @@ public class AllServiceVipLevelUPDialog extends BaseDialog {
.append(ResUtil.getString(R.string.widget_dialog_allserviceviplevelupdialog_01), new ForegroundColorSpan(Color.WHITE)) .append(ResUtil.getString(R.string.widget_dialog_allserviceviplevelupdialog_01), new ForegroundColorSpan(Color.WHITE))
.append("-", new CircleImageSpan(new ColorDrawable(Color.TRANSPARENT), vipMessageInfo.getAvatar(), 50, 50)) .append("-", new CircleImageSpan(new ColorDrawable(Color.TRANSPARENT), vipMessageInfo.getAvatar(), 50, 50))
.append(" " + StringExtensionKt.sub(vipMessageInfo.getNick(), 6) + " ", new ForegroundColorSpan(getContext().getResources().getColor(R.color.notice_nick))) .append(" " + StringExtensionKt.sub(vipMessageInfo.getNick(), 6) + " ", new ForegroundColorSpan(getContext().getResources().getColor(R.color.notice_nick)))
.append(ResUtil.getString(R.string.widget_dialog_allserviceviplevelupdialog_02) + vipMessageInfo.getCurrVipName(), new ForegroundColorSpan(Color.WHITE)+"!"); .append(ResUtil.getString(R.string.widget_dialog_allserviceviplevelupdialog_02) + vipMessageInfo.getCurrVipName(), new ForegroundColorSpan(Color.WHITE) + "!");
SVGAImageView svgaImageView = new SVGAImageView(getContext()); SVGAImageView svgaImageView = new SVGAImageView(getContext());
svgaImageView.setLoops(1); svgaImageView.setLoops(1);
@@ -87,7 +90,19 @@ public class AllServiceVipLevelUPDialog extends BaseDialog {
svgaImageView.setCallback(new SimpleSvgaCallback() { svgaImageView.setCallback(new SimpleSvgaCallback() {
@Override @Override
public void onFinished() { public void onFinished() {
closeSelf(); long offset = ServiceTime.INSTANCE.getTime() - startTime;
if (offset < 6000) {
int centerFrame = frameCount / 2;
if (centerFrame > 0) {
// 目前的SVGA资源最后一帧是半透明的这里强制跳到中间帧最大程度避免这种情况
svgaImageView.stepToFrame(centerFrame, false);
}
svgaImageView.postDelayed(() -> {
closeSelf();
}, 6000 - offset);
} else {
closeSelf();
}
} }
}); });
binding.flSvgaVipNotify.addView(svgaImageView); binding.flSvgaVipNotify.addView(svgaImageView);
@@ -95,6 +110,8 @@ public class AllServiceVipLevelUPDialog extends BaseDialog {
SVGAParser.Companion.shareParser().decodeFromURL(new URL(vipMessageInfo.getFloatPic()), new SVGAParser.ParseCompletion() { SVGAParser.Companion.shareParser().decodeFromURL(new URL(vipMessageInfo.getFloatPic()), new SVGAParser.ParseCompletion() {
@Override @Override
public void onComplete(@NonNull SVGAVideoEntity svgaVideoEntity) { public void onComplete(@NonNull SVGAVideoEntity svgaVideoEntity) {
frameCount = svgaVideoEntity.getFrames();
startTime = ServiceTime.INSTANCE.getTime();
SVGADynamicEntity dynamicEntity = new SVGADynamicEntity(); SVGADynamicEntity dynamicEntity = new SVGADynamicEntity();
TextPaint textPaint = new TextPaint(); TextPaint textPaint = new TextPaint();
textPaint.setColor(Color.WHITE);//字体颜色 textPaint.setColor(Color.WHITE);//字体颜色