红包需求

This commit is contained in:
oujunhui
2020-07-10 19:25:38 +08:00
parent 0fd426436c
commit 6335ae1f7e
32 changed files with 129 additions and 58 deletions

View File

@@ -23,6 +23,8 @@ import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.viewpager.widget.ViewPager;
import com.alibaba.fastjson.JSON;
@@ -262,55 +264,18 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
// setIntent(intent);
// 如果是同一个房间,则只更新房间的信息
long newRoomUid = intent.getLongExtra(Constants.ROOM_UID, 0);
fromType = intent.getIntExtra("fromType", 0);
workAuthor = intent.getStringExtra("workAuthor");
boolean isParty = getIntent().getBooleanExtra(Constants.IS_PARTY, false);
//从嗨聊房进入
if (isParty) {
if (AvRoomDataManager.get().getRoomUidList() != null) {
List<SimplePartyRoomInfo> list = AvRoomDataManager.get().getRoomUidList();
if (list.size() > 0) {
AvRoomDataManager.get().setIsParty(true);
roomUid = list.get(0).getUid();
if (mCurrentFragment != null) {
mCurrentFragment = null;
}
if (roomUid != AuthModel.get().getCurrentUid()) {
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.EVENT_ENTERROOM, "进入别人房间");
}
updateRoomInfo();
return;
} else {
AvRoomDataManager.get().setIsParty(false);
}
} else {
AvRoomDataManager.get().setIsParty(false);
}
}
if (newRoomUid != 0 && newRoomUid == roomUid) {
updateRoomInfo();
//updateRoomInfo之后进入云信进房逻辑后直接return了,不会再次调用addRoomFragment()
showRedPackage(AvRoomDataManager.get().mCurrentRoomInfo);
return;
}
// 师徒任务三判定
if (AvRoomDataManager.get().isFromMentoring() && Objects.equals(AvRoomDataManager.get().getMasterUid(),
AvRoomDataManager.get().mCurrentRoomInfo.getUid())) {
// 只有从任务三分享房间链接进来的时候才开始倒计时
EventBus.getDefault().post(new MentoringStartCountingEvent());
} else {
EventBus.getDefault().post(new MentoringStopCountingEvent());
}
roomUid = newRoomUid;
if (roomUid != AuthModel.get().getCurrentUid()) {
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.EVENT_ENTERROOM, "进入别人房间");
}
if (mCurrentFragment != null) {
getSupportFragmentManager().beginTransaction()
.remove(mCurrentFragment).commitAllowingStateLoss();
@@ -629,7 +594,9 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
if (roomInfo != null) {
setBackBg(this, roomInfo, svgaRoomBg, bgPicture, shade);
int roomType = roomInfo.getType();
if ((roomType == RoomInfo.ROOMTYPE_HOME_PARTY || roomType == RoomInfo.ROOMTYPE_CP) &&
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
if (roomType == RoomInfo.ROOMTYPE_HOME_PARTY &&
!(mCurrentFragment instanceof HomePartyFragment)) {
fragmentList.clear();
List<SimplePartyRoomInfo> roomUidList = AvRoomDataManager.get().getRoomUidList();

View File

@@ -1,5 +1,6 @@
package com.yizhuan.erban.avroom.dialog;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
@@ -12,12 +13,15 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
import androidx.recyclerview.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.netease.nim.uikit.common.util.log.LogUtil;
import com.yinyuan.xchat_android_core.redpackage.RedPackageModel;
import com.yizhuan.erban.R;
import com.yizhuan.erban.module_hall.HallDataManager;
import com.yizhuan.erban.ui.widget.marqueeview.Utils;
@@ -34,6 +38,8 @@ import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import io.reactivex.SingleObserver;
import io.reactivex.disposables.Disposable;
/**
@@ -91,11 +97,39 @@ public class RoomOperationDialog extends BottomSheetDialog {
addOpenOrClosePublicScreenAction(optAdapter);
addGiftValueAction(optAdapter);
addRoomSettingAction(optAdapter);
addRedPackageSwitch();
//addRoomModuleHallAction(optAdapter);
//addRoomManagerAction(optAdapter);
addSuperAdminAction(optAdapter);
rvOPtList.setAdapter(optAdapter);
}
@SuppressLint("CheckResult")
private void addRedPackageSwitch(){
if (!AvRoomDataManager.get().isManager()) {
return;
}
// boolean b;
RedPackageModel.INSTANCE.getRedPackageSwitch(AvRoomDataManager.get().getRoomUid()).subscribe(s -> {
LogUtil.e("addRedPackageSwitch"+s);
boolean redPackage = Boolean.parseBoolean(s);
String text = redPackage ?
context.getResources().getString(R.string.close_redpackage_notice) :
context.getResources().getString(R.string.open_redpackage_notice);
int icon = redPackage ?
R.drawable.ic_room_open_redpackage :
R.drawable.ic_room_close_redpackage;
optAdapter.addData(new OptAction(icon, text,
new OptAction.OnAction() {
@Override
public void onAction() {
if (onActionListener != null) {
RedPackageModel.INSTANCE.setRedPackageSwitch(AvRoomDataManager.get().getRoomUid()).subscribe();
}
}
}));
});
}
private void addGameAction(OptAdapter optAdapter) {
@@ -415,6 +449,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
void onGiftValue();
void onSuperAdmin();
}
public void setOnActionListener(OnActionListener onActionListener) {

View File

@@ -51,6 +51,7 @@ import com.orhanobut.logger.Logger;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.tongdaxing.erban.sadmin.RoomSAdminManagerActivity;
import com.trello.rxlifecycle3.android.FragmentEvent;
import com.yinyuan.xchat_android_core.redpackage.RedPackageModel;
import com.yizhuan.erban.R;
import com.yizhuan.erban.avroom.BottomViewListenerWrapper;
import com.yizhuan.erban.avroom.ButtonItemFactory;
@@ -211,6 +212,8 @@ import java.util.ListIterator;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.Single;
import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
@@ -2203,6 +2206,7 @@ public class HomePartyRoomFragment extends BaseMvpFragment<IHomePartyView, HomeP
} else
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.EVENT_MP_ROOM_MORE_CLICK, "更多面板按钮");
RoomOperationDialog dialog = new RoomOperationDialog(mContext);
dialog.setOnActionListener(new RoomOperationDialog.OnActionListener() {
@Override

View File

@@ -86,11 +86,13 @@ class RedPackageOpenDialog : BaseDialog<DialogRedPackageOpenBinding>() {
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
@@ -147,7 +149,7 @@ class RedPackageOpenDialog : BaseDialog<DialogRedPackageOpenBinding>() {
}
}
TIME_OUT, REMAIN_ZERO, TIME_OUT_BACK -> {
binding.clOpened.setBackgroundResource(R.drawable.room_red_package_no_get_bg)
binding.clOpened.setBackgroundResource(R.drawable.room_red_package_get_bg)
binding.tvDiamondNum.visibility = View.GONE
binding.tvTips.visibility = View.GONE
binding.tvNoGet.visibility = View.VISIBLE

View File

@@ -772,6 +772,7 @@ public class MessageView extends FrameLayout {
}
} else if (first == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_FOLLOW_ROOM){
if (second == CustomAttachment.CUSTOM_MSG_SUB_TYPE_FOLLOW_ROOM_SUCCESS) {
clearBackground(tvContent);
//收藏了房间
setFollowRoomTip(tvContent, (RoomTipAttachment) attachment, chatRoomMessage);
}

View File

@@ -25,6 +25,7 @@ import android.widget.Toast;
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,6 +36,9 @@ import com.tbruyelle.rxpermissions2.RxPermissions;
import com.trello.rxlifecycle3.android.ActivityEvent;
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;
@@ -44,18 +48,24 @@ import com.yizhuan.erban.common.widget.StatusLayout;
import com.yizhuan.erban.common.widget.dialog.DialogManager;
import com.yizhuan.erban.common.widget.dialog.DialogUiHelper;
import com.yizhuan.erban.reciever.ConnectiveChangedReceiver;
import com.yizhuan.erban.ui.login.AddUserInfoActivity;
import com.yizhuan.erban.ui.login.LoginActivity;
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.AllServiceGiftProtocol;
import com.yizhuan.xchat_android_core.noble.NobleInfo;
import com.yizhuan.xchat_android_core.noble.NobleProtocol;
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
import com.yizhuan.xchat_android_core.statistic.StatisticManager;
import com.yizhuan.xchat_android_library.base.AbstractMvpActivity;
import com.yizhuan.xchat_android_library.base.AbstractMvpPresenter;
@@ -82,6 +92,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;
/**
@@ -948,6 +961,22 @@ public abstract class BaseMvpActivity<V extends IMvpBaseView, P extends Abstract
}
}
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 (context instanceof AddUserInfoActivity || context 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;
}
default:
break;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 804 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 301 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -47,11 +47,13 @@
<ImageView
<com.yizhuan.erban.common.widget.CircleImageView
android:id="@+id/iv_avatar"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/default_avatar"
app:cborder_width="1dp"
app:cborder_color="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/line1" />
@@ -141,7 +143,7 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.465" />
app:layout_constraintGuide_percent="0.459" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/line5"
@@ -156,7 +158,7 @@
android:layout_height="30dp"
android:src="@drawable/default_avatar"
app:cborder_color="@color/white"
app:cborder_width="@dimen/dp_2"
app:cborder_width="1dp"
app:layout_constraintEnd_toStartOf="@id/tv_nickname_opened"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
@@ -278,19 +280,31 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/line4" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_users"
<FrameLayout
android:id="@+id/fl_red_text"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"
android:layout_marginBottom="40dp"
android:background="@drawable/shape_eb203e_round_10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/line5">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_users"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/room_red_package_open_btn"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/line5" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.Barrier

View File

@@ -324,15 +324,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/line5" />
<ImageView
android:id="@+id/iv_balance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:layout_marginBottom="35dp"
android:src="@drawable/ic_redpackage_diamond"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/tv_balance_num"
@@ -341,9 +332,13 @@
android:textColor="@color/white"
android:textSize="@dimen/sp_15"
android:includeFontPadding="false"
app:layout_constraintBottom_toBottomOf="@id/iv_balance"
app:layout_constraintStart_toEndOf="@id/iv_balance"
app:layout_constraintTop_toTopOf="@id/iv_balance"
android:gravity="center"
android:drawablePadding="@dimen/dp_4"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="50dp"
android:layout_marginBottom="35dp"
android:drawableStart="@drawable/ic_redpackage_diamond"
tools:text="12531" />
<TextView

View File

@@ -109,6 +109,10 @@ public final class AvRoomDataManager {
* 是否需要打开礼物特效
*/
public boolean mIsNeedGiftEffect = true;
/**
* 是否需要打开全服红包
*/
public boolean mIsNeedOpenRedPackage = true;
/**
* 自己是否操作过礼物特效
*/

View File

@@ -43,6 +43,18 @@ object RedPackageModel {
.map { RedPackageNotifyInfo(it.id, it.type, it.message, it.userVO?.avatar?:"", it.userVO?.nick?:"", it.roomUId, "") }
}
fun getRedPackageSwitch(roomUid: Long):Single<String>{
return api.getRedPackageSwitch(roomUid)
.io2main()
.handleStringData()
}
fun setRedPackageSwitch(roomUid: Long):Single<String> {
return api.setRedPackageSwitch(roomUid)
.io2main()
.handleStringData()
}
private interface Api {
/**
@@ -76,6 +88,12 @@ object RedPackageModel {
*/
@GET("/room/red-envelop")
fun getRedPackage(@Query("uid") uid: Long): Single<ServiceResult<List<RedEnvelopeVO>>>
@GET("/red-envelope/{roomUid}")
fun getRedPackageSwitch(@Path("roomUid") uid: Long): Single<ServiceResult<String>>
@POST("/red-envelope/switch/{roomUid}")
fun setRedPackageSwitch(@Path("roomUid") uid: Long): Single<ServiceResult<String>>
}

View File

@@ -113,6 +113,8 @@
<string name="remove_member">移出本群</string>
<string name="team_member_info">成员信息</string>
<string name="team_admin">管理员</string>
<string name="open_redpackage_notice">开启全服红包</string>
<string name="close_redpackage_notice">关闭全服红包</string>
<string name="team_creator">群主</string>
<string name="team_member">群成员</string>
<string name="update_success">保存成功</string>