diff --git a/app/src/main/java/com/yizhuan/erban/avroom/activity/AVRoomActivity.java b/app/src/main/java/com/yizhuan/erban/avroom/activity/AVRoomActivity.java index faa482efd..b02286cd3 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/activity/AVRoomActivity.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/activity/AVRoomActivity.java @@ -1,13 +1,5 @@ package com.yizhuan.erban.avroom.activity; -import static android.view.View.VISIBLE; -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT; -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT; -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT; -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY; -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_PK; -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_ROOM_PK_NOTIFY; - import android.annotation.SuppressLint; import android.app.Dialog; import android.content.Context; @@ -48,9 +40,11 @@ import com.opensource.svgaplayer.SVGAParser; import com.opensource.svgaplayer.SVGAVideoEntity; import com.orhanobut.logger.Logger; import com.tencent.bugly.crashreport.CrashReport; +import com.trello.rxlifecycle3.android.ActivityEvent; import com.yizhuan.erban.R; import com.yizhuan.erban.avroom.dialog.NewUserGiftDialog; import com.yizhuan.erban.avroom.dialog.SingleRoomTipDialog; +import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog; import com.yizhuan.erban.avroom.fragment.FakeSingleRoomBackFragment; import com.yizhuan.erban.avroom.fragment.FakeSingleRoomFragment; import com.yizhuan.erban.avroom.fragment.HomePartyFragment; @@ -121,6 +115,7 @@ import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol; import com.yizhuan.xchat_android_core.super_admin.util.SAdminOptUtil; import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil; import com.yizhuan.xchat_android_core.user.UserModel; +import com.yizhuan.xchat_android_core.user.bean.FirstChargeInfo; import com.yizhuan.xchat_android_core.user.bean.UserInfo; import com.yizhuan.xchat_android_core.utils.LogUtils; import com.yizhuan.xchat_android_core.utils.StringUtils; @@ -142,11 +137,21 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; import io.reactivex.Single; import io.reactivex.SingleObserver; +import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; +import static android.view.View.VISIBLE; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_PK; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_ROOM_PK_NOTIFY; + /** * 房间入口 @@ -477,10 +482,12 @@ public class AVRoomActivity extends BaseMvpActivity { + FirstChargeDialog.start(this); + getMvpPresenter().postFirstCharge(); + }) + .subscribe(); + } + @Subscribe(threadMode = ThreadMode.MAIN) public void onImPushMsgPmLimitTimeEvent(ImPushMsgPmLimitTimeEvent event) { //时间到限制时间段之后,后台推送im消息 diff --git a/app/src/main/java/com/yizhuan/erban/avroom/firstcharge/FirstChargeDialog.kt b/app/src/main/java/com/yizhuan/erban/avroom/firstcharge/FirstChargeDialog.kt index c6be391ff..d7156b894 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/firstcharge/FirstChargeDialog.kt +++ b/app/src/main/java/com/yizhuan/erban/avroom/firstcharge/FirstChargeDialog.kt @@ -160,15 +160,12 @@ class FirstChargeDialog : BaseViewBindingActivity(), } binding.recyclerView.adapter = mReward2Adapter - dialogManager.showProgressDialog(this) PayModel.get().firstChargeList .compose(bindToLifecycle()) .subscribe({ initData(it) - dialogManager.dismissDialog() }, { it.printStackTrace() - dialogManager.dismissDialog() SingleToastUtil.showToast(it.message) finish() }) diff --git a/app/src/main/java/com/yizhuan/erban/avroom/presenter/AvRoomPresenter.java b/app/src/main/java/com/yizhuan/erban/avroom/presenter/AvRoomPresenter.java index 2ac97b612..ebac5e142 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/presenter/AvRoomPresenter.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/presenter/AvRoomPresenter.java @@ -372,7 +372,6 @@ public class AvRoomPresenter extends BaseMvpPresenter { .subscribe(); } - /** * 获取房间内固定成员列表 */ @@ -450,6 +449,32 @@ public class AvRoomPresenter extends BaseMvpPresenter { } + /** + * 检查是否需要显示首充弹窗 + */ + @SuppressLint("CheckResult") + public void checkFirstCharge() { + if (AvRoomDataManager.get().isRoomOwner()) return; + AvRoomModel.get().getFirstCharge() + .compose(bindToLifecycle()) + .subscribe(firstChargeInfo -> { + if (getMvpView() != null && firstChargeInfo.getNeedToShow()) { + getMvpView().showFirstChargeDialog(firstChargeInfo); + } + }); + } + + /** + * 更新首充弹窗显示 + */ + @SuppressLint("CheckResult") + public void postFirstCharge() { + if (AvRoomDataManager.get().isRoomOwner()) return; + AvRoomModel.get().postFirstCharge() + .compose(bindToLifecycle()) + .subscribe(); + } + private void startGetOnlineMemberNumberJob() { Observable.interval(1, 10, TimeUnit.SECONDS, Schedulers.from(ThreadPoolManager.instance().getScheduleExecutor())) .subscribe(new Observer() { diff --git a/app/src/main/java/com/yizhuan/erban/avroom/view/IAvRoomView.java b/app/src/main/java/com/yizhuan/erban/avroom/view/IAvRoomView.java index e272bb816..aa043768e 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/view/IAvRoomView.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/view/IAvRoomView.java @@ -5,6 +5,7 @@ import com.yizhuan.xchat_android_core.channel_page.bean.HelloMessageInfo; import com.yizhuan.xchat_android_core.gift.bean.GiftInfo; import com.yizhuan.xchat_android_core.monsterhunting.bean.MonsterInfo; import com.yizhuan.xchat_android_core.room.bean.RoomInfo; +import com.yizhuan.xchat_android_core.user.bean.FirstChargeInfo; import com.yizhuan.xchat_android_library.base.IMvpBaseView; /** @@ -82,4 +83,7 @@ public interface IAvRoomView extends IMvpBaseView { void recoverRoomMinWhenPmLimit(Throwable throwable); void showNewUserDialog(GiftInfo giftInfo); + + void showFirstChargeDialog(FirstChargeInfo firstChargeInfo); + } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/model/AvRoomModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/model/AvRoomModel.java index 7e528ffff..64f6259f9 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/model/AvRoomModel.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/room/model/AvRoomModel.java @@ -53,6 +53,7 @@ import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol; import com.yizhuan.xchat_android_core.super_admin.bean.KickOutExtBean; import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil; import com.yizhuan.xchat_android_core.user.UserModel; +import com.yizhuan.xchat_android_core.user.bean.FirstChargeInfo; import com.yizhuan.xchat_android_core.user.bean.UserInfo; import com.yizhuan.xchat_android_core.utils.net.RxHelper; import com.yizhuan.xchat_android_library.net.rxnet.callback.CallBack; @@ -637,6 +638,21 @@ public class AvRoomModel extends RoomBaseModel implements IAvRoomModel { .compose(RxHelper.handleSchedulers()); } + @Override + public Single getFirstCharge() { + return mRoomService.getFirstCharge(AvRoomDataManager.get().getRoomUid()) + .compose(RxHelper.handleBeanData()) + .compose(RxHelper.handleSchedulers()); + } + + @Override + public Single postFirstCharge() { + return mRoomService.postFirstCharge(AvRoomDataManager.get().getRoomUid()) + .compose(RxHelper.handleStringData()) + .compose(RxHelper.handleSchedulers()); + } + + /** * 公屏历史消息 */ diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/model/RoomBaseModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/model/RoomBaseModel.java index 9dd8e88fb..3ca37c190 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/model/RoomBaseModel.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/room/model/RoomBaseModel.java @@ -50,6 +50,7 @@ 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.user.UserModel; import com.yizhuan.xchat_android_core.user.bean.BaseInfo; +import com.yizhuan.xchat_android_core.user.bean.FirstChargeInfo; import com.yizhuan.xchat_android_core.user.bean.UserInfo; import com.yizhuan.xchat_android_core.utils.net.RxHelper; import com.yizhuan.xchat_android_core.vip.UserVipInfo; @@ -1162,6 +1163,25 @@ public class RoomBaseModel extends BaseModel implements IRoomBaseModel { @GET("/roomFreeGift/get") Single> getFreeFlower(); + /** + * 获取首充弹窗 + * + * @param roomUid + * @return + */ + @GET("/roomFirstChargeWindow/get") + Single> getFirstCharge(@Query("roomUid") long roomUid); + + /** + * 更新首充弹窗显示 + * + * @param roomUid + * @return + */ + @FormUrlEncoded + @POST("/roomFirstChargeWindow/update") + Single> postFirstCharge(@Field("roomUid") long roomUid); + } } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/model/inteface/IAvRoomModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/model/inteface/IAvRoomModel.java index 12b52fe38..77ab9ce5f 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/model/inteface/IAvRoomModel.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/room/model/inteface/IAvRoomModel.java @@ -14,6 +14,7 @@ import com.yizhuan.xchat_android_core.room.bean.RoomResult; import com.yizhuan.xchat_android_core.room.bean.RoomWelcomeConfig; import com.yizhuan.xchat_android_core.room.bean.SearchRoomInfo; import com.yizhuan.xchat_android_core.room.bean.SimplePartyRoomInfo; +import com.yizhuan.xchat_android_core.user.bean.FirstChargeInfo; import com.yizhuan.xchat_android_library.net.rxnet.callback.CallBack; import java.util.List; @@ -185,4 +186,8 @@ public interface IAvRoomModel extends IModel { void loadMessageHistory(long startTime); + Single getFirstCharge(); + + Single postFirstCharge(); + } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/user/bean/FirstChargeInfo.kt b/core/src/main/java/com/yizhuan/xchat_android_core/user/bean/FirstChargeInfo.kt new file mode 100644 index 000000000..e28367fdd --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/user/bean/FirstChargeInfo.kt @@ -0,0 +1,10 @@ +package com.yizhuan.xchat_android_core.user.bean + +import lombok.Data + +@Data +data class FirstChargeInfo( + val needToShow: Boolean = false, + val roomUid: Long = 0, + val showAfterSecond: Long = 0 +) \ No newline at end of file