From 96e7b5844602966c2e893a8b6d37c72c679d7af3 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 26 Feb 2024 18:22:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=BA=A2=E5=8C=85=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/avroom/activity/AVRoomActivity.java | 23 - .../chwl/app/avroom/core/AudioRoomContext.kt | 3 - .../app/avroom/fragment/BaseRoomFragment.kt | 34 -- .../fragment/HomePartyRoomFragment.java | 2 - .../app/avroom/fragment/SingleRoomFragment.kt | 2 - .../avroom/redpackage/RedPackageEvent.java | 4 - .../redpackage/RedPackageGoRoomDialog.kt | 84 --- .../avroom/redpackage/RedPackageHandler.kt | 169 ------ .../app/avroom/redpackage/RedPackageWidget.kt | 239 -------- .../redpackage/open/RedPackageOpenDialog.kt | 561 ------------------ .../open/RedPackageResultAdapter.kt | 45 -- .../send/PrivateRedPackageEditorFragment.kt | 284 --------- .../send/PublicRedPackageEditorFragment.kt | 157 ----- .../redpackage/send/RedPackageSendDialog.kt | 172 ------ .../send/RedPackageTypeItemAdapter.kt | 76 --- .../redpackage/send/TabIndicatorAdapter.java | 115 ---- .../java/com/chwl/app/base/BaseActivity.java | 26 - .../main/res/layout/fragment_av_room_game.xml | 28 +- .../main/res/layout/fragment_single_room.xml | 27 +- .../res/layout/red_package_open_dialog.xml | 343 ----------- .../layout/red_package_open_item_result.xml | 91 --- .../layout/red_package_private_fragment.xml | 227 ------- .../layout/red_package_private_item_type.xml | 36 -- .../layout/red_package_public_fragment.xml | 177 ------ .../res/layout/red_package_send_dialog.xml | 96 --- .../main/res/layout/red_package_widget.xml | 46 -- app/src/main/res/layout/red_packet_dialog.xml | 211 ------- 27 files changed, 2 insertions(+), 3276 deletions(-) delete mode 100644 app/src/main/java/com/chwl/app/avroom/redpackage/RedPackageEvent.java delete mode 100644 app/src/main/java/com/chwl/app/avroom/redpackage/RedPackageGoRoomDialog.kt delete mode 100644 app/src/main/java/com/chwl/app/avroom/redpackage/RedPackageHandler.kt delete mode 100644 app/src/main/java/com/chwl/app/avroom/redpackage/RedPackageWidget.kt delete mode 100644 app/src/main/java/com/chwl/app/avroom/redpackage/open/RedPackageOpenDialog.kt delete mode 100644 app/src/main/java/com/chwl/app/avroom/redpackage/open/RedPackageResultAdapter.kt delete mode 100644 app/src/main/java/com/chwl/app/avroom/redpackage/send/PrivateRedPackageEditorFragment.kt delete mode 100644 app/src/main/java/com/chwl/app/avroom/redpackage/send/PublicRedPackageEditorFragment.kt delete mode 100644 app/src/main/java/com/chwl/app/avroom/redpackage/send/RedPackageSendDialog.kt delete mode 100644 app/src/main/java/com/chwl/app/avroom/redpackage/send/RedPackageTypeItemAdapter.kt delete mode 100644 app/src/main/java/com/chwl/app/avroom/redpackage/send/TabIndicatorAdapter.java delete mode 100644 app/src/main/res/layout/red_package_open_dialog.xml delete mode 100644 app/src/main/res/layout/red_package_open_item_result.xml delete mode 100644 app/src/main/res/layout/red_package_private_fragment.xml delete mode 100644 app/src/main/res/layout/red_package_private_item_type.xml delete mode 100644 app/src/main/res/layout/red_package_public_fragment.xml delete mode 100644 app/src/main/res/layout/red_package_send_dialog.xml delete mode 100644 app/src/main/res/layout/red_package_widget.xml delete mode 100644 app/src/main/res/layout/red_packet_dialog.xml diff --git a/app/src/main/java/com/chwl/app/avroom/activity/AVRoomActivity.java b/app/src/main/java/com/chwl/app/avroom/activity/AVRoomActivity.java index 052116252..d759e970b 100644 --- a/app/src/main/java/com/chwl/app/avroom/activity/AVRoomActivity.java +++ b/app/src/main/java/com/chwl/app/avroom/activity/AVRoomActivity.java @@ -68,7 +68,6 @@ import com.chwl.app.avroom.fragment.HomePartyFragment; import com.chwl.app.avroom.fragment.InputPwdDialogFragment; import com.chwl.app.avroom.presenter.AvRoomPresenter; import com.chwl.app.avroom.presenter.HomePartyPresenter; -import com.chwl.app.avroom.redpackage.RedPackageHandler; import com.chwl.app.avroom.view.IAvRoomView; import com.chwl.app.avroom.widget.VerticalViewPagerAdapter; import com.chwl.app.base.BaseMvpActivity; @@ -690,11 +689,6 @@ public class AVRoomActivity extends BaseMvpActivity) { super.loadAbility(list) - // 红包处理器 - list[RedPackageHandler::class.java.simpleName] = RedPackageHandler() } } \ No newline at end of file diff --git a/app/src/main/java/com/chwl/app/avroom/fragment/BaseRoomFragment.kt b/app/src/main/java/com/chwl/app/avroom/fragment/BaseRoomFragment.kt index 4e4edb8fe..162f5f191 100644 --- a/app/src/main/java/com/chwl/app/avroom/fragment/BaseRoomFragment.kt +++ b/app/src/main/java/com/chwl/app/avroom/fragment/BaseRoomFragment.kt @@ -18,16 +18,11 @@ import android.view.ViewStub import android.widget.EditText import android.widget.ImageView import android.widget.RelativeLayout -import android.widget.TextView import androidx.annotation.CallSuper import androidx.core.content.ContextCompat import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.lifecycleScope import androidx.lifecycle.withResumed -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView -import com.chad.library.adapter.base.BaseQuickAdapter -import com.chad.library.adapter.base.BaseViewHolder import com.netease.nim.uikit.common.antispam.AntiSpamEvent import com.netease.nimlib.sdk.StatusCode import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder @@ -46,10 +41,8 @@ import com.chwl.app.avroom.adapter.OnMicroItemClickListener import com.chwl.app.avroom.dialog.AttentionHintDialog import com.chwl.app.avroom.dialog.DatingVipRuleDialog import com.chwl.app.avroom.dialog.RoomFreeGiftDialog -import com.chwl.app.avroom.dialog.RoomOperationDialog import com.chwl.app.avroom.firstcharge.FirstChargeDialog import com.chwl.app.avroom.presenter.BaseRoomPresenter -import com.chwl.app.avroom.redpackage.send.RedPackageSendDialog import com.chwl.app.avroom.room_album.RoomAlbumModel import com.chwl.app.avroom.view.IBaseRoomView import com.chwl.app.avroom.widget.BottomView @@ -61,8 +54,6 @@ import com.chwl.app.event.OpenRoomIntroEvent import com.chwl.app.friend.view.SelectFriendActivity import com.chwl.app.home.adapter.RoomActAdapter import com.chwl.app.shipantics.PullRadishActivity -import com.chwl.app.treasure_box.widget.GoldBoxHelper -import com.chwl.app.ui.webview.DialogWebViewActivity import com.chwl.app.ui.widget.ButtonItem import com.chwl.app.ui.widget.GiftDialog import com.chwl.app.ui.widget.GiftDialog.OnGiftDialogBtnClickListener @@ -78,8 +69,6 @@ import com.chwl.app.music.widget.MusicPlayerView import com.chwl.app.room_chat.activity.RoomMsgActivity import com.chwl.core.XConstants import com.chwl.core.Constants -import com.chwl.core.DemoCache -import com.chwl.core.UriProvider import com.chwl.core.auth.AuthModel import com.chwl.core.bean.RoomMicInfo import com.chwl.core.gift.GiftModel @@ -97,7 +86,6 @@ import com.chwl.core.manager.RoomEvent import com.chwl.core.mentoring_relationship.event.MentoringStopCountingEvent import com.chwl.core.room.anotherroompk.ShowGiftDialogEvent import com.chwl.core.room.anotherroompk.ShowUserInfoDialogEvent -import com.chwl.core.room.bean.RoomContributeUserInfo import com.chwl.core.room.bean.RoomInfo import com.chwl.core.room.event.RoomAtEvent import com.chwl.core.room.event.RoomClearScreenEvent @@ -113,7 +101,6 @@ import com.chwl.core.support.room.RoomWidget import com.chwl.core.user.UserModel import com.chwl.core.user.bean.BaseInfo import com.chwl.core.user.bean.UserInfo -import com.chwl.core.utils.CurrentTimeUtils import com.chwl.core.utils.net.VipLevelNotEnoughException import com.chwl.library.common.util.LimitClickUtils import com.chwl.library.common.util.SPUtils @@ -147,7 +134,6 @@ open class BaseRoomFragment?> : protected lateinit var inputSend: ImageView protected lateinit var microView: MicroView private var musicPlayerView: MusicPlayerView? = null - private var ivRadishEntrance: View? = null private var mVsMusicPlayer: ViewStub? = null private var mDisposable: Disposable? = null private var isCloseScreen = false @@ -170,7 +156,6 @@ open class BaseRoomFragment?> : * 是否開啟禮物值顯示 */ private var showGiftValue = false - private var redPackageSendDialog: RedPackageSendDialog? = null private val mOnSoftKeyBoardChangeListener: OnSoftKeyBoardChangeListener = object : OnSoftKeyBoardChangeListener { override fun keyBoardShow(height: Int) { @@ -207,7 +192,6 @@ open class BaseRoomFragment?> : inputSend = mView.findViewById(R.id.input_send) microView = mView.findViewById(R.id.micro_view) mVsMusicPlayer = mView.findViewById(R.id.vs_music_player) - ivRadishEntrance = mView.findViewById(R.id.iv_radish_entrance) messageView.setClickConsumer { if (!TextUtils.isEmpty(it) && it != "0") { showUserCardDialog(it) @@ -289,10 +273,6 @@ open class BaseRoomFragment?> : checkFollowOwner() GiftValueMrg.get().updateRoomGiftValue(false) - //先隐藏航海冒险 -// ivRadishEntrance?.isVisible = -// !GoldBoxHelper.needIntegrateBoxEntrance() && GoldBoxHelper.isShowRadish() - //获取免费礼物详情 mvpPresenter?.queryFreeFlower() initRoomAlbum() @@ -680,10 +660,6 @@ open class BaseRoomFragment?> : } R.id.iv_first_charge_enter -> FirstChargeDialog.start(mContext) -// R.id.iv_treasure_box, -// R.id.iv_treasure_box_cp -> GoldBoxHelper.handleBoxClick(mContext) - - R.id.iv_radish_entrance -> PullRadishActivity.start(mContext) } } @@ -931,7 +907,6 @@ open class BaseRoomFragment?> : try { giftDialog?.dismiss() dynamicFaceDialog?.dismiss() - redPackageSendDialog?.dismissAllowingStateLoss() } catch (e: Exception) { e.printStackTrace() } @@ -1240,15 +1215,6 @@ open class BaseRoomFragment?> : } override fun onMoreBtnClick() { - val dialog = RoomOperationDialog(mContext) - dialog.setOnActionListener { - redPackageSendDialog = RedPackageSendDialog.newInstance(AvRoomDataManager.get().redEnvelopeType) - redPackageSendDialog?.setOnDismissListener { - redPackageSendDialog = null - } - redPackageSendDialog?.show(activity) - } - dialog.show() } override fun onRoomMessageClick() { diff --git a/app/src/main/java/com/chwl/app/avroom/fragment/HomePartyRoomFragment.java b/app/src/main/java/com/chwl/app/avroom/fragment/HomePartyRoomFragment.java index c793f9b5e..32061ca70 100644 --- a/app/src/main/java/com/chwl/app/avroom/fragment/HomePartyRoomFragment.java +++ b/app/src/main/java/com/chwl/app/avroom/fragment/HomePartyRoomFragment.java @@ -30,7 +30,6 @@ import com.chwl.app.avroom.dialog.PKScoreBoardDialog; import com.chwl.app.avroom.firstcharge.FirstChargePrizeDialog; import com.chwl.app.avroom.giftvalue.GiftValueDialogUiHelper; import com.chwl.app.avroom.presenter.HomePartyPresenter; -import com.chwl.app.avroom.redpackage.RedPackageWidget; import com.chwl.app.avroom.view.IHomePartyView; import com.chwl.app.avroom.widget.PKBoardView; import com.chwl.app.base.BaseMvpActivity; @@ -137,7 +136,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment() { - - - private val redPackageNotifyInfo by lazy { arguments?.getSerializable(KEY_NOTIFY_INFO) as RedPackageNotifyInfo } - - - companion object { - private const val KEY_NOTIFY_INFO = "redPackageNotifyInfo" - private var dialogManager: DialogManager? = null - fun newInstance(redPackageNotifyInfo: RedPackageNotifyInfo): RedPackageGoRoomDialog { - return RedPackageGoRoomDialog().apply { - arguments = Bundle().apply { - putSerializable(KEY_NOTIFY_INFO, redPackageNotifyInfo) - } - } - } - } - - override fun onStart() { - width = WindowManager.LayoutParams.MATCH_PARENT - height = WindowManager.LayoutParams.MATCH_PARENT - - super.onStart() - } - - override fun init() { - AnimationUtils.loadAnimation(context, R.anim.anim_all_red_package).apply { - binding?.clRed?.animation = this - start() - } - AnimationUtils.loadAnimation(context, R.anim.anim_all_red_package_in_btn).let { - binding?.ivGoRoom?.animation = it - it.start() - } - binding?.ivClose?.setOnClickListener { dismissAllowingStateLoss() } - binding?.ivGoRoom?.setOnClickListener { - val jump = { - AVRoomActivity.start(context, redPackageNotifyInfo.roomUid, - AVRoomActivity.FROM_TYPE_ALL_RED, redPackageNotifyInfo.sendUserNick, redPackageNotifyInfo) - dismissAllowingStateLoss() - EventBus.getDefault().post(RedPackageEvent()) - } -// StatUtil.onEvent("gethongbao_get", ResUtil.getString(R.string.avroom_redpackage_redpackagegoroomdialog_01)) - if (AvRoomDataManager.get().isOwnerOnMic && AvRoomDataManager.get().roomId != redPackageNotifyInfo.roomUid) { - //如果显示这个弹窗的时候,又收到了一个全服,再次点击进房抢的时候需要关闭前面的那个 - dialogManager?.dismissDialog() - dialogManager = DialogManager(context) - dialogManager?.showOkCancelDialog(ResUtil.getString(R.string.avroom_redpackage_redpackagegoroomdialog_02), true, jump) - } else { - jump() - } - - } - redPackageNotifyInfo.let { - ImageLoadUtils.loadAvatar(context, it.sendUserAvatar, binding?.ivAvatar) - binding?.tvContent?.text = it.redEnvelopeMessage - binding?.tvNickname?.text = it.sendUserNick.subAndReplaceDot() - binding?.tvRoomName?.text = it.roomTitle.subAndReplaceDot() - } -// StatUtil.onEvent("gethongbao", ResUtil.getString(R.string.avroom_redpackage_redpackagegoroomdialog_03)) - } - - override fun onDestroy() { - super.onDestroy() - dialogManager = null - } -} diff --git a/app/src/main/java/com/chwl/app/avroom/redpackage/RedPackageHandler.kt b/app/src/main/java/com/chwl/app/avroom/redpackage/RedPackageHandler.kt deleted file mode 100644 index a98643e5b..000000000 --- a/app/src/main/java/com/chwl/app/avroom/redpackage/RedPackageHandler.kt +++ /dev/null @@ -1,169 +0,0 @@ -package com.chwl.app.avroom.redpackage - -import android.content.Context -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.MutableLiveData -import com.chwl.app.avroom.activity.AVRoomActivity -import com.chwl.app.avroom.redpackage.open.RedPackageOpenDialog -import com.chwl.core.im.custom.bean.RedPackageAttachment -import com.chwl.core.manager.IMNetEaseManager -import com.chwl.core.manager.RoomEvent -import com.chwl.core.redpackage.RedPackageModel -import com.chwl.core.redpackage.bean.RedPackageNotifyInfo -import com.chwl.core.support.room.RoomContext -import com.chwl.core.support.room.RoomHandler - -/** - * Created by Max on 2023/10/26 11:26 - * Desc:红包处理器 - **/ -class RedPackageHandler : RoomHandler() { - - // 入口图标-数据 - val iconLiveData: MutableLiveData = MutableLiveData() - - /** - * 红包相关操作计数;目前的红包操作为:【正在打开当前房间的红包弹窗】。 - * 展示时+1,销毁时-1,以此来判断是否正在进行红包操作) - */ - private var operationCount: Int = 0 - - val inOperation get() = operationCount > 0 - - override fun onStart(context: RoomContext) { - super.onStart(context) - registerSignaling() - } - - override fun onStop(context: RoomContext) { - super.onStop(context) - } - - override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) { - super.onStateChanged(source, event) - if (event == Lifecycle.Event.ON_RESUME) { - requestLatestRoomRedPackage() - } - } - - /** - * 尝试展示红包 - * PS:目前这个方法仅为了解决:通过房间外的红包入口进入房间后,需要查询该红包,展示出来。 - */ - fun tryShowRedPackage(redPackageId: Long) { - val disposable = RedPackageModel.getRedPackage(redPackageId) - .compose(bindToLifecycle()) - .subscribe({ item -> - if (item.state != 3 && item.state != 6 && item.state != 4) { - roomView?.getActivity().let { - RedPackageOpenDialog.newInstance(item).show(it) - } - } - }, {}) - } - - /** - * 监听房间信令 - */ - private fun registerSignaling() { - // TODO 临时方案:不应在这里直接监听IM,后续会统一分发出口 - // 信令来源:新/旧版的厅内红包,非全服红包 - IMNetEaseManager.get().chatRoomEventObservable - .compose(bindToLifecycle()) - .filter { - it?.event == RoomEvent.RECEIVE_RED_PACKAGE && it?.chatRoomMessage?.attachment is RedPackageAttachment - }.map { - (it.chatRoomMessage.attachment as RedPackageAttachment).getRedPackageNotifyInfo() - } - .subscribe { data: RedPackageNotifyInfo -> - handleRoomRedPackage(data, true) - } - } - - /** - * 查找最新的厅内红包(新/旧版的厅内红包,非全服红包) - */ - private fun requestLatestRoomRedPackage() { - val roomId = roomContext?.roomId ?: return - RedPackageModel.getLatestRoomRedPackage(roomId) - .compose(bindToLifecycle()) - .subscribe({ data -> - handleRoomRedPackage(data, false) - }, { - if (it.message == "No RedPackage") { - updateIcon(null) - } else { - // 网络等原因的失败,不处理就好 - } - }) - } - - /** - * 处理厅内红包,非全服红包 - * @param isSignaling 是否来自信令? - */ - private fun handleRoomRedPackage(data: RedPackageNotifyInfo, isSignaling: Boolean) { - tryShowOpenDialog(data, isSignaling) - updateIcon(data) - } - - /** - * 更新红包入口图标 - */ - private fun updateIcon(data: RedPackageNotifyInfo?) { - iconLiveData.postValue(data) - } - - /** - * 尝试展示红包领取弹窗 - */ - private fun tryShowOpenDialog(data: RedPackageNotifyInfo, isSignaling: Boolean) { - val activity = roomView?.getActivity() ?: return - if (activity.isFinishing) { - return - } - if (!isSignaling) { - return - } - if (data.kind == 0 || (data.kind == 1 && data.validityType == 0)) { - //【旧版本-厅内红包:kind=0】、【新版本-厅内无门槛-立即生效红包:kind=1&validityType=0】 - RedPackageOpenDialog.newInstance(data).show(activity) - } - } - - /** - * 请求刷新Icon(数据已过期) - */ - fun requestRefreshIcon() { -// updateIcon(null) - requestLatestRoomRedPackage() - } - - fun startOperation() { - operationCount++ - } - - fun stopOperation() { - operationCount-- - } - - /** - * 全服红包信令(之前是在BaseActivity中处理的;现在为了红包的一个需求,暂且拦截到这里处理) - */ - fun onAllServiceSignaling(context: Context, data: RedPackageNotifyInfo) { - if (context is AVRoomActivity) { - if (roomContext?.roomId == data.roomUid) { - RedPackageOpenDialog.newInstance(data).show(context) - } else { - if (!inOperation) { - RedPackageGoRoomDialog.newInstance(data).show(context) - } else { - // 需求:正在房间中领取红包时,不展示其他房间的全服红包 - } - } - } else { - RedPackageGoRoomDialog.newInstance(data).show(context) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/chwl/app/avroom/redpackage/RedPackageWidget.kt b/app/src/main/java/com/chwl/app/avroom/redpackage/RedPackageWidget.kt deleted file mode 100644 index b360e57c5..000000000 --- a/app/src/main/java/com/chwl/app/avroom/redpackage/RedPackageWidget.kt +++ /dev/null @@ -1,239 +0,0 @@ -package com.chwl.app.avroom.redpackage - -import android.content.Context -import android.util.AttributeSet -import android.util.TypedValue -import android.view.LayoutInflater -import androidx.core.view.isVisible -import androidx.databinding.DataBindingUtil -import com.example.lib_utils.ServiceTime -import com.example.lib_utils.ktx.singleClick -import com.chwl.app.R -import com.chwl.app.avroom.redpackage.open.RedPackageOpenDialog -import com.chwl.app.common.widget.dialog.DialogManager -import com.chwl.app.databinding.RedPackageWidgetBinding -import com.chwl.core.redpackage.RedPackageModel -import com.chwl.core.redpackage.bean.RedPackageNotifyInfo -import com.chwl.core.support.room.FrameLayoutRoomWidget -import com.chwl.core.support.room.RoomContext -import com.chwl.core.support.room.RoomView -import com.chwl.core.support.room.RoomWidget -import com.chwl.library.utils.SingleToastUtil -import io.reactivex.Observable -import io.reactivex.android.schedulers.AndroidSchedulers -import io.reactivex.disposables.CompositeDisposable -import io.reactivex.disposables.Disposable -import okhttp3.internal.toLongOrDefault -import java.text.SimpleDateFormat -import java.util.TimeZone -import java.util.concurrent.TimeUnit - -/** - * Created by Max on 2023/10/24 16:37 - * Desc:房间内的红包入口 - **/ -class RedPackageWidget : FrameLayoutRoomWidget, RoomWidget { - private var countDownDisposable: Disposable? = null - private var data: RedPackageNotifyInfo? = null - private val redPackageHandler: RedPackageHandler? - get() = RoomContext.get() - ?.findAbility(RedPackageHandler::class.java.simpleName) - - // 临时这样实现,后续优化进度弹窗 - private var dialogManager: DialogManager? = null - - // 倒计时格式(分:秒) - private val mmssFormat by lazy(LazyThreadSafetyMode.NONE) { - SimpleDateFormat("mm:ss").apply { - timeZone = TimeZone.getTimeZone("GMT+00:00") - } - } - - private val binding: RedPackageWidgetBinding = - DataBindingUtil.inflate( - LayoutInflater.from( - context - ), R.layout.red_package_widget, this, true - ) - - constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super( - context, - attrs, - defStyleAttr - ) - - constructor( - context: Context, - attrs: AttributeSet?, - defStyleAttr: Int, - defStyleRes: Int - ) : super(context, attrs, defStyleAttr, defStyleRes) - - init { - // 默认不可见 - this.isVisible = false - this.setBackgroundResource(R.drawable.red_package_widget_bg) - singleClick { - data?.let { - tryShowRedPackage(it) - } - } - } - - /** - * 开始倒计时 - * @param time 开抢时间 - */ - private fun startCountDown(time: Long) { - val count = time - ServiceTime.time - if (count <= 0) { - switchUI(false) - return - } - countDownDisposable = - Observable.intervalRange(0, count / 1000, 0, 1000L, TimeUnit.MILLISECONDS) - .observeOn(AndroidSchedulers.mainThread()) - .doOnNext { - val gap = time - ServiceTime.time - if (gap >= 0) { - binding.tvText.text = mmssFormat.format(gap) - } - } - .doOnComplete { - switchUI(false) - } - .subscribe() - } - - /** - * 切换UI - * @param isCountDown 是否倒计时模式?否则为可抢红包模式 - */ - private fun switchUI(isCountDown: Boolean) { - if (isCountDown) { - binding.tvText.setBackgroundResource(R.drawable.shape_99292929_8) - binding.tvText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10f) - } else { - binding.tvText.setBackgroundResource(R.drawable.red_package_widget_bg_text) - binding.tvText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 9f) - binding.tvText.setText(R.string.red_package_widget_get) - } - } - - override fun onStart(roomView: RoomView) { - super.onStart(roomView) - roomView.getActivity()?.let { - this.dialogManager = DialogManager(it) - this.dialogManager?.setCanceledOnClickOutside(false) - } - } - - override fun onInitialize(roomView: RoomView, roomContext: RoomContext) { - super.onInitialize(roomView, roomContext) - val lifecycleOwner = roomView.getLifecycleOwner() - redPackageHandler?.iconLiveData?.observe(lifecycleOwner) { - loadData(it) - } - } - - /** - * 更新数据 - */ - private fun loadData(data: RedPackageNotifyInfo?) { - this.data = data - stopCountDown() - if (data != null) { - val num = data.redEnvelopeNum - if (num > 0) { - if (num > 99) { - binding.tvNum.text = "99+" - } else { - binding.tvNum.text = num.toString() - } - binding.tvNum.isVisible = true - } else { - binding.tvNum.isVisible = false - } - if (data.validityType == 1) { - // 限时生效 - switchUI(true) - startCountDown(data.beginTime) - } else { - // 立即生效 - switchUI(false) - } - this.isVisible = true - } else { - this.isVisible = false - } - } - - /** - * 尝试展示红包 - */ - private fun tryShowRedPackage(data: RedPackageNotifyInfo) { - dialogManager?.context?.let { - dialogManager?.showProgressDialog(it, false) - } - val disposable = RedPackageModel.getRedPackage(data.redEnvelopeId.toLongOrDefault(0)) - .subscribe({ item -> - dialogManager?.dismissDialog() - when (item.state) { - 3 -> { - redPackageHandler?.requestRefreshIcon() - SingleToastUtil.showToast(R.string.red_package_result_empty_tips) - } - - 4 -> { - val newData = item.result?.redEnvelopeVO - if (newData != null && newData.pickNum == newData.totalNum) { - redPackageHandler?.requestRefreshIcon() - SingleToastUtil.showToast(R.string.red_package_result_empty_tips) - } else { - roomView?.getActivity().let { - RedPackageOpenDialog.newInstance(item).show(it) - } - } - } - - 2, 6 -> { - redPackageHandler?.requestRefreshIcon() - SingleToastUtil.showToast(R.string.red_package_disabled_tips) - } - - else -> { - roomView?.getActivity().let { - RedPackageOpenDialog.newInstance(item).show(it) - } - } - } - }, { - SingleToastUtil.showToast(it.message) - dialogManager?.dismissDialog() - }) - getCompositeDisposable().add(disposable) - } - - override fun onStop() { - super.onStop() - this.dialogManager?.dismissDialog() - this.dialogManager = null - } - - override fun onUnbindContext() { - super.onUnbindContext() - loadData(null) - } - - override fun onBindContext(roomContext: RoomContext) { - super.onBindContext(roomContext) - } - - private fun stopCountDown() { - if (countDownDisposable?.isDisposed == false) { - countDownDisposable?.dispose() - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/chwl/app/avroom/redpackage/open/RedPackageOpenDialog.kt b/app/src/main/java/com/chwl/app/avroom/redpackage/open/RedPackageOpenDialog.kt deleted file mode 100644 index c0bf54482..000000000 --- a/app/src/main/java/com/chwl/app/avroom/redpackage/open/RedPackageOpenDialog.kt +++ /dev/null @@ -1,561 +0,0 @@ -package com.chwl.app.avroom.redpackage.open - - -import android.animation.Animator -import android.animation.AnimatorListenerAdapter -import android.animation.ObjectAnimator -import android.animation.ValueAnimator -import android.annotation.SuppressLint -import android.os.Bundle -import android.view.View -import android.view.WindowManager -import android.view.animation.LinearInterpolator -import androidx.core.view.isVisible -import com.example.lib_utils.ServiceTime -import com.example.lib_utils.ktx.getColorById -import com.example.lib_utils.ktx.singleClick -import com.example.lib_utils.ktx.toStringRes -import com.example.lib_utils.log.ILog -import com.example.lib_utils.spannable.spannableBuilder -import com.trello.rxlifecycle3.android.FragmentEvent -import com.chwl.app.R -import com.chwl.app.avroom.redpackage.RedPackageHandler -import com.chwl.app.base.BaseDialog -import com.chwl.app.databinding.RedPackageOpenDialogBinding -import com.chwl.app.ui.utils.loadAvatar -import com.chwl.app.ui.widget.UserInfoDialog -import com.chwl.core.auth.AuthModel -import com.chwl.core.home.event.FollowRoomEvent -import com.chwl.core.home.event.OpenRoomMessageInputEvent -import com.chwl.core.home.event.ShareRoomEvent -import com.chwl.core.home.model.CollectionRoomModel -import com.chwl.core.manager.AvRoomDataManager -import com.chwl.core.pay.PayModel -import com.chwl.core.redpackage.* -import com.chwl.core.redpackage.bean.RedEnvelopeState -import com.chwl.core.redpackage.bean.RedPackageData -import com.chwl.core.redpackage.bean.RedPackageInfo -import com.chwl.core.redpackage.bean.RedPackageNotifyInfo -import com.chwl.core.support.config.Constants -import com.chwl.core.support.room.RoomContext -import com.chwl.library.annatation.ActLayoutRes -import com.chwl.library.utils.SingleToastUtil -import io.reactivex.Observable -import io.reactivex.android.schedulers.AndroidSchedulers -import io.reactivex.disposables.Disposable -import org.greenrobot.eventbus.EventBus -import java.text.SimpleDateFormat -import java.util.TimeZone -import java.util.concurrent.TimeUnit - -/** - * Created by Max on 2023/10/24 10:14 - * Desc:领取红包 - **/ -@ActLayoutRes(R.layout.red_package_open_dialog) -class RedPackageOpenDialog : BaseDialog(), ILog { - - private var btnAnimator: ObjectAnimator? = null - - private var countDownDisposable: Disposable? = null - - // 倒计时格式(分:秒) - private val mmssFormat by lazy(LazyThreadSafetyMode.NONE) { - SimpleDateFormat("mm:ss").apply { - timeZone = TimeZone.getTimeZone("GMT+00:00") - } - } - - private val data by lazy(LazyThreadSafetyMode.NONE) { - arguments?.getSerializable(Constants.KEY_INTENT) as? RedPackageData - } - - // 打开红包的结果 - private var openResultRunnable: (() -> Unit)? = null - - // 按钮动画是否有效(至少转过了一周期) - private var isValidOfBtnAnimator: Boolean = false - - // 按钮执行函数 - private var btnRunnable: (() -> Unit)? = null - - // 打开红包接口请求中 - private var opening = false - - companion object { - /** - * 此入口来源仅限:【全服红包信令】、【厅内无门槛-立即生效红包信令】 - */ - fun newInstance(data: RedPackageNotifyInfo): RedPackageOpenDialog { - /** - * 收到这两种信令直接展示即可,无需再次请求接口查询状态, - * 但由于信令和接口查询的数据格式不一致,所以这里做下转换,达到逻辑共用 - */ - val item = RedPackageData( - amount = null, - avatar = data.sendUserAvatar, - beginTime = data.beginTime, - commissionAmount = null, - createTime = null, - duration = null, - endTime = null, - finish = true, - id = data.redEnvelopeId.toLongOrNull(), - kind = data.kind, - message = data.redEnvelopeMessage, - nick = data.sendUserNick, - num = null, - originalAmount = null, - position = null, - roomTitle = null, - roomUid = data.roomUid, - //红包状态 1 开抢中 2 过时 3 抢光了 4 抢到了 5 将要开始 6 超时已退还 - state = null, - type = null, - updateTime = null, - userId = null, - validityType = data.validityType, - result = null - ) - return newInstance(item) - } - - fun newInstance(data: RedPackageData): RedPackageOpenDialog { - return RedPackageOpenDialog().apply { - arguments = Bundle().apply { - putSerializable(Constants.KEY_INTENT, data) - } - } - } - } - - override fun onStart() { - width = WindowManager.LayoutParams.MATCH_PARENT - height = WindowManager.LayoutParams.WRAP_CONTENT - super.onStart() - } - - override fun init() { - val data = this.data - if (data == null) { - dismissAllowingStateLoss() - return - } - dialog?.setCanceledOnTouchOutside(false) - - binding.ivClose.singleClick { - dismissAllowingStateLoss() - } - - binding.layoutBtn.singleClick { - btnRunnable?.invoke() - } - loadData(data) - } - - /** - * 加载红包数据 - */ - private fun loadData(data: RedPackageData) { - //红包状态 1 开抢中 2 过时 3 抢光了 4 抢到了 5 将要开始 6 超时已退还 - if (data.state == 4) { - loadResult(data.result) - } else { - // else简单理解为可领取状态,正常情况下在RedPackageWidget点击时有异常状态过滤 - loadOpen(data) - } - } - - /** - * 加载可领取数据 - */ - private fun loadOpen(data: RedPackageData) { - switchResultViewVisible(false) - switchOpenViewVisible(true) - binding.ivSendAvatar.loadAvatar(data.avatar) - binding.tvSendName.text = data.nick - loadTips(data) - loadBtnState(data) - } - - /** - * 加载红包提示 - */ - private fun loadTips(data: RedPackageData) { - binding.tvOpenTips.isVisible = false - when (data.kind) { - 0 -> { - loadTips(data.message) - } - - 1 -> { - binding.tvOpenTips.setText(R.string.red_package_quick_tips) - binding.tvOpenTips.isVisible = true - } - - 2 -> { - if (data.finish == true) { - binding.tvOpenTips.setText(R.string.red_package_complete_tips) - } else { - binding.tvOpenTips.spannableBuilder() - .appendText( - text = R.string.red_package_open_tips_follow.toStringRes(), - textColor = getColorById(R.color.color_FFF87A) - ) - .appendText(text = R.string.red_package_open_tips_msg_end.toStringRes()) - .apply() - } - binding.tvOpenTips.isVisible = true - } - - 3 -> { - if (data.finish == true) { - binding.tvOpenTips.setText(R.string.red_package_complete_tips) - } else { - binding.tvOpenTips.spannableBuilder() - .appendText( - text = R.string.red_package_open_tips_share.toStringRes(), - textColor = getColorById(R.color.color_FFF87A) - ) - .appendText(text = R.string.red_package_open_tips_msg_end.toStringRes()) - .apply() - } - binding.tvOpenTips.isVisible = true - } - - 4 -> { - if (data.finish == true) { - binding.tvOpenTips.setText(R.string.red_package_complete_tips) - } else { - binding.tvOpenTips.spannableBuilder() - .appendText(text = R.string.red_package_open_tips_msg1.toStringRes()) - .appendText( - text = data.message ?: "", - textColor = getColorById(R.color.color_FFF87A) - ) - .appendText(text = R.string.red_package_open_tips_msg_end.toStringRes()) - .apply() - } - binding.tvOpenTips.isVisible = true - } - - else -> { - loadTips(data.message) - } - } - } - - /** - * 加载按钮状态 - */ - private fun loadBtnState(data: RedPackageData) { - binding.groupBtnTime.isVisible = false - binding.ivBtnGet.isVisible = false - binding.tvBtnMsg.isVisible = false - btnRunnable = null - - val gap = (data.beginTime ?: 0) - ServiceTime.time - // 开始了? - val started = gap < 0 - if (data.kind == 0) { - // 旧厅内红包or全服红包 - switchToOpenState() - return - } - if (data.kind == 1 || data.finish == true) { - if (started) { - switchToOpenState() - } else { - startCountDown(data.beginTime ?: 0) - } - } else { - binding.tvBtnMsg.isVisible = true - if (started) { - binding.tvBtnMsg.setText(R.string.red_package_open_btn_no) - btnRunnable = { - SingleToastUtil.showToast(R.string.red_package_open_no_tips) - } - } else { - when (data.kind) { - 2 -> { - binding.tvBtnMsg.setText(R.string.red_package_open_btn_follow) - btnRunnable = { - dismissAllowingStateLoss() - showUserDialog(data.userId) - } - } - - 3 -> { - binding.tvBtnMsg.setText(R.string.red_package_open_btn_share) - btnRunnable = { - dismissAllowingStateLoss() - EventBus.getDefault().post(ShareRoomEvent()) - } - } - - 4 -> { - binding.tvBtnMsg.setText(R.string.red_package_open_btn_msg) - btnRunnable = { - dismissAllowingStateLoss() - EventBus.getDefault().post(OpenRoomMessageInputEvent(data.message)) - } - } - - else -> { - binding.tvBtnMsg.text = "" - } - } - startTimerForUncompletedState(gap) - } - } - } - - /** - * 开启定时器:未完成状态更新(倒计时结束时,更新对应View状态) - */ - private fun startTimerForUncompletedState(time: Long) { - val d = Observable.timer(time, TimeUnit.MILLISECONDS) - .compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW)) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe { - binding.tvBtnMsg.setText(R.string.red_package_open_btn_no) - btnRunnable = { - SingleToastUtil.showToast(R.string.red_package_open_no_tips) - } - } - } - - /** - * 开始倒计时 - * @param time 开抢时间 - */ - private fun startCountDown(time: Long) { - stopCountDown() - val count = time - ServiceTime.time - if (count <= 0) { - switchToOpenState() - return - } - binding.groupBtnTime.isVisible = true - countDownDisposable = - Observable.intervalRange(0, count / 1000, 0, 1000L, TimeUnit.MILLISECONDS) - .observeOn(AndroidSchedulers.mainThread()) - .doOnNext { - val gap = time - ServiceTime.time - if (gap >= 0) { - binding.tvBtnTime.text = mmssFormat.format(gap) - } - } - .doOnComplete { - switchToOpenState() - } - .subscribe() - } - - - private fun stopCountDown() { - if (countDownDisposable?.isDisposed == false) { - countDownDisposable?.dispose() - } - } - - - /** - * 切换为可抢状态 - */ - private fun switchToOpenState() { - binding.tvBtnMsg.isVisible = false - binding.groupBtnTime.isVisible = false - binding.ivBtnGet.isVisible = true - btnRunnable = { - if (!opening) { - this.data?.let { - openRedPackage(it) - } - } - } - } - - private fun loadTips(msg: String?) { - if (msg.isNullOrEmpty()) { - binding.tvOpenTips.isVisible = false - } else { - binding.tvOpenTips.text = msg - binding.tvOpenTips.isVisible = true - } - } - - /** - * 打开红包 - */ - private fun openRedPackage(data: RedPackageData) { - opening = true - openResultRunnable = null - startRedPacketAnim(binding.layoutBtn) - val d = RedPackageModel.openRedPackage(data.id ?: 0) - .compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW)).subscribe({ - if (isValidOfBtnAnimator) { - btnAnimator?.cancel() - onOpenSuccess(it) - } else { - openResultRunnable = { - onOpenSuccess(it) - } - } - }, { - if (isValidOfBtnAnimator) { - btnAnimator?.cancel() - onOpenFail(it) - } else { - openResultRunnable = { - onOpenFail(it) - } - } - }) - } - - /** - * 加载结果 - */ - private fun loadResult(data: RedPackageInfo?) { - binding.layoutContent.setBackgroundResource(R.drawable.red_package_result_bg) - switchOpenViewVisible(false) - switchResultViewVisible(true) - binding.groupResultMoney.isVisible = false - binding.tvResultEmptyTips.isVisible = false - binding.ivResultSendAvatar.loadAvatar(data?.redEnvelopeVO?.userVO?.avatar) - binding.tvResultSendName.text = data?.redEnvelopeVO?.userVO?.nick ?: "" - val name = data?.redEnvelopeVO?.userVO?.nick ?: "" - if (name.length > 8) { - binding.tvResultSendName.text = name?.take(8) + "..的紅包" - } else { - binding.tvResultSendName.text = name + "的紅包" - } - binding.tvMessage.text = data?.redEnvelopeVO?.message - binding.tvCount.text = R.string.red_package_result_count_format.toStringRes() - .format(data?.redEnvelopeVO?.pickNum ?: 0, data?.redEnvelopeVO?.totalNum ?: 0) - - val adapter = RedPackageResultAdapter() - binding.recyclerView.adapter = adapter - adapter.setNewData(data?.redEnvelopeItemVOs) - - when (data?.redEnvelopeState) { - RedEnvelopeState.SUCCESS -> { - binding.tvMoney.text = data.currentUserAmount.toString().substringBefore(".") - binding.groupResultMoney.isVisible = true - } - - RedEnvelopeState.TIME_OUT, RedEnvelopeState.REMAIN_ZERO, RedEnvelopeState.TIME_OUT_BACK -> { - binding.tvResultEmptyTips.isVisible = true - } - } - } - - /** - * 打开红包响应成功 - * @param data 结果 - */ - private fun onOpenSuccess(data: RedPackageInfo) { - loadResult(data) - RoomContext.get() - ?.findAbility(RedPackageHandler::class.simpleName) - ?.requestRefreshIcon() - when (data.redEnvelopeState) { - RedEnvelopeState.SUCCESS -> { - // 下面这段是延续老代码保留的 - if (!AvRoomDataManager.get().isRoomFans) { - AvRoomDataManager.get().roomUid.let { - CollectionRoomModel.get().followRoom("1", it) - .subscribe { _: String? -> - AvRoomDataManager.get().isRoomFans = true - EventBus.getDefault().post(FollowRoomEvent()) - } - } - } - } - } - PayModel.get().getWalletInfo(AuthModel.get().currentUid).subscribe() - opening = false - } - - /** - * 打开红包响应失败 - */ - private fun onOpenFail(throwable: Throwable) { - switchToOpenState() - btnAnimator?.cancel() - SingleToastUtil.showToast(throwable.message) - opening = false - } - - @SuppressLint("CheckResult") - private fun startRedPacketAnim(v: View) { - if (btnAnimator?.isRunning == true) { - btnAnimator?.cancel() - } - isValidOfBtnAnimator = false - btnAnimator = ObjectAnimator.ofFloat(v, "rotationY", 0f, 360f) - btnAnimator?.let { - it.duration = 600 - it.repeatCount = ValueAnimator.INFINITE - it.repeatMode = ValueAnimator.RESTART - it.interpolator = LinearInterpolator() - it.addListener(object : AnimatorListenerAdapter() { - override fun onAnimationRepeat(animation: Animator) { - super.onAnimationRepeat(animation) - isValidOfBtnAnimator = true - if (openResultRunnable != null) { - animation.cancel() - openResultRunnable?.invoke() - } - } - }) - it.start() - } - } - - private fun switchResultViewVisible(isVisible: Boolean) { - binding.groupResult.isVisible = isVisible - binding.groupResultMoney.isVisible = isVisible - binding.tvResultEmptyTips.isVisible = isVisible - } - - private fun switchOpenViewVisible(isVisible: Boolean) { - binding.groupOpen.isVisible = isVisible - binding.tvOpenTips.isVisible = isVisible - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - RoomContext.get() - ?.findAbility(RedPackageHandler::class.simpleName) - ?.startOperation() - super.onViewCreated(view, savedInstanceState) - } - - override fun onDestroyView() { - super.onDestroyView() - btnAnimator?.cancel() - btnAnimator = null - stopCountDown() - RoomContext.get() - ?.findAbility(RedPackageHandler::class.simpleName) - ?.stopOperation() - } - - override fun onPause() { - super.onPause() - dismissAllowingStateLoss() - } - - private fun showUserDialog(uid: Long?) { - if (uid == null) { - return - } - activity?.let { - UserInfoDialog.showNewUserInfoDialog( - activity, - uid - ) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/chwl/app/avroom/redpackage/open/RedPackageResultAdapter.kt b/app/src/main/java/com/chwl/app/avroom/redpackage/open/RedPackageResultAdapter.kt deleted file mode 100644 index ac1aaeca2..000000000 --- a/app/src/main/java/com/chwl/app/avroom/redpackage/open/RedPackageResultAdapter.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.chwl.app.avroom.redpackage.open - -import android.view.View -import android.widget.ImageView -import androidx.core.view.isVisible -import com.chad.library.adapter.base.BaseQuickAdapter -import com.chad.library.adapter.base.BaseViewHolder -import com.chwl.app.R -import com.chwl.app.ui.utils.loadAvatar -import com.chwl.app.utils.UserUtils -import com.chwl.core.redpackage.bean.RedEnvelopeItemVO -import com.chwl.core.utils.extension.subAndReplaceDot -import com.chwl.library.utils.ResUtil -import java.text.SimpleDateFormat -import java.util.Locale - -/** - * Created by Max on 2023/10/27 20:24 - * Desc:红包领取结果 - **/ -class RedPackageResultAdapter : - BaseQuickAdapter(R.layout.red_package_open_item_result) { - private val dateFormat = SimpleDateFormat( - ResUtil.getString(R.string.avroom_redpackage_redpackageopenadapter_01), - Locale.CHINA - ) - - override fun convert(helper: BaseViewHolder, item: RedEnvelopeItemVO) { - helper.getView(R.id.iv_avatar).loadAvatar(item.userVO.avatar) - val isSelf = item.userVO.uid == UserUtils.getUserUid() - helper.setText( - R.id.tv_name, - if (isSelf) ResUtil.getString(R.string.avroom_redpackage_redpackageopenadapter_02) else item.userVO.nick.subAndReplaceDot( - 6 - ) - ) - helper.setText(R.id.tv_money, item.amount.substringBefore(".")) - try { - helper.setText(R.id.tv_time, dateFormat.format(item.createTime)) - } catch (e: Exception) { - helper.setText(R.id.tv_time, "") - } - helper.getView(R.id.v_line).isVisible = helper.bindingAdapterPosition != itemCount - 1 - } -} \ No newline at end of file diff --git a/app/src/main/java/com/chwl/app/avroom/redpackage/send/PrivateRedPackageEditorFragment.kt b/app/src/main/java/com/chwl/app/avroom/redpackage/send/PrivateRedPackageEditorFragment.kt deleted file mode 100644 index 06ab38489..000000000 --- a/app/src/main/java/com/chwl/app/avroom/redpackage/send/PrivateRedPackageEditorFragment.kt +++ /dev/null @@ -1,284 +0,0 @@ -package com.chwl.app.avroom.redpackage.send - -import android.graphics.Color -import androidx.core.view.isVisible -import com.example.lib_utils.ktx.addDisableFilter -import com.example.lib_utils.ktx.getColorById -import com.example.lib_utils.ktx.singleClick -import com.example.lib_utils.ktx.toStringRes -import com.example.lib_utils.log.ILog -import com.chwl.app.R -import com.chwl.app.base.BaseBindingFragment -import com.chwl.app.databinding.RedPackagePrivateFragmentBinding -import com.chwl.app.pay.password.GiveGoldPassWordFragment -import com.chwl.app.pay.widget.GridPasswordNoFocusView -import com.chwl.app.ui.setting.ModifyPwdActivity -import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil -import com.chwl.app.ui.widget.recyclerview.decoration.ColorDecoration -import com.chwl.core.auth.AuthModel -import com.chwl.core.initial.InitialModel -import com.chwl.core.manager.AvRoomDataManager -import com.chwl.core.pay.PayModel -import com.chwl.core.redpackage.RedPackageModel -import com.chwl.core.user.UserModel -import com.chwl.core.utils.extension.toIntOrDef -import com.chwl.library.annatation.ActLayoutRes -import com.chwl.library.utils.ResUtil -import com.chwl.library.utils.SingleToastUtil -import com.chwl.library.utils.codec.DESUtils -import okhttp3.internal.toLongOrDefault -import java.math.RoundingMode -import java.text.NumberFormat - -/** - * Created by Max on 2023/10/23 12:14 - * Desc: 厅内红包 - **/ -@ActLayoutRes(R.layout.red_package_private_fragment) -class PrivateRedPackageEditorFragment : BaseBindingFragment(), - ILog { - - private var passWordFragment: GiveGoldPassWordFragment? = null - - private var typeAdapter: RedPackageTypeItemAdapter? = null - - // 生效时间类型 0 立即生效 1 限时生效 - private var timeType = 0 - override fun initiate() { - mBinding.etText.addDisableFilter(" ", "\n") - initTypeView() - updateTimeView(true) - initTips() - } - - override fun onSetListener() { - super.onSetListener() - mBinding.tvNow.singleClick { - updateTimeView(true) - } - mBinding.tvDelay.singleClick { - updateTimeView(false) - } - mBinding.tvSend.singleClick { - checkSend() - } - } - - private fun initTips() { - val time = InitialModel.get().cacheInitInfo?.redEnvelopeConfig?.endSecond - if (time != null) { - try { - val hour = NumberFormat.getInstance().apply { - maximumFractionDigits = 2 - roundingMode = RoundingMode.FLOOR - }.format(time / 3600.0) - mBinding.tvTips.text = R.string.red_package_tips_format.toStringRes().format(hour) - } catch (e: Exception) { - e.printStackTrace() - } - } - } - - private fun initTypeView() { - mBinding.recyclerView.addItemDecoration( - ColorDecoration( - Color.TRANSPARENT, UIUtil.dip2px(context, 6.0), 0, false - ) - ) - val list = ArrayList() - list.add( - RedPackageTypeItemAdapter.ItemData( - 1, - R.string.red_package_type_unlimited_name, - R.string.red_package_type_unlimited_tips - ) - ) - list.add( - RedPackageTypeItemAdapter.ItemData( - 2, - R.string.red_package_type_follow_name, - R.string.red_package_type_follow_tips - ) - ) - list.add( - RedPackageTypeItemAdapter.ItemData( - 3, - R.string.red_package_type_share_name, - R.string.red_package_type_share_tips - ) - ) - list.add( - RedPackageTypeItemAdapter.ItemData( - 4, - R.string.red_package_type_msg_name, - R.string.red_package_type_msg_tips - ) - ) - val adapter = RedPackageTypeItemAdapter(list) - typeAdapter = adapter - adapter.setOnItemClickListener { _, view, position -> - adapter.select(position) - updateTypeView(adapter.getSelect()?.type) - } - mBinding.recyclerView.adapter = adapter - // 默认选择第一个 - adapter.select(0) - updateTypeView(adapter.getSelect()?.type) - } - - /** - * 更新红包类型对应的视图 - */ - private fun updateTypeView(type: Int?) { - when (type) { - 1 -> { - mBinding.tvNow.isVisible = true - mBinding.tvDelay.isVisible = true - mBinding.etText.isVisible = false - } - - 4 -> { - mBinding.tvNow.isVisible = false - mBinding.tvDelay.isVisible = false - mBinding.etText.isVisible = true - } - - else -> { - mBinding.tvNow.isVisible = false - mBinding.tvDelay.isVisible = false - mBinding.etText.isVisible = false - } - } - } - - /** - * 更新时间选项 - */ - private fun updateTimeView(nowOrDelay: Boolean) { - if (nowOrDelay) { - timeType = 0 - mBinding.tvNow.setBackgroundResource(R.drawable.red_package_bg_type_selected) - mBinding.tvDelay.setBackgroundResource(R.drawable.shape_f8f8fa_8) - mBinding.tvNow.setTextColor(mBinding.root.context.getColorById(R.color.color_FF285C)) - mBinding.tvDelay.setTextColor(mBinding.root.context.getColorById(R.color.color_767585)) - } else { - timeType = 1 - mBinding.tvNow.setBackgroundResource(R.drawable.shape_f8f8fa_8) - mBinding.tvDelay.setBackgroundResource(R.drawable.red_package_bg_type_selected) - mBinding.tvNow.setTextColor(mBinding.root.context.getColorById(R.color.color_767585)) - mBinding.tvDelay.setTextColor(mBinding.root.context.getColorById(R.color.color_FF285C)) - } - } - - private fun checkSend() { - val initInfo = InitialModel.get().cacheInitInfo - if (initInfo == null) { - SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_redpackage_redpackagesenddialog_01)) - return - } - val typeItem = typeAdapter?.getSelect() - if (typeItem?.type == 4) { - if (mBinding.etText.text.toString().trim().isEmpty()) { - toast(R.string.red_package_msg_empty_tips) - return - } - } - val minNum = initInfo.redEnvelopeConfig.roomRedEnvelopeMinNum - val maxNum = initInfo.redEnvelopeConfig.roomRedEnvelopeMaxNum - val minGold = initInfo.redEnvelopeConfig.roomRedEnvelopeMinAmount - val maxGold = initInfo.redEnvelopeConfig.roomRedEnvelopeMaxAmount - val rate = - if (initInfo.redEnvelopeConfig.exchangeDiamondsRate == 0.0) 0.68 else initInfo.redEnvelopeConfig.exchangeDiamondsRate - - val redNum = mBinding?.etNum?.text.toString().toIntOrDef() - if (redNum < minNum || redNum > maxNum) { - SingleToastUtil.showToast("紅包數量不能小於${minNum}或大於${maxNum}!") - return - } - val goldNum = mBinding?.etMoney?.text.toString().toIntOrDef() - if (goldNum % 10 != 0) { - SingleToastUtil.showToast("鉆石數必須為10的倍數!") - return - } - - if (goldNum < minGold || goldNum > maxGold) { - SingleToastUtil.showToast("鉆石數量不能小於${minGold}或大於${maxGold}!") - return - } - if (goldNum.toFloat() / redNum * rate < 0.1) {//單個手氣紅包價值不低於0.1水晶 - SingleToastUtil.showToast("單個紅包金額過低") - return - } - UserModel.get().cacheLoginUserInfo?.let { - if (!it.isBindPaymentPwd) { - ModifyPwdActivity.start(context, ModifyPwdActivity.PAY_PWD) - return - } - } - GiveGoldPassWordFragment.newInstance( - childFragmentManager, - mBinding?.etMoney?.text.toString() - ).apply { - setListener(object : GridPasswordNoFocusView.OnPasswordChangedListener { - override fun onTextChanged(psw: String?) { - val password = passWordFragment?.password?.password ?: "" - if (password.length == 6) { - send(password) - } - } - - override fun onInputFinish(psw: String?) { - } - }) - passWordFragment = this - } - } - - /** - * 密码输入完成 - */ - private fun send(password: String) { - dialogManager.showProgressDialog(context) - val kind = typeAdapter?.getSelect()?.type ?: 1 - val message = if (kind == 4) { - mBinding.etText.text.trim().toString() - } else { - null - } - val validityType = if (kind == 1) { - timeType - } else { - // 非无门槛红包 默认限时 - 1 - } - RedPackageModel.sendRedPackage( - goldNum = mBinding.etMoney.text.trim().toString().toLongOrDefault(0), - message = message, - num = mBinding.etNum.text.trim().toString().toLongOrDefault(0), - roomUId = AvRoomDataManager.get().mCurrentRoomInfo?.uid.toString(), - type = 1, - kind = kind, - validityType = validityType, - password = DESUtils.DESAndBase64(password) - ) - .compose(bindToLifecycle()) - .doOnError { - dialogManager.dismissDialog() - SingleToastUtil.showToast(it.message) - passWordFragment?.password?.clearPassword() - } - .subscribe { _ -> - PayModel.get().getWalletInfo(AuthModel.get().currentUid).subscribe() - dialogManager.dismissDialog() - SingleToastUtil.showToast("發送成功") - passWordFragment?.dismissAllowingStateLoss() - (parentFragment as? RedPackageSendDialog)?.dismissAllowingStateLoss() - } - } - - override fun onDestroy() { - super.onDestroy() - passWordFragment?.dismissAllowingStateLoss() - passWordFragment = null - } -} \ No newline at end of file diff --git a/app/src/main/java/com/chwl/app/avroom/redpackage/send/PublicRedPackageEditorFragment.kt b/app/src/main/java/com/chwl/app/avroom/redpackage/send/PublicRedPackageEditorFragment.kt deleted file mode 100644 index 087dc40a3..000000000 --- a/app/src/main/java/com/chwl/app/avroom/redpackage/send/PublicRedPackageEditorFragment.kt +++ /dev/null @@ -1,157 +0,0 @@ -package com.chwl.app.avroom.redpackage.send - -import com.example.lib_utils.ktx.addDisableFilter -import com.example.lib_utils.ktx.setOnInputChangedListener -import com.example.lib_utils.ktx.singleClick -import com.example.lib_utils.ktx.toStringRes -import com.chwl.app.R -import com.chwl.app.base.BaseBindingFragment -import com.chwl.app.databinding.RedPackagePublicFragmentBinding -import com.chwl.app.pay.password.GiveGoldPassWordFragment -import com.chwl.app.pay.widget.GridPasswordNoFocusView -import com.chwl.app.ui.setting.ModifyPwdActivity -import com.chwl.core.auth.AuthModel -import com.chwl.core.initial.InitialModel -import com.chwl.core.initial.bean.InitInfo -import com.chwl.core.manager.AvRoomDataManager -import com.chwl.core.pay.PayModel -import com.chwl.core.redpackage.RedPackageModel -import com.chwl.core.user.UserModel -import com.chwl.core.utils.extension.toIntOrDef -import com.chwl.library.annatation.ActLayoutRes -import com.chwl.library.utils.SingleToastUtil -import com.chwl.library.utils.codec.DESUtils -import okhttp3.internal.toLongOrDefault -import java.math.RoundingMode -import java.text.NumberFormat - -/** - * Created by Max on 2023/10/23 12:14 - * Desc:全服红包 - **/ -@ActLayoutRes(R.layout.red_package_public_fragment) -class PublicRedPackageEditorFragment : BaseBindingFragment() { - - private var passWordFragment: GiveGoldPassWordFragment? = null - - override fun initiate() { - initTips() - mBinding.etText.addDisableFilter("\n") - mBinding.etText.setOnInputChangedListener { - mBinding.tvTextLength.text = - R.string.red_package_result_count_format.toStringRes().format(this, 10) - true - } - - mBinding.tvSend.singleClick { - checkSend() - } - } - - private fun initTips() { - val time = InitialModel.get().cacheInitInfo?.redEnvelopeConfig?.endSecond - if (time != null) { - try { - val hour = NumberFormat.getInstance().apply { - maximumFractionDigits = 2 - roundingMode = RoundingMode.FLOOR - }.format(time / 3600.0) - mBinding.tvTips.text = R.string.red_package_tips_format.toStringRes().format(hour) - } catch (e: Exception) { - e.printStackTrace() - } - } - } - - private fun checkSend() { - val initInfo = InitialModel.get().cacheInitInfo ?: InitInfo() - val minNum = initInfo.redEnvelopeConfig.serverRedEnvelopeMinNum - val maxNum = initInfo.redEnvelopeConfig.serverRedEnvelopeMaxNum - val minGold = initInfo.redEnvelopeConfig.serverRedEnvelopeMinAmount - val maxGold = initInfo.redEnvelopeConfig.serverRedEnvelopeMaxAmount - val rate = - if (initInfo.redEnvelopeConfig.exchangeDiamondsRate == 0.0) 0.68 else initInfo.redEnvelopeConfig.exchangeDiamondsRate - - val redNum = mBinding?.etNum?.text.toString().toIntOrDef() - if (redNum < minNum || redNum > maxNum) { - SingleToastUtil.showToast("紅包數量不能小於${minNum}或大於${maxNum}!") - return - } - val goldNum = mBinding?.etMoney?.text.toString().toIntOrDef() - if (goldNum % 100 != 0) { - SingleToastUtil.showToast("鉆石數必須為100的倍數!") - return - } - if (goldNum < minGold || goldNum > maxGold) { - SingleToastUtil.showToast("鉆石數量不能小於${minGold}或大於${maxGold}!") - return - } - if (goldNum.toFloat() / redNum * rate < 0.1) {//單個手氣紅包價值不低於0.1水晶 - SingleToastUtil.showToast("單個紅包金額過低") - return - } - UserModel.get().cacheLoginUserInfo?.let { - if (!it.isBindPaymentPwd) { - ModifyPwdActivity.start(context, ModifyPwdActivity.PAY_PWD) - return - } - } - GiveGoldPassWordFragment.newInstance( - childFragmentManager, - mBinding?.etMoney?.text.toString() - ).apply { - setListener(object : GridPasswordNoFocusView.OnPasswordChangedListener { - override fun onTextChanged(psw: String?) { - val password = passWordFragment?.password?.password ?: "" - if (password.length == 6) { - send(password) - } - } - - override fun onInputFinish(psw: String?) { - } - }) - passWordFragment = this - } - } - - /** - * 密码输入完成 - */ - private fun send(password: String) { - dialogManager.showProgressDialog(context) - var message = mBinding.etText.text.trim().toString() - if (message.isEmpty()) { - message = R.string.red_package_msg_def.toStringRes() - } - RedPackageModel.sendRedPackage( - goldNum = mBinding.etMoney.text.trim().toString().toLongOrDefault(0), - message = message, - num = mBinding.etNum.text.trim().toString().toLongOrDefault(0), - roomUId = AvRoomDataManager.get().mCurrentRoomInfo?.uid.toString(), - type = 2, - kind = 0, - validityType = 0, - password = DESUtils.DESAndBase64(password) - ) - .compose(bindToLifecycle()) - .doOnError { - dialogManager.dismissDialog() - SingleToastUtil.showToast(it.message) - passWordFragment?.password?.clearPassword() - } - .subscribe { _ -> - PayModel.get().getWalletInfo(AuthModel.get().currentUid).subscribe() - dialogManager.dismissDialog() - SingleToastUtil.showToast("發送成功") - passWordFragment?.dismissAllowingStateLoss() - (parentFragment as? RedPackageSendDialog)?.dismissAllowingStateLoss() - } - } - - override fun onDestroy() { - super.onDestroy() - passWordFragment?.dismissAllowingStateLoss() - passWordFragment = null - } -} \ No newline at end of file diff --git a/app/src/main/java/com/chwl/app/avroom/redpackage/send/RedPackageSendDialog.kt b/app/src/main/java/com/chwl/app/avroom/redpackage/send/RedPackageSendDialog.kt deleted file mode 100644 index dedb408f8..000000000 --- a/app/src/main/java/com/chwl/app/avroom/redpackage/send/RedPackageSendDialog.kt +++ /dev/null @@ -1,172 +0,0 @@ -package com.chwl.app.avroom.redpackage.send - - -import android.annotation.SuppressLint -import android.os.Bundle -import android.view.Gravity -import android.view.WindowManager -import androidx.fragment.app.Fragment -import com.example.lib_utils.ktx.singleClick -import com.example.lib_utils.ktx.toStringRes -import com.chwl.app.R -import com.chwl.app.avroom.redpackage.RedPackageEvent -import com.chwl.app.base.BaseDialog -import com.chwl.app.common.ViewPagerAdapter -import com.chwl.app.databinding.RedPackageSendDialogBinding -import com.chwl.app.ui.pay.ChargeActivity -import com.chwl.app.ui.webview.CommonWebViewActivity -import com.chwl.app.ui.webview.DialogWebViewActivity -import com.chwl.app.ui.widget.magicindicator.ViewPagerHelper -import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator -import com.chwl.core.Constants -import com.chwl.core.UriProvider -import com.chwl.core.initial.InitialModel -import com.chwl.core.pay.PayModel -import com.chwl.core.pay.event.UpdateWalletInfoEvent -import com.chwl.core.redpackage.* -import com.chwl.library.annatation.ActLayoutRes -import com.chwl.library.common.util.DeviceUtil -import com.chwl.library.utils.AppMetaDataUtil -import com.chwl.library.utils.ResUtil -import com.chwl.library.utils.SingleToastUtil -import org.greenrobot.eventbus.EventBus -import org.greenrobot.eventbus.Subscribe -import org.greenrobot.eventbus.ThreadMode - -/** - * Created by Max on 2023/10/23 12:14 - * Desc:发红包 - **/ -@ActLayoutRes(R.layout.red_package_send_dialog) -class RedPackageSendDialog : BaseDialog() { - - private val permissionType: Int - get() = arguments?.getInt(com.chwl.core.support.config.Constants.KEY_INTENT) - ?: 0 - - /** - * 是否有厅内红包权限 - */ - private val haveRoomRedPackagePermission get() = (permissionType and 1) != 0 - - /** - * 是否有全服红包权限 - */ - private val haveAllServicePackagePermission get() = (permissionType and 2) != 0 - - companion object { - /** - * 红包权限类型 - */ - fun newInstance(permissionType: Int): RedPackageSendDialog { - return RedPackageSendDialog().apply { - this.arguments = Bundle().apply { - putInt( - com.chwl.core.support.config.Constants.KEY_INTENT, - permissionType - ) - } - } - } - } - - override fun onStart() { - gravity = Gravity.BOTTOM - width = WindowManager.LayoutParams.MATCH_PARENT - height = WindowManager.LayoutParams.WRAP_CONTENT - super.onStart() - } - - @SuppressLint("SetTextI18n") - override fun init() { - EventBus.getDefault().register(this) - if (!haveRoomRedPackagePermission && !haveAllServicePackagePermission) { - SingleToastUtil.showToast(R.string.avroom_presenter_avroompresenter_04) - dismissAllowingStateLoss() - return - } - if (InitialModel.get().cacheInitInfo == null) { - InitialModel.get().init(true) - SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_redpackage_redpackagesenddialog_01)) - dismissAllowingStateLoss() - return - } - initView() - initEvent() - PayModel.get().currentWalletInfo?.let { - binding.tvBalance.text = it.diamondNum.toLong().toString() - } - } - - private fun initView() { - val tabTitles = ArrayList() - val fragments = ArrayList() - if (haveRoomRedPackagePermission) { - tabTitles.add(R.string.red_package_room.toStringRes()) - fragments.add(PrivateRedPackageEditorFragment()) - } - if (haveAllServicePackagePermission) { - tabTitles.add(R.string.red_package_public.toStringRes()) - fragments.add(PublicRedPackageEditorFragment()) - } - val topMagicIndicatorAdapter = TabIndicatorAdapter(context, tabTitles) - topMagicIndicatorAdapter.setOnItemSelectListener { - binding.viewPager.currentItem = it - } - val commonNavigator = CommonNavigator(context) - commonNavigator.isAdjustMode = true - commonNavigator.adapter = topMagicIndicatorAdapter - binding.tabLayout.navigator = commonNavigator - binding.viewPager.adapter = ViewPagerAdapter( - childFragmentManager, - fragments.toList(), - null - ) - ViewPagerHelper.bind(binding.tabLayout, binding.viewPager) - } - - private fun initEvent() { - binding.vTopBlank.singleClick { - dismissAllowingStateLoss() - } - - binding.ivHelp.singleClick { - DialogWebViewActivity.start( - context, - UriProvider.getRedPacketRule() - ) - } - - binding.tvBalance.singleClick { -// if (AppMetaDataUtil.getChannelID() == Constants.GOOGLE) { - ChargeActivity.start(context) -// } else { -// CommonWebViewActivity.start( -// context, UriProvider.getOfficialPay( -// 4, -// DeviceUtil.getDeviceId(context) -// ) -// ) -// } - } - } - - override fun onDestroy() { - super.onDestroy() - EventBus.getDefault().unregister(this) - } - - @Subscribe(threadMode = ThreadMode.MAIN) - fun onWalletInfoUpdate(event: UpdateWalletInfoEvent?) { - if (!isViewLoaded) { - return - } - binding.tvBalance.text = PayModel.get().currentWalletInfo?.diamondNum?.toString() - ?: "0" - } - - @Subscribe(threadMode = ThreadMode.MAIN) - fun handleRedPackageDialog(event: RedPackageEvent?) { - dismissAllowingStateLoss() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/chwl/app/avroom/redpackage/send/RedPackageTypeItemAdapter.kt b/app/src/main/java/com/chwl/app/avroom/redpackage/send/RedPackageTypeItemAdapter.kt deleted file mode 100644 index daec058f3..000000000 --- a/app/src/main/java/com/chwl/app/avroom/redpackage/send/RedPackageTypeItemAdapter.kt +++ /dev/null @@ -1,76 +0,0 @@ -package com.chwl.app.avroom.redpackage.send - -import com.chad.library.adapter.base.BaseQuickAdapter -import com.chad.library.adapter.base.BaseViewHolder -import com.example.lib_utils.ktx.getColorById -import com.chwl.app.R -import io.realm.internal.Keep - -/** - * Created by Max on 2023/10/23 18:02 - * Desc: - **/ -class RedPackageTypeItemAdapter(list: List) : - BaseQuickAdapter( - R.layout.red_package_private_item_type, - list - ) { - - private var selectPosition = -1 - - @Keep - data class ItemData( - /** - * 红包种类 0 旧版本 1 无门槛红包 2 关注红包 3 分享红包 4 弹幕红包 - */ - val type: Int, val name: Int, val tips: Int - ) - - override fun convert(helper: BaseViewHolder, item: ItemData) { - helper.setText(R.id.tv_name, item.name) - helper.setText(R.id.tv_tips, item.tips) - convertState(helper, item) - } - - override fun convertPayloads( - helper: BaseViewHolder, - item: ItemData, - payloads: MutableList - ) { - super.convertPayloads(helper, item, payloads) - convertState(helper, item) - } - - private fun convertState(helper: BaseViewHolder, item: ItemData) { - if (helper.bindingAdapterPosition == selectPosition) { - helper.setBackgroundRes(R.id.layout_root, R.drawable.red_package_bg_type_selected) - helper.setTextColor( - R.id.tv_name, - helper.itemView.context.getColorById(R.color.color_FF285C) - ) - helper.setTextColor( - R.id.tv_tips, - helper.itemView.context.getColorById(R.color.color_FF285C) - ) - } else { - helper.setBackgroundRes(R.id.layout_root, R.drawable.shape_f8f8fa_8) - helper.setTextColor( - R.id.tv_name, - helper.itemView.context.getColorById(R.color.color_767585) - ) - helper.setTextColor( - R.id.tv_tips, - helper.itemView.context.getColorById(R.color.color_94959C) - ) - } - } - - fun select(position: Int) { - this.selectPosition = position - notifyItemRangeChanged(0, itemCount, true) - } - - fun getSelect(): ItemData? { - return data.getOrNull(selectPosition) - } -} \ No newline at end of file diff --git a/app/src/main/java/com/chwl/app/avroom/redpackage/send/TabIndicatorAdapter.java b/app/src/main/java/com/chwl/app/avroom/redpackage/send/TabIndicatorAdapter.java deleted file mode 100644 index 9440f8a6d..000000000 --- a/app/src/main/java/com/chwl/app/avroom/redpackage/send/TabIndicatorAdapter.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.chwl.app.avroom.redpackage.send; - -import android.content.Context; -import android.view.Gravity; -import android.view.View; -import android.view.ViewGroup; -import android.widget.FrameLayout; - -import androidx.appcompat.widget.AppCompatTextView; - -import com.chwl.app.R; -import com.chwl.library.common.util.Utils; -import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil; -import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter; -import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerIndicator; -import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerTitleView; -import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator; - -import java.util.List; - -/** - * @author jack - * @Description - * @Date 2018/11/1 - */ -public class TabIndicatorAdapter extends CommonNavigatorAdapter { - private List mTitleList; - private Context mContext; - - public TabIndicatorAdapter(Context mContext, List mTitleList ) { - this.mTitleList = mTitleList; - this.mContext = mContext; - } - - @Override - public int getCount() { - return mTitleList == null ? 0 : mTitleList.size(); - } - - @Override - public IPagerTitleView getTitleView(Context context, int index) { - ContactsPagerTitleView categoryPagerTitleView = new ContactsPagerTitleView(context, mTitleList.get(index)); - categoryPagerTitleView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (null != mOnItemSelectListener) { - mOnItemSelectListener.onItemSelect(index); - } - } - }); - return categoryPagerTitleView; - } - - @Override - public IPagerIndicator getIndicator(Context context) { - LinePagerIndicator indicator = new LinePagerIndicator(context); - indicator.setMode(LinePagerIndicator.MODE_EXACTLY); - indicator.setLineHeight(UIUtil.dip2px(mContext, 4)); - indicator.setRoundRadius(UIUtil.dip2px(mContext, 4)); - indicator.setLineWidth(UIUtil.dip2px(mContext, 12)); - indicator.setColors(context.getResources().getColor(R.color.color_FF285C)); - FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); - lp.topMargin = UIUtil.dip2px(mContext, 2); - indicator.setLayoutParams(lp); - return indicator; - } - - private OnItemSelectListener mOnItemSelectListener; - - public void setOnItemSelectListener(OnItemSelectListener onItemSelectListener) { - mOnItemSelectListener = onItemSelectListener; - } - - public interface OnItemSelectListener { - void onItemSelect(int position); - } - - class ContactsPagerTitleView extends AppCompatTextView implements IPagerTitleView { - - - public ContactsPagerTitleView(Context context, String tabInfo) { - super(context); - setHeight(Utils.dip2px(getContext(), 25)); - setTextSize(18); - setText(tabInfo); - setGravity(Gravity.CENTER); - - } - - - @Override - public void onSelected(int index, int totalCount) { -// setBackgroundResource(R.drawable.shape_bg_contact_indicator_item); - setTextColor(getResources().getColor(R.color.color_FF285C)); - } - - @Override - public void onDeselected(int index, int totalCount) { -// setBackgroundDrawable(null); - setTextColor(getResources().getColor(R.color.color_767585)); - } - - @Override - public void onLeave(int index, int totalCount, float leavePercent, boolean leftToRight) { - - } - - @Override - public void onEnter(int index, int totalCount, float enterPercent, boolean leftToRight) { - - } - } - - -} diff --git a/app/src/main/java/com/chwl/app/base/BaseActivity.java b/app/src/main/java/com/chwl/app/base/BaseActivity.java index c1464fac2..96b84e6be 100644 --- a/app/src/main/java/com/chwl/app/base/BaseActivity.java +++ b/app/src/main/java/com/chwl/app/base/BaseActivity.java @@ -68,9 +68,6 @@ import com.chwl.app.application.ReportManager; import com.chwl.app.application.App; import com.chwl.app.avroom.activity.AVRoomActivity; import com.chwl.app.avroom.firstcharge.FirstChargeDialog; -import com.chwl.app.avroom.redpackage.RedPackageGoRoomDialog; -import com.chwl.app.avroom.redpackage.RedPackageHandler; -import com.chwl.app.avroom.redpackage.open.RedPackageOpenDialog; import com.chwl.app.common.LoadingFragment; import com.chwl.app.common.NetworkErrorFragment; import com.chwl.app.common.NoDataFragment; @@ -940,29 +937,6 @@ public abstract class BaseActivity extends RxAppCompatActivity } } break; - case CUSTOM_MSG_RED_PACKAGE: - if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND) { - if (this instanceof AddUserInfoActivity || - UserUtils.getUserInfo() == null || - AvRoomDataManager.get().isSelfGamePlaying()) - return; - RedPackageNotifyInfo notifyInfo = new Gson().fromJson(String.valueOf(baseProtocol.getData()), RedPackageNotifyInfo.class); - RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo; - RoomContext roomContext = RoomContext.Companion.get(); - RedPackageHandler redPackageHandler = null; - if (roomContext != null) { - redPackageHandler = roomContext.findAbility(RedPackageHandler.class.getSimpleName()); - } - if (redPackageHandler != null) { - redPackageHandler.onAllServiceSignaling(this, notifyInfo); - } else { - if (roomInfo != null && roomInfo.getUid() == notifyInfo.getRoomUid() && context instanceof AVRoomActivity) { - RedPackageOpenDialog.Companion.newInstance(notifyInfo).show(BaseActivity.this); - } else { - RedPackageGoRoomDialog.Companion.newInstance(notifyInfo).show(this); - } - } - } case CUSTOM_MSG_VIP: if (baseProtocol.getSecond() == CUSTOM_MSG_VIP_USER_ALL_UPGRADE) { VipMessageInfo vipMessageInfo = new Gson().fromJson(String.valueOf(baseProtocol.getData()), VipMessageInfo.class); diff --git a/app/src/main/res/layout/fragment_av_room_game.xml b/app/src/main/res/layout/fragment_av_room_game.xml index 8dfbe97d5..61387347c 100644 --- a/app/src/main/res/layout/fragment_av_room_game.xml +++ b/app/src/main/res/layout/fragment_av_room_game.xml @@ -187,7 +187,7 @@ android:id="@+id/iv_first_charge_enter" android:layout_width="65dp" android:layout_height="65dp" - android:layout_above="@id/iv_radish_entrance" + android:layout_above="@id/iv_queuing_micro" android:layout_alignParentEnd="true" android:layout_marginEnd="15dp" android:layout_marginBottom="6dp" @@ -197,32 +197,6 @@ tools:contentDescription="@string/layout_fragment_av_room_game_02" tools:visibility="visible" /> - - - - - - - @@ -196,17 +182,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/red_package_open_item_result.xml b/app/src/main/res/layout/red_package_open_item_result.xml deleted file mode 100644 index a9f9a2cfb..000000000 --- a/app/src/main/res/layout/red_package_open_item_result.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/red_package_private_fragment.xml b/app/src/main/res/layout/red_package_private_fragment.xml deleted file mode 100644 index 5f6066d5c..000000000 --- a/app/src/main/res/layout/red_package_private_fragment.xml +++ /dev/null @@ -1,227 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/red_package_private_item_type.xml b/app/src/main/res/layout/red_package_private_item_type.xml deleted file mode 100644 index 9f321ede9..000000000 --- a/app/src/main/res/layout/red_package_private_item_type.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/red_package_public_fragment.xml b/app/src/main/res/layout/red_package_public_fragment.xml deleted file mode 100644 index e3aba3c18..000000000 --- a/app/src/main/res/layout/red_package_public_fragment.xml +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/red_package_send_dialog.xml b/app/src/main/res/layout/red_package_send_dialog.xml deleted file mode 100644 index 3d1fea15d..000000000 --- a/app/src/main/res/layout/red_package_send_dialog.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/red_package_widget.xml b/app/src/main/res/layout/red_package_widget.xml deleted file mode 100644 index 9ddba6de7..000000000 --- a/app/src/main/res/layout/red_package_widget.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/red_packet_dialog.xml b/app/src/main/res/layout/red_packet_dialog.xml deleted file mode 100644 index b981ce339..000000000 --- a/app/src/main/res/layout/red_packet_dialog.xml +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -