From c20225bbe84de2b5b991f15f64c9f184a14b317c Mon Sep 17 00:00:00 2001 From: huangjian Date: Fri, 6 May 2022 16:49:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E6=B8=B8=E6=88=8F:=E7=8B=BC=E4=BA=BA?= =?UTF-8?q?=E6=9D=80=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../avroom/adapter/GameMicroViewAdapter.kt | 18 ++- .../adapter/GameMiniMicroViewAdapter.kt | 4 +- .../erban/avroom/fragment/BaseRoomFragment.kt | 1 - .../erban/avroom/fragment/GameRoomFragment.kt | 77 +++++----- .../yizhuan/erban/avroom/game/GameDelegate.kt | 2 +- .../erban/avroom/widget/GiftV2View.java | 17 ++- .../erban/avroom/widget/MicroView.java | 137 ++++-------------- app/src/main/res/layout/item_boss_micro.xml | 8 + app/src/main/res/layout/item_micro_dating.xml | 11 ++ .../res/layout/item_micro_dating_boss.xml | 10 ++ app/src/main/res/layout/item_micro_game.xml | 16 +- .../main/res/layout/item_micro_game_mini.xml | 16 +- .../res/layout/item_micro_single_anchor.xml | 7 + .../layout/item_micro_single_anchor_boss.xml | 12 ++ .../layout/item_micro_single_room_pk_boss.xml | 12 ++ app/src/main/res/layout/list_item_micro.xml | 7 + .../res/layout/fragment_game_room.xml | 11 +- .../manager/IMNetEaseManager.java | 7 +- .../room/bean/RoomInfo.java | 2 + 19 files changed, 205 insertions(+), 170 deletions(-) diff --git a/app/src/main/java/com/yizhuan/erban/avroom/adapter/GameMicroViewAdapter.kt b/app/src/main/java/com/yizhuan/erban/avroom/adapter/GameMicroViewAdapter.kt index c0126926f..eb48d43f1 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/adapter/GameMicroViewAdapter.kt +++ b/app/src/main/java/com/yizhuan/erban/avroom/adapter/GameMicroViewAdapter.kt @@ -7,12 +7,14 @@ import android.view.View import android.view.ViewGroup import android.widget.TextView import androidx.core.view.isVisible -import androidx.recyclerview.widget.GridLayoutManager +import androidx.core.view.updateLayoutParams import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import com.netease.nim.uikit.common.util.sys.ScreenUtil import com.yizhuan.erban.R import com.yizhuan.xchat_android_core.bean.RoomQueueInfo import com.yizhuan.xchat_android_core.manager.AvRoomDataManager +import kotlin.math.max /** @@ -25,8 +27,8 @@ class GameMicroViewAdapter(context: Context?) : BaseMicroViewAdapter(context) { * Set LayoutManager and bind this to RecyclerView */ override fun bindToRecyclerView(recyclerView: RecyclerView) { - val layoutManager = GridLayoutManager(context, 6) - layoutManager.orientation = LinearLayoutManager.VERTICAL + val layoutManager = LinearLayoutManager(context) + layoutManager.orientation = LinearLayoutManager.HORIZONTAL recyclerView.layoutManager = layoutManager recyclerView.adapter = this } @@ -47,6 +49,14 @@ class GameMicroViewAdapter(context: Context?) : BaseMicroViewAdapter(context) { @SuppressLint("SetTextI18n") public override fun bind(info: RoomQueueInfo, position: Int) { + + itemView.updateLayoutParams { + width = when (itemCount) { + 6 -> ScreenUtil.screenWidth / 6 + 7 -> ScreenUtil.screenWidth / 7 + else -> (ScreenUtil.screenWidth / 7.5f).toInt() + } + } super.bind(info, position) info.mChatRoomMember?.let { if (it.gameStatus == 0 && !AvRoomDataManager.get().isRoomOwner(it.account)) { @@ -82,7 +92,7 @@ class GameMicroViewAdapter(context: Context?) : BaseMicroViewAdapter(context) { } override fun getItemCount(): Int { - return 6 + return max(AvRoomDataManager.get().mCurrentRoomInfo?.mgMicNum ?: 6, 6) } } \ No newline at end of file diff --git a/app/src/main/java/com/yizhuan/erban/avroom/adapter/GameMiniMicroViewAdapter.kt b/app/src/main/java/com/yizhuan/erban/avroom/adapter/GameMiniMicroViewAdapter.kt index 2cae89091..0232814ea 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/adapter/GameMiniMicroViewAdapter.kt +++ b/app/src/main/java/com/yizhuan/erban/avroom/adapter/GameMiniMicroViewAdapter.kt @@ -10,6 +10,8 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.yizhuan.erban.R import com.yizhuan.xchat_android_core.bean.RoomQueueInfo +import com.yizhuan.xchat_android_core.manager.AvRoomDataManager +import kotlin.math.max /** @@ -61,7 +63,7 @@ class GameMiniMicroViewAdapter(context: Context?) : BaseMicroViewAdapter(context } override fun getItemCount(): Int { - return 6 + return max(AvRoomDataManager.get().mCurrentRoomInfo?.mgMicNum ?: 6, 6) } diff --git a/app/src/main/java/com/yizhuan/erban/avroom/fragment/BaseRoomFragment.kt b/app/src/main/java/com/yizhuan/erban/avroom/fragment/BaseRoomFragment.kt index 295d92a52..eb86e90c6 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/fragment/BaseRoomFragment.kt +++ b/app/src/main/java/com/yizhuan/erban/avroom/fragment/BaseRoomFragment.kt @@ -751,7 +751,6 @@ open class BaseRoomFragment?> : private fun onDownMicro(micPosition: Int) { showBottomViewForDifRole() updateMicBtn() - microView.removeDragonBar(micPosition) microView.adapter.notifyDataSetChanged() //下麦时更新最高最低头饰 GiftValueMrg.get().updateRoomGiftValue(false) diff --git a/app/src/main/java/com/yizhuan/erban/avroom/fragment/GameRoomFragment.kt b/app/src/main/java/com/yizhuan/erban/avroom/fragment/GameRoomFragment.kt index 053386030..9ac5f8705 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/fragment/GameRoomFragment.kt +++ b/app/src/main/java/com/yizhuan/erban/avroom/fragment/GameRoomFragment.kt @@ -4,6 +4,7 @@ import android.annotation.SuppressLint import android.os.Bundle import android.view.View import android.widget.LinearLayout +import androidx.core.view.isInvisible import androidx.core.view.isVisible import androidx.core.view.updateLayoutParams import androidx.databinding.DataBindingUtil @@ -55,6 +56,7 @@ class GameRoomFragment : BaseRoomFragment(), private lateinit var gameBinding: FragmentGameRoomBinding private lateinit var gameDelegate: GameDelegate + private var isShowMiniMic = false override fun getRootLayoutId(): Int { return R.layout.fragment_game_room @@ -83,39 +85,30 @@ class GameRoomFragment : BaseRoomFragment(), PlayerModel.get().stop() gameBinding.roomInfo = AvRoomDataManager.get().mCurrentRoomInfo mvpPresenter?.getBannerList() - gameBinding.tvShowMiniMic.setOnClickListener { - gameBinding.microView.updateLayoutParams { - width = LinearLayout.LayoutParams.WRAP_CONTENT - marginStart = ScreenUtil.dip2px(2f) - marginEnd = ScreenUtil.dip2px(2f) - } - gameBinding.microView.bindAdapter(GameMiniMicroViewAdapter(context).apply { - setOnClick { gameBinding.ivShowMic.callOnClick() } - }) - gameBinding.llMicView.updateLayoutParams { - width = LinearLayout.LayoutParams.WRAP_CONTENT - } - gameBinding.tvShowMiniMic.isVisible = false - gameBinding.microView.postDelayed({ - gameBinding.ivShowMic.isVisible = true - gameBinding.llMicView.setBackgroundResource(R.drawable.bg_mini_mic_entrance) - }, 100) - } + gameBinding.tvShowMiniMic.setOnClickListener { showMiniMic() } + gameBinding.ivShowMic.setOnClickListener { showMic() } + } - gameBinding.ivShowMic.setOnClickListener { - gameBinding.microView.updateLayoutParams { - width = LinearLayout.LayoutParams.MATCH_PARENT - marginStart = ScreenUtil.dip2px(10f) - marginEnd = ScreenUtil.dip2px(10f) - } - gameBinding.llMicView.updateLayoutParams { - width = LinearLayout.LayoutParams.MATCH_PARENT - } - gameBinding.microView.bindAdapter(GameMicroViewAdapter(context)) - gameBinding.tvShowMiniMic.isVisible = true - gameBinding.llMicView.background = null - gameBinding.ivShowMic.isVisible = false - } + private fun showMiniMic() { + if (isShowMiniMic) return + isShowMiniMic = true + gameBinding.microView.bindAdapter(GameMiniMicroViewAdapter(context).apply { + setOnClick { showMic() } + }) + gameBinding.tvShowMiniMic.isVisible = false + gameBinding.microView.postDelayed({ + gameBinding.ivShowMic.isVisible = true + gameBinding.llMicView.setBackgroundResource(R.drawable.bg_mini_mic_entrance) + }, 100) + } + + private fun showMic() { + if (!isShowMiniMic) return + isShowMiniMic = false + gameBinding.microView.bindAdapter(GameMicroViewAdapter(context)) + gameBinding.tvShowMiniMic.isVisible = true + gameBinding.llMicView.background = null + gameBinding.ivShowMic.isVisible = false } override fun onSetListener() { @@ -127,15 +120,31 @@ class GameRoomFragment : BaseRoomFragment(), super.updateView() gameDelegate.updateGame(AvRoomDataManager.get().mCurrentRoomInfo?.mgId) gameBinding.roomInfo = AvRoomDataManager.get().mCurrentRoomInfo + if (isSixMic()) { + gameBinding.tvShowMiniMic.isVisible = !isShowMiniMic + gameBinding.ivShowMic.isVisible = isShowMiniMic + } else { + showMic() + gameBinding.tvShowMiniMic.isInvisible = true + gameBinding.ivShowMic.isVisible = false + } gameBinding.microView.adapter.notifyDataSetChanged() } override fun onGameStart() { - gameBinding.tvShowMiniMic.callOnClick() + if (isSixMic()) { + showMiniMic() + } } override fun onGameEnd() { - gameBinding.ivShowMic.callOnClick() + if (isSixMic()) { + showMic() + } + } + + fun isSixMic(): Boolean { + return AvRoomDataManager.get().mCurrentRoomInfo?.mgMicNum == 6 } override fun onSendMsgSuccess(msg: String?) { diff --git a/app/src/main/java/com/yizhuan/erban/avroom/game/GameDelegate.kt b/app/src/main/java/com/yizhuan/erban/avroom/game/GameDelegate.kt index 8b067feb5..064e15eae 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/game/GameDelegate.kt +++ b/app/src/main/java/com/yizhuan/erban/avroom/game/GameDelegate.kt @@ -313,7 +313,7 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId: //游戏安全操作区域 val viewGameRect = JSONObject() viewGameRect.put("left", 0) - viewGameRect.put("top", ScreenUtil.dip2px(220f)) + viewGameRect.put("top", ScreenUtil.dip2px(200f)) viewGameRect.put("right", 0) viewGameRect.put("bottom", ScreenUtil.dip2px(200f)) jsonObject.put("view_game_rect", viewGameRect) diff --git a/app/src/main/java/com/yizhuan/erban/avroom/widget/GiftV2View.java b/app/src/main/java/com/yizhuan/erban/avroom/widget/GiftV2View.java index dffd759de..75360606b 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/widget/GiftV2View.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/widget/GiftV2View.java @@ -205,7 +205,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect Point senderPoint = micViewPoint.get(senderPosition); Point receivePoint = micViewPoint.get(receivePosition); - if (receivePoint == null) { //这种情况就是接收者已经不在麦上 + if (receivePoint == null || isGameRoomMoreThan6People()) { //这种情况就是接收者已经不在麦上 //礼物送到上面中间的位置 receivePoint = new Point(UIUtil.getScreenWidth(context) / 2, UIUtil.dip2px(context, 35)); @@ -261,7 +261,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect Point senderPoint = micViewPoint.get(senderPosition); Point receivePoint = micViewPoint.get(receivePosition); - if (receivePoint == null) { //这种情况就是接收者已经不在麦上 + if (receivePoint == null || isGameRoomMoreThan6People()) { //这种情况就是接收者已经不在麦上 //礼物送到上面中间的位置 receivePoint = new Point(UIUtil.getScreenWidth(context) / 2, UIUtil.dip2px(context, 35)); @@ -344,7 +344,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect Point senderPoint = micViewPoint.get(senderPosition); Point receivePoint = micViewPoint.get(receivePosition); - if (receivePoint == null) { //这种情况就是接收者已经不在麦上 + if (receivePoint == null || isGameRoomMoreThan6People()) { //这种情况就是接收者已经不在麦上 //礼物送到上面中间的位置 receivePoint = new Point(UIUtil.getScreenWidth(context) / 2, UIUtil.dip2px(context, 35)); @@ -555,7 +555,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect Point senderPoint = micViewPoint.get(senderPosition); Point receivePoint = micViewPoint.get(receivePosition); - if (receivePoint == null) { + if (receivePoint == null || isGameRoomMoreThan6People()) { //礼物送到上面中间的位置 receivePoint = new Point(UIUtil.getScreenWidth(context) / 2, UIUtil.dip2px(context, 35)); @@ -646,7 +646,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect return; } - if (senderPoint == null) + if (senderPoint == null || isGameRoomMoreThan6People()) senderPoint = new Point(mScreenWidth - giftWidth, mScreenHeight - UIUtil.dip2px(context, 50)); SVGAImageView imageView = mMagicViewPool.borrowMagicObject(senderPoint); String animationUrl = getValidPathAnimationUrl(magicReceivedInfo.getMagicId(), @@ -732,7 +732,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect final Point center = new Point(); center.x = context.getResources().getDisplayMetrics().widthPixels / 2; center.y = context.getResources().getDisplayMetrics().heightPixels / 2; - if (senderPoint == null) { + if (senderPoint == null || isGameRoomMoreThan6People()) { senderPoint = new Point(mScreenWidth / 2 - giftWidth / 2, UIUtil.dip2px(context, 25)); } SVGAImageView imageView = mMagicViewPool.borrowGiftObject(senderPoint); @@ -761,6 +761,11 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect }); } + private boolean isGameRoomMoreThan6People() { + RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo; + return AvRoomDataManager.get().isOpenGame() && roomInfo != null && roomInfo.getMgMicNum() > 6; + } + private Path getBezierCurvePath(Point sendPoint, Point receivePoint, boolean center) { Point endPoint = new Point(receivePoint.x - sendPoint.x, receivePoint.y - sendPoint.y); diff --git a/app/src/main/java/com/yizhuan/erban/avroom/widget/MicroView.java b/app/src/main/java/com/yizhuan/erban/avroom/widget/MicroView.java index 0b5d97ce0..3f9d60c32 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/widget/MicroView.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/widget/MicroView.java @@ -7,11 +7,10 @@ import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.Drawable; import android.text.TextUtils; import android.util.AttributeSet; -import android.util.Log; import android.util.SparseArray; import android.view.View; -import android.widget.FrameLayout; import android.widget.ImageView; +import android.widget.LinearLayout; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; @@ -22,11 +21,9 @@ import com.opensource.svgaplayer.SVGAParser; import com.opensource.svgaplayer.SVGAVideoEntity; import com.yizhuan.erban.R; import com.yizhuan.erban.avroom.adapter.BaseMicroViewAdapter; -import com.yizhuan.erban.avroom.adapter.CpMicroViewAdapter; import com.yizhuan.erban.avroom.adapter.DatingMicroViewAdapter; import com.yizhuan.erban.avroom.adapter.GameMicroViewAdapter; import com.yizhuan.erban.avroom.adapter.GameMiniMicroViewAdapter; -import com.yizhuan.erban.avroom.adapter.MicroViewAdapter; import com.yizhuan.erban.avroom.adapter.OnMicroItemClickListener; import com.yizhuan.erban.ui.anim.AnimFactory; import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil; @@ -58,11 +55,9 @@ import io.reactivex.disposables.Disposable; * @author xiaoyu * @date 2017/12/20 */ -public class MicroView extends FrameLayout implements View.OnLayoutChangeListener { +public class MicroView extends LinearLayout implements View.OnLayoutChangeListener { private static final String TAG = "MicroView"; public RecyclerView recyclerView; - private SparseArray faceImageViews; - private SparseArray dragonBarImageViews; private Context mContext; private int giftWidth; private int giftHeight; @@ -99,25 +94,11 @@ public class MicroView extends FrameLayout implements View.OnLayoutChangeListene inflate(mContext, R.layout.layout_micro_view, this); recyclerView = findViewById(R.id.recycler_view); recyclerView.addOnLayoutChangeListener(this); - giftWidth = UIUtil.dip2px(mContext, 80); giftHeight = UIUtil.dip2px(mContext, 80); - faceImageViews = new SparseArray<>(10); - dragonBarImageViews = new SparseArray<>(9); - } public void bindAdapter(@NonNull BaseMicroViewAdapter adapter) { - if (adapter instanceof GameMicroViewAdapter) { - giftWidth = UIUtil.dip2px(mContext, 60); - giftHeight = UIUtil.dip2px(mContext, 60); - } else if (adapter instanceof GameMiniMicroViewAdapter) { - giftWidth = UIUtil.dip2px(mContext, 16); - giftHeight = UIUtil.dip2px(mContext, 16); - } else { - giftWidth = UIUtil.dip2px(mContext, 80); - giftHeight = UIUtil.dip2px(mContext, 80); - } if (adapter instanceof DatingMicroViewAdapter) { if (datingItemDecoration == null) datingItemDecoration = new DatingItemDecoration(); recyclerView.addItemDecoration(datingItemDecoration); @@ -155,41 +136,11 @@ public class MicroView extends FrameLayout implements View.OnLayoutChangeListene private void onReceiveRoomEvent(RoomEvent roomEvent) { if (roomEvent == null || roomEvent.getEvent() == RoomEvent.NONE) return; - switch (roomEvent.getEvent()) { - case RoomEvent.SPEAK_STATE_CHANGE: - onSpeakQueueUpdate(roomEvent.getMicPositionList()); - break; - case RoomEvent.DRAGON_BAR_START: - onDragonBarOpen((FaceAttachment) roomEvent.getChatRoomMessage().getAttachment(), true, false, false); - break; - case RoomEvent.DRAGON_BAR_SELF_START: - onDragonBarOpen((FaceAttachment) roomEvent.getChatRoomMessage().getAttachment(), true, true, false); - break; - case RoomEvent.DRAGON_BAR_END: - onDragonBarOpen((FaceAttachment) roomEvent.getChatRoomMessage().getAttachment(), false, true, true); - break; - case RoomEvent.DRAGON_BAR_CANCEL: - onDragonBarCancel((FaceAttachment) roomEvent.getChatRoomMessage().getAttachment()); - break; - default: + if (roomEvent.getEvent() == RoomEvent.SPEAK_STATE_CHANGE) { + onSpeakQueueUpdate(roomEvent.getMicPositionList()); } } - private void onDragonBarCancel(FaceAttachment attachment) { - int position = AvRoomDataManager.get().getMicPosition(attachment.getUid()); - if (position < -1) return; - ImageView imageView = dragonBarImageViews.get(position); - if (imageView == null) return; - imageView.setImageDrawable(null); - imageView.clearAnimation(); - } - - private void onDragonBarOpen(FaceAttachment attachment, boolean needAnim, boolean needResult, boolean needGone) { - List faceReceiveInfos = attachment.getFaceReceiveInfos(); - if (faceReceiveInfos == null || faceReceiveInfos.size() <= 0) return; - faceAnima(faceReceiveInfos, true, needAnim, needResult, needGone); - } - @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { //高度和位置都没发生变化,就没必要要reset了 @@ -200,35 +151,30 @@ public class MicroView extends FrameLayout implements View.OnLayoutChangeListene isNeedResetMicCenterPoint = false; recyclerView.post(() -> { isNeedResetMicCenterPoint = true; - faceImageViews = setMicCenterPoint(faceImageViews); - if (AvRoomDataManager.get().hasDragonGame()) { - dragonBarImageViews = setMicCenterPoint(dragonBarImageViews); - } + setMicCenterPoint(); }); } } - public SparseArray setMicCenterPoint(SparseArray array) { - if (array == null) array = new SparseArray<>(9); + private void setMicCenterPoint() { SparseArray centerPoints = new SparseArray<>(); // 算出每一个麦位的位置 int childCount = recyclerView.getChildCount(); View child; for (int i = 0; i < childCount; i++) { child = recyclerView.getChildAt(i); - addFaceView(array, centerPoints, child, i - 1); + addFaceView(centerPoints, child, i - 1); if (i == 0) { RecyclerView rvVip = child.findViewById(R.id.rv_vip); if (rvVip != null && rvVip.getChildCount() > 0) { - addFaceView(array, centerPoints, rvVip.getChildAt(0), AvRoomDataManager.POSITION_VIP_MIC); + addFaceView(centerPoints, rvVip.getChildAt(0), AvRoomDataManager.POSITION_VIP_MIC); } } } AvRoomDataManager.get().mMicPointMap = centerPoints; - return array; } - private void addFaceView(SparseArray array, SparseArray centerPoints, View child, int micPosition) { + private void addFaceView(SparseArray centerPoints, View child, int micPosition) { int[] location = new int[2]; // 找到头像 View view = child.findViewById(R.id.micro_layout); @@ -236,23 +182,6 @@ public class MicroView extends FrameLayout implements View.OnLayoutChangeListene child.getLocationInWindow(location); int x = (location[0] + child.getWidth() / 2) - giftWidth / 2; int y = (location[1] + child.getHeight() / 2) - giftHeight / 2; - // 放置表情占位image view - ImageView face = array.get(micPosition); - LayoutParams params = new LayoutParams(giftWidth, giftHeight); - child.getLocationInWindow(location); - int[] containerLocation = new int[2]; - this.getLocationInWindow(containerLocation); - params.leftMargin = ((location[0] - containerLocation[0] + child.getWidth() / 2) - giftHeight / 2); - params.topMargin = ((location[1] - containerLocation[1] + child.getHeight() / 2) - giftHeight / 2); - //如果不为空,只改变View的位置就行了 - if (face == null) { - face = new ImageView(mContext); - array.put(micPosition, face); - face.setLayoutParams(params); - addView(face); - } else { - face.setLayoutParams(params); - } Point point = new Point(x, y); LogUtils.d("x= " + x + " y= " + y); centerPoints.put(micPosition, point); @@ -264,7 +193,8 @@ public class MicroView extends FrameLayout implements View.OnLayoutChangeListene @SuppressLint("CheckResult") public void onSpeakQueueUpdate(List positions) { - int count = recyclerView.getChildCount(); + if (recyclerView == null || getAdapter() == null) return; + int count = getAdapter().getItemCount(); for (int i = 0; i < positions.size(); i++) { int pos = positions.get(i) + 1; if (pos >= count && pos != AvRoomDataManager.POSITION_VIP_MIC + 1) continue; @@ -272,10 +202,10 @@ public class MicroView extends FrameLayout implements View.OnLayoutChangeListene final SVGAImageView speakState; //相亲模式VIP位置光圈 if (pos == AvRoomDataManager.POSITION_VIP_MIC + 1) { - speakState = ((RecyclerView) recyclerView.getChildAt(0).findViewById(R.id.rv_vip)) + speakState = ((RecyclerView) findItemView(pos).findViewById(R.id.rv_vip)) .getChildAt(0).findViewById(R.id.iv_halo); } else { - speakState = recyclerView.getChildAt(pos).findViewById(R.id.iv_halo); + speakState = findItemView(pos).findViewById(R.id.iv_halo); } if (speakState != null) { @@ -341,6 +271,14 @@ public class MicroView extends FrameLayout implements View.OnLayoutChangeListene } } + private View findItemView(int pos) { + RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForLayoutPosition(pos); + if (viewHolder != null) { + return viewHolder.itemView; + } + return recyclerView.getChildAt(pos); + } + @Subscribe(threadMode = ThreadMode.MAIN) public void onReceiveFace(ReceiveFaceEvent event) { List faceReceiveInfos = event.getFaceReceiveInfos(); @@ -357,33 +295,24 @@ public class MicroView extends FrameLayout implements View.OnLayoutChangeListene ((BaseMicroViewAdapter.NormalMicroViewHolder) holder).clear(); } } - //key 是从[-1, 7],9个key - // 移除所有的表情动画 - for (int i = -1; i < faceImageViews.size() - 1; i++) { - ImageView imageView = faceImageViews.get(i); - if (imageView == null) continue; - imageView.setImageDrawable(null); - imageView.clearAnimation(); - } - // 移除龙珠的动画 - for (int i = -1; i < dragonBarImageViews.size() - 1; i++) { - ImageView imageView = dragonBarImageViews.get(i); - if (imageView == null) continue; - imageView.setImageDrawable(null); - imageView.clearAnimation(); - } } //开始表情动画和龙珠动画 + @SuppressLint("CheckResult") private void faceAnima(List faceReceiveInfos, boolean isDragon, boolean needAnim, boolean needResult, boolean needGone) { for (FaceReceiveInfo faceReceiveInfo : faceReceiveInfos) { int position = AvRoomDataManager.get().getMicPosition(faceReceiveInfo.getUid()); if (position < -1) continue; ImageView imageView; if (isDragon) { - imageView = dragonBarImageViews.get(position); + return; } else { - imageView = faceImageViews.get(position); + if (position == AvRoomDataManager.POSITION_VIP_MIC + 1) { + imageView = ((RecyclerView) findItemView(position + 1).findViewById(R.id.rv_vip)) + .getChildAt(0).findViewById(R.id.iv_face); + } else { + imageView = findItemView(position + 1).findViewById(R.id.iv_face); + } } if (imageView == null) continue; AnimFactory.getFaceAnimation(faceReceiveInfo, mContext, imageView.getWidth(), imageView.getHeight(), needAnim, needResult, needGone) @@ -402,12 +331,4 @@ public class MicroView extends FrameLayout implements View.OnLayoutChangeListene }); } } - - public void removeDragonBar(int micPosition) { - ImageView imageView = dragonBarImageViews.get(micPosition); - if (imageView == null) return; - imageView.setImageDrawable(null); - imageView.clearAnimation(); - } - } diff --git a/app/src/main/res/layout/item_boss_micro.xml b/app/src/main/res/layout/item_boss_micro.xml index 91128f1c6..87736c8ee 100644 --- a/app/src/main/res/layout/item_boss_micro.xml +++ b/app/src/main/res/layout/item_boss_micro.xml @@ -102,6 +102,14 @@ + + + + + diff --git a/app/src/main/res/layout/item_micro_dating_boss.xml b/app/src/main/res/layout/item_micro_dating_boss.xml index bdfa2aa34..6f61ae8b9 100644 --- a/app/src/main/res/layout/item_micro_dating_boss.xml +++ b/app/src/main/res/layout/item_micro_dating_boss.xml @@ -190,6 +190,16 @@ app:layout_constraintStart_toStartOf="parent" tools:visibility="visible" /> + diff --git a/app/src/main/res/layout/item_micro_game.xml b/app/src/main/res/layout/item_micro_game.xml index 253575843..8f44bb73b 100644 --- a/app/src/main/res/layout/item_micro_game.xml +++ b/app/src/main/res/layout/item_micro_game.xml @@ -2,13 +2,12 @@ + tools:background="@color/color_activity_blue_bg"> + + diff --git a/app/src/main/res/layout/item_micro_game_mini.xml b/app/src/main/res/layout/item_micro_game_mini.xml index cae9957f0..328517f03 100644 --- a/app/src/main/res/layout/item_micro_game_mini.xml +++ b/app/src/main/res/layout/item_micro_game_mini.xml @@ -6,8 +6,7 @@ android:layout_height="16dp" android:layout_marginStart="1dp" android:layout_marginEnd="1dp" - tools:background="@color/color_activity_blue_bg" - > + tools:background="@color/color_activity_blue_bg"> + android:layout_gravity="center" + android:visibility="gone" /> + + diff --git a/app/src/main/res/layout/item_micro_single_anchor.xml b/app/src/main/res/layout/item_micro_single_anchor.xml index 2b2db4eda..8ed5dfba2 100644 --- a/app/src/main/res/layout/item_micro_single_anchor.xml +++ b/app/src/main/res/layout/item_micro_single_anchor.xml @@ -76,6 +76,13 @@ android:layout_gravity="start|bottom" tools:visibility="visible" /> + + + + + + + + + + @@ -93,7 +94,7 @@ + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> 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 295532a5b..0d2df9b70 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 @@ -56,6 +56,7 @@ import com.netease.nimlib.sdk.util.Entry; import com.netease.nimlib.sdk.util.api.RequestResult; import com.orhanobut.logger.Logger; import com.yizhuan.xchat_android_constants.XChatConstants; +import com.yizhuan.xchat_android_core.BuildConfig; import com.yizhuan.xchat_android_core.Constants; import com.yizhuan.xchat_android_core.R; import com.yizhuan.xchat_android_core.auth.AuthModel; @@ -180,6 +181,7 @@ import org.greenrobot.eventbus.EventBus; import org.reactivestreams.Publisher; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -1602,7 +1604,10 @@ public final class IMNetEaseManager { // 1----房间信息更新 2-----麦序信息更新 // 3----更新房间信息和麦序信息(排麦模式) int type = (int) extension.get("type"); - LogUtils.d("chatRoomInfoUpdate type =" + type); + + if (BuildConfig.DEBUG) { + LogUtils.d("chatRoomInfoUpdate type =" + type + " extension=" + Arrays.toString(extension.entrySet().toArray())); + } if (type == 2) { roomQueueMicUpdate(extension); } else if (type == 1) { 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 573d974b9..5e43ca26f 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 @@ -195,6 +195,8 @@ public class RoomInfo implements Parcelable,Serializable { private String mgName; + private int mgMicNum; + private long clearScreenTime; // /** // * 房间角标