新增H5进入房间打开礼物面板方法
This commit is contained in:
@@ -106,6 +106,7 @@ import com.yizhuan.xchat_android_core.patriarch.event.PmDismissAllLimitDialogEve
|
||||
import com.yizhuan.xchat_android_core.patriarch.exception.PmRoomLimitException;
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedPackageModel;
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
|
||||
import com.yizhuan.xchat_android_core.room.anotherroompk.ShowGiftDialogEvent;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomModeType;
|
||||
import com.yizhuan.xchat_android_core.room.dragonball.DragonBallModel;
|
||||
@@ -166,6 +167,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
private int fromType = FROM_TYPE_NORMAL;// 入口类型 0 其他 1 推荐 2 个人主页或者广场
|
||||
private String fromNick = "";// 从萌圈进入时 需要传入作品发布者的昵称
|
||||
private String fromUid = "";
|
||||
private int giftId;
|
||||
private RelativeLayout finishLayout;
|
||||
private ViewStub mVsRoomOffline;
|
||||
private ImageView avatarBg;
|
||||
@@ -199,15 +201,20 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
}
|
||||
|
||||
public static void start(Context context, long roomUid, int fromType, String fromNick, @Nullable RedPackageNotifyInfo notifyInfo) {
|
||||
startForFromType(context, roomUid, fromType, fromNick, null, notifyInfo);
|
||||
startForFromType(context, roomUid, fromType, fromNick, null, notifyInfo, 0);
|
||||
}
|
||||
|
||||
public static void startForFromType(Context context, long roomUid, int fromType) {
|
||||
startForFromType(context, roomUid, fromType, null, null);
|
||||
}
|
||||
|
||||
public static void startForFromGiftId(Context context, long roomUid, int giftId) {
|
||||
startForFromType(context, roomUid, FROM_TYPE_NORMAL, null, null, null, giftId);
|
||||
}
|
||||
|
||||
|
||||
public static void startForFromType(Context context, long roomUid, int fromType, @Nullable String fromNick, @Nullable String fromUid) {
|
||||
startForFromType(context, roomUid, fromType, fromNick, fromUid, null);
|
||||
startForFromType(context, roomUid, fromType, fromNick, fromUid, null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,7 +232,13 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_INTO_ROOM_CLICK, "进入房间");
|
||||
}
|
||||
|
||||
public static void startForFromType(Context context, long roomUid, int fromType, @Nullable String fromNick, @Nullable String fromUid, @Nullable RedPackageNotifyInfo notifyInfo) {
|
||||
public static void startForFromType(Context context,
|
||||
long roomUid,
|
||||
int fromType,
|
||||
@Nullable String fromNick,
|
||||
@Nullable String fromUid,
|
||||
@Nullable RedPackageNotifyInfo notifyInfo,
|
||||
int giftId) {
|
||||
Intent intent = new Intent(context, AVRoomActivity.class);
|
||||
intent.putExtra(Constants.ROOM_UID, roomUid);
|
||||
intent.putExtra("fromType", fromType);
|
||||
@@ -238,6 +251,9 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
if (notifyInfo != null) {
|
||||
intent.putExtra("notifyInfo", notifyInfo);
|
||||
}
|
||||
if (giftId != 0) {
|
||||
intent.putExtra("giftId", giftId);
|
||||
}
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_INTO_ROOM_CLICK, "进入房间");
|
||||
@@ -325,19 +341,15 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
// 如果是同一个房间,则只更新房间的信息
|
||||
long newRoomUid = intent.getLongExtra(Constants.ROOM_UID, 0);
|
||||
fromType = intent.getIntExtra("fromType", 0);
|
||||
fromNick = intent.getStringExtra("fromNick");
|
||||
fromUid = intent.getStringExtra("fromUid");
|
||||
mRoomInfo = intent.getParcelableExtra(Constants.ROOM_INFO);
|
||||
if (newRoomUid != 0 && newRoomUid == roomUid) {
|
||||
long oldRoomUid = roomUid;
|
||||
initIntentExtra(intent);
|
||||
if (roomUid != 0 && oldRoomUid == roomUid) {
|
||||
updateRoomInfo();
|
||||
showRedPackage(AvRoomDataManager.get().mCurrentRoomInfo);
|
||||
showRoomFragment(false);
|
||||
dismissLoadingDialog();
|
||||
return;
|
||||
}
|
||||
roomUid = newRoomUid;
|
||||
// 相同类型的房间,但是是不同人的房间
|
||||
if (AvRoomDataManager.get().isFirstEnterRoomOrChangeOtherRoom(roomUid)) {
|
||||
showLoadingDialog();
|
||||
@@ -358,17 +370,23 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
}
|
||||
}
|
||||
|
||||
private void initIntentExtra(Intent intent) {
|
||||
if (intent == null) return;
|
||||
roomUid = getIntent().getLongExtra(Constants.ROOM_UID, 0);
|
||||
fromType = intent.getIntExtra("fromType", 0);
|
||||
fromNick = intent.getStringExtra("fromNick");
|
||||
fromUid = intent.getStringExtra("fromUid");
|
||||
giftId = intent.getIntExtra("giftId", 0);
|
||||
mRoomInfo = intent.getParcelableExtra(Constants.ROOM_INFO);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_chat_room);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
roomUid = getIntent().getLongExtra(Constants.ROOM_UID, 0);
|
||||
fromType = getIntent().getIntExtra("fromType", 0);
|
||||
fromNick = getIntent().getStringExtra("fromNick");
|
||||
fromUid = getIntent().getStringExtra("fromUid");
|
||||
mRoomInfo = (RoomInfo) getIntent().getSerializableExtra(Constants.ROOM_INFO);
|
||||
initIntentExtra(getIntent());
|
||||
mVsRoomOffline = findViewById(R.id.vs_room_offline);
|
||||
mVsNobleOpen = findViewById(R.id.vs_noble_open_notice);
|
||||
viewpager = findViewById(R.id.fragment_container);
|
||||
@@ -1001,6 +1019,10 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
DemoCache.saveNewUserChargeGift(1);
|
||||
}
|
||||
dismissLoadingDialog();
|
||||
if (giftId != 0) {
|
||||
EventBus.getDefault().post(new ShowGiftDialogEvent().setGiftId(giftId));
|
||||
giftId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -254,7 +254,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
RxBus.get().toFlowable(ShowGiftDialogEvent::class.java)
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { onSendGiftBtnClick() }
|
||||
.subscribe { onSendGiftBtnClick(it.giftId) }
|
||||
|
||||
RxBus.get().toFlowable(ShowUserInfoDialogEvent::class.java)
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
|
||||
@@ -1126,10 +1126,10 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
}
|
||||
}
|
||||
|
||||
private fun onSendGiftBtnClick() {
|
||||
private fun onSendGiftBtnClick(giftId: Int = 0) {
|
||||
if (giftDialog == null) {
|
||||
GiftDialog.GIFT_DIALOG_FROM = "房间"
|
||||
giftDialog = GiftDialog(context, 0, true)
|
||||
giftDialog = GiftDialog(context, giftId)
|
||||
giftDialog?.setGiftDialogBtnClickListener(this@BaseRoomFragment)
|
||||
giftDialog?.setOnDismissListener { giftDialog = null }
|
||||
}
|
||||
|
@@ -178,6 +178,25 @@ public class JSInterface {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 调转房间
|
||||
*
|
||||
* @param uid 房主uid
|
||||
*/
|
||||
@JavascriptInterface
|
||||
public void openRoomForGiftId(String uid, int giftId) {
|
||||
LogUtil.i(TAG, "openRoom:" + uid + "giftId=" + giftId);
|
||||
if (!TextUtils.isEmpty(uid)) {
|
||||
try {
|
||||
long uidLong = Long.parseLong(uid);
|
||||
mActivity.runOnUiThread(() -> AVRoomActivity.startForFromGiftId(context, uidLong, giftId));
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户ticket
|
||||
*
|
||||
|
@@ -179,6 +179,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
* 被送礼物的人的uid
|
||||
*/
|
||||
private long uid;
|
||||
private int giftId;
|
||||
private List<MicMemberInfo> micMemberInfos;
|
||||
private View giftNumLayout;
|
||||
private Disposable mSubscribe;
|
||||
@@ -200,6 +201,10 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
private WalletInfo goldWalletInfo;
|
||||
private int itemType = ITEM_TYPE_GOLD;
|
||||
|
||||
public GiftDialog(Context context, int giftId) {
|
||||
this(context, 0, true, false, true, giftId);
|
||||
}
|
||||
|
||||
public GiftDialog(Context context, long OtherUid, boolean isInRoom) {
|
||||
this(context, OtherUid, isInRoom, false);
|
||||
}
|
||||
@@ -208,6 +213,10 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
this(context, OtherUid, isInRoom, isMagic, true);
|
||||
}
|
||||
|
||||
public GiftDialog(Context context, long OtherUid, boolean isInRoom, boolean isMagic, boolean isHideMagicTab) {
|
||||
this(context, OtherUid, isInRoom, isMagic, isHideMagicTab, 0);
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param context context
|
||||
@@ -216,10 +225,11 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
* false表示不在房间,此时OtherUid就是被赠送人的ID
|
||||
* @param isHideMagicTab true则隐藏魔法,默认false
|
||||
*/
|
||||
public GiftDialog(Context context, long OtherUid, boolean isInRoom, boolean isMagic, boolean isHideMagicTab) {
|
||||
public GiftDialog(Context context, long OtherUid, boolean isInRoom, boolean isMagic, boolean isHideMagicTab, int giftId) {
|
||||
super(context, R.style.ErbanBottomSheetDialogDimFalse);
|
||||
this.context = context;
|
||||
this.uid = OtherUid;
|
||||
this.giftId = giftId;
|
||||
this.micMemberInfos = new ArrayList<>();
|
||||
this.micMemberInfos.addAll(transformAvatarList(OtherUid));
|
||||
this.isInRoom = isInRoom;
|
||||
@@ -229,11 +239,16 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
this.userOnMic = AvRoomDataManager.get().checkIsOnMicByAccount(String.valueOf(uid));
|
||||
}
|
||||
|
||||
private static <T> List<List<IItem>> beanTransformVm(Context context, List<T> data, boolean isKnap, int pageSize) {
|
||||
private static <T> List<List<IItem>> beanTransformVm(Context context,
|
||||
List<T> data,
|
||||
boolean isKnap,
|
||||
int pageSize,
|
||||
@Nullable GiftInfo selectGiftInfo) {
|
||||
List<List<IItem>> result = new ArrayList<>();
|
||||
if (ListUtils.isListEmpty(data)) {
|
||||
return result;
|
||||
}
|
||||
boolean hasSelectGift = false;
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
IItem item = null;
|
||||
List<IItem> page = null;
|
||||
@@ -245,8 +260,14 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
page = result.get(result.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.get(i) instanceof GiftInfo) {
|
||||
item = createGiftItem(context, (GiftInfo) data.get(i), i == 0, isKnap);
|
||||
boolean select = false;
|
||||
if (selectGiftInfo != null && selectGiftInfo.getGiftId() == ((GiftInfo) data.get(i)).getGiftId()) {
|
||||
hasSelectGift = true;
|
||||
select = true;
|
||||
}
|
||||
item = createGiftItem(context, (GiftInfo) data.get(i), select, isKnap);
|
||||
} else if (data.get(i) instanceof MagicInfo) {
|
||||
item = createMagicItem(context, (MagicInfo) data.get(i), i == 0);
|
||||
}
|
||||
@@ -254,6 +275,9 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
page.add(item);
|
||||
}
|
||||
}
|
||||
if (!hasSelectGift && result.get(0).get(0) instanceof GiftInfoVm) {
|
||||
((GiftInfoVm) result.get(0).get(0)).isSelect.set(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -408,11 +432,6 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
}
|
||||
});
|
||||
|
||||
if (isMagic) { //如果是送魔法,则直接指向魔法的tab
|
||||
giftIndicator.setPosition(GiftIndicator.TYPE_MAGIC);
|
||||
} else {
|
||||
giftIndicator.setPosition(GiftIndicator.TYPE_NORMAL);
|
||||
}
|
||||
if (isHideMagicTab) {
|
||||
giftIndicator.hidePosition(GiftIndicator.TYPE_MAGIC);
|
||||
} else {
|
||||
@@ -458,8 +477,33 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
tvGiftValue = root.findViewById(R.id.tv_gift_value);
|
||||
ivFirstRecharge.setOnClickListener(this);
|
||||
tvLuckyBagIntro.setOnClickListener(this);
|
||||
if (giftId == 0) {
|
||||
// 更新所有礼物
|
||||
giftIndicator.setPosition(GiftIndicator.TYPE_NORMAL);
|
||||
updateGiftView(giftIndicator.getCurrrentType());
|
||||
} else {
|
||||
int indicatorType = GiftIndicator.TYPE_NORMAL;
|
||||
GiftInfo giftInfo = GiftModel.get().findGiftInfoById(giftId);
|
||||
if (giftInfo != null) {
|
||||
switch (giftInfo.getGiftType()) {
|
||||
case GiftType.GIFT_TYPE_NORMAL:
|
||||
indicatorType = GiftIndicator.TYPE_NORMAL;
|
||||
break;
|
||||
case GiftType.GIFT_TYPE_LUCKY:
|
||||
indicatorType = GiftIndicator.TYPE_LUCKY;
|
||||
break;
|
||||
case GiftType.GIFT_TYPE_VIP:
|
||||
indicatorType = GiftIndicator.TYPE_NOBLE;
|
||||
break;
|
||||
case GiftType.GIFT_TYPE_WEEK_STAR:
|
||||
indicatorType = GiftIndicator.TYPE_WEEK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
giftIndicator.setPosition(indicatorType);
|
||||
updateGiftView(giftIndicator.getCurrrentType(), giftInfo);
|
||||
}
|
||||
|
||||
goldWalletInfo = PayModel.get().getCurrentWalletInfo();
|
||||
|
||||
View descLayout = root.findViewById(R.id.desc_layout);
|
||||
@@ -630,11 +674,15 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
}
|
||||
currentMagicInfo = currentMagicInfoList.get(0);
|
||||
etSendMessage.setVisibility(View.GONE);
|
||||
List<List<IItem>> pagerList = beanTransformVm(context, currentMagicInfoList, false, 8);
|
||||
List<List<IItem>> pagerList = beanTransformVm(context, currentMagicInfoList, false, 8, null);
|
||||
setGridViewData(pagerList);
|
||||
}
|
||||
|
||||
private void updateGiftView(int position) {
|
||||
updateGiftView(position, null);
|
||||
}
|
||||
|
||||
private void updateGiftView(int position, @Nullable GiftInfo selectGiftInfo) {
|
||||
if (position == GiftIndicator.TYPE_MAGIC) {
|
||||
updateMagicView();
|
||||
return;
|
||||
@@ -677,11 +725,11 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
}
|
||||
return;
|
||||
}
|
||||
currentGiftInfo = currentGiftInfoList.get(0);
|
||||
currentGiftInfo = selectGiftInfo == null ? currentGiftInfoList.get(0) : selectGiftInfo;
|
||||
if (currentGiftInfo.isSendMsg()) {
|
||||
etSendMessage.setVisibility(View.VISIBLE);
|
||||
}
|
||||
pagerList = beanTransformVm(context, currentGiftInfoList, isKnap, position == GiftIndicator.TYPE_WEEK ? 4 : 8);
|
||||
pagerList = beanTransformVm(context, currentGiftInfoList, isKnap, position == GiftIndicator.TYPE_WEEK ? 4 : 8, selectGiftInfo);
|
||||
setGridViewData(pagerList);
|
||||
if (isKnap) {
|
||||
tvGiftValue.setVisibility(View.VISIBLE);
|
||||
@@ -813,13 +861,27 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
return;
|
||||
}
|
||||
indicatorView.initIndicator(pagerList.size());
|
||||
indicatorView.setSelectedPage(0);
|
||||
int defaultSelectPage = 0;
|
||||
int defaultSelectItem = 0;
|
||||
wai:
|
||||
for (int i = 0; i < pagerList.size(); i++) {
|
||||
List<IItem> pager = pagerList.get(i);
|
||||
for (int j = 0; j < pager.size(); j++) {
|
||||
IItem iItem = pager.get(j);
|
||||
if (iItem instanceof GiftInfoVm && ((GiftInfoVm) iItem).isSelect.get()) {
|
||||
defaultSelectPage = i;
|
||||
defaultSelectItem = j;
|
||||
break wai;
|
||||
}
|
||||
}
|
||||
}
|
||||
indicatorView.setSelectedPage(defaultSelectPage);
|
||||
layoutEmpty.setVisibility(View.GONE);
|
||||
gridView.setVisibility(View.VISIBLE);
|
||||
|
||||
indicatorView.setVisibility(pagerList.size() > 1 ? View.VISIBLE : View.INVISIBLE);
|
||||
SparseArray<RecyclerView> cacheItemView = new SparseArray<>();
|
||||
LastSelectedItem = pagerList.get(0).get(0);
|
||||
LastSelectedItem = pagerList.get(defaultSelectPage).get(defaultSelectItem);
|
||||
setGoldOrRadishText(LastSelectedItem);
|
||||
gridView.setAdapter(new PagerAdapter() {
|
||||
|
||||
@@ -896,6 +958,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
container.removeView(recyclerView);
|
||||
}
|
||||
});
|
||||
gridView.setCurrentItem(defaultSelectPage);
|
||||
gridView.addOnPageChangeListener(new OnPageSelectedListener() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
|
@@ -1,5 +1,14 @@
|
||||
package com.yizhuan.xchat_android_core.room.anotherroompk;
|
||||
|
||||
public class ShowGiftDialogEvent {
|
||||
private int giftId;
|
||||
|
||||
public int getGiftId() {
|
||||
return giftId;
|
||||
}
|
||||
|
||||
public ShowGiftDialogEvent setGiftId(int giftId) {
|
||||
this.giftId = giftId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user