diff --git a/app/build.gradle b/app/build.gradle index 08160600b..251a4d493 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -290,6 +290,9 @@ dependencies { implementation 'com.github.fodroid:XRadioGroup:v1.5' implementation files('libs/msa_mdid_1.0.13.aar') + implementation "androidx.core:core-ktx:+" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } @@ -297,4 +300,5 @@ repositories { flatDir { dirs 'aliyun-libs', 'hw-push-libs', 'quick-pass-libs' } + mavenCentral() } 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 b7f6d1337..be9c82b96 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 @@ -19,6 +19,7 @@ import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; +import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; @@ -36,6 +37,8 @@ import com.opensource.svgaplayer.SVGAImageView; import com.opensource.svgaplayer.SVGAParser; import com.opensource.svgaplayer.SVGAVideoEntity; import com.orhanobut.logger.Logger; +import com.yinyuan.xchat_android_core.redpackage.RedPackageModel; +import com.yinyuan.xchat_android_core.redpackage.RedPackageNotifyInfo; import com.yizhuan.erban.R; import com.yizhuan.erban.avroom.fragment.AbsRoomFragment; import com.yizhuan.erban.avroom.fragment.HomePartyFragment; @@ -43,6 +46,7 @@ import com.yizhuan.erban.avroom.fragment.InputPwdDialogFragment; import com.yizhuan.erban.avroom.game.PlayGameActivity; import com.yizhuan.erban.avroom.presenter.AvRoomPresenter; import com.yizhuan.erban.avroom.presenter.HomePartyPresenter; +import com.yizhuan.erban.avroom.redpackage.RedPackageOpenDialog; import com.yizhuan.erban.avroom.view.IAvRoomView; import com.yizhuan.erban.base.BaseMvpActivity; import com.yizhuan.erban.base.TitleBar; @@ -69,6 +73,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.home.bean.BannerInfo; +import com.yizhuan.xchat_android_core.im.custom.bean.RedPackageAttachment; import com.yizhuan.xchat_android_core.im.game.ImGameMode; import com.yizhuan.xchat_android_core.manager.AvRoomDataManager; import com.yizhuan.xchat_android_core.manager.IMNetEaseManager; @@ -118,6 +123,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.Objects; import io.reactivex.Single; @@ -143,6 +149,13 @@ public class AVRoomActivity extends BaseMvpActivity openDialogs; + private static final int SHOW_RED_DIALOG_MAX = 10; /** * 管理限制进房 @@ -198,6 +213,18 @@ public class AVRoomActivity extends BaseMvpActivity redMap = DemoCache.readRedPackage(); + RedPackageModel.INSTANCE.getRedPackage(roomInfo.getUid()) + .compose(bindToLifecycle()) + .doFinally(() -> { + if (inRoomNotifyInfo != null && (redMap == null || !redMap.containsKey(inRoomNotifyInfo.getRedEnvelopeId()))) { + showRedPackageOpenDialog(inRoomNotifyInfo); + } + }) + .filter(notifyInfo -> inRoomNotifyInfo == null || !notifyInfo.getRedEnvelopeId().equals(inRoomNotifyInfo.getRedEnvelopeId())) + .subscribe(this::showRedPackageOpenDialog); + } + + private void showRedPackageOpenDialog(RedPackageNotifyInfo notifyInfo) { + if (!isResume) return; + if (openDialogs == null) { + openDialogs = new ArrayList<>(); + } + RedPackageOpenDialog openDialog = RedPackageOpenDialog.Companion.newInstance(notifyInfo); + openDialog.show(this); + if (openDialog.getDialog() != null) { + openDialog.getDialog().setOnDismissListener(dialog -> openDialogs.remove(openDialog)); + } + openDialogs.add(openDialog); + if (openDialogs.size() >= SHOW_RED_DIALOG_MAX) { + openDialogs.get(SHOW_RED_DIALOG_MAX - 1).dismissAllowingStateLoss(); + } + } + + private void dismissRedPackageDialog() { + if (openDialogs != null) { + openDialogs.clear(); + } + if (mCurrentFragment instanceof HomePartyFragment) { + ((HomePartyFragment) mCurrentFragment).dismissSendRedPackageDialog(); + } + } + private void showPartyRoomTip() { boolean isFirst = (boolean) SharedPreferenceUtils.get(SHOW_PARTY_ROOM_FIRST_ENTER_TIP, true); if (isFirst) { diff --git a/app/src/main/java/com/yizhuan/erban/avroom/adapter/BaseMicroViewAdapter.java b/app/src/main/java/com/yizhuan/erban/avroom/adapter/BaseMicroViewAdapter.java index eb329fc1b..d9ee76bbb 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/adapter/BaseMicroViewAdapter.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/adapter/BaseMicroViewAdapter.java @@ -254,6 +254,8 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter buttonItemList, String uid) { GiftDialog.GIFT_DIALOG_FROM = "房间"; - UserInfoDialog dialog = new UserInfoDialog(mContext, JavaUtil.str2long(uid), buttonItemList, true); - dialog.show(); + userInfoDialog = new UserInfoDialog(mContext, JavaUtil.str2long(uid), buttonItemList, true); + userInfoDialog.show(); //getDialogManager().showCommonPopupDialog(buttonItemList, getString(R.string.cancel)); } @@ -1853,6 +1860,21 @@ public class HomePartyRoomFragment extends BaseMvpFragment(layoutId) { + + override fun convert(helper: BaseViewHolder, item: RedEnvelopeGiftItemVO) { + ImageLoadUtils.loadAvatar(mContext, item.giftVo?.giftUrl, helper.getView(R.id.iv_gift)) + helper.setText(R.id.tv_gift_num, "x${item.giftNum}") + helper.getView(R.id.tv_gift_name)?.let { + it.text = item.giftVo?.giftName + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/yizhuan/erban/avroom/redpackage/RedPackageGoRoomDialog.kt b/app/src/main/java/com/yizhuan/erban/avroom/redpackage/RedPackageGoRoomDialog.kt new file mode 100644 index 000000000..adfd0db20 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/avroom/redpackage/RedPackageGoRoomDialog.kt @@ -0,0 +1,87 @@ +package com.yizhuan.erban.avroom.redpackage + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.WindowManager +import android.view.animation.AnimationUtils + +import com.yinyuan.xchat_android_core.redpackage.RedPackageNotifyInfo +import com.yizhuan.erban.R +import com.yizhuan.erban.avroom.activity.AVRoomActivity + +import com.yizhuan.erban.base.BaseDialog +import com.yizhuan.erban.common.widget.dialog.DialogManager +import com.yizhuan.erban.databinding.DialogRedPackageGoRoomBinding +import com.yizhuan.erban.ui.utils.ImageLoadUtils +import com.yizhuan.xchat_android_core.manager.AvRoomDataManager +import com.yizhuan.xchat_android_core.utils.subAndReplaceDot + +class RedPackageGoRoomDialog : BaseDialog() { + + + 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 initBinding(inflater: LayoutInflater): DialogRedPackageGoRoomBinding { + return DialogRedPackageGoRoomBinding.inflate(inflater) + } + + 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() + } +// StatUtil.onEvent("gethongbao_get", "进房抢红包弹窗-进房抢") + if (AvRoomDataManager.get().isOwnerOnMic && AvRoomDataManager.get().roomId != redPackageNotifyInfo.roomUid) { + //如果显示这个弹窗的时候,又收到了一个全服,再次点击进房抢的时候需要关闭前面的那个 + dialogManager?.dismissDialog() + dialogManager = DialogManager(context) + dialogManager?.showOkCancelDialog("是否下麦退出当前房间?", 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", "进房抢红包弹窗") + } + + override fun onDestroy() { + super.onDestroy() + dialogManager = null + } +} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/redpackage/RedPackageOpenAdapter.kt b/app/src/main/java/com/yizhuan/erban/avroom/redpackage/RedPackageOpenAdapter.kt new file mode 100644 index 000000000..ce2922b46 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/avroom/redpackage/RedPackageOpenAdapter.kt @@ -0,0 +1,41 @@ +package com.yizhuan.erban.avroom.redpackage + +import android.graphics.Color +import android.view.View +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.yinyuan.xchat_android_core.redpackage.RedEnvelopeItemVO +import com.yizhuan.erban.R +import com.yizhuan.erban.ui.utils.ImageLoadUtils +import com.yizhuan.erban.utils.UserUtils +import com.yizhuan.xchat_android_core.utils.subAndReplaceDot +import java.text.SimpleDateFormat +import java.util.* + +class RedPackageOpenAdapter : BaseQuickAdapter(R.layout.item_red_package_diamond) { + private val dateFormat = SimpleDateFormat("MM月dd日 HH:mm", Locale.CHINA) + override fun convert(helper: BaseViewHolder, item: RedEnvelopeItemVO) { + ImageLoadUtils.loadAvatar(mContext, item.userVO.avatar, helper.getView(R.id.iv_avatar)) + val isSelf = item.userVO.uid == UserUtils.getUserUid() + helper.setText(R.id.tv_nickname, if (isSelf) "我" else item.userVO.nick.subAndReplaceDot(6)) + .setTextColor(R.id.tv_nickname, Color.parseColor(if (isSelf) "#FDCD00" else "#FFFFFF")) + .setText(R.id.tv_time, dateFormat.format(item.createTime)) + .setText(R.id.tv_diamond_num, item.amount) + + item.redEnvelopeGiftItemVOs?.let { + if (it.isNotEmpty()) { + helper.setGone(R.id.tv_diamond_num, false) + .setGone(R.id.tv_diamond, false) + val rvGift = helper.getView(R.id.rv_gift) + val adapter = RedPackageGiftAdapter() + rvGift.visibility = View.VISIBLE + rvGift.layoutManager = LinearLayoutManager(mContext, RecyclerView.HORIZONTAL, false) + rvGift.adapter = adapter + adapter.setNewData(it) + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/yizhuan/erban/avroom/redpackage/RedPackageOpenDialog.kt b/app/src/main/java/com/yizhuan/erban/avroom/redpackage/RedPackageOpenDialog.kt new file mode 100644 index 000000000..2b3fde02b --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/avroom/redpackage/RedPackageOpenDialog.kt @@ -0,0 +1,176 @@ +package com.yizhuan.erban.avroom.redpackage + +import android.animation.Animator +import android.animation.AnimatorListenerAdapter +import android.animation.ObjectAnimator +import android.annotation.SuppressLint +import android.graphics.Color +import android.os.Bundle +import android.text.style.ForegroundColorSpan +import android.view.LayoutInflater +import android.view.View +import android.view.WindowManager +import android.view.animation.AccelerateDecelerateInterpolator +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView + + +import com.yinyuan.xchat_android_core.redpackage.* +import com.yinyuan.xchat_android_core.redpackage.RedEnvelopeState.Companion.REMAIN_ZERO +import com.yinyuan.xchat_android_core.redpackage.RedEnvelopeState.Companion.SUCCESS +import com.yinyuan.xchat_android_core.redpackage.RedEnvelopeState.Companion.TIME_OUT +import com.yinyuan.xchat_android_core.redpackage.RedEnvelopeState.Companion.TIME_OUT_BACK +import com.yizhuan.erban.R +import com.yizhuan.erban.avroom.widget.MessageView + +import com.yizhuan.erban.base.BaseDialog +import com.yizhuan.erban.databinding.DialogGameResultBinding +import com.yizhuan.erban.databinding.DialogRedPackageOpenBinding +import com.yizhuan.erban.ui.utils.ImageLoadUtils +import com.yizhuan.erban.utils.UserUtils +import com.yizhuan.xchat_android_core.DemoCache +import com.yizhuan.xchat_android_core.redpackage.ALL_DIAMOND +import com.yizhuan.xchat_android_core.redpackage.ALL_GIFT +import com.yizhuan.xchat_android_library.utils.SingleToastUtil + +class RedPackageOpenDialog : BaseDialog() { + + private var mObjectAnimator: ObjectAnimator? = null + + private val redPackageNotifyInfo by lazy { arguments?.getSerializable(KEY_NOTIFY_INFO) as RedPackageNotifyInfo } + + private var isOpened = false + private var redPackageInfo: RedPackageInfo? = null + + companion object { + private const val KEY_NOTIFY_INFO = "redPackageNotifyInfo" + fun newInstance(redPackageNotifyInfo: RedPackageNotifyInfo): RedPackageOpenDialog { + return RedPackageOpenDialog().apply { + arguments = Bundle().apply { + putSerializable(KEY_NOTIFY_INFO, redPackageNotifyInfo) + } + } + } + } + + override fun initBinding(inflater: LayoutInflater): DialogRedPackageOpenBinding { + return DialogRedPackageOpenBinding.inflate(inflater) + } + + override fun onStart() { + width = WindowManager.LayoutParams.MATCH_PARENT + height = WindowManager.LayoutParams.WRAP_CONTENT + super.onStart() + } + + override fun init() { + dialog?.setCanceledOnTouchOutside(false) + binding.ivClose.setOnClickListener { dismissAllowingStateLoss() } + binding.ivOpen.setOnClickListener { + startRedPacketAnim(it) + it.isEnabled = false + } + redPackageNotifyInfo.let { + ImageLoadUtils.loadAvatar(context, it.sendUserAvatar, binding.ivAvatar) + binding.tvContent.text = it.redEnvelopeMessage + binding.tvNickname.text = it.sendUserNick + } +// StatUtil.onEvent("openhongbao", "当前房开红包弹窗") + } + + @SuppressLint("CheckResult") + private fun startRedPacketAnim(v: View) { + RedPackageModel.openRedPackage(redPackageNotifyInfo.redEnvelopeId) + .subscribe({ + redPackageInfo = it + if (mObjectAnimator?.isRunning == false) { + openRedPackage() + } + }, { + binding.ivOpen.isEnabled = true + mObjectAnimator?.cancel() + SingleToastUtil.showToast(it.message) + }) + mObjectAnimator = ObjectAnimator.ofFloat(v, "rotationY", 0f, 360f) + mObjectAnimator?.let { + it.duration = 1500 + it.interpolator = AccelerateDecelerateInterpolator() + it.addListener(object : AnimatorListenerAdapter() { + + var isCanceled = false + override fun onAnimationCancel(animation: Animator?) { + isCanceled = true + } + + override fun onAnimationEnd(animation: Animator?) { + if (!isCanceled) { + openRedPackage() + } + } + }) + it.start() + } +// StatUtil.onEvent("openhongbao_open", "当前房开红包弹窗-开启") + } + + @SuppressLint("SetTextI18n") + private fun openRedPackage() { + if (isOpened) return + redPackageInfo?.let { packageInfo -> + isOpened = true + binding.clOpened.visibility = View.VISIBLE + binding.clRed.visibility = View.GONE + binding.tvNicknameOpened.text = redPackageNotifyInfo.sendUserNick + ImageLoadUtils.loadAvatar(context, redPackageNotifyInfo.sendUserAvatar, binding.ivAvatarOpened) + packageInfo.redEnvelopeVO?.apply { + binding.tvContentOpened.text = message + when (packageInfo.redEnvelopeState) { + SUCCESS -> { + packageInfo.redEnvelopeItemVOs?.firstOrNull { item -> item.userVO.uid == UserUtils.getUserUid() }?.let { + it.redEnvelopeGiftItemVOs?.apply { + if (!isEmpty()) { + val adapter = RedPackageGiftAdapter(R.layout.item_red_package_gift_top) + binding.rvGift.visibility = View.VISIBLE + binding.tvDiamondNum.visibility = View.GONE + binding.tvDiamond.visibility = View.GONE + binding.rvGift.layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false) + binding.rvGift.adapter = adapter + adapter.setNewData(this) + binding.tvTips.setTextColor(Color.WHITE) + binding.tvTips.text = MessageView.SpannableBuilder(binding.tvTips) + .append("礼物已存入背包,总价值") + .append(it.amount, ForegroundColorSpan(Color.parseColor("#FDCD00"))) + .append("钻石") + .build() + } + } + binding.tvDiamondNum.text = it.amount + } + } + TIME_OUT, REMAIN_ZERO, TIME_OUT_BACK -> { + binding.clOpened.setBackgroundResource(R.drawable.room_red_package_no_get_bg) + binding.tvDiamondNum.visibility = View.GONE + binding.tvDiamond.visibility = View.GONE + binding.tvTips.visibility = View.GONE + binding.tvNoGet.visibility = View.VISIBLE + } + } + binding.tvRedNum.text = "已领取${pickNum}/${totalNum}个" + if (type == ALL_GIFT || type == ALL_DIAMOND) { + DemoCache.saveRedPackage(id) + } + } + val adapter = RedPackageOpenAdapter() + binding.rvUsers.adapter = adapter + binding.rvUsers.layoutManager = LinearLayoutManager(context) + adapter.setNewData(packageInfo.redEnvelopeItemVOs) + } + } + + override fun onDestroyView() { + super.onDestroyView() + mObjectAnimator?.cancel() + mObjectAnimator = null + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/yizhuan/erban/avroom/redpackage/RedPackageSendDialog.kt b/app/src/main/java/com/yizhuan/erban/avroom/redpackage/RedPackageSendDialog.kt new file mode 100644 index 000000000..8c81a61f1 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/avroom/redpackage/RedPackageSendDialog.kt @@ -0,0 +1,237 @@ +package com.yizhuan.erban.avroom.redpackage + +import android.annotation.SuppressLint +import android.content.Intent +import android.graphics.Paint +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.LayoutInflater +import android.view.View +import android.view.WindowManager +import com.jungly.gridpasswordview.GridPasswordView +import com.yinyuan.xchat_android_core.redpackage.RedPackageModel + + + +import com.yizhuan.erban.base.BaseDialog +import com.yizhuan.erban.common.widget.dialog.DialogManager +import com.yizhuan.erban.databinding.DialogRedPackageSendBinding +import com.yizhuan.erban.pay.password.GiveGoldPassWordFragment +import com.yizhuan.erban.ui.login.BinderPhoneActivity +import com.yizhuan.erban.ui.pay.ChargeActivity +import com.yizhuan.erban.ui.setting.ModifyPwdActivity +import com.yizhuan.erban.ui.webview.DialogWebViewActivity +import com.yizhuan.xchat_android_core.UriProvider +import com.yizhuan.xchat_android_core.initial.InitialModel +import com.yizhuan.xchat_android_core.manager.AvRoomDataManager +import com.yizhuan.xchat_android_core.pay.PayModel +import com.yizhuan.xchat_android_core.pay.event.UpdateWalletInfoEvent +import com.yizhuan.xchat_android_core.redpackage.ALL_DIAMOND +import com.yizhuan.xchat_android_core.redpackage.ALL_GIFT +import com.yizhuan.xchat_android_core.redpackage.ROOM_DIAMOND +import com.yizhuan.xchat_android_core.redpackage.ROOM_GIFT +import com.yizhuan.xchat_android_core.user.UserModel +import com.yizhuan.xchat_android_core.utils.toIntOrDef +import com.yizhuan.xchat_android_library.utils.SingleToastUtil +import com.yizhuan.xchat_android_library.utils.codec.DESUtils +import org.greenrobot.eventbus.EventBus +import org.greenrobot.eventbus.Subscribe +import org.greenrobot.eventbus.ThreadMode + +class RedPackageSendDialog : BaseDialog(), GridPasswordView.OnPasswordChangedListener, TextWatcher { + + private var passWordFragment: GiveGoldPassWordFragment? = null + private val dialogManager by lazy { DialogManager(context) } + private var isAll = false + private var isGift = false + + + override fun initBinding(inflater: LayoutInflater): DialogRedPackageSendBinding { + return DialogRedPackageSendBinding.inflate(inflater) + } + + override fun onStart() { + width = WindowManager.LayoutParams.MATCH_PARENT + height = WindowManager.LayoutParams.WRAP_CONTENT + super.onStart() + } + + @SuppressLint("SetTextI18n") + override fun init() { + EventBus.getDefault().register(this) + PayModel.get().currentWalletInfo?.let { + binding.tvBalanceNum.text = it.diamondNum.toString() + } + val initInfo = InitialModel.get().cacheInitInfo + fun changeToAll() { + isAll = true + binding.tvAllRed.alpha = 1f + binding.tvRoomRed.alpha = 0.5f + binding.indicatorAllRed.visibility = View.VISIBLE + binding.indicatorRoomRed.visibility = View.GONE + binding.tvGoldNumHint.text = "红包总金额不低于${initInfo.redEnvelopeConfig.serverRedEnvelopeMinAmount}钻石,且必须为100的倍数" + binding.editRedNum.hint = "${initInfo.redEnvelopeConfig.serverRedEnvelopeMinNum}-${initInfo.redEnvelopeConfig.serverRedEnvelopeMaxNum}" + } + + fun changeToNotAll() { + isAll = false + binding.tvAllRed.alpha = 0.5f + binding.tvRoomRed.alpha = 1f + binding.indicatorAllRed.visibility = View.GONE + binding.indicatorRoomRed.visibility = View.VISIBLE + binding.tvGoldNumHint.text = "红包总金额不低于${initInfo.redEnvelopeConfig.roomRedEnvelopeMinAmount}钻石,且必须为100的倍数" + binding.editRedNum.hint = "${initInfo.redEnvelopeConfig.roomRedEnvelopeMinNum}-${initInfo.redEnvelopeConfig.roomRedEnvelopeMaxNum}" + } + when (initInfo.redEnvelopedPosition) { + 2 -> changeToAll() + else -> changeToNotAll() + } + binding.tvCharge.paint.flags = Paint.UNDERLINE_TEXT_FLAG + binding.tvCharge.paint.isAntiAlias = true + binding.tvChangeType.paint.flags = Paint.UNDERLINE_TEXT_FLAG + binding.tvChangeType.paint.isAntiAlias = true + binding.tvChangeType.setOnClickListener { + if (isGift) { + isGift = false + binding.tvRedTypeHint.text = "当前为手气红包," + binding.tvChangeType.text = "改为礼物红包" + } else { + isGift = true + binding.tvRedTypeHint.text = "当前为礼物红包," + binding.tvChangeType.text = "改为手气红包" + } + } + //默认就已经是手气红包,如果后台配置为了礼物红包就在这里改下 + if (initInfo.redEnvelopeType == 2 && !isGift) { + binding.tvChangeType.callOnClick() + } + + binding.tvCharge.setOnClickListener { ChargeActivity.start(context) } + binding.ivClose.setOnClickListener { dismissAllowingStateLoss() } + binding.ivHelp.setOnClickListener { DialogWebViewActivity.start(context, UriProvider.getRedPacketRule()) } + binding.ivSend.setOnClickListener { + UserModel.get().cacheLoginUserInfo?.let { + if (!it.isBindPhone) { + startActivity(Intent(context, BinderPhoneActivity::class.java)) + return@setOnClickListener + } else if (!it.isBindPaymentPwd) { + ModifyPwdActivity.start(context, ModifyPwdActivity.PAY_PWD) + return@setOnClickListener + } + } + val minNum = if (isAll) initInfo.redEnvelopeConfig.serverRedEnvelopeMinNum else initInfo.redEnvelopeConfig.roomRedEnvelopeMinNum + val maxNum = if (isAll) initInfo.redEnvelopeConfig.serverRedEnvelopeMaxNum else initInfo.redEnvelopeConfig.roomRedEnvelopeMaxNum + val minGold = if (isAll) initInfo.redEnvelopeConfig.serverRedEnvelopeMinAmount else initInfo.redEnvelopeConfig.roomRedEnvelopeMinAmount + val maxGold = if (isAll) initInfo.redEnvelopeConfig.serverRedEnvelopeMaxAmount else initInfo.redEnvelopeConfig.roomRedEnvelopeMaxAmount + val rate = if (initInfo.redEnvelopeConfig.exchangeDiamondsRate == 0.0) 0.68 else initInfo.redEnvelopeConfig.exchangeDiamondsRate + + val redNum = binding.editRedNum.text.toString().toIntOrDef() + if (redNum < minNum || redNum > maxNum) { + SingleToastUtil.showToast("红包数量不能小于${minNum}或大于${maxNum}!") + return@setOnClickListener + } + val goldNum = binding.editGoldNum.text.toString().toIntOrDef() + if (goldNum % 100 != 0) { + SingleToastUtil.showToast("钻石数必须为100的倍数!") + return@setOnClickListener + } + if (goldNum < minGold || goldNum > maxGold) { + SingleToastUtil.showToast("钻石数量不能小于${minGold}或大于${maxGold}!") + return@setOnClickListener + } + if (isGift && goldNum.toFloat() / redNum < 1) {//单个礼物红包价值不低于1钻石 + SingleToastUtil.showToast("单个红包金额过低") + return@setOnClickListener + } + if (!isGift && goldNum.toFloat() / redNum * rate < 0.1) {//单个手气红包价值不低于0.1水晶 + SingleToastUtil.showToast("单个红包金额过低") + return@setOnClickListener + } + GiveGoldPassWordFragment.newInstance(requireFragmentManager(), binding.editGoldNum.text.toString()).apply { + setListener(this@RedPackageSendDialog) + passWordFragment = this + } + }; + binding.tvAllRed.setOnClickListener { + if (isAll) return@setOnClickListener + changeToAll() + } + binding.tvRoomRed.setOnClickListener { + if (!isAll) return@setOnClickListener + changeToNotAll() + } + binding.editRedText.addTextChangedListener(this) + + binding.editRedText.setOnEditorActionListener { _, _, event -> + event.keyCode == KeyEvent.KEYCODE_ENTER + } + +// StatUtil.onEvent("room_sendhongbao", "进入发红包页面") + } + + private fun getRedType(): Int { + return if (isAll) { + if (isGift) ALL_GIFT else ALL_DIAMOND + } else { + if (isGift) ROOM_GIFT else ROOM_DIAMOND + } + } + + override fun onDestroyView() { + binding.editRedText.removeTextChangedListener(this) + super.onDestroyView() + } + + + @SuppressLint("CheckResult") + override fun onTextChanged(psw: String) { + val password = passWordFragment?.password?.password ?: "" + if (password.length == 6) { + dialogManager.showProgressDialog(context) + RedPackageModel.sendRedPackage(binding.editGoldNum.text.toString(), + binding.editRedText.text.toString().ifEmpty { "恭喜发财,大吉大利!" }, + binding.editRedNum.text.toString(), + AvRoomDataManager.get().mCurrentRoomInfo?.uid.toString(), getRedType(), DESUtils.DESAndBase64(password)) + .doOnError { + dialogManager.dismissDialog() + SingleToastUtil.showToast(it.message) + passWordFragment?.password?.clearPassword() + } + .subscribe { _ -> + dialogManager.dismissDialog() + SingleToastUtil.showToast("发送成功") +// StatUtil.onEvent("room_sendhongbao_success", "发红包成功") + passWordFragment?.dismissAllowingStateLoss() + dismissAllowingStateLoss() + } + } + } + + @Subscribe(threadMode = ThreadMode.MAIN) + fun onWalletInfoUpdate(event: UpdateWalletInfoEvent?) { + binding.tvBalanceNum.text = PayModel.get().currentWalletInfo?.getGoldNum()?.toString() + ?: "0" + } + + override fun onDestroy() { + super.onDestroy() + EventBus.getDefault().unregister(this) + } + + override fun onInputFinish(psw: String) { + + } + + @SuppressLint("SetTextI18n") + override fun afterTextChanged(s: Editable) { + binding.tvRedTextLimit.text = "${s.length}/20" + } + + override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { + } + + override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java b/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java index 40995d47b..8d85cf2ed 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java @@ -45,6 +45,7 @@ import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum; import com.netease.nimlib.sdk.msg.model.IMMessage; import com.orhanobut.logger.Logger; import com.tongdaxing.erban.sadmin.utils.SaAttachmentToMsgUtil; +import com.yinyuan.xchat_android_core.redpackage.RedEnvelopeRoomMsg; import com.yizhuan.erban.R; import com.yizhuan.erban.UIHelper; import com.yizhuan.erban.avroom.activity.AVRoomActivity; @@ -89,6 +90,7 @@ import com.yizhuan.xchat_android_core.im.custom.bean.MonsterStatusAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.MultiGiftAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.MusicInfoAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.NobleAttachment; +import com.yizhuan.xchat_android_core.im.custom.bean.RedPackageRoomMsgAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment2; @@ -164,6 +166,11 @@ import io.reactivex.functions.Consumer; import io.reactivex.functions.Function; import lombok.Setter; +import static com.yizhuan.xchat_android_core.redpackage.RedPackageTypeKt.ALL_DIAMOND; +import static com.yizhuan.xchat_android_core.redpackage.RedPackageTypeKt.ALL_GIFT; +import static com.yizhuan.xchat_android_core.redpackage.RedPackageTypeKt.ROOM_DIAMOND; +import static com.yizhuan.xchat_android_core.redpackage.RedPackageTypeKt.ROOM_GIFT; + /** * 直播间消息界面 * @@ -172,7 +179,7 @@ import lombok.Setter; public class MessageView extends FrameLayout { private static final String TAG = "MessageView"; - + private final int textColor = 0x80ffffff; private final static int MAX_MESSAGE_SIZE = 2000;//公屏最多展示条数 private final static int BLOCK_MAX_MESSAGE_SIZE = MAX_MESSAGE_SIZE * 3 / 2;//在查看消息停住的时候 最多消息条数. private RecyclerView messageListView; @@ -768,6 +775,8 @@ public class MessageView extends FrameLayout { //收藏了房间 setFollowRoomTip(tvContent, (RoomTipAttachment) attachment, chatRoomMessage); } + } else if (second == CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_MSG) { + setRedPackageMsg(chatRoomMessage, tvContent); } else { tvContent.setTextColor(Color.WHITE); @@ -818,6 +827,35 @@ public class MessageView extends FrameLayout { tvContent.setMovementMethod(new LinkMovementMethod()); } + private void setRedPackageMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) { + if (chatRoomMessage.getAttachment() instanceof RedPackageRoomMsgAttachment) { + RedPackageRoomMsgAttachment attachment = (RedPackageRoomMsgAttachment) chatRoomMessage.getAttachment(); + + RedEnvelopeRoomMsg roomMsg = attachment.getRedEnvelopeRoomMsg(); + String openNickname = RegexUtil.getPrintableString(roomMsg.getOpenRedEnvelopeUserNick()); + String sendNickname = RegexUtil.getPrintableString(roomMsg.getRedEnvelopeMasterNick()); + SpannableBuilder text = new SpannableBuilder(tvContent) + .append(openNickname, new ForegroundColorSpan(roomTipColor)) + .append("打开", new ForegroundColorSpan(textColor)) + .append(sendNickname, new ForegroundColorSpan(roomTipColor)); + switch (roomMsg.getRedEnvelopeType()) { + case ALL_DIAMOND: + case ROOM_DIAMOND: + text.append("的红包领取了", new ForegroundColorSpan(textColor)) + .append(roomMsg.getAmount() + "水晶", new ForegroundColorSpan(roomTipColor)); + tvContent.setText(text.build()); + break; + case ALL_GIFT: + case ROOM_GIFT: + text.append("的红包领取了价值", new ForegroundColorSpan(textColor)) + .append(roomMsg.getAmount() + "灵石", new ForegroundColorSpan(roomTipColor)) + .append("的礼物", new ForegroundColorSpan(textColor)); + tvContent.setText(text.build()); + } + } + + } + /** * 提示加入话题 * diff --git a/app/src/main/java/com/yizhuan/erban/base/BaseActivity.java b/app/src/main/java/com/yizhuan/erban/base/BaseActivity.java index 379bda1cc..196c4d4d9 100644 --- a/app/src/main/java/com/yizhuan/erban/base/BaseActivity.java +++ b/app/src/main/java/com/yizhuan/erban/base/BaseActivity.java @@ -26,6 +26,7 @@ import androidx.fragment.app.FragmentManager; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; import com.netease.nim.uikit.common.util.log.LogUtil; import com.netease.nimlib.sdk.NIMSDK; import com.netease.nimlib.sdk.Observer; @@ -35,10 +36,14 @@ import com.readystatesoftware.systembartint.SystemBarTintManager; import com.tbruyelle.rxpermissions2.RxPermissions; import com.trello.rxlifecycle3.android.ActivityEvent; import com.trello.rxlifecycle3.components.support.RxAppCompatActivity; +import com.yinyuan.xchat_android_core.redpackage.RedPackageNotifyInfo; import com.yizhuan.erban.MiddleActivity; import com.yizhuan.erban.NimMiddleActivity; import com.yizhuan.erban.R; import com.yizhuan.erban.application.XChatApplication; +import com.yizhuan.erban.avroom.activity.AVRoomActivity; +import com.yizhuan.erban.avroom.redpackage.RedPackageGoRoomDialog; +import com.yizhuan.erban.avroom.redpackage.RedPackageOpenDialog; import com.yizhuan.erban.common.LoadingFragment; import com.yizhuan.erban.common.NetworkErrorFragment; import com.yizhuan.erban.common.NoDataFragment; @@ -59,14 +64,17 @@ import com.yizhuan.erban.ui.login.RegisterActivity; import com.yizhuan.erban.ui.pay.ChargeActivity; import com.yizhuan.erban.ui.widget.DefaultToolBar; import com.yizhuan.erban.ui.widget.dialog.OpenNobleGlobalNoticeDialog; +import com.yizhuan.erban.utils.UserUtils; import com.yizhuan.tutu.mentoring_relationship.dialog.GrabApprenticesNoticeDialog; import com.yizhuan.xchat_android_constants.XChatConstants; import com.yizhuan.xchat_android_core.bean.BaseProtocol; +import com.yizhuan.xchat_android_core.manager.AvRoomDataManager; import com.yizhuan.xchat_android_core.manager.IMNetEaseManager; import com.yizhuan.xchat_android_core.manager.RoomEvent; import com.yizhuan.xchat_android_core.mentoring_relationship.event.GrabApprenticesEvent; import com.yizhuan.xchat_android_core.noble.NobleInfo; import com.yizhuan.xchat_android_core.noble.NobleProtocol; +import com.yizhuan.xchat_android_core.room.bean.RoomInfo; import com.yizhuan.xchat_android_core.statistic.StatisticManager; import com.yizhuan.xchat_android_library.rxbus.RxBus; import com.yizhuan.xchat_android_library.utils.ImeUtil; @@ -91,6 +99,9 @@ import static com.yizhuan.xchat_android_core.Constants.DEBUG_MAX_UID; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_HEAD_NOBLE; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_OPENNOBLE; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_RENEWNOBLE; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_GIFT; /** @@ -643,15 +654,6 @@ public abstract class BaseActivity extends RxAppCompatActivity getSupportFragmentManager().beginTransaction().replace(status.getId(), fragment, STATUS_TAG).commitAllowingStateLoss(); } - public void showCustomFragment(Fragment fragment) { - View status = findViewById(R.id.status_layout); - if (status == null || status.getId() <= 0) { - MLog.error(this, "xuwakao, had not set layout id "); - return; - } - getSupportFragmentManager().beginTransaction().replace(status.getId(), fragment, STATUS_TAG).commitAllowingStateLoss(); - } - @Override public void showLoading(View view, int drawable, int tips) { @@ -978,6 +980,22 @@ public abstract class BaseActivity extends RxAppCompatActivity } } break; + case CUSTOM_MSG_RED_PACKAGE: + switch (baseProtocol.getSecond()) { + case CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_GIFT: + case CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND: + if (this instanceof AddUserInfoActivity || this instanceof LoginActivity || UserUtils.getUserInfo() == null) + return; + RedPackageNotifyInfo notifyInfo = new Gson().fromJson(String.valueOf(baseProtocol.getData()), RedPackageNotifyInfo.class); + RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo; + if (roomInfo != null && roomInfo.getUid() == notifyInfo.getRoomUid() && context instanceof AVRoomActivity) { + RedPackageOpenDialog.Companion.newInstance(notifyInfo).show(this); + } else { + RedPackageGoRoomDialog.Companion.newInstance(notifyInfo).show(this); + } + break; + } + break; default: break; } diff --git a/app/src/main/java/com/yizhuan/erban/base/BaseDialog.kt b/app/src/main/java/com/yizhuan/erban/base/BaseDialog.kt new file mode 100644 index 000000000..2a4d66c56 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/base/BaseDialog.kt @@ -0,0 +1,61 @@ +package com.yizhuan.erban.base + +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.* +import androidx.fragment.app.FragmentActivity +import androidx.viewbinding.ViewBinding +import com.netease.nim.uikit.common.util.sys.ScreenUtil +import com.trello.rxlifecycle3.components.support.RxDialogFragment +import java.lang.Exception + +abstract class BaseDialog : RxDialogFragment() { + + private var _binding: T? = null + val binding get() = _binding!! + var width = ScreenUtil.getDialogWidth() + var height = WindowManager.LayoutParams.WRAP_CONTENT + + override fun onStart() { + super.onStart() + val window = dialog?.window + if (window != null) { + window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + val windowParams = window.attributes + windowParams.width = width + windowParams.height = height + windowParams.dimAmount = 0.5f + windowParams.gravity = Gravity.CENTER + window.attributes = windowParams + } + } + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + _binding = initBinding(inflater) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + init() + } + + fun show(context: Context?) { + try { + show((context as FragmentActivity).supportFragmentManager, null) + } catch (e: Exception) { + e.printStackTrace() + } + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + + abstract fun initBinding(inflater: LayoutInflater): T + + abstract fun init() +} \ No newline at end of file diff --git a/app/src/main/java/com/yizhuan/erban/common/EmptyViewHelper.java b/app/src/main/java/com/yizhuan/erban/common/EmptyViewHelper.java new file mode 100644 index 000000000..88768d946 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/common/EmptyViewHelper.java @@ -0,0 +1,33 @@ +package com.yizhuan.erban.common; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import com.yizhuan.erban.R; +import com.yizhuan.xchat_android_library.utils.NetworkUtils; + + +public class EmptyViewHelper { + + public static View createEmptyView(Context context, String text) { + if (!NetworkUtils.isNetworkAvailable(context)) text = "网络异常,请检查网络再试~"; + View view = LayoutInflater.from(context).inflate(R.layout.layout_ktv_empty, null); + view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + ((TextView) view.findViewById(R.id.tv_hint)).setText(text); + return view; + } + + public static View createDarkEmptyView(Context context, String text) { + if (!NetworkUtils.isNetworkAvailable(context)) text = "网络异常,请检查网络再试~"; + View view = LayoutInflater.from(context).inflate(R.layout.layout_ktv_empty, null); + view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + ((TextView) view.findViewById(R.id.tv_hint)).setText(text); + ((ImageView) view.findViewById(R.id.iv_status)).setImageResource(R.drawable.empty_content_dark); + return view; + } + +} diff --git a/app/src/main/java/com/yizhuan/erban/pay/activity/GiveGoldActivity.kt b/app/src/main/java/com/yizhuan/erban/pay/activity/GiveGoldActivity.kt new file mode 100644 index 000000000..f66b47698 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/pay/activity/GiveGoldActivity.kt @@ -0,0 +1,65 @@ +package com.yinyuan.doudou.pay.activity + +import android.annotation.SuppressLint +import android.app.Activity +import android.content.Intent +import android.os.Bundle +import androidx.recyclerview.widget.LinearLayoutManager +import com.yinyuan.doudou.pay.adapter.LatelyGiveAdapter +import com.yizhuan.erban.R +import com.yizhuan.erban.base.BaseActivity +import com.yizhuan.erban.common.EmptyViewHelper +import com.yizhuan.xchat_android_core.room.bean.SearchRoomInfo +import com.yizhuan.xchat_android_core.user.UserModel +import com.yizhuan.xchat_android_core.user.bean.UserInfo +import kotlinx.android.synthetic.main.activity_give_gold.* + + +class GiveGoldActivity : BaseActivity() { + + private lateinit var adapter: LatelyGiveAdapter + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_give_gold) + initTitleBar("钻石转赠") + recyclerView.layoutManager = LinearLayoutManager(this) + adapter = LatelyGiveAdapter() + adapter.bindToRecyclerView(recyclerView) + adapter.emptyView = EmptyViewHelper.createEmptyView(this, "暂无数据") + adapter.setOnItemClickListener { _, _, position -> + adapter.getItem(position)?.let { + GiveGoldToUserActivity.start(this, it) + } + } + llSearch.setOnClickListener { GiveGoldSearchActivity.start(this) } + } + + @SuppressLint("CheckResult") + override fun onResume() { + super.onResume() + UserModel.get().giveUserList + .compose(bindToLifecycle()) + .doOnError { toast(it.message) } + .subscribe { users -> + adapter.setNewData(users.filterNotNull()) + } + } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) + if (resultCode == Activity.RESULT_OK && requestCode == GiveGoldSearchActivity.REQUEST_CODE) { + GiveGoldToUserActivity.start(this, UserInfo().apply { + val room = data?.getParcelableExtra("searchRoomInfo") + room?.let { + birth = it.birth + erbanNo = it.erbanNo + uid = it.uid + nick = it.nick + avatar = it.avatar + } + }) + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/yizhuan/erban/pay/activity/GiveGoldSearchActivity.kt b/app/src/main/java/com/yizhuan/erban/pay/activity/GiveGoldSearchActivity.kt new file mode 100644 index 000000000..0d19575e9 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/pay/activity/GiveGoldSearchActivity.kt @@ -0,0 +1,83 @@ +package com.yinyuan.doudou.pay.activity + +import android.annotation.SuppressLint +import android.app.Activity +import android.content.Intent +import android.os.Bundle +import android.os.Parcelable +import androidx.recyclerview.widget.LinearLayoutManager +import android.text.Editable +import android.text.TextWatcher +import com.yinyuan.doudou.pay.adapter.GiveSearchAdapter +import com.yizhuan.erban.R +import com.yizhuan.erban.base.BaseActivity +import com.yizhuan.erban.common.EmptyViewHelper +import com.yizhuan.erban.ui.utils.RVDelegate +import com.yizhuan.xchat_android_core.room.bean.SearchRoomInfo +import com.yizhuan.xchat_android_core.room.model.AvRoomModel +import com.yizhuan.xchat_android_core.utils.net.RxHelper + + +import kotlinx.android.synthetic.main.activity_give_gold_search.* + +class GiveGoldSearchActivity : BaseActivity(), TextWatcher { + + companion object { + const val REQUEST_CODE = 0xff12 + + @JvmStatic + fun start(context: Activity) { + val intent = Intent(context, GiveGoldSearchActivity::class.java) + context.startActivityForResult(intent, REQUEST_CODE) + } + } + + private lateinit var rvDelegate: RVDelegate + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_give_gold_search) + val adapter = GiveSearchAdapter() + rvDelegate = RVDelegate.Builder() + .setPageSize(Int.MAX_VALUE) + .setEmptyView(EmptyViewHelper.createEmptyView(this, "暂无搜索内容")) + .setLayoutManager(LinearLayoutManager(this)) + .setRecyclerView(recyclerView) + .setAdapter(adapter) + .build() + adapter.setOnItemClickListener { _, _, position -> + setResult(Activity.RESULT_OK, Intent().apply { + adapter.getItem(position)?.let { + putExtra("searchRoomInfo", it as Parcelable) + } + }) + finish() + } + editSearch.addTextChangedListener(this) + tvCancel.setOnClickListener { finish() } + } + + override fun afterTextChanged(s: Editable?) { + + } + + override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { + } + + @SuppressLint("CheckResult") + override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { + if (s.isNullOrEmpty()) { + rvDelegate.setNewData(null) + } else { + AvRoomModel.get() + .roomSearch(s.toString()) + .compose(RxHelper.handleBeanData()) + .doOnError { rvDelegate.loadErr(true) } + .compose(bindToLifecycle()) + .subscribe { rooms -> + rvDelegate.setNewData(rooms) + } + } + + } +} diff --git a/app/src/main/java/com/yizhuan/erban/pay/activity/GiveGoldSuccessActivity.kt b/app/src/main/java/com/yizhuan/erban/pay/activity/GiveGoldSuccessActivity.kt new file mode 100644 index 000000000..1ad7ea5df --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/pay/activity/GiveGoldSuccessActivity.kt @@ -0,0 +1,33 @@ +package com.yizhuan.erban.pay.activity + +import android.content.Context +import android.content.Intent +import android.os.Bundle +import com.yizhuan.erban.R +import com.yizhuan.erban.base.BaseActivity + +import kotlinx.android.synthetic.main.activity_give_gold_success.* + +class GiveGoldSuccessActivity : BaseActivity() { + + companion object { + @JvmStatic + fun start(context: Context, gold: String, nickname: String) { + val intent = Intent(context, GiveGoldSuccessActivity::class.java) + intent.putExtra("gold", gold) + intent.putExtra("nickname", nickname) + context.startActivity(intent) + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_give_gold_success) + initTitleBar("转赠到寻梦帐号") + tvNickname.text = "转赠给:${intent.getStringExtra("nickname")}" + tvGold.text = "${intent.getStringExtra("gold").toInt()}钻石" + tvSure.setOnClickListener { finish() } + } + + +} diff --git a/app/src/main/java/com/yizhuan/erban/pay/activity/GiveGoldToUserActivity.kt b/app/src/main/java/com/yizhuan/erban/pay/activity/GiveGoldToUserActivity.kt new file mode 100644 index 000000000..d7f851bfd --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/pay/activity/GiveGoldToUserActivity.kt @@ -0,0 +1,113 @@ +package com.yinyuan.doudou.pay.activity + +import android.annotation.SuppressLint +import android.content.Context +import android.content.Intent +import android.os.Bundle +import android.text.Editable +import android.text.TextWatcher +import com.jungly.gridpasswordview.GridPasswordView +import com.yizhuan.erban.R +import com.yizhuan.erban.base.BaseActivity +import com.yizhuan.erban.pay.activity.GiveGoldSuccessActivity +import com.yizhuan.erban.pay.password.GiveGoldPassWordFragment +import com.yizhuan.erban.ui.utils.ImageLoadUtils +import com.yizhuan.xchat_android_core.DemoCache +import com.yizhuan.xchat_android_core.pay.PayModel +import com.yizhuan.xchat_android_core.user.bean.UserInfo + +import kotlinx.android.synthetic.main.activity_give_gold_to_user.* + +class GiveGoldToUserActivity : BaseActivity(), GridPasswordView.OnPasswordChangedListener, TextWatcher { + + companion object { + @JvmStatic + fun start(context: Context, user: UserInfo) { + val intent = Intent(context, GiveGoldToUserActivity::class.java) + intent.putExtra("user", user) + context.startActivity(intent) + } + } + + private var userInfo: UserInfo? = null + private var passWordFragment: GiveGoldPassWordFragment? = null + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_give_gold_to_user) + userInfo = intent.getSerializableExtra("user") as UserInfo? + init() + } + + @SuppressLint("SetTextI18n") + private fun init() { + initTitleBar("转赠到寻梦帐号") + userInfo?.apply { + tvId.text = "Id:${erbanNo}" + tvNickname.text = nick + ImageLoadUtils.loadAvatar(context, avatar, ivAvatar) + val initInfo = DemoCache.readInitInfo() + editGold.hint = if (initInfo.redEnvelopeConfig.rate == 0.0) "请输入转赠钻石数量" else "请输入转赠钻石数量,需为10倍数" + tv_desc.text = if (initInfo.redEnvelopeConfig.rate == 0.0) "钻石" else "钻石,另将收取一定比例手续费" + + tvSure.setOnClickListener { + var gold = editGold.text.toString().toInt() + if (gold <= 0) { + toast("请输入正确钻石数量") + return@setOnClickListener + } + var rateGold = gold * initInfo.redEnvelopeConfig.rate / 100 + GiveGoldPassWordFragment.newInstance(supportFragmentManager, gold.toString(), nick, if (rateGold == 0.0) "" else "手续费:(${initInfo.redEnvelopeConfig.rate.toInt()}%): ${rateGold}钻石") + .apply { + passWordFragment = this + setListener(this@GiveGoldToUserActivity) + } + } + } + tvCoin.text = PayModel.get().currentWalletInfo?.canGiveGoldNum?.toString() ?: "0" + editGold.addTextChangedListener(this) + } + + @SuppressLint("CheckResult") + override fun onInputFinish(psw: String) { + } + + override fun onTextChanged(psw: String) { + val password = passWordFragment?.password?.password ?: "" + if (password.length == 6) { + userInfo?.apply { + dialogManager.showProgressDialog(context) + PayModel.get().giveGold(uid, editGold.text.toString(), password) + .compose(bindToLifecycle()) + .doOnError { + toast(it.message) + passWordFragment?.password?.clearPassword() + dialogManager.dismissDialog() + } + .subscribe { _ -> + passWordFragment?.dismissAllowingStateLoss() + dialogManager.dismissDialog() + finish() + GiveGoldSuccessActivity.start(context, editGold.text.toString(), nick) + } + } + } + } + + override fun afterTextChanged(s: Editable?) { + } + + override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { + } + + override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { + if (s.isNullOrBlank()) { + editGold.textSize = 15f + tvSure.isEnabled = false + } else { + editGold.textSize = 35f + tvSure.isEnabled = true + } + } + +} diff --git a/app/src/main/java/com/yizhuan/erban/pay/adapter/ChargeAdapter.java b/app/src/main/java/com/yizhuan/erban/pay/adapter/ChargeAdapter.java new file mode 100644 index 000000000..e3788e8bc --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/pay/adapter/ChargeAdapter.java @@ -0,0 +1,30 @@ +package com.yizhuan.erban.pay.adapter; + +import android.text.TextUtils; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.chad.library.adapter.base.BaseViewHolder; +import com.yizhuan.erban.R; +import com.yizhuan.xchat_android_core.pay.bean.ChargeBean; + + +/** + *

充值adapter

+ * Created by Administrator on 2017/11/20. + */ +public class ChargeAdapter extends BaseQuickAdapter { + public ChargeAdapter() { + super(R.layout.list_item_charge); + } + + @Override + protected void convert(BaseViewHolder baseViewHolder, ChargeBean chargeBean) { + if (chargeBean == null) return; + baseViewHolder +// .setText(R.id.item_charge_gold, chargeBean.chargeGoldNum) + .setText(R.id.tv_desc, chargeBean.prodDesc) +// .setText(R.id.item_charge_money, "" + chargeBean.money) + .setGone(R.id.tv_desc, !TextUtils.isEmpty(chargeBean.prodDesc)); + } + +} diff --git a/app/src/main/java/com/yizhuan/erban/pay/adapter/GiveSearchAdapter.kt b/app/src/main/java/com/yizhuan/erban/pay/adapter/GiveSearchAdapter.kt new file mode 100644 index 000000000..112f6f4d9 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/pay/adapter/GiveSearchAdapter.kt @@ -0,0 +1,37 @@ +package com.yinyuan.doudou.pay.adapter + +import android.annotation.SuppressLint +import android.graphics.Color +import android.widget.TextView +import com.chad.library.adapter.base.BaseQuickAdapter +import com.chad.library.adapter.base.BaseViewHolder +import com.coorchice.library.SuperTextView +import com.yizhuan.erban.R +import com.yizhuan.erban.ui.utils.ImageLoadUtils +import com.yizhuan.xchat_android_core.room.bean.SearchRoomInfo +import com.yizhuan.xchat_android_core.utils.CurrentTimeUtils + + +class GiveSearchAdapter : BaseQuickAdapter(R.layout.item_lately_give) { + + @SuppressLint("SetTextI18n") + override fun convert(helper: BaseViewHolder, item: SearchRoomInfo) { + helper.getView(R.id.tv_id).text = "Id:${item.erbanNo}" + helper.getView(R.id.tv_nickname).text = item.nick + setGenderAndBirth(helper.getView(R.id.tv_gender), item.gender, item.birth) + ImageLoadUtils.loadAvatar(mContext, item.avatar, helper.getView(R.id.iv_avatar)) + } + + private fun setGenderAndBirth(tvGender: SuperTextView, gender: Int, birth: Long) { + if (gender == 1) { + tvGender.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_man_white, 0, 0, 0) + tvGender.solid = Color.parseColor("#FF72D1E7") + } + if (gender == 2) { + tvGender.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_women_white, 0, 0, 0) + tvGender.solid = Color.parseColor("#FFEF82B6") + } + tvGender.text = ((CurrentTimeUtils.getCurrentTime() - birth) / 1000 / 60 / 60 / 24 / 365).toString() + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/yizhuan/erban/pay/adapter/LatelyGiveAdapter.kt b/app/src/main/java/com/yizhuan/erban/pay/adapter/LatelyGiveAdapter.kt new file mode 100644 index 000000000..3d493eef3 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/pay/adapter/LatelyGiveAdapter.kt @@ -0,0 +1,37 @@ +package com.yinyuan.doudou.pay.adapter + +import android.annotation.SuppressLint +import android.graphics.Color +import android.widget.TextView +import com.chad.library.adapter.base.BaseQuickAdapter +import com.chad.library.adapter.base.BaseViewHolder +import com.coorchice.library.SuperTextView +import com.yizhuan.erban.R +import com.yizhuan.erban.ui.utils.ImageLoadUtils +import com.yizhuan.xchat_android_core.user.bean.UserInfo +import com.yizhuan.xchat_android_core.utils.CurrentTimeUtils + + +class LatelyGiveAdapter : BaseQuickAdapter(R.layout.item_lately_give) { + + @SuppressLint("SetTextI18n") + override fun convert(helper: BaseViewHolder, item: UserInfo) { + helper.getView(R.id.tv_id).text = "Id:${item.erbanNo}" + helper.getView(R.id.tv_nickname).text = item.nick + setGenderAndBirth(helper.getView(R.id.tv_gender), item.gender, item.birth) + ImageLoadUtils.loadAvatar(mContext, item.avatar, helper.getView(R.id.iv_avatar)) + } + + private fun setGenderAndBirth(tvGender: SuperTextView, gender: Int, birth: Long) { + if (gender == 1) { + tvGender.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_man_white, 0, 0, 0) + tvGender.solid = Color.parseColor("#FF72D1E7") + } + if (gender == 2) { + tvGender.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_women_white, 0, 0, 0) + tvGender.solid = Color.parseColor("#FFEF82B6") + } + tvGender.text = ((CurrentTimeUtils.getCurrentTime() - birth) / 1000 / 60 / 60 / 24 / 365).toString() + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/yizhuan/erban/pay/password/GiveGoldPassWordFragment.java b/app/src/main/java/com/yizhuan/erban/pay/password/GiveGoldPassWordFragment.java new file mode 100644 index 000000000..0d8362fc4 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/pay/password/GiveGoldPassWordFragment.java @@ -0,0 +1,132 @@ +package com.yizhuan.erban.pay.password; + + +import android.graphics.drawable.ColorDrawable; +import android.os.Bundle; +import android.text.TextUtils; +import android.util.DisplayMetrics; +import android.view.Display; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; + +import androidx.annotation.Nullable; +import androidx.fragment.app.DialogFragment; +import androidx.fragment.app.FragmentManager; + +import com.jungly.gridpasswordview.GridPasswordView; +import com.yizhuan.erban.R; +import com.yizhuan.erban.ui.setting.VerifyPhoneActivity; + + +//也可继承design中的BottomSheetDialogFragment +public class GiveGoldPassWordFragment extends DialogFragment { + + private GiveGoldPasswordView mPassword; + + private GridPasswordView.OnPasswordChangedListener listener; + + private static GiveGoldPassWordFragment passWordFragment; + + private static final String EXTRA_GOLD = "gold"; + private static final String EXTRA_NICKNAME = "nickname"; + private static final String EXTRA_GOLD_RATE = "rate"; + + public static GiveGoldPassWordFragment newInstance(FragmentManager fragmentManager, String gold) { + if (passWordFragment == null) { + passWordFragment = new GiveGoldPassWordFragment(); + Bundle bundle = new Bundle(); + bundle.putString(EXTRA_GOLD, gold); + passWordFragment.setArguments(bundle); + passWordFragment.show(fragmentManager, "GiveGoldPassWordFragment"); + } + return passWordFragment; + } + + /** + * @param gold 金额 + * @param nickname 转账对象昵称 + * @param rate 手续费 + * @return + */ + public static GiveGoldPassWordFragment newInstance(FragmentManager fragmentManager, String gold, String nickname, String rate) { + if (passWordFragment == null) { + passWordFragment = new GiveGoldPassWordFragment(); + Bundle bundle = new Bundle(); + bundle.putString(EXTRA_GOLD, gold); + bundle.putString(EXTRA_NICKNAME, nickname); + bundle.putString(EXTRA_GOLD_RATE, rate); + passWordFragment.setArguments(bundle); + passWordFragment.show(fragmentManager, "GiveGoldPassWordFragment"); + } + return passWordFragment; + } + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + //继承BottomSheetDialogFragment时onStart()可注释掉 + @Override + public void onStart() { + super.onStart(); + Window window = getDialog().getWindow(); + if (window != null) { + window.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparent))); + WindowManager.LayoutParams layoutParams = window.getAttributes(); + DisplayMetrics dm = new DisplayMetrics(); + Display d = window.getWindowManager().getDefaultDisplay(); + d.getRealMetrics(dm); + window.getWindowManager().getDefaultDisplay().getMetrics(dm); + layoutParams.width = dm.widthPixels; + layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; + window.setAttributes(layoutParams); + } + + } + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.dialog_give_gold_password, container); + init(view); + return view; + } + + private void init(View view) { + mPassword = view.findViewById(R.id.give_gold_password_view); + mPassword.getCloseImageView().setOnClickListener(view12 -> dismiss()); + mPassword.getForgetTextView().setOnClickListener(view1 -> VerifyPhoneActivity.start(getActivity(), true)); + mPassword.getPswView().setOnPasswordChangedListener(listener); + if (getArguments() != null) { + if (!TextUtils.isEmpty(getArguments().getString(EXTRA_NICKNAME))) { + mPassword.getTvNickname().setText("转赠给:" + getArguments().getString(EXTRA_NICKNAME)); + } else { + mPassword.getTvNickname().setVisibility(View.GONE); + } + if (!TextUtils.isEmpty(getArguments().getString(EXTRA_GOLD_RATE))) { + mPassword.getTvRate().setText(getArguments().getString(EXTRA_GOLD_RATE)); + } else { + mPassword.getTvRate().setVisibility(View.GONE); + } + mPassword.getTvGold().setText(getArguments().getString(EXTRA_GOLD) + "钻石"); + } + } + + public void setListener(GridPasswordView.OnPasswordChangedListener listener) { + this.listener = listener; + } + + public GiveGoldPasswordView getPassword() { + return mPassword; + } + + @Override + public void onDestroy() { + super.onDestroy(); + passWordFragment = null; + } +} diff --git a/app/src/main/java/com/yizhuan/erban/pay/password/GiveGoldPasswordView.java b/app/src/main/java/com/yizhuan/erban/pay/password/GiveGoldPasswordView.java new file mode 100644 index 000000000..52e5bb86c --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/pay/password/GiveGoldPasswordView.java @@ -0,0 +1,136 @@ +package com.yizhuan.erban.pay.password; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.jungly.gridpasswordview.GridPasswordView; +import com.yizhuan.erban.R; +import com.yizhuan.erban.ui.widget.password.PasswordKeyboardView; + + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by lcw on 2016/11/28. + */ + +public class GiveGoldPasswordView extends RelativeLayout { + + private ImageView mClose; + private TextView mTitle; + private TextView mForgetPwd; + private GridPasswordView mPassword; + private TextView tvNickname; + private TextView tvRate; + private TextView tvGold; + private PasswordKeyboardView mKeyboard; + private List passwordList;//记录键盘输入的值 + private StringBuilder mValue;//最后保存的密码 + + public GiveGoldPasswordView(Context context) { + this(context, null); + } + + public GiveGoldPasswordView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public GiveGoldPasswordView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + View.inflate(context, R.layout.view_give_gold_password, this); + initView(); + initEvent(); + } + + private void initView() { + mPassword = findViewById(R.id.view_password); + mClose = findViewById(R.id.img_close); + mTitle = findViewById(R.id.tv_title); + mForgetPwd = findViewById(R.id.tv_forgetPwd); + mKeyboard = findViewById(R.id.view_keyboard); + tvGold = findViewById(R.id.tv_gold); + tvNickname = findViewById(R.id.tv_nickname); + tvRate = findViewById(R.id.tv_rate); + //打乱数字的位置 + //mKeyboard.shuffleKeyboard(); + } + + private void initEvent() { + mValue = new StringBuilder(); + passwordList = new ArrayList<>(); + mKeyboard.setIOnKeyboardListener(new PasswordKeyboardView.IOnKeyboardListener() { + + @Override + public void onInsertKeyEvent(String text) { + mValue.setLength(0); + passwordList.add(text); + for (int i = 0; i < passwordList.size(); i++) { + mValue.append(passwordList.get(i)); + } + mPassword.setPassword(mValue.toString()); + } + + @Override + public void onDeleteKeyEvent() { + mValue.setLength(0); + if (passwordList.size() != 0) { + passwordList.remove(passwordList.size() - 1); + for (int i = 0; i < passwordList.size(); i++) { + mValue.append(passwordList.get(i)); + } + mPassword.setPassword(mValue.toString()); + } + } + }); + } + + //获取输入的密码 + public String getPassword() { + return mValue.toString(); + } + + //取消 + public ImageView getCloseImageView() { + return mClose; + } + + //标题 + public TextView getTitleTextView() { + return mTitle; + } + + //忘记密码 + public TextView getForgetTextView() { + return mForgetPwd; + } + + + public TextView getTvNickname() { + return tvNickname; + } + + public TextView getTvRate() { + return tvRate; + } + + public TextView getTvGold() { + return tvGold; + } + + //输入密码控件 + public GridPasswordView getPswView() { + return mPassword; + } + + public void clearPassword(){ + mValue.setLength(0); + mPassword.clearPassword(); + passwordList.clear(); + } + +} diff --git a/app/src/main/java/com/yizhuan/erban/pay/presenter/ChargePresenter.java b/app/src/main/java/com/yizhuan/erban/pay/presenter/ChargePresenter.java new file mode 100644 index 000000000..32db54ef9 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/pay/presenter/ChargePresenter.java @@ -0,0 +1,83 @@ +package com.yizhuan.erban.pay.presenter; + +import android.annotation.SuppressLint; +import android.content.Context; + +import com.yizhuan.erban.pay.view.IChargeView; +import com.yizhuan.xchat_android_core.pay.PayModel; +import com.yizhuan.xchat_android_core.user.UserModel; +import com.yizhuan.xchat_android_core.user.bean.UserInfo; + +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; + +/** + * Created by MadisonRong on 05/01/2018. + */ +public class ChargePresenter extends PayPresenter { + + private static final String TAG = "ChargePresenter"; + + public ChargePresenter() { + this.payModel = PayModel.get(); + } + + /** + * 加载用户信息(显示用户账号和钱包余额) + */ + public void loadUserInfo() { + UserInfo userInfo = UserModel.get().getCacheLoginUserInfo(); + if (userInfo != null) { + getMvpView().setupUserInfo(userInfo); + } + refreshWalletInfo(false); + } + + /** + * 获取充值产品列表 + */ + @SuppressLint("CheckResult") + public void getChargeList() { + payModel.getChargeList(1) + .compose(bindToLifecycle()) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(chargeBeans -> { + if (chargeBeans != null) { + getMvpView().buildChargeList(chargeBeans); + } else { + getMvpView().getChargeListFail("请求数据为空"); + } + }); + } + + /** + * 显示充值选项(支付宝或者微信) + */ + public void showChargeOptionsDialog() { + getMvpView().displayChargeOptionsDialog(); + } + + /** + * 发起充值 + * @param context context + * @param chargeProdId 充值产品 ID + * @param payChannel 充值渠道,目前只支持 + * {@link com.yinyuan.xchat_android_core.Constants#CHARGE_ALIPAY} 和 + * {@link com.yinyuan.xchat_android_core.Constants#CHARGE_WX} + */ + @SuppressLint("CheckResult") + public void requestCharge(Context context, String chargeProdId, String payChannel) { + payModel.requestCharge(context, chargeProdId, payChannel) + .compose(bindToLifecycle()) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(jsonObject -> { + if (jsonObject != null) { + getMvpView().getChargeOrOrderInfo(jsonObject.toString()); + } else { + getMvpView().getChargeOrOrderInfoFail("请求错误"); + } + }); + } +} diff --git a/app/src/main/java/com/yizhuan/erban/pay/presenter/PayPresenter.java b/app/src/main/java/com/yizhuan/erban/pay/presenter/PayPresenter.java new file mode 100644 index 000000000..6588d581f --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/pay/presenter/PayPresenter.java @@ -0,0 +1,47 @@ +package com.yizhuan.erban.pay.presenter; + +import android.annotation.SuppressLint; + +import com.yizhuan.erban.pay.view.IPayView; +import com.yizhuan.xchat_android_core.pay.PayModel; +import com.yizhuan.xchat_android_core.pay.bean.WalletInfo; +import com.yizhuan.xchat_android_library.base.AbstractMvpPresenter; + +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; + +/** + * Created by MadisonRong on 08/01/2018. + */ + +public class PayPresenter extends AbstractMvpPresenter { + + protected PayModel payModel; + protected WalletInfo walletInfo; + + public PayPresenter() { + this.payModel = PayModel.get(); + } + + /** + * 刷新钱包信息 + */ + @SuppressLint("CheckResult") + public void refreshWalletInfo(boolean force) { + payModel.getWalletInfo() + .compose(bindToLifecycle()) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(walletInfo -> { + if (walletInfo != null) { + // cache walletInfo for calling in the future + this.walletInfo = walletInfo; + PayModel.get().setCurrentWalletInfo(walletInfo); + getMvpView().setupUserWalletBalance(walletInfo); + } else { + getMvpView().getUserWalletInfoFail("请求错误"); + } + }); + + } +} diff --git a/app/src/main/java/com/yizhuan/erban/pay/view/IChargeView.java b/app/src/main/java/com/yizhuan/erban/pay/view/IChargeView.java new file mode 100644 index 000000000..0dd33f8b5 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/pay/view/IChargeView.java @@ -0,0 +1,26 @@ +package com.yizhuan.erban.pay.view; + + +import com.yizhuan.xchat_android_core.pay.bean.ChargeBean; +import com.yizhuan.xchat_android_core.user.bean.UserInfo; + +import java.util.List; + +/** + * Created by MadisonRong on 05/01/2018. + */ + +public interface IChargeView extends IPayView { + + public void setupUserInfo(UserInfo userInfo); + + public void buildChargeList(List chargeBeanList); + + public void getChargeListFail(String error); + + public void displayChargeOptionsDialog(); + + public void getChargeOrOrderInfo(String data); + + public void getChargeOrOrderInfoFail(String error); +} diff --git a/app/src/main/java/com/yizhuan/erban/pay/view/IPayView.java b/app/src/main/java/com/yizhuan/erban/pay/view/IPayView.java new file mode 100644 index 000000000..7670a34b8 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/pay/view/IPayView.java @@ -0,0 +1,16 @@ +package com.yizhuan.erban.pay.view; + + +import com.yizhuan.xchat_android_core.pay.bean.WalletInfo; +import com.yizhuan.xchat_android_library.base.IMvpBaseView; + +/** + * Created by MadisonRong on 08/01/2018. + */ + +public interface IPayView extends IMvpBaseView { + + public void setupUserWalletBalance(WalletInfo walletInfo); + + public void getUserWalletInfoFail(String error); +} diff --git a/app/src/main/java/com/yizhuan/erban/ui/utils/RVDelegate.java b/app/src/main/java/com/yizhuan/erban/ui/utils/RVDelegate.java new file mode 100644 index 000000000..77a73ebb2 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/ui/utils/RVDelegate.java @@ -0,0 +1,192 @@ +package com.yizhuan.erban.ui.utils; + +import android.view.View; + +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.chad.library.adapter.base.BaseViewHolder; +import com.netease.nim.uikit.common.util.sys.NetworkUtil; +import com.yizhuan.erban.base.IDataStatus; +import com.yizhuan.erban.common.EmptyViewHelper; +import com.yizhuan.xchat_android_library.utils.ListUtils; + + +import java.util.List; + +/** + * 无聊写的,好像没什么用的样子 + * create time 2018/11/28 + * + * @param Adapter对应数据类型 + */ + +public class RVDelegate { + private BaseQuickAdapter adapter; + private RecyclerView recyclerView; + private SwipeRefreshLayout refreshLayout; + private int pageSize; + private IDataStatus dataStatus; + private View emptyView; + + private RVDelegate(BaseQuickAdapter adapter, RecyclerView.LayoutManager layoutManager, RecyclerView recyclerView, SwipeRefreshLayout refreshLayout, IDataStatus dataStatus, View emptyView, int pageSize) { + this.adapter = adapter; + this.recyclerView = recyclerView; + this.pageSize = pageSize; + this.dataStatus = dataStatus; + this.refreshLayout = refreshLayout; + this.emptyView = emptyView; + recyclerView.setLayoutManager(layoutManager); + adapter.bindToRecyclerView(recyclerView); + } + + public void addData(List data) { + if (data != null) { + adapter.addData(data); + } + if (data != null && data.size() >= pageSize) { + adapter.loadMoreComplete(); + } else { + adapter.loadMoreEnd(); + } + } + + public void setNewData(List data) { + adapter.setNewData(data); + if (emptyView != null && ListUtils.isListEmpty(data)) { + adapter.setEmptyView(emptyView); + } + adapter.disableLoadMoreIfNotFullPage(); + if (refreshLayout != null) refreshLayout.setRefreshing(false); + if (dataStatus != null) { + if (!ListUtils.isListEmpty(data)) { + dataStatus.hideStatus(); + } else { + dataStatus.showNoData(); + } + } + } + + public void setNewData(List data, View headView) { + adapter.setNewData(data); + if (emptyView != null && ListUtils.isListEmpty(data)) { + adapter.setEmptyView(emptyView); + } + adapter.removeAllHeaderView(); + if (headView != null) { + adapter.addHeaderView(headView); + } + adapter.disableLoadMoreIfNotFullPage(); + if (refreshLayout != null) refreshLayout.setRefreshing(false); + if (dataStatus != null) { + if (!ListUtils.isListEmpty(data)) { + dataStatus.hideStatus(); + } else { + dataStatus.showNoData(); + } + } + } + + public BaseQuickAdapter getAdapter() { + return adapter; + } + + public void loadData(List data, boolean isRefresh) { + if (isRefresh) { + setNewData(data); + } else { + addData(data); + } + } + + public void loadData(List data, View headView, boolean isRefresh) { + if (isRefresh) { + setNewData(data, headView); + } else { + addData(data); + } + } + + public void loadErr(boolean isRefresh) { + if (isRefresh) { + if (!NetworkUtil.isNetAvailable(recyclerView.getContext())) { + adapter.setEmptyView(EmptyViewHelper.createEmptyView(recyclerView.getContext(), "网络异常,请检查网络再试")); + } else if (emptyView != null) { + adapter.setEmptyView(emptyView); + } + if (refreshLayout != null) refreshLayout.setRefreshing(false); + if (dataStatus != null) { + if (NetworkUtil.isNetAvailable(recyclerView.getContext())) { + dataStatus.showNoData(); + } else { + dataStatus.showNetworkErr(); + } + } + } else { + adapter.loadMoreFail(); + } + } + + + public static class Builder { + private BaseQuickAdapter adapter; + private RecyclerView.LayoutManager layoutManager; + private RecyclerView recyclerView; + private int pageSize = Integer.MAX_VALUE; + private IDataStatus dataStatus; + private SwipeRefreshLayout refreshLayout; + private View emptyView; + + public Builder setAdapter(BaseQuickAdapter mAdapter) { + this.adapter = mAdapter; + return this; + } + + /** + * @param pageSize 每页数量,不设置默认不分页 + * @return + */ + + public Builder setPageSize(int pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder setLayoutManager(RecyclerView.LayoutManager layoutManager) { + this.layoutManager = layoutManager; + return this; + } + + public Builder setRecyclerView(RecyclerView recyclerView) { + this.recyclerView = recyclerView; + return this; + } + + /** + * 如果设置refreshLayout,可会在每次加载完数据后隐藏刷新的view + * + * @param refreshLayout + * @return + */ + public Builder setRefreshLayout(SwipeRefreshLayout refreshLayout) { + this.refreshLayout = refreshLayout; + return this; + } + + public Builder setDataStatus(IDataStatus dataStatus) { + this.dataStatus = dataStatus; + return this; + } + + public Builder setEmptyView(View emptyView) { + this.emptyView = emptyView; + return this; + } + + public RVDelegate build() { + return new RVDelegate<>(adapter, layoutManager, recyclerView, refreshLayout, dataStatus, emptyView, pageSize); + } + + } +} diff --git a/app/src/main/res/anim/anim_all_red_package.xml b/app/src/main/res/anim/anim_all_red_package.xml new file mode 100644 index 000000000..fcab6228a --- /dev/null +++ b/app/src/main/res/anim/anim_all_red_package.xml @@ -0,0 +1,26 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/anim_all_red_package_in_btn.xml b/app/src/main/res/anim/anim_all_red_package_in_btn.xml new file mode 100644 index 000000000..059ce65cf --- /dev/null +++ b/app/src/main/res/anim/anim_all_red_package_in_btn.xml @@ -0,0 +1,13 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-xhdpi/empty_content_dark.png b/app/src/main/res/drawable-xhdpi/empty_content_dark.png new file mode 100644 index 000000000..912e8f626 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/empty_content_dark.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_man_white.png b/app/src/main/res/drawable-xhdpi/ic_man_white.png new file mode 100644 index 000000000..26aae7183 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_man_white.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_women_white.png b/app/src/main/res/drawable-xhdpi/ic_women_white.png new file mode 100644 index 000000000..0d80a6d44 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_women_white.png differ diff --git a/app/src/main/res/drawable-xhdpi/room_red_package_bg.png b/app/src/main/res/drawable-xhdpi/room_red_package_bg.png new file mode 100644 index 000000000..fb73a33f2 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/room_red_package_bg.png differ diff --git a/app/src/main/res/drawable-xhdpi/room_red_package_close.png b/app/src/main/res/drawable-xhdpi/room_red_package_close.png new file mode 100644 index 000000000..667840446 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/room_red_package_close.png differ diff --git a/app/src/main/res/drawable-xhdpi/room_red_package_get_bg.png b/app/src/main/res/drawable-xhdpi/room_red_package_get_bg.png new file mode 100644 index 000000000..503636ee7 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/room_red_package_get_bg.png differ diff --git a/app/src/main/res/drawable-xhdpi/room_red_package_go_room_bg.png b/app/src/main/res/drawable-xhdpi/room_red_package_go_room_bg.png new file mode 100644 index 000000000..294608b38 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/room_red_package_go_room_bg.png differ diff --git a/app/src/main/res/drawable-xhdpi/room_red_package_go_room_btn.png b/app/src/main/res/drawable-xhdpi/room_red_package_go_room_btn.png new file mode 100644 index 000000000..91d235dfd Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/room_red_package_go_room_btn.png differ diff --git a/app/src/main/res/drawable-xhdpi/room_red_package_help.png b/app/src/main/res/drawable-xhdpi/room_red_package_help.png new file mode 100644 index 000000000..560e9f785 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/room_red_package_help.png differ diff --git a/app/src/main/res/drawable-xhdpi/room_red_package_in.png b/app/src/main/res/drawable-xhdpi/room_red_package_in.png new file mode 100644 index 000000000..57d08d3ad Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/room_red_package_in.png differ diff --git a/app/src/main/res/drawable-xhdpi/room_red_package_no_get_bg.png b/app/src/main/res/drawable-xhdpi/room_red_package_no_get_bg.png new file mode 100644 index 000000000..2b7146042 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/room_red_package_no_get_bg.png differ diff --git a/app/src/main/res/drawable-xhdpi/room_red_package_open_bg.png b/app/src/main/res/drawable-xhdpi/room_red_package_open_bg.png new file mode 100644 index 000000000..189fa7c3f Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/room_red_package_open_bg.png differ diff --git a/app/src/main/res/drawable-xhdpi/room_red_package_open_btn.png b/app/src/main/res/drawable-xhdpi/room_red_package_open_btn.png new file mode 100644 index 000000000..cf1361bab Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/room_red_package_open_btn.png differ diff --git a/app/src/main/res/drawable-xhdpi/room_red_package_send.png b/app/src/main/res/drawable-xhdpi/room_red_package_send.png new file mode 100644 index 000000000..8739472bc Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/room_red_package_send.png differ diff --git a/app/src/main/res/drawable/common_btn_bg.xml b/app/src/main/res/drawable/common_btn_bg.xml new file mode 100644 index 000000000..bf772fd2c --- /dev/null +++ b/app/src/main/res/drawable/common_btn_bg.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/common_rb_bg.xml b/app/src/main/res/drawable/common_rb_bg.xml new file mode 100644 index 000000000..90cdd4d9e --- /dev/null +++ b/app/src/main/res/drawable/common_rb_bg.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_give_gold_success.png b/app/src/main/res/drawable/ic_give_gold_success.png new file mode 100644 index 000000000..9d9db6dc8 Binary files /dev/null and b/app/src/main/res/drawable/ic_give_gold_success.png differ diff --git a/app/src/main/res/drawable/selector_common_button.xml b/app/src/main/res/drawable/selector_common_button.xml new file mode 100644 index 000000000..be20d5635 --- /dev/null +++ b/app/src/main/res/drawable/selector_common_button.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_dbdbdb_100dp.xml b/app/src/main/res/drawable/shape_dbdbdb_100dp.xml new file mode 100644 index 000000000..30835757f --- /dev/null +++ b/app/src/main/res/drawable/shape_dbdbdb_100dp.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_eb203e_round_10dp.xml b/app/src/main/res/drawable/shape_eb203e_round_10dp.xml new file mode 100644 index 000000000..7d8423c00 --- /dev/null +++ b/app/src/main/res/drawable/shape_eb203e_round_10dp.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_ffbdcc_round_100dp.xml b/app/src/main/res/drawable/shape_ffbdcc_round_100dp.xml new file mode 100644 index 000000000..fb1a90f62 --- /dev/null +++ b/app/src/main/res/drawable/shape_ffbdcc_round_100dp.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_white_round_2dp.xml b/app/src/main/res/drawable/shape_white_round_2dp.xml new file mode 100644 index 000000000..7710b4129 --- /dev/null +++ b/app/src/main/res/drawable/shape_white_round_2dp.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_give_gold_success.xml b/app/src/main/res/layout/activity_give_gold_success.xml new file mode 100644 index 000000000..8b9fd04b0 --- /dev/null +++ b/app/src/main/res/layout/activity_give_gold_success.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/item_boss_micro.xml b/app/src/main/res/layout/item_boss_micro.xml index f41efca08..88d9a95b4 100644 --- a/app/src/main/res/layout/item_boss_micro.xml +++ b/app/src/main/res/layout/item_boss_micro.xml @@ -261,5 +261,18 @@ android:textSize="9dp" /> + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_lately_give.xml b/app/src/main/res/layout/item_lately_give.xml new file mode 100644 index 000000000..09d001392 --- /dev/null +++ b/app/src/main/res/layout/item_lately_give.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/view_give_gold_password.xml b/app/src/main/res/layout/view_give_gold_password.xml new file mode 100644 index 000000000..30389cb99 --- /dev/null +++ b/app/src/main/res/layout/view_give_gold_password.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/module_bank_card/res/layout/activity_give_gold_search.xml b/app/src/module_bank_card/res/layout/activity_give_gold_search.xml new file mode 100644 index 000000000..f59cdfbad --- /dev/null +++ b/app/src/module_bank_card/res/layout/activity_give_gold_search.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/module_community/res/layout/activity_give_gold.xml b/app/src/module_community/res/layout/activity_give_gold.xml new file mode 100644 index 000000000..95c22dcd1 --- /dev/null +++ b/app/src/module_community/res/layout/activity_give_gold.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/module_community/res/layout/dialog_red_package_go_room.xml b/app/src/module_community/res/layout/dialog_red_package_go_room.xml new file mode 100644 index 000000000..f793ceecc --- /dev/null +++ b/app/src/module_community/res/layout/dialog_red_package_go_room.xml @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/module_community/res/layout/dialog_red_package_open.xml b/app/src/module_community/res/layout/dialog_red_package_open.xml new file mode 100644 index 000000000..3bf4eb5db --- /dev/null +++ b/app/src/module_community/res/layout/dialog_red_package_open.xml @@ -0,0 +1,309 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/module_community/res/layout/dialog_red_package_send.xml b/app/src/module_community/res/layout/dialog_red_package_send.xml new file mode 100644 index 000000000..e70e2cc04 --- /dev/null +++ b/app/src/module_community/res/layout/dialog_red_package_send.xml @@ -0,0 +1,374 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/module_community/res/layout/item_red_package_diamond.xml b/app/src/module_community/res/layout/item_red_package_diamond.xml new file mode 100644 index 000000000..43a197be9 --- /dev/null +++ b/app/src/module_community/res/layout/item_red_package_diamond.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/module_community/res/layout/item_red_package_gift.xml b/app/src/module_community/res/layout/item_red_package_gift.xml new file mode 100644 index 000000000..2c0ecb5d4 --- /dev/null +++ b/app/src/module_community/res/layout/item_red_package_gift.xml @@ -0,0 +1,39 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/module_quick_pass/res/layout/activity_give_gold_to_user.xml b/app/src/module_quick_pass/res/layout/activity_give_gold_to_user.xml new file mode 100644 index 000000000..91f19e989 --- /dev/null +++ b/app/src/module_quick_pass/res/layout/activity_give_gold_to_user.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/module_quick_pass/res/layout/dialog_give_gold_password.xml b/app/src/module_quick_pass/res/layout/dialog_give_gold_password.xml new file mode 100644 index 000000000..a187e16b1 --- /dev/null +++ b/app/src/module_quick_pass/res/layout/dialog_give_gold_password.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/app/src/module_quick_pass/res/layout/item_red_package_gift_top.xml b/app/src/module_quick_pass/res/layout/item_red_package_gift_top.xml new file mode 100644 index 000000000..2fb3260a6 --- /dev/null +++ b/app/src/module_quick_pass/res/layout/item_red_package_gift_top.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 21d5eceba..c6350c976 100644 --- a/build.gradle +++ b/build.gradle @@ -9,6 +9,8 @@ buildscript { println "\n\n\n" repositories { + maven { url 'https://maven.aliyun.com/repository/public' } + maven { url 'https://jitpack.io' } google() jcenter() } @@ -18,7 +20,7 @@ buildscript { //realm 数据库插件 classpath "io.realm:realm-gradle-plugin:5.3.0" // android 资源混淆插件 - classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.2.15' + classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.2.16' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } @@ -28,6 +30,8 @@ allprojects { repositories { google() jcenter() + mavenCentral() + maven { url 'https://maven.aliyun.com/repository/public' } maven { url 'https://jitpack.io' } maven { url "http://mvn.mob.com/android" } maven { url 'https://dl.bintray.com/umsdk/release' } diff --git a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/UriProvider.java b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/UriProvider.java index b82db9fbb..c9860e316 100644 --- a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/UriProvider.java +++ b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/UriProvider.java @@ -346,4 +346,13 @@ public class UriProvider { return JAVA_WEB_URL.concat("/accompany/activity/explore/index.html"); } + /** + * 红包规则 + * + * @return + */ + public static String getRedPacketRule() { + return JAVA_WEB_URL.concat("seekdreams/modules/rules/rule-red-packet.html"); + } + } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/DemoCache.java b/core/src/main/java/com/yizhuan/xchat_android_core/DemoCache.java index 5e50e8427..52ab99420 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/DemoCache.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/DemoCache.java @@ -16,10 +16,13 @@ import com.yizhuan.xchat_android_core.initial.SplashComponent; import com.yizhuan.xchat_android_core.initial.bean.InitInfo; import com.yizhuan.xchat_android_core.noble.NobleConfig; import com.yizhuan.xchat_android_core.noble.NobleRight; +import com.yizhuan.xchat_android_core.utils.CurrentTimeUtils; import com.yizhuan.xchat_android_library.utils.config.BasicConfig; import com.yizhuan.xchat_android_library.utils.pref.ObjectPref; import com.yizhuan.xchat_android_library.utils.pref.SettingsPref; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -51,6 +54,7 @@ public class DemoCache { private static final String KEY_IS_FIRST_HIGH_PARTY_DIALOG = "IsFirstHighPartyDialog"; private static final String KEY_FILTRATE_TYPE = "FilTrateType"; public static final String KEY_IS_FIRST_HOME_HIGH_PARTY_DIALOG = "IsFirstHomeHighPartyDialog"; + private static final String KEY_RED_PACKAGE = "RedPackage"; /**保存网页域名*/ private static final String KEY_INIT_DATA_WEBHOSTNAME = "InitDataWebHostName"; @@ -83,6 +87,27 @@ public class DemoCache { }.getType()); } + public static Map readRedPackage() { + String string = SettingsPref.instance().getString(KEY_RED_PACKAGE, null); + if (TextUtils.isEmpty(string)) return null; + return new Gson().fromJson(string, + new TypeToken>() { + }.getType()); + } + + public static void saveRedPackage(String id) { + Map map = readRedPackage(); + if (map == null) map = new HashMap<>(); + for (Iterator> it = map.entrySet().iterator(); it.hasNext(); ) { + if (CurrentTimeUtils.getCurrentTime() - it.next().getValue() > 60 * 60 * 24 * 7 * 1000) { + it.remove(); + } + } + map.put(id, CurrentTimeUtils.getCurrentTime()); + SettingsPref.instance().putString(KEY_RED_PACKAGE, new Gson().toJson(map)); + } + + public static void saveBoolean(String key, boolean value) { SettingsPref.instance(BasicConfig.INSTANCE.getAppContext()).putBoolean(key, value); } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/initial/bean/InitInfo.java b/core/src/main/java/com/yizhuan/xchat_android_core/initial/bean/InitInfo.java index 60c991575..0938300bb 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/initial/bean/InitInfo.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/initial/bean/InitInfo.java @@ -21,6 +21,7 @@ import lombok.Data; public class InitInfo implements Serializable { private FaceComponent faceJson; private SplashComponent splashVo; + private RedEnvelopeConfig redEnvelopeConfig; private List rights; @SerializedName("nobleZip") private NobleResourceComponent nobleResource; @@ -84,6 +85,18 @@ public class InitInfo implements Serializable { private int gameTime;//游戏链接有效期 private int gameFrequency;// 游戏发起间隔时间 + + + /** + * 1厅内 2全服 + */ + private int redEnvelopedPosition; + + /** + * 1 水晶 2礼物 + */ + private int redEnvelopeType; + /** * 注册图片验证码开关 */ diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/initial/bean/RedEnvelopeConfig.java b/core/src/main/java/com/yizhuan/xchat_android_core/initial/bean/RedEnvelopeConfig.java new file mode 100644 index 000000000..507e07957 --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/initial/bean/RedEnvelopeConfig.java @@ -0,0 +1,51 @@ +package com.yizhuan.xchat_android_core.initial.bean; + +import java.io.Serializable; + +import lombok.Data; + +@Data +public class RedEnvelopeConfig implements Serializable { + + /** + * 钻石转赠手续费 + */ + private double rate; + + private int roomRedEnvelopeMinNum; + private int roomRedEnvelopeMaxNum; + private int serverRedEnvelopeMinNum; + private int serverRedEnvelopeMaxNum; + private int roomRedEnvelopeMinAmount; + private int serverRedEnvelopeMinAmount; + + private double exchangeDiamondsRate;//手气红包兑换水晶比率 + + /** + * 全服红包最大金额 + */ + private int serverRedEnvelopeMaxAmount; + /** + * 房间红包最大金额 + */ + private int roomRedEnvelopeMaxAmount; + + private boolean redEnvelopeSwitch; + + @Override + public String toString() { + return "RedEnvelopeConfig{" + + "rate=" + rate + + ", roomRedEnvelopeMinNum=" + roomRedEnvelopeMinNum + + ", roomRedEnvelopeMaxNum=" + roomRedEnvelopeMaxNum + + ", serverRedEnvelopeMinNum=" + serverRedEnvelopeMinNum + + ", serverRedEnvelopeMaxNum=" + serverRedEnvelopeMaxNum + + ", roomRedEnvelopeMinAmount=" + roomRedEnvelopeMinAmount + + ", serverRedEnvelopeMinAmount=" + serverRedEnvelopeMinAmount + + ", exchangeDiamondsRate=" + exchangeDiamondsRate + + ", serverRedEnvelopeMaxAmount=" + serverRedEnvelopeMaxAmount + + ", roomRedEnvelopeMaxAmount=" + roomRedEnvelopeMaxAmount + + ", redEnvelopeSwitch=" + redEnvelopeSwitch + + '}'; + } +} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java b/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java index 240c16f1f..8d5040dff 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java @@ -174,6 +174,8 @@ public class RoomEvent { */ public static final int MY_SELF_KICK_OUT_ROOM_BY_S_ADMIN = 60; + public static final int RECEIVE_RED_PACKAGE = 63; + private int event = NONE; private int micPosition = Integer.MIN_VALUE; private int posState = -1; diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/pay/IPayModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/pay/IPayModel.java index 3611cfa57..c80f35fce 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/pay/IPayModel.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/pay/IPayModel.java @@ -29,6 +29,7 @@ public interface IPayModel extends IModel { // 查询钱包的方法,需要加权限ticket Single getWalletInfo(long uid, String cache); Single getWalletInfo(long uid); + Single getWalletInfo(); /* 获取充值产品列表 1,支付宝 @@ -94,4 +95,6 @@ public interface IPayModel extends IModel { void setFirstChargeSuccess(boolean firstChargeSuccess); + Single giveGold(long toUid, String goldNum,String password); + } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/pay/PayModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/pay/PayModel.java index b2b5ad573..af24bd4ca 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/pay/PayModel.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/pay/PayModel.java @@ -34,6 +34,8 @@ import io.reactivex.Single; import io.reactivex.SingleSource; import io.reactivex.functions.Consumer; import io.reactivex.functions.Function; +import retrofit2.http.Field; +import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.Header; import retrofit2.http.POST; @@ -159,6 +161,19 @@ public class PayModel extends BaseModel implements IPayModel { return getWalletInfo(uid, CACHE_STRATEGY_NO_CACHE); } + //获取钱包信息 + @Override + public Single getWalletInfo() { + return api.getMyWallet() + .compose(RxHelper.handleBeanData()) + .compose(RxHelper.handleSchedulers()) + .doOnSuccess(info -> { + walletInfo = info; + EventBus.getDefault().post(new GetWalletInfoEvent()); + }); + + } + @Override public Single> getChargeList(int channelType) { return api.getChargeList( @@ -400,6 +415,13 @@ public class PayModel extends BaseModel implements IPayModel { this.firstChargeSuccess = firstChargeSuccess; } + @Override + public Single giveGold(long toUid, String goldNum,String password) { + return api.giveGold(toUid, goldNum,password) + .compose(RxHelper.handleStringData()) + .compose(RxHelper.handleSchedulers()); + } + public interface Api { /** @@ -416,6 +438,12 @@ public class PayModel extends BaseModel implements IPayModel { @Query("ticket") String ticket, @Header("Cache-Control") String cacheStrategy); + /** + * 获取钱包 + * @return + */ + @GET("/purse/query") + Single> getMyWallet(); /** * 获取充值产品列表 @@ -534,6 +562,17 @@ public class PayModel extends BaseModel implements IPayModel { */ @GET("/charge/wxpay/type") Single> getWxpayType(); + + /** + * 钻石转赠 + * + * @return + */ + @FormUrlEncoded + @POST("/user/gold/give") + Single> giveGold(@Field("toUid") long toUid, + @Field("goldNum") String goldNum, + @Field("password") String password); } } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/pay/bean/WalletInfo.java b/core/src/main/java/com/yizhuan/xchat_android_core/pay/bean/WalletInfo.java index 998632447..17eb21367 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/pay/bean/WalletInfo.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/pay/bean/WalletInfo.java @@ -34,6 +34,9 @@ public class WalletInfo implements Parcelable { */ private double crystals; + /** 可转赠的钻石 */ + private double canGiveGoldNum; + public WalletInfo() { } @@ -46,6 +49,7 @@ public class WalletInfo implements Parcelable { amount = in.readInt(); chargeGoldNum = in.readDouble(); nobleGoldNum = in.readDouble(); + canGiveGoldNum = in.readDouble(); } @Override @@ -57,6 +61,7 @@ public class WalletInfo implements Parcelable { dest.writeInt(amount); dest.writeDouble(chargeGoldNum); dest.writeDouble(nobleGoldNum); + dest.writeDouble(canGiveGoldNum); } @Override @@ -117,6 +122,14 @@ public class WalletInfo implements Parcelable { this.amount = amount; } + public double getCanGiveGoldNum() { + return canGiveGoldNum; + } + + public void setCanGiveGoldNum(double canGiveGoldNum) { + this.canGiveGoldNum = canGiveGoldNum; + } + @Override public String toString() { return "WalletInfo{" + @@ -124,6 +137,7 @@ public class WalletInfo implements Parcelable { ", goldNum=" + golds + ", diamondNum=" + diamonds + ", depositNum=" + depositNum + + ", canGiveGoldNum=" + canGiveGoldNum + ", amount=" + amount + '}'; } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/redpackage/RedPackageType.kt b/core/src/main/java/com/yizhuan/xchat_android_core/redpackage/RedPackageType.kt index c014c678b..3b6702e51 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/redpackage/RedPackageType.kt +++ b/core/src/main/java/com/yizhuan/xchat_android_core/redpackage/RedPackageType.kt @@ -1,4 +1,4 @@ -package com.yinyuan.xchat_android_core.redpackage +package com.yizhuan.xchat_android_core.redpackage const val ROOM_DIAMOND = 1 const val ROOM_GIFT = 3 diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/SearchRoomInfo.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/SearchRoomInfo.java index 76c58203b..244e5ae77 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/SearchRoomInfo.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/SearchRoomInfo.java @@ -45,6 +45,8 @@ public class SearchRoomInfo extends RoomInfo implements Parcelable, MultiItemEnt //角标相关的 public String badge; + private long birth; + /** 是否是靓号,1:靓号 */ public boolean hasPrettyErbanNo; public NobleInfo nobleUsers; 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 4ef2db5f7..abd589f09 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 @@ -468,6 +468,12 @@ public class AvRoomModel extends RoomBaseModel implements IAvRoomModel { .compose(RxHelper.handleSchedulers()); } + @Override + public Single>> roomSearch(String key) { + return mRoomService.roomSearch(key) + .compose(RxHelper.handleSchedulers()); + } + @Override public Single getUserRoom(long uid) { return mRoomService.getUserRoom(String.valueOf(uid)) 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 53e5f2c9e..b2a1698c7 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 @@ -793,6 +793,13 @@ public class RoomBaseModel extends BaseModel implements IRoomBaseModel { Single>> roomSearch(@Query("key") String key, @Query("type") int type); + /** + * @param key + * @return + */ + @GET("/search/room") + Single>> roomSearch(@Query("key") String key); + /** * 获取该Uid 所在的房间信息,如果不在房间 返回的房间实体uid==0,或者roomId == 0 * 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 985c9865d..d63bbbf5b 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 @@ -134,4 +134,9 @@ public interface IAvRoomModel extends IModel { Single getWelcomeConfig(long toUid); + /** + * 搜索房间 + */ + Single>> roomSearch(String key); + } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/user/IUserModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/user/IUserModel.java index a92398e3c..a76fb4dc2 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/user/IUserModel.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/user/IUserModel.java @@ -215,4 +215,6 @@ public interface IUserModel extends IModel { */ Single getRandomAvatar(); + Single> getGiveUserList(); + } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/user/UserModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/user/UserModel.java index 91220f2b2..9fbb39484 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/user/UserModel.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/user/UserModel.java @@ -785,6 +785,13 @@ public final class UserModel extends BaseModel implements IUserModel { .compose(RxHelper.handleCommon()); } + @Override + public Single> getGiveUserList() { + return api.getGiveUserList() + .compose(RxHelper.handleBeanData()) + .compose(RxHelper.handleSchedulers()); + } + private interface Api { /** * 获取某个用户的用户信息 @@ -987,5 +994,13 @@ public final class UserModel extends BaseModel implements IUserModel { @GET("/userRandom/getAvatar") Single> apiRandomAvatar(); + + /** + * 最近转赠联系人信息 + * + * @return - + */ + @GET("user/gold/give/recent") + Single>> getGiveUserList(); } } diff --git a/library/src/main/java/com/yizhuan/xchat_android_library/utils/pref/SettingsPref.java b/library/src/main/java/com/yizhuan/xchat_android_library/utils/pref/SettingsPref.java index 34c465372..9bb991c47 100644 --- a/library/src/main/java/com/yizhuan/xchat_android_library/utils/pref/SettingsPref.java +++ b/library/src/main/java/com/yizhuan/xchat_android_library/utils/pref/SettingsPref.java @@ -3,6 +3,8 @@ package com.yizhuan.xchat_android_library.utils.pref; import android.content.Context; import android.content.SharedPreferences; +import com.yizhuan.xchat_android_library.utils.config.BasicConfig; + /** * Creator: 舒强睿 * Date:2015/1/12 @@ -30,6 +32,14 @@ public class SettingsPref extends YSharedPref { return instanse; } + public synchronized static SettingsPref instance() { + if(instanse == null){ + SharedPreferences pref = BasicConfig.INSTANCE.getAppContext().getSharedPreferences("SettingsPrefs", Context.MODE_PRIVATE); + instanse = new SettingsPref(pref); + } + return instanse; + } + public String getString(String key, String defaultValue) { return get(key) == null ? defaultValue : get(key); }