小游戏:狼人杀接入
This commit is contained in:
@@ -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<RecyclerView.LayoutParams> {
|
||||
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)
|
||||
}
|
||||
|
||||
}
|
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
|
@@ -751,7 +751,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
private fun onDownMicro(micPosition: Int) {
|
||||
showBottomViewForDifRole()
|
||||
updateMicBtn()
|
||||
microView.removeDragonBar(micPosition)
|
||||
microView.adapter.notifyDataSetChanged()
|
||||
//下麦时更新最高最低头饰
|
||||
GiftValueMrg.get().updateRoomGiftValue(false)
|
||||
|
@@ -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<IGameRoomView?, GameRoomPresenter?>(),
|
||||
|
||||
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<IGameRoomView?, GameRoomPresenter?>(),
|
||||
PlayerModel.get().stop()
|
||||
gameBinding.roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
|
||||
mvpPresenter?.getBannerList()
|
||||
gameBinding.tvShowMiniMic.setOnClickListener {
|
||||
gameBinding.microView.updateLayoutParams<LinearLayout.LayoutParams> {
|
||||
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<LinearLayout.LayoutParams> {
|
||||
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<LinearLayout.LayoutParams> {
|
||||
width = LinearLayout.LayoutParams.MATCH_PARENT
|
||||
marginStart = ScreenUtil.dip2px(10f)
|
||||
marginEnd = ScreenUtil.dip2px(10f)
|
||||
}
|
||||
gameBinding.llMicView.updateLayoutParams<LinearLayout.LayoutParams> {
|
||||
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<IGameRoomView?, GameRoomPresenter?>(),
|
||||
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?) {
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
|
@@ -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<ImageView> faceImageViews;
|
||||
private SparseArray<ImageView> 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<FaceReceiveInfo> 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<ImageView> setMicCenterPoint(SparseArray<ImageView> array) {
|
||||
if (array == null) array = new SparseArray<>(9);
|
||||
private void setMicCenterPoint() {
|
||||
SparseArray<Point> 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<ImageView> array, SparseArray<Point> centerPoints, View child, int micPosition) {
|
||||
private void addFaceView(SparseArray<Point> 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<Integer> 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<FaceReceiveInfo> 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<FaceReceiveInfo> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -102,6 +102,14 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_face"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_gravity="center"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
|
@@ -161,6 +161,17 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_face"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
@@ -190,6 +190,16 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_face"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
@@ -2,13 +2,12 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="5dp"
|
||||
tools:background="@color/color_activity_blue_bg"
|
||||
tools:layout_width="60dp">
|
||||
tools:background="@color/color_activity_blue_bg">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/micro_layout"
|
||||
@@ -74,6 +73,7 @@
|
||||
app:layout_constraintWidth_percent="0.76"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_head_wear"
|
||||
android:layout_width="0dp"
|
||||
@@ -128,6 +128,16 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_face"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
@@ -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">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/micro_layout"
|
||||
@@ -20,10 +19,10 @@
|
||||
|
||||
<com.opensource.svgaplayer.SVGAImageView
|
||||
android:id="@+id/iv_halo"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center" />
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/up_image"
|
||||
@@ -63,16 +62,23 @@
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_face"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
tools:visibility="gone" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_nick"
|
||||
android:layout_width="0dp"
|
||||
android:visibility="gone"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginLeft="@dimen/dp_5"
|
||||
android:layout_marginRight="@dimen/dp_5"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/micro_layout">
|
||||
|
@@ -76,6 +76,13 @@
|
||||
android:layout_gravity="start|bottom"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_face"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="center"
|
||||
tools:visibility="gone" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
@@ -126,6 +126,18 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_face"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
|
@@ -120,6 +120,18 @@
|
||||
app:layout_constraintEnd_toEndOf="@id/avatar"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_face"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="@id/avatar"
|
||||
app:layout_constraintEnd_toEndOf="@id/avatar"
|
||||
app:layout_constraintStart_toStartOf="@id/avatar"
|
||||
app:layout_constraintTop_toTopOf="@id/avatar"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_nick"
|
||||
android:layout_width="0dp"
|
||||
|
@@ -94,6 +94,13 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_face"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_gravity="center"
|
||||
tools:visibility="gone" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
|
@@ -76,8 +76,9 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginTop="75dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
@@ -93,7 +94,7 @@
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_mic_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:gravity="end|center_vertical"
|
||||
@@ -111,10 +112,8 @@
|
||||
|
||||
<com.yizhuan.erban.avroom.widget.MicroView
|
||||
android:id="@+id/micro_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp" />
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@@ -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) {
|
||||
|
@@ -195,6 +195,8 @@ public class RoomInfo implements Parcelable,Serializable {
|
||||
|
||||
private String mgName;
|
||||
|
||||
private int mgMicNum;
|
||||
|
||||
private long clearScreenTime;
|
||||
// /**
|
||||
// * 房间角标
|
||||
|
Reference in New Issue
Block a user