[Modify]免费礼物功能开发
This commit is contained in:
@@ -83,6 +83,7 @@ import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.auth.event.LogoutEvent;
|
||||
import com.yizhuan.xchat_android_core.bean.BaseProtocol;
|
||||
import com.yizhuan.xchat_android_core.channel_page.bean.HelloMessageInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.GiftModel;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPKAttachment;
|
||||
@@ -895,6 +896,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
} catch (Exception e) {
|
||||
CrashReport.postCatchedException(e);
|
||||
}
|
||||
GiftModel.get().cancelCountDownTimer();
|
||||
EventBus.getDefault().unregister(this);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
@@ -0,0 +1,67 @@
|
||||
package com.yizhuan.erban.avroom.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.databinding.DialogRoomFreeGiftBinding;
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftFreeInfo;
|
||||
|
||||
/**
|
||||
* 房间免费礼物弹窗
|
||||
* Created by wushaocheng on 2022/12/14.
|
||||
*/
|
||||
public class RoomFreeGiftDialog extends BottomSheetDialog implements View.OnClickListener {
|
||||
private Context context;
|
||||
private GiftFreeInfo giftFreeInfo;
|
||||
private DialogRoomFreeGiftBinding binding;
|
||||
|
||||
public RoomFreeGiftDialog(Context context, GiftFreeInfo giftFreeInfo) {
|
||||
super(context, R.style.ErbanBottomSheetDialog);
|
||||
this.context = context;
|
||||
this.giftFreeInfo = giftFreeInfo;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setCanceledOnTouchOutside(true);
|
||||
setContentView(R.layout.dialog_room_free_gift);
|
||||
binding = DataBindingUtil.bind(findViewById(R.id.dialog_container));
|
||||
binding.setClick(this);
|
||||
|
||||
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display d = windowManager.getDefaultDisplay();
|
||||
DisplayMetrics realDisplayMetrics = new DisplayMetrics();
|
||||
d.getRealMetrics(realDisplayMetrics);
|
||||
WindowManager.LayoutParams params = getWindow().getAttributes();
|
||||
params.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
params.height = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
params.dimAmount = 0f;
|
||||
getWindow().setAttributes(params);
|
||||
|
||||
binding.tvTop.setText(context.getString(R.string.dialog_free_gift_top, (int) giftFreeInfo.getFirstSecond()));
|
||||
binding.tvBottom.setText(String.format(context.getString(R.string.dialog_free_gift_bottom_text), giftFreeInfo.getGiftName(), giftFreeInfo.getMaxStage()));
|
||||
ImageLoadUtilsV2.loadImage(binding.ivGiftIcon, giftFreeInfo.getGiftUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.iv_delete:
|
||||
case R.id.tv_know:
|
||||
dismiss();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -41,6 +41,7 @@ import com.yizhuan.erban.avroom.activity.RoomTitleEditActivity
|
||||
import com.yizhuan.erban.avroom.adapter.OnMicroItemClickListener
|
||||
import com.yizhuan.erban.avroom.dialog.AttentionHintDialog
|
||||
import com.yizhuan.erban.avroom.dialog.DatingVipRuleDialog
|
||||
import com.yizhuan.erban.avroom.dialog.RoomFreeGiftDialog
|
||||
import com.yizhuan.erban.avroom.dialog.RoomOperationDialog
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog
|
||||
import com.yizhuan.erban.avroom.presenter.BaseRoomPresenter
|
||||
@@ -79,6 +80,7 @@ import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.bean.RoomMicInfo
|
||||
import com.yizhuan.xchat_android_core.gift.GiftModel
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo
|
||||
import com.yizhuan.xchat_android_core.gift.event.RoomFreeGiftEvent
|
||||
import com.yizhuan.xchat_android_core.helper.AtProxy
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment
|
||||
@@ -269,6 +271,9 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
// ivRadishEntrance?.isVisible =
|
||||
// !GoldBoxHelper.needIntegrateBoxEntrance() && GoldBoxHelper.isShowRadish()
|
||||
|
||||
//获取免费礼物详情
|
||||
mvpPresenter?.queryFreeFlower()
|
||||
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@@ -1193,6 +1198,13 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
}, 200)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRoomFreeGiftEvent(event: RoomFreeGiftEvent) {
|
||||
event.giftFreeInfo?.let {
|
||||
RoomFreeGiftDialog(context, it).show()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 底部按鈕點擊處理
|
||||
*/
|
||||
|
@@ -18,6 +18,7 @@ import com.yizhuan.erban.avroom.view.IBaseRoomView;
|
||||
import com.yizhuan.erban.base.BaseMvpPresenter;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.bean.RoomQueueInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.GiftModel;
|
||||
import com.yizhuan.xchat_android_core.helper.AtProxy;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RequestUpmicAttachment;
|
||||
@@ -565,4 +566,14 @@ public class BaseRoomPresenter<V extends IBaseRoomView> extends BaseMvpPresenter
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求免费礼物
|
||||
*/
|
||||
public void queryFreeFlower() {
|
||||
GiftModel.get().getFreeGift()
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -72,4 +72,5 @@ interface IBaseRoomView : IMvpBaseView {
|
||||
fun updateMicView()
|
||||
|
||||
fun updateRoomRanks(data: List<RoomContributeUserInfo>)
|
||||
|
||||
}
|
@@ -11,6 +11,7 @@ import com.yizhuan.erban.vip.VipHelper;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.SimpleVipInfo;
|
||||
import com.yizhuan.xchat_android_library.bindinglist.BaseItem;
|
||||
import com.yizhuan.xchat_android_library.utils.TimeUtils;
|
||||
|
||||
/**
|
||||
* 礼物item
|
||||
@@ -27,6 +28,8 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
|
||||
|
||||
public final ObservableField<String> countText = new ObservableField<>();
|
||||
|
||||
public final ObservableField<String> countDownText = new ObservableField<>();
|
||||
|
||||
public Drawable nobleDrawable = null;
|
||||
|
||||
public Drawable radishDrawable = null;
|
||||
@@ -57,6 +60,11 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
|
||||
|
||||
public String vipIcon;
|
||||
|
||||
/**
|
||||
* 是否显示免费礼物
|
||||
*/
|
||||
public boolean isFreeGift;
|
||||
|
||||
public GiftInfoVm(Context context, GiftInfo data, boolean select, boolean isKnap) {
|
||||
super(context, data);
|
||||
this.isSelect.set(select);
|
||||
@@ -64,6 +72,10 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
|
||||
radishDrawable = null;
|
||||
radishDrawableSelected = null;
|
||||
goldText.set(context.getResources().getString(R.string.how_much_gold, data.getGoldPrice()));
|
||||
} else if (data.getConsumeType() == GiftInfo.CONSUME_TYPE_FREE_GIFT) {
|
||||
radishDrawable = null;
|
||||
radishDrawableSelected = null;
|
||||
goldText.set(context.getResources().getString(R.string.free_gift));
|
||||
} else {
|
||||
radishDrawable = context.getResources().getDrawable(R.drawable.icon_radish_transparent);
|
||||
radishDrawableSelected = context.getResources().getDrawable(R.drawable.icon_radish_transparent_selected);
|
||||
@@ -85,6 +97,9 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
|
||||
isShowLimit = data.isHasTimeLimit();
|
||||
isShowEffect = data.isHasEffect();
|
||||
isExclusive = data.isRoomExclude();
|
||||
if (data.getConsumeType() == GiftInfo.CONSUME_TYPE_FREE_GIFT) {
|
||||
isFreeGift = true;
|
||||
}
|
||||
SimpleVipInfo vipInfo = data.getGiftVipInfo();
|
||||
isLocked = vipInfo != null && VipHelper.getMyVipLevel() < vipInfo.getVipLevel();
|
||||
vipIcon = vipInfo == null ? "" : vipInfo.getVipIcon();
|
||||
@@ -104,4 +119,14 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
|
||||
this.countText.set("x" + data.getCount());
|
||||
}
|
||||
|
||||
public void updateFreeGiftCount() {
|
||||
int progress = data.getFreeGiftProgress();
|
||||
String countDown = TimeUtils.timeConversion(progress);
|
||||
if (progress == 0) {
|
||||
this.countDownText.set("");
|
||||
} else {
|
||||
this.countDownText.set(countDown);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -69,6 +69,7 @@ import com.yizhuan.xchat_android_core.gift.bean.GiftTab;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftType;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.SimpleUserInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.event.UpdateKnapEvent;
|
||||
import com.yizhuan.xchat_android_core.gift.event.UpdateKnapFreeGiftEvent;
|
||||
import com.yizhuan.xchat_android_core.initial.InitialModel;
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
||||
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
|
||||
@@ -80,8 +81,6 @@ import com.yizhuan.xchat_android_core.pay.event.UpdateWalletInfoEvent;
|
||||
import com.yizhuan.xchat_android_core.room.anotherroompk.ShowUserInfoDialogEvent;
|
||||
import com.yizhuan.xchat_android_core.room.pk.model.PkModel;
|
||||
import com.yizhuan.xchat_android_core.room.queue.bean.MicMemberInfo;
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager;
|
||||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol;
|
||||
import com.yizhuan.xchat_android_core.user.UserModel;
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
|
||||
import com.yizhuan.xchat_android_core.utils.StringExtensionKt;
|
||||
@@ -1470,6 +1469,26 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
updateTotalPrice();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onReceiveFreeGift(UpdateKnapFreeGiftEvent event){
|
||||
if (giftIndicator.getCurrrentType() == GiftIndicator.TYPE_KNAP) {
|
||||
int giftId = event.getGiftId();
|
||||
int progress = event.getProgress();
|
||||
if (ListUtils.isListEmpty(pagerList)) {
|
||||
return;
|
||||
}
|
||||
for (List<GiftInfoVm> page : pagerList) {
|
||||
for (GiftInfoVm item : page) {
|
||||
if (item.data.getGiftId() == giftId) {
|
||||
item.data.setFreeGiftProgress(progress);
|
||||
item.updateFreeGiftCount();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onGiftOutOfDate(String message) {
|
||||
((BaseActivity) getContext()).toast(message);
|
||||
}
|
||||
|
BIN
app/src/main/res/drawable-xhdpi/dialog_free_gift_delete.webp
Normal file
BIN
app/src/main/res/drawable-xhdpi/dialog_free_gift_delete.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 990 B |
13
app/src/main/res/drawable/bg_common_top_25_black.xml
Normal file
13
app/src/main/res/drawable/bg_common_top_25_black.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="#e5000000" />
|
||||
|
||||
<corners
|
||||
android:bottomLeftRadius="0dp"
|
||||
android:bottomRightRadius="0dp"
|
||||
android:topLeftRadius="@dimen/dp_25"
|
||||
android:topRightRadius="@dimen/dp_25" />
|
||||
|
||||
</shape>
|
81
app/src/main/res/layout/dialog_room_free_gift.xml
Normal file
81
app/src/main/res/layout/dialog_room_free_gift.xml
Normal file
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="click"
|
||||
type="android.view.View.OnClickListener" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dialog_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="349dp"
|
||||
android:background="@drawable/bg_common_top_25_black"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_delete"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
android:onClick="@{click}"
|
||||
android:src="@drawable/dialog_free_gift_delete" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_top"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginStart="55dp"
|
||||
android:layout_marginTop="@dimen/dp_5"
|
||||
android:layout_marginEnd="55dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/dialog_free_gift_top"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/sp_15" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_gift_icon"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="106dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="@dimen/dp_16" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_bottom"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_24"
|
||||
android:layout_marginTop="@dimen/dp_22"
|
||||
android:layout_marginEnd="@dimen/dp_24"
|
||||
android:gravity="center"
|
||||
android:text="@string/dialog_free_gift_bottom_text"
|
||||
android:textColor="@color/color_B3B3C3"
|
||||
android:textSize="@dimen/sp_12" />
|
||||
|
||||
<View
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_know"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="46dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginStart="88dp"
|
||||
android:layout_marginEnd="88dp"
|
||||
android:layout_marginBottom="@dimen/dp_20"
|
||||
android:background="@drawable/bg_common_confirm_normal"
|
||||
android:gravity="center"
|
||||
android:onClick="@{click}"
|
||||
android:text="@string/dialog_free_gift_know"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/sp_16" />
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
@@ -63,6 +63,18 @@
|
||||
tools:ignore="SpUsage"
|
||||
tools:text="123" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_free_count_down"
|
||||
android:text="@{item.countDownText}"
|
||||
android:textSize="8sp"
|
||||
android:textColor="@color/color_white"
|
||||
android:layout_marginEnd="@dimen/dp_6"
|
||||
android:layout_marginTop="@dimen/dp_4"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:visibility="@{item.isFreeGift ? View.VISIBLE : View.GONE}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="00:00:00"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@@ -5010,5 +5010,9 @@
|
||||
<string name="in_the_star_kitchen_draw">在星級厨房抽中</string>
|
||||
<string name="times_reward_get">倍獎勵,獲得</string>
|
||||
<string name="diamond_point">鉆石!</string>
|
||||
<string name="free_gift">免費禮物</string>
|
||||
<string name="dialog_free_gift_top">今天觀看直播滿%d分鐘啦,送你一個禮物</string>
|
||||
<string name="dialog_free_gift_bottom_text">每天觀看直播達到特別時長,即可獲得一個%s,每日上限%d個,禮物當日生效</string>
|
||||
<string name="dialog_free_gift_know">我知道啦</string>
|
||||
|
||||
</resources>
|
@@ -4,6 +4,7 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_LUCKY_GIFT;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_MULTI_LUCK_GIFT;
|
||||
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
@@ -16,6 +17,7 @@ import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.base.BaseModel;
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftFreeInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftListInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftMultiReceiverInfo;
|
||||
@@ -25,7 +27,9 @@ import com.yizhuan.xchat_android_core.gift.bean.GiftType;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagGifts;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.MultiGiftReceiveInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.SimpleVipInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.event.RoomFreeGiftEvent;
|
||||
import com.yizhuan.xchat_android_core.gift.event.UpdateKnapEvent;
|
||||
import com.yizhuan.xchat_android_core.gift.event.UpdateKnapFreeGiftEvent;
|
||||
import com.yizhuan.xchat_android_core.gift.exception.GiftOutOfDateException;
|
||||
import com.yizhuan.xchat_android_core.gift.toolbox.GiftToolbox;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment;
|
||||
@@ -43,6 +47,7 @@ import com.yizhuan.xchat_android_core.room.giftvalue.bean.GiftValueCommonUpdate;
|
||||
import com.yizhuan.xchat_android_core.room.giftvalue.helper.GiftValueMrg;
|
||||
import com.yizhuan.xchat_android_core.user.UserModel;
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
|
||||
import com.yizhuan.xchat_android_core.utils.Logger;
|
||||
import com.yizhuan.xchat_android_core.utils.net.BalanceNotEnoughExeption;
|
||||
import com.yizhuan.xchat_android_core.utils.net.RadishNotEnoughException;
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper;
|
||||
@@ -74,12 +79,14 @@ import retrofit2.http.Query;
|
||||
*/
|
||||
|
||||
public class GiftModel extends BaseModel implements IGiftModel {
|
||||
public static final String TAG = "GiftModel";
|
||||
private volatile static IGiftModel model;
|
||||
private Api api;
|
||||
private UiHandler handler;
|
||||
private GiftListInfo allGiftListInfo;
|
||||
private List<GiftInfo> knapList;
|
||||
private List<CustomAttachment> giftQueue;
|
||||
private GiftFreeInfo giftFreeInfo;
|
||||
|
||||
private GiftModel() {
|
||||
api = RxNet.create(Api.class);
|
||||
@@ -619,6 +626,70 @@ public class GiftModel extends BaseModel implements IGiftModel {
|
||||
.compose(RxHelper.handleSchAndExce());
|
||||
}
|
||||
|
||||
/**
|
||||
* 免费礼物接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Single<ServiceResult<GiftFreeInfo>> getFreeGift() {
|
||||
return api.getFreeGift().compose(new Transformer<>()).doOnSuccess(response -> {
|
||||
if (response.isSuccess()) {
|
||||
giftFreeInfo = response.getData();
|
||||
startFreeGiftCountDown(giftFreeInfo.getGiftId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private CountDownTimer countDownTimer;
|
||||
|
||||
private void startFreeGiftCountDown(int giftId) {
|
||||
cancelCountDownTimer();
|
||||
if (giftFreeInfo.getCurStage() < giftFreeInfo.getMaxStage()) {
|
||||
if (giftFreeInfo.getCurStageSecond() > 0) {
|
||||
countDownTimer = new CountDownTimer(giftFreeInfo.getCurStageSecond() * 1000, 1000) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
Logger.info(TAG, String.valueOf(millisUntilFinished / 1000));
|
||||
EventBus.getDefault().post(new UpdateKnapFreeGiftEvent(giftId, (int) (millisUntilFinished / 1000)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
if(giftFreeInfo.getCurStage() == 0){
|
||||
EventBus.getDefault().post(new RoomFreeGiftEvent(giftFreeInfo));
|
||||
}
|
||||
Logger.info(TAG, "FREE_GIFT onTimerFinish");
|
||||
// 鲜花倒计时结束,去请求
|
||||
getFreeGift().subscribe();
|
||||
}
|
||||
};
|
||||
countDownTimer.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelCountDownTimer() {
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取免费礼物数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public GiftFreeInfo getFreeGiftInfo() {
|
||||
if (giftFreeInfo != null) {
|
||||
return giftFreeInfo;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private interface Api {
|
||||
|
||||
/**
|
||||
@@ -635,7 +706,7 @@ public class GiftModel extends BaseModel implements IGiftModel {
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
@GET("backpack/listUserBackpackV2")
|
||||
@GET("backpack/listUserBackpackV3")
|
||||
Single<ServiceResult<List<GiftInfo>>> getGiftKnapList(@Query("uid") String uid);
|
||||
|
||||
/**
|
||||
@@ -678,6 +749,14 @@ public class GiftModel extends BaseModel implements IGiftModel {
|
||||
@Field("giftSource") int giftSource,
|
||||
@Field("chatSessionId") String chatSessionId);
|
||||
|
||||
/**
|
||||
* 获取新用户进房礼物
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GET("/roomFreeGift/get")
|
||||
Single<ServiceResult<GiftFreeInfo>> getFreeGift();
|
||||
|
||||
}
|
||||
|
||||
private static class UiHandler extends Handler {
|
||||
|
@@ -4,6 +4,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftFreeInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftListInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftMultiReceiverInfo;
|
||||
@@ -198,4 +199,22 @@ public interface IGiftModel {
|
||||
*/
|
||||
Single<ServiceResult<GiftMultiReceiverInfo>> sendFansTeamGift(int giftId,
|
||||
String targetUid);
|
||||
|
||||
/**
|
||||
* 获取免费礼物
|
||||
*/
|
||||
Single<ServiceResult<GiftFreeInfo>> getFreeGift();
|
||||
|
||||
/**
|
||||
* 取消倒计时
|
||||
*/
|
||||
public void cancelCountDownTimer();
|
||||
|
||||
/**
|
||||
* 从内存里取出免费礼物
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
GiftFreeInfo getFreeGiftInfo();
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,23 @@
|
||||
package com.yizhuan.xchat_android_core.gift.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Created by wushaocheng
|
||||
* on 2022/12/13.
|
||||
*/
|
||||
@Data
|
||||
public class GiftFreeInfo {
|
||||
|
||||
private long uid;//用户id
|
||||
private int giftId;//礼物id
|
||||
private String giftName;//礼物名称
|
||||
private long goldPrice;//礼物价格
|
||||
private String giftUrl;//礼物icon
|
||||
private long firstSecond;//首次时长
|
||||
private long curStage;//当前阶段
|
||||
private long curStageSecond;//当前阶段剩余多少秒去倒计时
|
||||
private long maxStage;//最大阶段
|
||||
private long restTime;//重置时间
|
||||
|
||||
}
|
@@ -17,6 +17,10 @@ public class GiftInfo implements Serializable {
|
||||
* 钻石礼物
|
||||
*/
|
||||
public final static int CONSUME_TYPE_GOLD = 1;
|
||||
/**
|
||||
* 免费礼物
|
||||
*/
|
||||
public final static int CONSUME_TYPE_FREE_GIFT = 3;
|
||||
|
||||
private int count;
|
||||
private int giftId;
|
||||
@@ -92,4 +96,15 @@ public class GiftInfo implements Serializable {
|
||||
|
||||
private boolean drawGift;
|
||||
|
||||
//免费礼物倒计时进度
|
||||
private int mFreeGiftProgress = 0;
|
||||
|
||||
public int getFreeGiftProgress() {
|
||||
return mFreeGiftProgress;
|
||||
}
|
||||
|
||||
public void setFreeGiftProgress(int freeGiftProgress) {
|
||||
mFreeGiftProgress = freeGiftProgress;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.yizhuan.xchat_android_core.gift.event;
|
||||
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftFreeInfo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 免費禮物彈窗事件
|
||||
* Created by wushaocheng on 2022/12/14.
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class RoomFreeGiftEvent {
|
||||
|
||||
private GiftFreeInfo giftFreeInfo;
|
||||
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.yizhuan.xchat_android_core.gift.event;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 更新背包免费礼物事件
|
||||
* Created by wushaocheng on 2022/12/14.
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class UpdateKnapFreeGiftEvent {
|
||||
|
||||
private int giftId;
|
||||
|
||||
private int progress;
|
||||
|
||||
}
|
@@ -102,7 +102,6 @@ public class AvRoomModel extends RoomBaseModel implements IAvRoomModel {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
private Map<String, Object> toMap(Map<String, Object> map, String namePlateWord, String namePlatePic) {
|
||||
if (map == null) {
|
||||
map = new HashMap<>();
|
||||
|
@@ -29,6 +29,7 @@ import com.yizhuan.xchat_android_core.bean.RoomQueueInfo;
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
import com.yizhuan.xchat_android_core.decoration.headwear.bean.HeadWearInfo;
|
||||
import com.yizhuan.xchat_android_core.exception.ErrorThrowable;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftFreeInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo;
|
||||
@@ -1154,6 +1155,13 @@ public class RoomBaseModel extends BaseModel implements IRoomBaseModel {
|
||||
@GET("/gift/newUser/inRoom")
|
||||
Single<ServiceResult<GiftInfo>> getNewUserGift(@Query("roomUid") long roomUid);
|
||||
|
||||
/**
|
||||
* 获取新用户进房礼物
|
||||
* @return
|
||||
*/
|
||||
@GET("/roomFreeGift/get")
|
||||
Single<ServiceResult<GiftFreeInfo>> getFreeFlower();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import com.google.gson.JsonElement;
|
||||
import com.netease.nimlib.sdk.chatroom.model.EnterChatRoomResultData;
|
||||
import com.yizhuan.xchat_android_core.base.IModel;
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftFreeInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo;
|
||||
import com.yizhuan.xchat_android_core.room.activitytimer.TimerBean;
|
||||
@@ -183,4 +184,5 @@ public interface IAvRoomModel extends IModel {
|
||||
Single<GiftInfo> getNewUserGift();
|
||||
|
||||
void loadMessageHistory(long startTime);
|
||||
|
||||
}
|
||||
|
@@ -380,11 +380,30 @@ public class TimeUtils {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static String getProgresstime(long progress) {
|
||||
if (progress < 0) progress = 0;
|
||||
Date date = new Date(progress);
|
||||
SimpleDateFormat format = new SimpleDateFormat("mm:ss");
|
||||
return format.format(date);
|
||||
public static String timeConversion(int time) {
|
||||
int hour = 0;
|
||||
int minutes = 0;
|
||||
int sencond = 0;
|
||||
int temp = time % 3600;
|
||||
if (time > 3600) {
|
||||
hour = time / 3600;
|
||||
if (temp != 0) {
|
||||
if (temp > 60) {
|
||||
minutes = temp / 60;
|
||||
if (temp % 60 != 0) {
|
||||
sencond = temp % 60;
|
||||
}
|
||||
} else {
|
||||
sencond = temp;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
minutes = time / 60;
|
||||
if (time % 60 != 0) {
|
||||
sencond = time % 60;
|
||||
}
|
||||
}
|
||||
return (hour<10?("0"+hour):hour) + ":" + (minutes<10?("0"+minutes):minutes) + ":" + (sencond<10?("0"+sencond):sencond);
|
||||
}
|
||||
|
||||
public static String getChineseMonth(Context context, long millis) {
|
||||
|
Reference in New Issue
Block a user