1.房间顶部飘屏动画入场间隔修改

2.5级svga飘屏动画和4级统一
This commit is contained in:
huangjian
2020-12-29 11:12:07 +08:00
parent 640dd5d43e
commit bd3de42433
2 changed files with 28 additions and 19 deletions

View File

@@ -19,6 +19,7 @@ import android.view.ViewConfiguration;
import android.view.ViewStub;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
@@ -47,6 +48,7 @@ import com.yizhuan.erban.avroom.presenter.HomePartyPresenter;
import com.yizhuan.erban.avroom.widget.GiftV2View;
import com.yizhuan.erban.avroom.widget.MessageView;
import com.yizhuan.erban.base.BaseMvpActivity;
import com.yizhuan.erban.common.svga.SimpleSvgaCallback;
import com.yizhuan.erban.common.widget.dialog.DialogManager;
import com.yizhuan.erban.databinding.FragmentChatroomGameMainBinding;
import com.yizhuan.erban.friend.view.SelectFriendActivity;
@@ -957,7 +959,10 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
private boolean isCreateLevelUp;
private Disposable disposableLevelUp;
private final int ANIM_TIME = 3500;
//顶部飘屏总展示时间
private final int SHOW_TIME = 3500;
//顶部飘屏周期
private final int PERIOD = 1000;
/**
* 开福袋飘屏
@@ -969,7 +974,7 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
messagesLuckyGift.add(chatRoomMessage);
if (disposableLuckyGift == null || messagesLuckyGift.size() == 1) {
isCreateLuckyGift = true;
disposableLuckyGift = Observable.interval(0, 500, TimeUnit.MILLISECONDS)
disposableLuckyGift = Observable.interval(0, PERIOD, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.doOnNext(aLong -> {
if (messagesLuckyGift.size() > 0 && !isCreateLuckyGift)
@@ -996,7 +1001,7 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
textView.setText(text.build());
animationLuckyGift = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify);
textView.startAnimation(animationLuckyGift);
gameMainBinding.flLuckyGiftNotify.postDelayed(() -> gameMainBinding.flLuckyGiftNotify.removeView(textView), 3500);
gameMainBinding.flLuckyGiftNotify.postDelayed(() -> gameMainBinding.flLuckyGiftNotify.removeView(textView), SHOW_TIME);
}
@@ -1010,7 +1015,7 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
messages.add(chatRoomMessage);
if (boxDisposable == null || messages.size() == 1) {
isCreate = true;
boxDisposable = Observable.interval(0, 500, TimeUnit.MILLISECONDS)
boxDisposable = Observable.interval(0, PERIOD, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.doOnNext(aLong -> {
if (messages.size() > 0 && !isCreate)
@@ -1035,7 +1040,7 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
animation = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify);
gameMainBinding.flBoxNotify.addView(textView);
textView.startAnimation(animation);
gameMainBinding.flBoxNotify.postDelayed(() -> gameMainBinding.flBoxNotify.removeView(textView), 3500);
gameMainBinding.flBoxNotify.postDelayed(() -> gameMainBinding.flBoxNotify.removeView(textView), SHOW_TIME);
}
/**
@@ -1048,7 +1053,7 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
messagesBoxSVGA.add(chatRoomMessage);
if (boxSVGADisposable == null || messagesBoxSVGA.size() == 1) {
isBoxSVGACreate = true;
boxSVGADisposable = Observable.interval(0, ANIM_TIME, TimeUnit.MILLISECONDS)
boxSVGADisposable = Observable.interval(0, PERIOD, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.doOnNext(aLong -> {
if (messagesBoxSVGA.size() > 0 && !isBoxSVGACreate)
@@ -1069,12 +1074,22 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
.append(attachment.getBoxTypeStr() + " ", new ForegroundColorSpan(Color.WHITE))
.append(attachment.getPrizeName(), new ForegroundColorSpan(getResources().getColor(R.color.notice_gift)))
.append("x" + attachment.getPrizeNum(), new ForegroundColorSpan(Color.WHITE));
SVGAImageView svgaImageView = new SVGAImageView(mContext);
svgaImageView.setLoops(1);
svgaImageView.setClearsAfterStop(true);
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() {
gameMainBinding.flSvgaBoxNotify.post(() -> gameMainBinding.flSvgaBoxNotify.removeView(svgaImageView));
}
});
gameMainBinding.flSvgaBoxNotify.addView(svgaImageView);
mSVGAParser.decodeFromAssets("svga/box_notify.svga", new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@Nullable SVGAVideoEntity svgaVideoEntity) {
gameMainBinding.svgaBoxNotify.setVisibility(View.VISIBLE);
gameMainBinding.svgaBoxNotify.setLoops(1);
gameMainBinding.svgaBoxNotify.setClearsAfterStop(true);
SVGADynamicEntity dynamicEntity = new SVGADynamicEntity();
TextPaint textPaint = new TextPaint();
textPaint.setColor(Color.WHITE);//字体颜色
@@ -1091,9 +1106,8 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
false
), "xtc_copywriting");
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity, dynamicEntity);
gameMainBinding.svgaBoxNotify.setImageDrawable(drawable);
gameMainBinding.svgaBoxNotify.stepToFrame(0, true);
gameMainBinding.svgaBoxNotify.startAnimation();
svgaImageView.setImageDrawable(drawable);
svgaImageView.stepToFrame(0, true);
}
@Override
@@ -1197,7 +1211,6 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity, dynamicEntity);
mSvgaMemberIn.setImageDrawable(drawable);
mSvgaMemberIn.stepToFrame(0, true);
mSvgaMemberIn.startAnimation();
}
@Override
@@ -1259,7 +1272,6 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity, dynamicEntity);
mSvgaLevelUp.setImageDrawable(drawable);
mSvgaLevelUp.stepToFrame(0, true);
mSvgaLevelUp.startAnimation();
mSvgaLevelUp.setCallback(new SVGACallback() {
@Override
public void onPause() {

View File

@@ -245,17 +245,14 @@
android:id="@+id/fl_box_notify"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_centerHorizontal="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="75:11"
app:layout_constraintTop_toTopOf="parent" />
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/svga_box_notify"
<FrameLayout
android:id="@+id/fl_svga_box_notify"
android:layout_width="match_parent"
android:layout_height="0dp"
android:visibility="gone"
app:autoPlay="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="75:11"
app:layout_constraintTop_toTopOf="parent" />