福袋和开箱横幅动画展示逻辑更改
This commit is contained in:
@@ -7,9 +7,8 @@ import android.content.res.AssetFileDescriptor;
|
||||
import android.graphics.Color;
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.text.Layout;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
@@ -17,23 +16,18 @@ import android.text.style.ForegroundColorSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewGroup;
|
||||
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;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.coorchice.library.SuperTextView;
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment;
|
||||
@@ -53,7 +47,6 @@ 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.widget.OriginalDrawStatusClickSpan;
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager;
|
||||
import com.yizhuan.erban.databinding.FragmentChatroomGameMainBinding;
|
||||
import com.yizhuan.erban.friend.view.SelectFriendActivity;
|
||||
@@ -117,7 +110,6 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import cn.sharesdk.framework.Platform;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
@@ -990,12 +982,26 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
|
||||
}
|
||||
|
||||
private void showLuckyBagNotify(ChatRoomMessage message) {
|
||||
if (animationLuckyGift == null)
|
||||
animationLuckyGift = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify);
|
||||
|
||||
if (animationLuckyGift != null) {
|
||||
final Animation tempAnimation = animationLuckyGift;
|
||||
long animationRunTime = SystemClock.uptimeMillis() - tempAnimation.getStartTime();
|
||||
if (animationRunTime < 3000) {
|
||||
gameMainBinding.flLuckyGiftNotify.postDelayed(() -> {
|
||||
tempAnimation.setAnimationListener(null);
|
||||
tempAnimation.cancel();
|
||||
if (gameMainBinding.flLuckyGiftNotify.getChildCount() > 1) {
|
||||
gameMainBinding.flLuckyGiftNotify.getChildAt(0).clearAnimation();
|
||||
gameMainBinding.flLuckyGiftNotify.removeViewAt(0);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
RoomReceivedLuckyGiftAttachment attachment = (RoomReceivedLuckyGiftAttachment) message.getAttachment();
|
||||
TextView textView = (TextView) LayoutInflater.from(mContext).inflate(R.layout.layout_room_lucky_gift_notify, null);
|
||||
LuckyBagNoticeInfo noticeInfo = attachment.getLuckyBagNoticeInfo();
|
||||
if (noticeInfo == null) return;
|
||||
|
||||
SpannableBuilder text = new SpannableBuilder()
|
||||
.append("哇偶! ", new ForegroundColorSpan(Color.WHITE))
|
||||
.append(noticeInfo.getNick() + " ", new ForegroundColorSpan(getResources().getColor(R.color.notice_nick)))
|
||||
@@ -1003,14 +1009,14 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
|
||||
.append(noticeInfo.getLuckyBagName() + " ", new ForegroundColorSpan(Color.WHITE))
|
||||
.append("开出了", new ForegroundColorSpan(Color.WHITE))
|
||||
.append(noticeInfo.getGiftName(), new ForegroundColorSpan(getResources().getColor(R.color.notice_gift)));
|
||||
|
||||
gameMainBinding.tvLuckyGiftNotify.setText(text.build());
|
||||
gameMainBinding.flLuckyGiftNotify.setVisibility(View.VISIBLE);
|
||||
gameMainBinding.flLuckyGiftNotify.startAnimation(animationLuckyGift);
|
||||
textView.setText(text.build());
|
||||
animationLuckyGift = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify);
|
||||
textView.startAnimation(animationLuckyGift);
|
||||
animationLuckyGift.setAnimationListener(new SimpleAnimationListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
gameMainBinding.flLuckyGiftNotify.setVisibility(View.GONE);
|
||||
public void onAnimationEnd(Animation a) {
|
||||
animationLuckyGift = null;
|
||||
gameMainBinding.flLuckyGiftNotify.post(() -> gameMainBinding.flLuckyGiftNotify.removeView(textView));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1025,7 +1031,7 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
|
||||
messages.add(chatRoomMessage);
|
||||
if (boxDisposable == null || messages.size() == 1) {
|
||||
isCreate = true;
|
||||
boxDisposable = Observable.interval(0, ANIM_TIME, TimeUnit.SECONDS)
|
||||
boxDisposable = Observable.interval(0, 500, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnNext(aLong -> {
|
||||
if (messages.size() > 0 && !isCreate)
|
||||
@@ -1038,23 +1044,38 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
|
||||
}
|
||||
|
||||
private void showBoxNotify(ChatRoomMessage chatRoomMessage) {
|
||||
if (animation != null) {
|
||||
final Animation tempAnimation = animation;
|
||||
long animationRunTime = SystemClock.uptimeMillis() - tempAnimation.getStartTime();
|
||||
if (animationRunTime < 3000) {
|
||||
gameMainBinding.flBoxNotify.postDelayed(() -> {
|
||||
tempAnimation.setAnimationListener(null);
|
||||
tempAnimation.cancel();
|
||||
if (gameMainBinding.flBoxNotify.getChildCount() > 1) {
|
||||
gameMainBinding.flBoxNotify.getChildAt(0).clearAnimation();
|
||||
gameMainBinding.flBoxNotify.removeViewAt(0);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
RoomBoxPrizeAttachment attachment = (RoomBoxPrizeAttachment) chatRoomMessage.getAttachment();
|
||||
// 内容
|
||||
SpannableBuilder text = new SpannableBuilder()
|
||||
TextView textView = (TextView) LayoutInflater.from(mContext).inflate(R.layout.layout_room_box_notify, null);
|
||||
SpannableBuilder text = new SpannableBuilder()
|
||||
.append("厉害了! ", new ForegroundColorSpan(Color.WHITE))
|
||||
.append(attachment.getNick() + " ", new ForegroundColorSpan(getResources().getColor(R.color.notice_nick)))
|
||||
.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));
|
||||
gameMainBinding.tvBoxNotify.setText(text.build());
|
||||
if (animation == null)
|
||||
animation = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify);
|
||||
gameMainBinding.flBoxNotify.setVisibility(View.VISIBLE);
|
||||
gameMainBinding.flBoxNotify.startAnimation(animation);
|
||||
textView.setText(text.build());
|
||||
animation = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify);
|
||||
gameMainBinding.flBoxNotify.addView(textView);
|
||||
textView.startAnimation(animation);
|
||||
animation.setAnimationListener(new SimpleAnimationListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
gameMainBinding.flBoxNotify.setVisibility(View.GONE);
|
||||
public void onAnimationEnd(Animation a) {
|
||||
animation = null;
|
||||
gameMainBinding.flBoxNotify.post(() -> gameMainBinding.flBoxNotify.removeView(textView));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -237,50 +237,18 @@
|
||||
android:id="@+id/fl_lucky_gift_notify"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:background="@drawable/bg_lucky_gift_notice"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="75:11"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_lucky_gift_notify"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxLines="2"
|
||||
android:paddingStart="60dp"
|
||||
android:paddingEnd="60dp"
|
||||
android:textSize="12sp"
|
||||
tools:text="" />
|
||||
</FrameLayout>
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fl_box_notify"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="@drawable/bg_box_notice"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="75:11"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_box_notify"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxLines="2"
|
||||
android:paddingStart="60dp"
|
||||
android:paddingEnd="60dp"
|
||||
android:textSize="12sp"
|
||||
tools:text="" />
|
||||
</FrameLayout>
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.opensource.svgaplayer.SVGAImageView
|
||||
android:id="@+id/svga_box_notify"
|
||||
|
13
app/src/main/res/layout/layout_room_box_notify.xml
Normal file
13
app/src/main/res/layout/layout_room_box_notify.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.coorchice.library.SuperTextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:background="@drawable/bg_box_notice"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:lines="2"
|
||||
android:textSize="12sp"
|
||||
tools:layout_height="wrap_content"
|
||||
tools:text="" />
|
13
app/src/main/res/layout/layout_room_lucky_gift_notify.xml
Normal file
13
app/src/main/res/layout/layout_room_lucky_gift_notify.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.coorchice.library.SuperTextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:background="@drawable/bg_lucky_gift_notice"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:lines="2"
|
||||
android:textSize="12sp"
|
||||
tools:layout_height="wrap_content"
|
||||
tools:text="" />
|
Reference in New Issue
Block a user