同步PIKO:移植超级幸运礼物

This commit is contained in:
max
2024-04-19 17:07:06 +08:00
parent 8d292ccac0
commit a8e7634920
11 changed files with 123 additions and 16 deletions

View File

@@ -9,6 +9,7 @@ import androidx.databinding.ObservableField;
import com.chwl.app.R;
import com.chwl.app.vip.util.VipHelper;
import com.chwl.core.gift.bean.GiftInfo;
import com.chwl.core.gift.bean.GiftType;
import com.chwl.core.gift.bean.SimpleVipInfo;
import com.chwl.library.bindinglist.BaseItem;
import com.chwl.library.utils.TimeUtils;
@@ -65,6 +66,11 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
*/
public boolean isFreeGift;
/**
* 是否超级幸运礼物
*/
public boolean isSuperLuckyGift;
public GiftInfoVm(Context context, GiftInfo data, boolean select, boolean isKnap) {
super(context, data);
this.isSelect.set(select);
@@ -100,6 +106,7 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
if (data.getConsumeType() == GiftInfo.CONSUME_TYPE_FREE_GIFT) {
isFreeGift = true;
}
isSuperLuckyGift = (data.getGiftType() == GiftType.GIFT_TYPE_SUPER_LUCKY);
SimpleVipInfo vipInfo = data.getGiftVipInfo();
isLocked = vipInfo != null && VipHelper.getMyVipLevel() < vipInfo.getVipLevel();
vipIcon = vipInfo == null ? "" : vipInfo.getVipIcon();

View File

@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
@@ -31,9 +32,16 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.widget.ViewPager2;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
import com.chwl.app.ui.webview.DialogWebViewActivity;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
import com.netease.nim.uikit.support.glide.GlideApp;
import com.trello.rxlifecycle3.components.support.RxAppCompatActivity;
import com.chwl.app.BR;
import com.chwl.app.R;
@@ -99,6 +107,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
@@ -175,6 +184,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
private boolean isShowDrawGiftModel;
@Nullable
private DrawGiftHelper drawGiftHelper;
private ImageView ivSuperLuckyGiftTips;
public GiftDialog(Context context, int giftId) {
this(context, 0, true, false, true, giftId);
@@ -325,13 +335,13 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
disableSlideClose();
}
private void disableSlideClose(){
private void disableSlideClose() {
BottomSheetBehavior bottomSheetBehavior = getBottomSheetBehavior();
if (bottomSheetBehavior != null) {
bottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if(newState == BottomSheetBehavior.STATE_DRAGGING){
if (newState == BottomSheetBehavior.STATE_DRAGGING) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
}
@@ -392,6 +402,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
ivDrawGiftRemoveLast = root.findViewById(R.id.iv_draw_gift_remove_last);
ivDrawGiftRemoveAll = root.findViewById(R.id.iv_draw_gift_remove_all);
ivDrawGiftClose = root.findViewById(R.id.iv_draw_gift_close);
ivSuperLuckyGiftTips = findViewById(R.id.iv_super_lucky_gift_tips);
ivDrawGiftClose.setOnClickListener(this);
ivDrawGiftRemoveLast.setOnClickListener(this);
ivDrawGiftRemoveAll.setOnClickListener(this);
@@ -572,7 +583,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
itemType = ITEM_TYPE_GOLD;
tvRecharge.setVisibility(View.VISIBLE);
tvRecharge.setText(context.getText(R .string.charge));
tvRecharge.setText(context.getText(R.string.charge));
if (goldWalletInfo == null) {
return;
}
@@ -648,6 +659,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
showEmptyView();
isShowDrawGiftModel = false;
updateDrawGift();
updateSuperLuckyGiftTips();
} else {
showLoadFailedView();
}
@@ -668,6 +680,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
}
}
isShowDrawGiftModel = false;
updateSuperLuckyGiftTips();
updateDrawGift();
giftIndicator.post(() -> {
if (position < GiftIndicator.TYPE_WEEK) {
@@ -678,6 +691,20 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
});
}
private void updateSuperLuckyGiftTips() {
if (currentGiftInfo == null || TextUtils.isEmpty(currentGiftInfo.getBannerUrl()) || currentGiftInfo.getGiftType() != GiftType.GIFT_TYPE_SUPER_LUCKY) {
ivSuperLuckyGiftTips.setVisibility(View.GONE);
} else {
ivSuperLuckyGiftTips.setVisibility(View.VISIBLE);
ImageLoadUtils.loadImage(ivSuperLuckyGiftTips.getContext(), currentGiftInfo.getBannerUrl(), ivSuperLuckyGiftTips);
ivSuperLuckyGiftTips.setOnClickListener(v -> {
if (!TextUtils.isEmpty(currentGiftInfo.getSkipUrl())) {
DialogWebViewActivity.start(context, currentGiftInfo.getSkipUrl(), true);
}
});
}
}
private void updateDrawGift() {
if (drawGiftHelper == null) {
drawGiftHelper = new DrawGiftHelper((Activity) context);
@@ -857,7 +884,8 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
recyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
recyclerView.setLayoutManager(new GridLayoutManager(context, 4));
return new RecyclerView.ViewHolder(recyclerView){};
return new RecyclerView.ViewHolder(recyclerView) {
};
}
@Override
@@ -883,6 +911,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
currentGiftInfo = item.data;
setGoldOrRadishText(lastSelectedItem);
isShowDrawGiftModel = true;
updateSuperLuckyGiftTips();
updateDrawGift();
});
}
@@ -1017,7 +1046,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
ReportManager.get().reportEvent(IReportConstants.PAYPAGE_SHOW, map);
}
// if (AppMetaDataUtil.getChannelID().equals(Constants.GOOGLE)) {
ChargeActivity.start(context);
ChargeActivity.start(context);
// } else {
// CommonWebViewActivity.start(
// context, UriProvider.getOfficialPay(

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

@@ -6,6 +6,18 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<ImageView
android:id="@+id/iv_super_lucky_gift_tips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="@id/ll_dialog_bottom_gift"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:layout_height="50dp"
tools:visibility="visible" />
<LinearLayout
android:id="@+id/ll_dialog_bottom_gift"
android:layout_width="0dp"
@@ -146,10 +158,9 @@
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_open_noble"
android:layout_width="84dp"
android:layout_height="26dp"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_gravity="center_vertical|end"
android:scaleType="fitCenter"
android:src="@drawable/ic_vip_gift_dialog"
android:visibility="gone"
tools:visibility="gone" />

View File

@@ -37,6 +37,15 @@
android:layout_marginTop="@dimen/dp_16"
android:alpha="@{item.isLocked?0.5f:1f}" />
<ImageView
android:id="@+id/iv_super_lucky_gift"
android:layout_width="@dimen/dp_46"
android:layout_height="@dimen/dp_12"
android:layout_alignBottom="@id/gift_image"
android:layout_marginStart="@dimen/dp_5"
android:src="@drawable/gift_ic_super_luck_logo"
android:visibility="@{item.isSuperLuckyGift ? View.VISIBLE : View.GONE}" />
<TextView
android:id="@+id/gift_name"
android:layout_width="wrap_content"

View File

@@ -96,6 +96,10 @@ public class GiftInfo implements Serializable {
private boolean drawGift;
private String bannerUrl;
private String skipUrl;
//免费礼物倒计时进度
private long mFreeGiftProgress = 0;

View File

@@ -41,4 +41,8 @@ public class GiftType {
public static final int GIFT_TYPE_SINGLE_ROOM = 11;
/**
* 超级幸运礼物
*/
public static final int GIFT_TYPE_SUPER_LUCKY = 16;
}

View File

@@ -2,6 +2,7 @@ package com.chwl.core.gift.toolbox;
import android.text.TextUtils;
import com.chwl.core.gift.bean.GiftType;
import com.google.gson.Gson;
import com.netease.nim.uikit.common.util.log.LogUtil;
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
@@ -206,12 +207,15 @@ public class GiftToolbox {
LogUtil.print("single send gift");
int giftType = giftInfo.getGiftType();
ImRetryManager.sendRoomGiftMsg(message)
.doOnSuccess(retryChatRoomMessage -> {
// 发送礼物成功的回调,显示动画
GiftModel.get().onSendRoomMessageSuccess(message);
// 插入到公屏上
IMNetEaseManager.get().addMessagesImmediately(message);
if (giftType != GiftType.GIFT_TYPE_SUPER_LUCKY) {
// 插入到公屏上
IMNetEaseManager.get().addMessagesImmediately(message);
}
})
.subscribe();
@@ -276,12 +280,15 @@ public class GiftToolbox {
LogUtil.print("multi send gift");
int giftType = giftInfo.getGiftType();
ImRetryManager.sendRoomGiftMsg(message)
.doOnSuccess(retryChatRoomMessage -> {
// 发送礼物成功的回调,显示动画
GiftModel.get().onSendRoomMessageSuccess(message);
// 插入到公屏上
IMNetEaseManager.get().addMessagesImmediately(message);
if (giftType != GiftType.GIFT_TYPE_SUPER_LUCKY) {
// 插入到公屏上
IMNetEaseManager.get().addMessagesImmediately(message);
}
})
.subscribe();
@@ -313,12 +320,15 @@ public class GiftToolbox {
LogUtil.print("all mic send gift");
int giftType = giftInfo.getGiftType();
ImRetryManager.sendRoomGiftMsg(message)
.doOnSuccess(retryChatRoomMessage -> {
// 发送礼物成功的回调,显示动画
GiftModel.get().onSendRoomMessageSuccess(message);
// 插入到公屏上
IMNetEaseManager.get().addMessagesImmediately(message);
if (giftType != GiftType.GIFT_TYPE_SUPER_LUCKY) {
// 插入到公屏上
IMNetEaseManager.get().addMessagesImmediately(message);
}
})
.subscribe();
}

View File

@@ -18,6 +18,7 @@ import androidx.annotation.Nullable;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chwl.core.gift.bean.GiftType;
import com.chwl.core.monsterhunting.bean.MonsterDataBean;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
@@ -721,7 +722,9 @@ public final class IMNetEaseManager {
|| customAttachment.getFirst() == CustomAttachment.CUSTOM_MESS_TAROT
|| customAttachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_MONSTER_HUNTING
|| customAttachment.getFirst() == CustomAttachment.CUSTOM_MSG_MINI_WORLD) {
addMessages(msg);
if (!isIgnoreMessageOfSuperLuckGift(customAttachment)) {
addMessages(msg);
}
}
Logger.i(ResUtil.getString(R.string.xchat_android_core_manager_imneteasemanager_015) + customAttachment);
int second = customAttachment.getSecond();
@@ -820,7 +823,7 @@ public final class IMNetEaseManager {
GiftModel.get().addNewGift(giftInfo);
messages.add(msg);
gift = true;
if (!giftReceiveInfo.isRoomAlbum()) {
if (!giftReceiveInfo.isRoomAlbum() && giftInfo.getGiftType() != GiftType.GIFT_TYPE_SUPER_LUCKY) {
addMessages(msg);
}
} else if (customAttachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_LUCKY_GIFT) {
@@ -1478,6 +1481,36 @@ public final class IMNetEaseManager {
}
}
/**
* 是否不需要添加到公屏(超级幸运礼物特殊,会单独添加到公屏)
*/
private boolean isIgnoreMessageOfSuperLuckGift(CustomAttachment attachment) {
if (attachment.getFirst() == CUSTOM_MSG_HEADER_TYPE_MULTI_GIFT) {
if (attachment.getSecond() == CUSTOM_MSG_SUB_TYPE_SEND_MULTI_GIFT || attachment.getSecond() == CUSTOM_MSG_SUB_TYPE_BATCH_SEND_GIFT) {
if (attachment instanceof MultiGiftAttachment) {
MultiGiftAttachment multiGiftAttachment = (MultiGiftAttachment) attachment;
GiftInfo giftInfo = multiGiftAttachment.getMultiGiftReceiveInfo().getGift();
if (giftInfo != null && giftInfo.getGiftType() == GiftType.GIFT_TYPE_SUPER_LUCKY) {
return true;
}
}
}
}
if (attachment.getFirst() == CUSTOM_MSG_HEADER_TYPE_GIFT) {
if (attachment.getSecond() == CUSTOM_MSG_SUB_TYPE_SEND_GIFT) {
if (attachment instanceof GiftAttachment) {
GiftAttachment giftAttachment = (GiftAttachment) attachment;
GiftReceiveInfo giftReceiveInfo = giftAttachment.getGiftReceiveInfo();
GiftInfo giftInfo = giftReceiveInfo.getGift();
if (giftInfo != null && giftInfo.getGiftType() == GiftType.GIFT_TYPE_SUPER_LUCKY) {
return true;
}
}
}
}
return false;
}
private void pkCloseUpdateSelfMicInfo() {
if (AvRoomDataManager.get().isOnMic(AuthModel.get().getCurrentUid())) {
UserModel.get().getCacheLoginUserInfo().setGroupType(PKTeamInfo.TEAM_NONE);