趣味活动

This commit is contained in:
18401019693 2022-11-10 16:41:27 +08:00
parent e2f8e52583
commit 752fae680c
8 changed files with 231 additions and 65 deletions

View File

@ -2,6 +2,7 @@ package com.yunbao.common.adapter;
import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -34,6 +35,7 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter {
private final int FUN_GAMES = 3;
private final int RIGHTS_INTERESTS = 4;
private final int RECOMMEND = 5;
private String liveId;
private List<AnchorRecommendItemModel> list = new ArrayList<>();
private List<CustomSidebarInfoModel> infoModels = new ArrayList<>();
@ -42,6 +44,12 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter {
this.mContext = mContext;
}
public CustomDrawerPopupAdapter setLiveId(String liveId) {
this.liveId = liveId;
return this;
}
public CustomDrawerPopupAdapter setList(List<AnchorRecommendItemModel> list) {
this.list = list;
return this;
@ -98,7 +106,15 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter {
public void onSuccess(AnchorRecommendModel anchorRecommendModel) {
List<AnchorRecommendItemModel> models = anchorRecommendModel.getList();
int userIndex = -1;
for (int i = 0; i < models.size(); i++) {
if (TextUtils.equals(models.get(i).getUid(), liveId)) {
userIndex = i;
}
}
if (userIndex != -1) {
models.remove(userIndex);
}
recommendViewHolder.updateData(models);
}

View File

@ -28,6 +28,17 @@ public class CustomSidebarChildModel extends BaseModel {
private String needNum;
@SerializedName("now_num")
private String nowNum;
@SerializedName("activity_id")
private String activityId;
public String getActivityId() {
return activityId;
}
public CustomSidebarChildModel setActivityId(String activityId) {
this.activityId = activityId;
return this;
}
private int resIcon;

View File

@ -10,14 +10,18 @@ import java.util.List;
public class CustomSidebarInfoModel extends BaseModel {
@SerializedName("id")
private String id;
//一级标题
@SerializedName("title")
private String title;
//二级标题
@SerializedName("subtitle")
private String subtitle;
@SerializedName("sort")
private String sort;
//1全屏 2半屏
@SerializedName("show_type")
private String showType;
//跳转链接
@SerializedName("src")
private String src;
@SerializedName("type")

View File

@ -5,7 +5,41 @@ import com.yunbao.common.bean.BaseModel;
public class CustomDrawerPopupEvent extends BaseModel {
//是否关闭弹窗
private boolean isDisMiss = false;
//权益的名字
private String rightsInterests = "";
//活动的id
private int activityId = -1;
//跳转网页地址
private String htmlUrl;
//是否半屏展示
private boolean screen = false;
public String getHtmlUrl() {
return htmlUrl;
}
public CustomDrawerPopupEvent setHtmlUrl(String htmlUrl) {
this.htmlUrl = htmlUrl;
return this;
}
public boolean isScreen() {
return screen;
}
public CustomDrawerPopupEvent setScreen(boolean screen) {
this.screen = screen;
return this;
}
public int getActivityId() {
return activityId;
}
public CustomDrawerPopupEvent setActivityId(int activityId) {
this.activityId = activityId;
return this;
}
public String getRightsInterests() {
return rightsInterests;

View File

@ -1,6 +1,7 @@
package com.yunbao.common.views;
import android.content.Context;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
@ -28,6 +29,12 @@ public class CustomDrawerPopupView extends DrawerPopupView {
private RecyclerView drawerList;
private CustomDrawerPopupAdapter adapter;
private List<AnchorRecommendItemModel> list = new ArrayList<>();
private String liveId;
public CustomDrawerPopupView setLiveId(String liveId) {
this.liveId = liveId;
return this;
}
public CustomDrawerPopupView setList(List<AnchorRecommendItemModel> list) {
this.list = list;
@ -62,7 +69,7 @@ public class CustomDrawerPopupView extends DrawerPopupView {
private void initView() {
drawerList = findViewById(R.id.drawerList);
adapter = new CustomDrawerPopupAdapter(mContext);
adapter.setList(list);
adapter.setList(list).setLiveId(liveId);
drawerList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
drawerList.setAdapter(adapter);
adapter.setListener(new CustomDrawerPopupAdapter.CustomDrawerListener() {
@ -101,12 +108,20 @@ public class CustomDrawerPopupView extends DrawerPopupView {
void goToLive(AnchorRecommendItemModel model);
void informationTransfer(CustomDrawerPopupEvent event);
void funGamesID(int zfunGamesID);
void showerHtml(String htmlUrl, boolean screen);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void OnCustomDrawerPopupEvent(CustomDrawerPopupEvent event) {
if (callBack != null) {
callBack.informationTransfer(event);
callBack.funGamesID(event.getActivityId());
if (!TextUtils.isEmpty(event.getHtmlUrl())) {
callBack.showerHtml(event.getHtmlUrl(), event.isScreen());
}
}
//是否关闭弹窗
if (event.isDisMiss()) {

View File

@ -1,5 +1,6 @@
package com.yunbao.common.views;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
@ -41,6 +42,10 @@ public class FunGamesChildViewHolder extends RecyclerView.ViewHolder {
if (!rigts) {
Bus.get().post(new CustomDrawerPopupEvent()
.setDisMiss(true).setRightsInterests(model.getTitle()));
} else {
int activityID = TextUtils.isEmpty(model.getActivityId()) ? -1 : Integer.parseInt(model.getActivityId());
Bus.get().post(new CustomDrawerPopupEvent()
.setDisMiss(true).setActivityId(activityID));
}
}
});

View File

@ -1,5 +1,7 @@
package com.yunbao.common.views;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
@ -7,9 +9,16 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.R;
import com.yunbao.common.adapter.FunGamesAdapter;
import com.yunbao.common.bean.CustomSidebarInfoModel;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.event.CustomDrawerPopupEvent;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
public class FunGamesViewHolder extends RecyclerView.ViewHolder {
private FunGamesAdapter funGamesAdapter;
@ -24,11 +33,36 @@ public class FunGamesViewHolder extends RecyclerView.ViewHolder {
funGamesAdapter = new FunGamesAdapter(itemView.getContext(), true);
childList.setLayoutManager(new GridLayoutManager(itemView.getContext(), 4));
childList.setAdapter(funGamesAdapter);
}
public void setData(CustomSidebarInfoModel model) {
sendGoodGift.setText(model.getTitle());
subtitle.setText(model.getSubtitle());
funGamesAdapter.updateData(model.getChild());
ViewClicksAntiShake.clicksAntiShake(subtitle, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
if (TextUtils.isEmpty(model.getSrc())) {
ToastUtil.show("SHOWER_ERROR");
} else {
IMLoginModel userInfo = IMLoginManager.get(itemView.getContext()).getUserInfo();
StringBuffer htmlUrl = new StringBuffer();
htmlUrl.append(CommonAppConfig.HOST)
.append("/")
.append(model.getSrc())
.append("&uid=")
.append(userInfo.getId())
.append("&token=")
.append(userInfo.getToken());
Bus.get().post(new CustomDrawerPopupEvent()
.setDisMiss(true)
.setHtmlUrl(htmlUrl.toString())
.setScreen(TextUtils.equals(model.getShowType(), "2")));
}
}
});
}
}

View File

@ -85,6 +85,7 @@ import com.yunbao.live.dialog.LiveGameDialogFragment;
import com.yunbao.live.dialog.LiveGiftDialogFragment;
import com.yunbao.live.dialog.LiveHDDialogFragment;
import com.yunbao.live.dialog.LiveMicUserDialogFragment;
import com.yunbao.live.dialog.LiveTotalDialog;
import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience;
import com.yunbao.live.dialog.SignDialogFragment;
import com.yunbao.live.event.LinkMicTxAccEvent;
@ -692,8 +693,41 @@ public class LiveAudienceActivity extends LiveActivity {
Bundle bundle = new Bundle();
Log.i("SocketRyClient", "onOpenDrawer: " + event.getType() + " " + event);
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
CustomDrawerPopupView customDrawerPopupView = new CustomDrawerPopupView(mContext).setList(list);
switch (event.getType()) {
case SIDEBAR:
case BOTTOM_COLLECTION:
if (event.isActivity()) {
LiveTotalDialog liveTotalDialog = new LiveTotalDialog();
liveTotalDialog.setAnchorBean(mLiveBean);
Bundle liveBundle = new Bundle();
liveBundle.putBoolean("isActivity", event.isActivity());
liveTotalDialog.setArguments(liveBundle);
liveTotalDialog.show(getSupportFragmentManager(), "LiveTotalDialog");
} else {
int userIndex = -1;
for (int i = 0; i < list.size(); i++) {
if (TextUtils.equals(list.get(i).getUid(), PortraitLiveManager.liveID)) {
userIndex = i;
}
}
if (userIndex != -1) {
list.remove(userIndex);
}
CustomDrawerPopupView customDrawerPopupView = new CustomDrawerPopupView(mContext).setList(list).setLiveId(mLiveBean.getUid());
customDrawerPopupView.setCallBack(new CustomDrawerPopupView.CustomDrawerPopupCallBack() {
@Override
public void funGamesID(int zfunGamesID) {
if (zfunGamesID != 0) {
LiveGameDialogFragment fragment = new LiveGameDialogFragment();
fragment.setActivityId(zfunGamesID);
fragment.setRoomId(mLiveUid);
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGameDialogFragment");
} else {
}
}
@Override
public void goToLive(AnchorRecommendItemModel model) {
//获取直播间状态
@ -717,10 +751,20 @@ public class LiveAudienceActivity extends LiveActivity {
.setType(LiveAudienceEvent.LiveAudienceType.FAN_CLUB));
}
}
@Override
public void showerHtml(String htmlUrl, boolean screen) {
if (!screen) {
ZhuangBanActivity.forward(mContext, htmlUrl, false);
} else {
Bundle bundle = new Bundle();
bundle.putString("url", htmlUrl);
LiveHDDialogFragment fragment = new LiveHDDialogFragment();
fragment.setArguments(bundle);
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
}
}
});
switch (event.getType()) {
case SIDEBAR:
case BOTTOM_COLLECTION:
new XPopup.Builder(mContext)
.hasShadowBg(false)
.isDestroyOnDismiss(true)
@ -775,8 +819,12 @@ public class LiveAudienceActivity extends LiveActivity {
})
.asCustom(customDrawerPopupView)
.show();
}
break;
case GIFT_POPUP:
if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream)) {
return;
}
@ -1102,7 +1150,6 @@ public class LiveAudienceActivity extends LiveActivity {
slideInfoModels.clear();
List<AnchorRecommendItemModel> models = anchorRecommendModel.getList();
models.add(0, new AnchorRecommendItemModel());
list.addAll(models);
slideInfoModels = anchorRecommendModel.getSlide();
}