From 17daa8ac83bd1620ed487bb5b986b47e4ae6587e Mon Sep 17 00:00:00 2001 From: huangjian Date: Wed, 13 Jul 2022 18:59:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E6=92=AD=E6=88=BF=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=90=91=E4=B8=8B=E6=BB=91=E5=8A=A8=E5=88=87=E6=8D=A2=E6=88=BF?= =?UTF-8?q?=E9=97=B4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erban/avroom/activity/AVRoomActivity.java | 142 +++++++---- .../avroom/fragment/FakeSingleRoomFragment.kt | 90 +++++++ .../avroom/fragment/HomePartyFragment.java | 32 ++- .../erban/avroom/widget/MessageView.java | 3 +- .../widget/VerticalViewPagerAdapter.java | 54 +++++ .../main/res/layout/activity_chat_room.xml | 31 +-- .../layout/fragment_chatroom_game_main.xml | 8 + .../res/layout/fragment_fake_single_room.xml | 17 ++ .../manager/IMNetEaseManager.java | 215 ++++++++--------- .../yizhuan/xchat_android_core/Constants.java | 1 + .../room/bean/RoomInfo.java | 227 +++++++++++------- 11 files changed, 531 insertions(+), 289 deletions(-) create mode 100644 app/src/main/java/com/yizhuan/erban/avroom/fragment/FakeSingleRoomFragment.kt create mode 100644 app/src/main/java/com/yizhuan/erban/avroom/widget/VerticalViewPagerAdapter.java create mode 100644 app/src/main/res/layout/fragment_fake_single_room.xml 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 166d904a6..c69867034 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 @@ -15,6 +15,7 @@ import android.content.Context; import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.os.Parcelable; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.TextUtils; @@ -30,6 +31,8 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import androidx.fragment.app.DialogFragment; +import androidx.recyclerview.widget.RecyclerView; +import androidx.viewpager2.widget.ViewPager2; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; @@ -47,19 +50,20 @@ import com.opensource.svgaplayer.SVGAVideoEntity; import com.orhanobut.logger.Logger; import com.tencent.bugly.crashreport.CrashReport; import com.yizhuan.erban.R; +import com.yizhuan.erban.avroom.fragment.FakeSingleRoomFragment; import com.yizhuan.erban.avroom.fragment.HomePartyFragment; import com.yizhuan.erban.avroom.fragment.InputPwdDialogFragment; 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.avroom.widget.VerticalViewPagerAdapter; import com.yizhuan.erban.base.BaseMvpActivity; import com.yizhuan.erban.common.widget.CircleImageView; import com.yizhuan.erban.common.widget.CustomImageSpan; import com.yizhuan.erban.common.widget.dialog.DialogManager; import com.yizhuan.erban.home.dialog.HelloMessageDialog; import com.yizhuan.erban.ui.patriarch.help.LimitEnterRoomHelper; -import com.yizhuan.erban.ui.pay.ChargeActivity; import com.yizhuan.erban.ui.user.UserInfoActivity; import com.yizhuan.erban.ui.utils.ImageLoadUtils; import com.yizhuan.erban.ui.widget.LoadingDialog; @@ -127,7 +131,6 @@ import java.lang.ref.WeakReference; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; -import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -160,10 +163,10 @@ public class AVRoomActivity extends BaseMvpActivity openDialogs; - private String[] bgPicture = new String[]{""}; + private ViewPager2 viewpager; + private VerticalViewPagerAdapter mAdapter; /*********************************显示全服礼物***************************************/ private GiftBroadcastObserver giftObserver; @@ -190,7 +196,15 @@ public class AVRoomActivity extends BaseMvpActivity { + mCurrentFragment = (HomePartyFragment) mAdapter.getItem(0); + //第一次进来 + if (AvRoomDataManager.get().isFirstEnterRoomOrChangeOtherRoom(roomUid)) { + showLoadingDialog(); + if (mRoomInfo == null) { + updateRoomInfo(); + } else { + requestRoomInfoSuccessView(mRoomInfo); + } + return; + } + addRoomFragment(true); + }); + } @@ -465,9 +506,6 @@ public class AVRoomActivity extends BaseMvpActivity giveUpDragonBar() { diff --git a/app/src/main/java/com/yizhuan/erban/avroom/fragment/FakeSingleRoomFragment.kt b/app/src/main/java/com/yizhuan/erban/avroom/fragment/FakeSingleRoomFragment.kt new file mode 100644 index 000000000..4ede4f73c --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/avroom/fragment/FakeSingleRoomFragment.kt @@ -0,0 +1,90 @@ +package com.yizhuan.erban.avroom.fragment + +import android.annotation.SuppressLint +import android.view.View +import com.opensource.svgaplayer.SVGADrawable +import com.opensource.svgaplayer.SVGAImageView +import com.opensource.svgaplayer.SVGAParser +import com.opensource.svgaplayer.SVGAVideoEntity +import com.yizhuan.erban.avroom.activity.AVRoomActivity +import com.yizhuan.erban.base.BaseViewBindingFragment +import com.yizhuan.erban.databinding.FragmentFakeSingleRoomBinding +import com.yizhuan.xchat_android_core.room.bean.RoomInfo +import com.yizhuan.xchat_android_core.room.model.AvRoomModel +import com.yizhuan.xchat_android_core.utils.CurrentTimeUtils +import com.yizhuan.xchat_android_core.utils.StringUtils + +class FakeSingleRoomFragment : BaseViewBindingFragment() { + + private var preRoomInfo: RoomInfo? = null + private var needJump = false + private var lastRequestTime = 0L + private var index = 1 + private val minRequestTime = 60 * 1000 + private val bgPicture = arrayOf("") + + override fun init() { + playSvgaBg(binding.svgaImageViewBg, "svga/single_back.svga") + + } + + @SuppressLint("CheckResult") + fun requestPreRoomInfo() { + if (CurrentTimeUtils.getCurrentTime() - lastRequestTime < minRequestTime) { + return + } + preRoomInfo = null + lastRequestTime = CurrentTimeUtils.getCurrentTime() + index++ + AvRoomModel.get() + .requestRoomInfo(if (index % 2 == 0) "1000429" else "1003696") + .subscribe({ + if (needJump) { + AVRoomActivity.start(mContext, it) + reSet() + } else { + preRoomInfo = it + if (!StringUtils.isBlank(it.backPic)) { + AVRoomActivity.setBackBg(mContext, it, binding.svgaImageViewBg, bgPicture) + } + } + }, { + + }) + } + + fun tryJumpRoom() { + preRoomInfo?.let { + AVRoomActivity.start(mContext, it) + reSet() + } ?: run { + needJump = true + } + } + + private fun reSet() { + preRoomInfo = null + lastRequestTime = 0 + needJump = false + } + + private fun playSvgaBg(svgaRoomBg: SVGAImageView, assets: String) { + svgaRoomBg.clearAnimation() + svgaRoomBg.visibility = View.VISIBLE + val mSVGAParser = SVGAParser(svgaRoomBg.context) + mSVGAParser.decodeFromAssets(assets, object : SVGAParser.ParseCompletion { + override fun onComplete(videoItem: SVGAVideoEntity) { + svgaRoomBg.visibility = View.VISIBLE + val drawable = SVGADrawable(videoItem) + svgaRoomBg.setImageDrawable(drawable) + svgaRoomBg.startAnimation() + } + + override fun onError() { + svgaRoomBg.visibility = View.GONE + } + + + }, null) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyFragment.java b/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyFragment.java index 58a87fbe3..828748041 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyFragment.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyFragment.java @@ -20,38 +20,29 @@ import com.netease.nim.uikit.common.util.string.StringUtil; import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder; import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage; import com.netease.nimlib.sdk.msg.attachment.MsgAttachment; +import com.opensource.svgaplayer.SVGAImageView; import com.trello.rxlifecycle3.android.FragmentEvent; import com.yizhuan.erban.R; -import com.yizhuan.erban.UIHelper; import com.yizhuan.erban.avroom.activity.AVRoomActivity; import com.yizhuan.erban.avroom.activity.RoomOnlineUserActivity; import com.yizhuan.erban.avroom.adapter.SelectGameAdapter; import com.yizhuan.erban.avroom.dialog.ExitRoomPopupWindow; -import com.yizhuan.erban.avroom.presenter.HomePartyPresenter; import com.yizhuan.erban.avroom.widget.GiftV2View; import com.yizhuan.erban.base.BaseFragment; -import com.yizhuan.erban.base.BaseMvpActivity; -import com.yizhuan.erban.common.widget.dialog.DialogManager; import com.yizhuan.erban.databinding.FragmentChatroomGameMainBinding; import com.yizhuan.erban.friend.view.SelectFriendActivity; import com.yizhuan.erban.home.helper.OpenRoomHelper; -import com.yizhuan.erban.ui.widget.ButtonItem; import com.yizhuan.erban.ui.widget.ShareDialog; import com.yizhuan.erban.utils.RegexUtil; -import com.yizhuan.xchat_android_constants.XChatConstants; import com.yizhuan.xchat_android_core.Constants; -import com.yizhuan.xchat_android_core.auth.AuthModel; -import com.yizhuan.xchat_android_core.gift.bean.GiftInfo; import com.yizhuan.xchat_android_core.gift.bean.GiftMultiReceiverInfo; import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo; import com.yizhuan.xchat_android_core.gift.bean.LuckyBagGifts; import com.yizhuan.xchat_android_core.gift.bean.MultiGiftReceiveInfo; -import com.yizhuan.xchat_android_core.home.bean.BannerInfo; import com.yizhuan.xchat_android_core.home.event.FollowRoomEvent; import com.yizhuan.xchat_android_core.home.event.ShareRoomEvent; import com.yizhuan.xchat_android_core.home.model.CollectionRoomModel; import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment; -import com.yizhuan.xchat_android_core.im.custom.bean.FansTeamMsgAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomInfoAttachment; import com.yizhuan.xchat_android_core.magic.bean.MagicReceivedInfo; import com.yizhuan.xchat_android_core.magic.bean.MultiMagicReceivedInfo; @@ -78,8 +69,6 @@ import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; import java.util.Objects; import cn.sharesdk.framework.Platform; @@ -105,12 +94,14 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe private ImageView roomMore; private ImageView ivRoomShare; - private long mTargetRoomUid; private boolean isRoomMin; private GiftV2View giftView; private ViewStub mVsGift2View; + private SVGAImageView svgaRoomBg; + private String[] bgPicture = new String[]{""}; + private UserInfo mUserInfo; private FragmentChatroomGameMainBinding gameMainBinding; @@ -121,10 +112,9 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe private SelectGameAdapter gameAdapter; - public static HomePartyFragment newInstance(long roomUid, boolean isRoomMin) { + public static HomePartyFragment newInstance(boolean isRoomMin) { HomePartyFragment homePartyFragment = new HomePartyFragment(); Bundle bundle = new Bundle(); - bundle.putLong(Constants.ROOM_UID, roomUid); //是否是最小化进来 bundle.putBoolean(Constants.IS_ROOM_MIN, isRoomMin); homePartyFragment.setArguments(bundle); @@ -159,7 +149,6 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe protected void onInitArguments(Bundle bundle) { super.onInitArguments(bundle); if (bundle != null) { - mTargetRoomUid = bundle.getLong(Constants.ROOM_UID, 0); isRoomMin = bundle.getBoolean(Constants.IS_ROOM_MIN, false); } } @@ -185,6 +174,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe mVsGift2View = mView.findViewById(R.id.vs_gift_view); mIvGoodNumber = mView.findViewById(R.id.iv_good_number); ivFollowRoom = mView.findViewById(R.id.iv_follow_room); + svgaRoomBg = mView.findViewById(R.id.svga_image_view_bg); } /** @@ -294,6 +284,11 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe currentRoomInfo.getRoomModeType() == 4); } + public void setRoomBg(RoomInfo roomInfo) { + if (svgaRoomBg == null) return; + AVRoomActivity.setBackBg(mContext, roomInfo, svgaRoomBg, bgPicture); + } + @SuppressLint("CheckResult") @Override @@ -313,6 +308,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe addTipMsg(); case RoomEvent.ROOM_INFO_UPDATE: updateView(); + setRoomBg(AvRoomDataManager.get().mCurrentRoomInfo); break; case RoomEvent.RECEIVE_NORMALE_GIFT: onReceiveGiftMsg(roomEvent.getGiftReceiveInfo()); @@ -531,7 +527,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe if (currentRoomInfo == null) { return; } - CollectionRoomModel.get().followRoom(FOLLOW_ROOM_TYPE, mTargetRoomUid) + CollectionRoomModel.get().followRoom(FOLLOW_ROOM_TYPE, currentRoomInfo.getUid()) .compose(bindUntilEvent(FragmentEvent.DESTROY)) .doOnError(throwable -> { toast(throwable.getMessage()); @@ -542,7 +538,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe ivFollowRoom.setImageResource(AvRoomDataManager.get().isRoomFans ? R.drawable.icon_room_liked : R.drawable.icon_room_like); if (AvRoomDataManager.get().isRoomFans) { SingleToastUtil.showToast("收藏成功!"); - PraiseModel.get().setFollowRoomSuccessRoomTip(mTargetRoomUid); + PraiseModel.get().setFollowRoomSuccessRoomTip(currentRoomInfo.getUid()); StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_ROOM_FOLLOW_BUTTON_CLICK, "语音房_收藏顶部按钮"); } }); 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 69cfce31e..361125316 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 @@ -65,6 +65,7 @@ import com.yizhuan.erban.common.widget.OriginalDrawStatusClickSpan; import com.yizhuan.erban.ui.utils.ImageLoadUtils; import com.yizhuan.erban.ui.widget.DividerItemDecoration; import com.yizhuan.erban.ui.widget.MyItemAnimator; +import com.yizhuan.erban.ui.widget.RecyclerViewNoViewpagerScroll; import com.yizhuan.erban.ui.widget.UserInfoDialog; import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil; import com.yizhuan.erban.ui.widget.marqueeview.Utils; @@ -290,7 +291,7 @@ public class MessageView extends FrameLayout { // 内容区域 layoutManger = new LinearLayoutManager(context, RecyclerView.VERTICAL, false); FrameLayout.LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); - messageListView = new RecyclerView(context); + messageListView = new RecyclerViewNoViewpagerScroll(context); messageListView.setLayoutParams(params); messageListView.setFadingEdgeLength(60); messageListView.setVerticalFadingEdgeEnabled(true); diff --git a/app/src/main/java/com/yizhuan/erban/avroom/widget/VerticalViewPagerAdapter.java b/app/src/main/java/com/yizhuan/erban/avroom/widget/VerticalViewPagerAdapter.java new file mode 100644 index 000000000..e82f44b3b --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/avroom/widget/VerticalViewPagerAdapter.java @@ -0,0 +1,54 @@ +package com.yizhuan.erban.avroom.widget; + +import android.util.SparseArray; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; +import androidx.viewpager2.adapter.FragmentStateAdapter; + +import com.yizhuan.erban.avroom.fragment.FakeSingleRoomFragment; +import com.yizhuan.erban.avroom.fragment.HomePartyFragment; + + +/** + * 作者: ch + * 时间: 2018/7/30 0030-下午 3:42 + * 描述: + * 来源: + */ + + +public class VerticalViewPagerAdapter extends FragmentStateAdapter { + private final SparseArray fragmentList; + + public VerticalViewPagerAdapter(FragmentActivity fm) { + super(fm); + fragmentList = new SparseArray<>(); + } + + + @NonNull + @Override + public Fragment createFragment(int position) { + Fragment fragment = fragmentList.get(position); + if (fragment == null) { + if (position == 0) { + fragment = HomePartyFragment.newInstance(false); + } else { + fragment = new FakeSingleRoomFragment(); + } + fragmentList.put(position, fragment); + } + return fragment; + } + + @Override + public int getItemCount() { + return 2; + } + + public Fragment getItem(int position) { + return fragmentList.get(position); + } +} diff --git a/app/src/main/res/layout/activity_chat_room.xml b/app/src/main/res/layout/activity_chat_room.xml index 978513e60..4564c8cb7 100644 --- a/app/src/main/res/layout/activity_chat_room.xml +++ b/app/src/main/res/layout/activity_chat_room.xml @@ -2,43 +2,38 @@ + android:layout_height="match_parent" + android:background="@drawable/bg_room_normal_default_pic"> - - - + android:clipToPadding="true" + android:overScrollMode="never" + android:scrollbars="none" /> + android:layout="@layout/layout_room_live_finish" /> + android:layout="@layout/room_noble_open_viewstub_layout" /> + android:layout_height="match_parent" + android:layout="@layout/vs_gift_value_first_show_layout" + android:visibility="gone" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_chatroom_game_main.xml b/app/src/main/res/layout/fragment_chatroom_game_main.xml index 6ac59abe8..376071a68 100644 --- a/app/src/main/res/layout/fragment_chatroom_game_main.xml +++ b/app/src/main/res/layout/fragment_chatroom_game_main.xml @@ -21,6 +21,14 @@ android:layout_height="match_parent" tools:background="@color/blue"> + + + + + + + + diff --git a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java index 769964d0c..e8c18dfc9 100644 --- a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java +++ b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java @@ -481,8 +481,9 @@ public final class IMNetEaseManager { MLog.info(TAG, "登录中..."); } else if (chatRoomStatusChangeData.status == StatusCode.LOGINED) { MLog.info(TAG, "云信聊天室已登录成功"); - noticeImNetReLogin(mCacheRoomQueueInfo); - + if (mCacheRoomQueueInfo != null) { + noticeImNetReLogin(mCacheRoomQueueInfo); + } Map parans = new HashMap<>(3); parans.put("user_id", String.valueOf(currentUid)); parans.put("net_type", NetworkUtils.getNetworkTypeName(BasicConfig.INSTANCE.getAppContext())); @@ -1316,10 +1317,10 @@ public final class IMNetEaseManager { UserModel.get().getCacheLoginUserInfo().setGroupType(PKTeamInfo.TEAM_NONE); //在麦上就更新信息 AvRoomModel.get().updateMyMicQueue( - AvRoomDataManager.get().getMicPosition(AuthModel.get().getCurrentUid()), - String.valueOf(AvRoomDataManager.get().mCurrentRoomInfo.getRoomId()), - UserModel.get().getCacheLoginUserInfo() - ) + AvRoomDataManager.get().getMicPosition(AuthModel.get().getCurrentUid()), + String.valueOf(AvRoomDataManager.get().mCurrentRoomInfo.getRoomId()), + UserModel.get().getCacheLoginUserInfo() + ) .subscribe(); } } @@ -2002,31 +2003,31 @@ public final class IMNetEaseManager { public Single> fetchRoomMembersByIds(final List accounts) { return Single.create((SingleOnSubscribe>) e -> { - final RoomInfo mCurrentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo; - if (mCurrentRoomInfo == null || ListUtils.isListEmpty(accounts)) { - e.onError(new IllegalArgumentException("RoomInfo is null or accounts is null")); - return; - } - NIMChatRoomSDK.getChatRoomService() - .fetchRoomMembersByIds(String.valueOf(mCurrentRoomInfo.getRoomId()), accounts) - .setCallback(new RequestCallback>() { - @Override - public void onSuccess(List param) { - e.onSuccess(param); - } + final RoomInfo mCurrentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo; + if (mCurrentRoomInfo == null || ListUtils.isListEmpty(accounts)) { + e.onError(new IllegalArgumentException("RoomInfo is null or accounts is null")); + return; + } + NIMChatRoomSDK.getChatRoomService() + .fetchRoomMembersByIds(String.valueOf(mCurrentRoomInfo.getRoomId()), accounts) + .setCallback(new RequestCallback>() { + @Override + public void onSuccess(List param) { + e.onSuccess(param); + } - @Override - public void onFailed(int code) { - e.onError(new Exception("错误码: " + code)); - } + @Override + public void onFailed(int code) { + e.onError(new Exception("错误码: " + code)); + } - @Override - public void onException(Throwable exception) { - e.onError(exception); - } - }); + @Override + public void onException(Throwable exception) { + e.onError(exception); + } + }); - }).subscribeOn(Schedulers.computation()) + }).subscribeOn(Schedulers.computation()) .observeOn(AndroidSchedulers.mainThread()); } @@ -2242,16 +2243,16 @@ public final class IMNetEaseManager { if (roomInfo == null) return null; String downMicUid = AvRoomDataManager.get().getRoomQueueMemberUidByMicPosition(micPosition); return Single.create((SingleOnSubscribe) e -> { - RequestResult> result = NIMClient.syncRequest(NIMChatRoomSDK.getChatRoomService() - .pollQueue(String.valueOf(roomInfo.getRoomId()), String.valueOf(micPosition))); - if (result.exception != null) - e.onError(result.exception); - else if (result.code != BaseMvpModel.RESULT_OK) - e.onError(new Throwable("错误码: " + result.code)); - else { - e.onSuccess("下麦回调成功"); - } - }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) + RequestResult> result = NIMClient.syncRequest(NIMChatRoomSDK.getChatRoomService() + .pollQueue(String.valueOf(roomInfo.getRoomId()), String.valueOf(micPosition))); + if (result.exception != null) + e.onError(result.exception); + else if (result.code != BaseMvpModel.RESULT_OK) + e.onError(new Throwable("错误码: " + result.code)); + else { + e.onSuccess("下麦回调成功"); + } + }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) .doOnSuccess(s -> GiftValueMrg.get().requestDownMic(micPosition, downMicUid)); } @@ -2320,10 +2321,10 @@ public final class IMNetEaseManager { @Override public void subscribe(SingleEmitter e) throws Exception { NIMChatRoomSDK.getChatRoomService().kickMember( - String.valueOf(roomId), - String.valueOf(account), - notifyExtension - ) + String.valueOf(roomId), + String.valueOf(account), + notifyExtension + ) .setCallback(new RequestCallback() { @Override public void onSuccess(Void param) { @@ -2429,28 +2430,28 @@ public final class IMNetEaseManager { return Single.error(new ErrorThrowable(ErrorThrowable.ROOM_INFO_NULL_ERROR)); final long micUid = baseInfo.getUid(); return Single.create( - new SingleOnSubscribe() { - @Override - public void subscribe(SingleEmitter e) throws Exception { - RoomQueueMsgAttachment queueMsgAttachment = new RoomQueueMsgAttachment(CUSTOM_MSG_HEADER_TYPE_QUEUE, - CUSTOM_MSG_HEADER_TYPE_QUEUE_INVITE); + new SingleOnSubscribe() { + @Override + public void subscribe(SingleEmitter e) throws Exception { + RoomQueueMsgAttachment queueMsgAttachment = new RoomQueueMsgAttachment(CUSTOM_MSG_HEADER_TYPE_QUEUE, + CUSTOM_MSG_HEADER_TYPE_QUEUE_INVITE); - queueMsgAttachment.uid = String.valueOf(micUid); - queueMsgAttachment.micPosition = position; - queueMsgAttachment.handleUid = AuthModel.get().getCurrentUid(); - UserInfo myInfo = UserModel.get().getCacheLoginUserInfo(); - if (myInfo != null) { - queueMsgAttachment.handleNick = myInfo.getNick() == null ? "" : myInfo.getNick(); - } - queueMsgAttachment.targetNick = baseInfo.getNick(); - if (baseInfo.getGroupType() != 0) { - queueMsgAttachment.groupType = baseInfo.getGroupType(); - } - ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage( - String.valueOf(roomInfo.getRoomId()), queueMsgAttachment); - e.onSuccess(message); - } - }).subscribeOn(Schedulers.io()) + queueMsgAttachment.uid = String.valueOf(micUid); + queueMsgAttachment.micPosition = position; + queueMsgAttachment.handleUid = AuthModel.get().getCurrentUid(); + UserInfo myInfo = UserModel.get().getCacheLoginUserInfo(); + if (myInfo != null) { + queueMsgAttachment.handleNick = myInfo.getNick() == null ? "" : myInfo.getNick(); + } + queueMsgAttachment.targetNick = baseInfo.getNick(); + if (baseInfo.getGroupType() != 0) { + queueMsgAttachment.groupType = baseInfo.getGroupType(); + } + ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage( + String.valueOf(roomInfo.getRoomId()), queueMsgAttachment); + e.onSuccess(message); + } + }).subscribeOn(Schedulers.io()) .unsubscribeOn(Schedulers.io()) .filter(new Predicate() { @Override @@ -2537,17 +2538,17 @@ public final class IMNetEaseManager { if (roomInfo == null) return Single.error(new ErrorThrowable(ErrorThrowable.ROOM_INFO_NULL_ERROR)); return Single.create( - (SingleOnSubscribe) e -> { - NobleAttachment nobleMsgAttachment = new NobleAttachment(CUSTOM_MESS_HEAD_NOBLE, - CUSTOM_MESS_SUB_ROOM_WELCOME); - nobleMsgAttachment.uid = uid; - nobleMsgAttachment.nick = nick; - nobleMsgAttachment.nobleInfo = nobleInfo; + (SingleOnSubscribe) e -> { + NobleAttachment nobleMsgAttachment = new NobleAttachment(CUSTOM_MESS_HEAD_NOBLE, + CUSTOM_MESS_SUB_ROOM_WELCOME); + nobleMsgAttachment.uid = uid; + nobleMsgAttachment.nick = nick; + nobleMsgAttachment.nobleInfo = nobleInfo; - ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage( - String.valueOf(roomInfo.getRoomId()), nobleMsgAttachment); - e.onSuccess(message); - }).subscribeOn(Schedulers.io()) + ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage( + String.valueOf(roomInfo.getRoomId()), nobleMsgAttachment); + e.onSuccess(message); + }).subscribeOn(Schedulers.io()) .unsubscribeOn(Schedulers.io()) .filter(chatRoomMessage -> nobleInfo != null && !TextUtils.isEmpty(nick) && uid != 0) .toSingle() @@ -2567,19 +2568,19 @@ public final class IMNetEaseManager { if (roomInfo == null) return Single.error(new ErrorThrowable(ErrorThrowable.ROOM_INFO_NULL_ERROR)); return Single.create( - (SingleOnSubscribe) e -> { - CarAttachment carAttachment = new CarAttachment(CUSTOM_MESS_HEAD_CAR, - CUSTOM_MESS_SUB_CAR_ENTER_ROOM); - carAttachment.uid = uid; - carAttachment.nick = nick; - carAttachment.effect = carInfo.getEffect(); - carAttachment.viewUrl = carInfo.getViewUrl(); - carAttachment.otherViewType = carInfo.getOtherViewType(); + (SingleOnSubscribe) e -> { + CarAttachment carAttachment = new CarAttachment(CUSTOM_MESS_HEAD_CAR, + CUSTOM_MESS_SUB_CAR_ENTER_ROOM); + carAttachment.uid = uid; + carAttachment.nick = nick; + carAttachment.effect = carInfo.getEffect(); + carAttachment.viewUrl = carInfo.getViewUrl(); + carAttachment.otherViewType = carInfo.getOtherViewType(); - ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage( - String.valueOf(roomInfo.getRoomId()), carAttachment); - e.onSuccess(message); - }).subscribeOn(Schedulers.io()) + ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage( + String.valueOf(roomInfo.getRoomId()), carAttachment); + e.onSuccess(message); + }).subscribeOn(Schedulers.io()) .unsubscribeOn(Schedulers.io()) .filter(chatRoomMessage -> carInfo != null && !TextUtils.isEmpty(nick) && uid != 0) .toSingle() @@ -2664,28 +2665,28 @@ public final class IMNetEaseManager { long delayTime, ReconnectListener listener) { return Single.create((SingleOnSubscribe) emitter -> { - retryChatRoomMessage.setRetryCount(retryChatRoomMessage.getRetryCount() + 1); - ImRetryManager.logIde("start send im msg :" + retryChatRoomMessage.getRetryCount()); - if (isExitRoom()) { - String error = "exite room when send msg"; - emitter.onError(new Throwable(error)); - return; - } - if (isChangeRoom(retryChatRoomMessage.getMessage())) { - String error = "changed room when send msg"; - emitter.onError(new Throwable(error)); - return; - } - sendChatRoomMessage(retryChatRoomMessage.getMessage(), false) - .subscribe((message, throwable) -> { - if (throwable == null) { - retryChatRoomMessage.setMessage(message); - emitter.onSuccess(retryChatRoomMessage); - } else { - emitter.onError(throwable); - } - }); - }) + retryChatRoomMessage.setRetryCount(retryChatRoomMessage.getRetryCount() + 1); + ImRetryManager.logIde("start send im msg :" + retryChatRoomMessage.getRetryCount()); + if (isExitRoom()) { + String error = "exite room when send msg"; + emitter.onError(new Throwable(error)); + return; + } + if (isChangeRoom(retryChatRoomMessage.getMessage())) { + String error = "changed room when send msg"; + emitter.onError(new Throwable(error)); + return; + } + sendChatRoomMessage(retryChatRoomMessage.getMessage(), false) + .subscribe((message, throwable) -> { + if (throwable == null) { + retryChatRoomMessage.setMessage(message); + emitter.onSuccess(retryChatRoomMessage); + } else { + emitter.onError(throwable); + } + }); + }) .retryWhen(flowable -> flowable .flatMap(new Function>() { @Override diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/Constants.java b/core/src/main/java/com/yizhuan/xchat_android_core/Constants.java index 9fc513223..58bf2cce1 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/Constants.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/Constants.java @@ -83,6 +83,7 @@ public class Constants { public static final String ROOM_UID = "ROOM_UID"; public static final String ROOM_TYPE = "ROOM_TYPE"; + public static final String ROOM_INFO = "ROOM_INFO"; public static final String IS_ROOM_MIN = "is_room_min"; public static final String IS_PARTY = "is_party"; diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/RoomInfo.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/RoomInfo.java index 5e43ca26f..0321614c1 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/RoomInfo.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/RoomInfo.java @@ -141,6 +141,140 @@ public class RoomInfo implements Parcelable,Serializable { private long worldId; // >0:语音派对房 + protected RoomInfo(Parcel in) { + uid = in.readLong(); + officeUser = in.readInt(); + roomId = in.readLong(); + roomUid = in.readLong(); + title = in.readString(); + avatar = in.readString(); + type = in.readInt(); + roomDesc = in.readString(); + backPic = in.readString(); + speakTemplate = in.createStringArrayList(); + valid = in.readByte() != 0; + operatorStatus = in.readInt(); + hasAnimationEffect = in.readByte() != 0; + audioQuality = in.readInt(); + isCloseScreen = in.readByte() != 0; + serverRedEnvelopeSwitch = in.readByte() != 0; + hasDragonGame = in.readByte() != 0; + meetingName = in.readString(); + roomPwd = in.readString(); + roomTag = in.readString(); + tagId = in.readInt(); + tagPict = in.readString(); + onlineNum = in.readInt(); + isRecom = in.readByte(); + isRoomFans = in.readByte() != 0; + background = in.readParcelable(BackgroundBean.class.getClassLoader()); + hasKTVPriv = in.readByte() != 0; + isOpenKTV = in.readByte() != 0; + isOpenGame = in.readByte() != 0; + boxSwitchVo = in.readParcelable(BoxSwitchVo.class.getClassLoader()); + singingMusicName = in.readString(); + limitType = in.readString(); + introduction = in.readString(); + roomModeType = in.readInt(); + isPermitRoom = in.readInt(); + isPureMode = in.readByte() != 0; + closeBox = in.readByte() != 0; + leaveMode = in.readByte() != 0; + nick = in.readString(); + gender = in.readInt(); + worldId = in.readLong(); + showGiftValue = in.readByte() != 0; + hideFlag = in.readInt(); + closeScreenFlag = in.readInt(); + redEnvelopeOpen = in.readByte() != 0; + blindDateState = in.readString(); + blindDateVipUid = in.readLong(); + canOpenBlindDate = in.readByte() != 0; + audioSdkType = in.readString(); + trtcSig = in.readString(); + isReselect = in.readByte() != 0; + mgId = in.readLong(); + mgName = in.readString(); + mgMicNum = in.readInt(); + clearScreenTime = in.readLong(); + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeLong(uid); + dest.writeInt(officeUser); + dest.writeLong(roomId); + dest.writeLong(roomUid); + dest.writeString(title); + dest.writeString(avatar); + dest.writeInt(type); + dest.writeString(roomDesc); + dest.writeString(backPic); + dest.writeStringList(speakTemplate); + dest.writeByte((byte) (valid ? 1 : 0)); + dest.writeInt(operatorStatus); + dest.writeByte((byte) (hasAnimationEffect ? 1 : 0)); + dest.writeInt(audioQuality); + dest.writeByte((byte) (isCloseScreen ? 1 : 0)); + dest.writeByte((byte) (serverRedEnvelopeSwitch ? 1 : 0)); + dest.writeByte((byte) (hasDragonGame ? 1 : 0)); + dest.writeString(meetingName); + dest.writeString(roomPwd); + dest.writeString(roomTag); + dest.writeInt(tagId); + dest.writeString(tagPict); + dest.writeInt(onlineNum); + dest.writeByte(isRecom); + dest.writeByte((byte) (isRoomFans ? 1 : 0)); + dest.writeParcelable(background, flags); + dest.writeByte((byte) (hasKTVPriv ? 1 : 0)); + dest.writeByte((byte) (isOpenKTV ? 1 : 0)); + dest.writeByte((byte) (isOpenGame ? 1 : 0)); + dest.writeParcelable(boxSwitchVo, flags); + dest.writeString(singingMusicName); + dest.writeString(limitType); + dest.writeString(introduction); + dest.writeInt(roomModeType); + dest.writeInt(isPermitRoom); + dest.writeByte((byte) (isPureMode ? 1 : 0)); + dest.writeByte((byte) (closeBox ? 1 : 0)); + dest.writeByte((byte) (leaveMode ? 1 : 0)); + dest.writeString(nick); + dest.writeInt(gender); + dest.writeLong(worldId); + dest.writeByte((byte) (showGiftValue ? 1 : 0)); + dest.writeInt(hideFlag); + dest.writeInt(closeScreenFlag); + dest.writeByte((byte) (redEnvelopeOpen ? 1 : 0)); + dest.writeString(blindDateState); + dest.writeLong(blindDateVipUid); + dest.writeByte((byte) (canOpenBlindDate ? 1 : 0)); + dest.writeString(audioSdkType); + dest.writeString(trtcSig); + dest.writeByte((byte) (isReselect ? 1 : 0)); + dest.writeLong(mgId); + dest.writeString(mgName); + dest.writeInt(mgMicNum); + dest.writeLong(clearScreenTime); + } + + @Override + public int describeContents() { + return 0; + } + + public static final Creator CREATOR = new Creator() { + @Override + public RoomInfo createFromParcel(Parcel in) { + return new RoomInfo(in); + } + + @Override + public RoomInfo[] newArray(int size) { + return new RoomInfo[size]; + } + }; + /** * 获取房间类型,目前是用于统计 */ @@ -207,99 +341,6 @@ public class RoomInfo implements Parcelable,Serializable { public RoomInfo() { } - protected RoomInfo(Parcel in) { - uid = in.readLong(); - officeUser = in.readInt(); - roomId = in.readLong(); - title = in.readString(); - type = in.readInt(); - roomDesc = in.readString(); - backPic = in.readString(); - valid = in.readByte() != 0; - hasAnimationEffect = in.readByte() != 0; - operatorStatus = in.readInt(); - meetingName = in.readString(); -// openTime = in.readLong(); - roomPwd = in.readString(); - roomTag = in.readString(); - tagId = in.readInt(); - audioQuality = in.readInt(); - tagPict = in.readString(); - onlineNum = in.readInt(); - limitType = in.readString(); - isRecom = in.readByte(); - isRoomFans = in.readByte()!=0; - avatar = in.readString(); - isOpenGame = in.readByte()!=0; - isOpenKTV = in.readByte() != 0; - hasKTVPriv = in.readByte() != 0; - introduction = in.readString(); - isPermitRoom = in.readInt(); - showGiftValue = in.readByte() != 0; - serverRedEnvelopeSwitch = in.readByte() != 0; - nick = in.readString(); - gender = in.readInt(); - hideFlag = in.readInt(); - closeScreenFlag = in.readInt(); - speakTemplate = in.createStringArrayList(); - boxSwitchVo = in.readParcelable(BoxSwitchVo.class.getClassLoader()); - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeLong(uid); - dest.writeInt(officeUser); - dest.writeLong(roomId); - dest.writeString(title); - dest.writeInt(type); - dest.writeString(roomDesc); - dest.writeString(backPic); - dest.writeByte((byte) (valid ? 1 : 0)); - dest.writeByte((byte) (hasAnimationEffect ? 1 : 0)); - dest.writeInt(operatorStatus); - dest.writeString(meetingName); -// dest.writeLong(openTime); - dest.writeString(roomPwd); - dest.writeString(roomTag); - dest.writeInt(tagId); - dest.writeInt(audioQuality); - dest.writeString(tagPict); - dest.writeInt(onlineNum); - dest.writeByte(isRecom); - dest.writeByte((byte) (isRoomFans ? 1 : 0)); - dest.writeString(limitType); - dest.writeString(avatar); - dest.writeByte((byte) (isOpenGame ? 1 : 0)); - dest.writeByte((byte) (isOpenKTV ? 1 : 0)); - dest.writeByte((byte) (hasKTVPriv ? 1 : 0)); - dest.writeString(introduction); - dest.writeInt(isPermitRoom); - dest.writeByte((byte) (showGiftValue ? 1 : 0)); - dest.writeByte((byte) (serverRedEnvelopeSwitch ? 1 : 0)); - dest.writeInt(gender); - dest.writeString(nick); - dest.writeStringList(speakTemplate); - dest.writeInt(hideFlag); - dest.writeInt(closeScreenFlag); - dest.writeParcelable(boxSwitchVo, flags); - } - - @Override - public int describeContents() { - return 0; - } - - public static final Creator CREATOR = new Creator() { - @Override - public RoomInfo createFromParcel(Parcel in) { - return new RoomInfo(in); - } - - @Override - public RoomInfo[] newArray(int size) { - return new RoomInfo[size]; - } - }; public static class BackgroundBean implements Parcelable{ /**