From ec3722b7d0dc94c9d3720b8c7104ee5c0f7665cd Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Thu, 10 Aug 2023 16:53:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=B2=89=E4=B8=9D=E5=9B=A2?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=BA=A2=E7=82=B9=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/bean/FansCheckRed.java | 19 ++++++++++ .../com/yunbao/common/http/PDLiveApi.java | 6 ++++ .../common/http/live/LiveNetManager.java | 22 ++++++++++++ .../live/activity/LiveAudienceActivity.java | 9 ++++- .../yunbao/live/dialog/LiveFansFragment.java | 4 +++ .../live/dialog/LiveRoleDialogFragment.java | 8 +++++ .../yunbao/live/event/LiveAudienceEvent.java | 3 +- .../yunbao/live/views/AbsLiveViewHolder.java | 4 ++- .../live/views/LiveAudienceViewHolder.java | 5 +-- .../yunbao/live/views/LiveRoomViewHolder.java | 28 ++++++++++----- .../live/views/PortraitLiveManager.java | 1 + live/src/main/res/layout/dialog_live_role.xml | 34 ++++++++++++++---- .../main/res/layout/view_live_audience.xml | 36 +++++++++++++++---- 13 files changed, 154 insertions(+), 25 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/bean/FansCheckRed.java diff --git a/common/src/main/java/com/yunbao/common/bean/FansCheckRed.java b/common/src/main/java/com/yunbao/common/bean/FansCheckRed.java new file mode 100644 index 000000000..179306b4f --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/FansCheckRed.java @@ -0,0 +1,19 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +public class FansCheckRed extends BaseModel{ + @SerializedName("fans_level_upgrade_status") + private int status; + + public FansCheckRed() { + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } +} diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 078435eea..303544ac4 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -12,6 +12,7 @@ import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.DiscountsModel; import com.yunbao.common.bean.EnterRoomNewModel; import com.yunbao.common.bean.FaceBookUpModel; +import com.yunbao.common.bean.FansCheckRed; import com.yunbao.common.bean.FansGroupGiftPack; import com.yunbao.common.bean.FansGroupGiftPackInfo; import com.yunbao.common.bean.GiftAlreadyWallModel; @@ -953,6 +954,11 @@ public interface PDLiveApi { */ @GET("/api/public/?service=Fans.userFansExclusivePackList") Observable>> userFansExclusivePackList(@Query("liveuid") String liveUid); + /** + * 获取粉丝团礼物包裹 + */ + @GET("/api/public/?service=Fans.getCheckFansLevelUpgrade") + Observable> getCheckFansLevelUpgrade(@Query("liveuid") String liveUid); } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 42ddb6305..8fc7bdbfe 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -13,6 +13,7 @@ import com.yunbao.common.bean.CheckLiveModel; import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.DiscountsModel; import com.yunbao.common.bean.EnterRoomNewModel; +import com.yunbao.common.bean.FansCheckRed; import com.yunbao.common.bean.FansGroupGiftPack; import com.yunbao.common.bean.FansGroupGiftPackInfo; import com.yunbao.common.bean.GiftAlreadyWallModel; @@ -2137,6 +2138,27 @@ public class LiveNetManager { } }).isDisposed(); } + public void getCheckFansLevelUpgrade(String liveUid, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .getCheckFansLevelUpgrade(liveUid) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(listResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } /** * 直播间取消网络请求 diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 56bedbc22..dafb2a61e 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -44,6 +44,7 @@ import com.yunbao.common.activity.WebViewActivity; import com.yunbao.common.bean.AnchorRecommendItemModel; import com.yunbao.common.bean.AnchorRecommendModel; import com.yunbao.common.bean.CrashSaveBean; +import com.yunbao.common.bean.FansCheckRed; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.LinkMicUserBean; import com.yunbao.common.bean.LiveBean; @@ -1601,7 +1602,13 @@ public class LiveAudienceActivity extends LiveActivity { } manager.mLiveAudienceViewHolder.mRedPoint.setVisibility(View.VISIBLE); } - + public void setShowCrownRed(boolean isShow){ + if(isShow){ + manager.mLiveAudienceViewHolder.mRedPointPrivilege.setVisibility(View.VISIBLE); + }else{ + manager.mLiveAudienceViewHolder.mRedPointPrivilege.setVisibility(View.GONE); + } + } public void closeRoom() { runOnUiThread(new Runnable() { diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java index 4a1018d66..45a3c034a 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java @@ -25,8 +25,10 @@ import com.yunbao.common.utils.L; import com.yunbao.common.utils.ToastUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveAudienceActivity; +import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.views.LiveRoomViewHolder; +import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -118,6 +120,8 @@ public class LiveFansFragment extends AbsDialogFragment { public void onDestroy() { super.onDestroy(); mContext = null; + EventBus.getDefault().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.UPDATE_FANS_TASK_STATUS)); } @Subscribe(threadMode = ThreadMode.MAIN) diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveRoleDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveRoleDialogFragment.java index 4327e7dee..74cd98431 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveRoleDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveRoleDialogFragment.java @@ -2,6 +2,7 @@ package com.yunbao.live.dialog; import android.os.Bundle; import android.view.Gravity; +import android.view.View; import android.view.Window; import android.view.WindowManager; @@ -14,6 +15,8 @@ import com.yunbao.live.R; import com.yunbao.live.event.LiveAudienceEvent; public class LiveRoleDialogFragment extends AbsDialogFragment { + View redPoint; + @Override protected int getLayoutId() { return R.layout.dialog_live_role; @@ -43,6 +46,11 @@ public class LiveRoleDialogFragment extends AbsDialogFragment { @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); + Bundle bundle = getArguments(); + redPoint = findViewById(R.id.red_point); + if (bundle != null && bundle.getBoolean("showRed", false)) { + redPoint.setVisibility(View.VISIBLE); + } //粉丝团 ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.fan_club), () -> { Bus.get().post(new LiveAudienceEvent() diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java index ad7dd3660..bbe5da6a8 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -464,7 +464,8 @@ public class LiveAudienceEvent extends BaseModel { RED_PACKET_SUPER_JACKPOT(70, "超级红包"), INPUT_DIALOG(71, "输入框"), IS_ATTENTION(72,"是否关注主播"), - GIFT_WALL(73,"礼物墙"); + GIFT_WALL(73,"礼物墙"), + UPDATE_FANS_TASK_STATUS(74,"更新粉丝任务状态"); private int type; private String name; diff --git a/live/src/main/java/com/yunbao/live/views/AbsLiveViewHolder.java b/live/src/main/java/com/yunbao/live/views/AbsLiveViewHolder.java index 4f38c8143..16b57fd00 100644 --- a/live/src/main/java/com/yunbao/live/views/AbsLiveViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/AbsLiveViewHolder.java @@ -17,7 +17,8 @@ import org.greenrobot.eventbus.EventBus; public abstract class AbsLiveViewHolder extends AbsViewHolder implements View.OnClickListener { - public TextView mRedPoint; + public TextView mRedPoint;//消息上的红点 + public View mRedPointPrivilege;//皇冠上的点 public AbsLiveViewHolder(Context context, ViewGroup parentView) { super(context, parentView); @@ -28,6 +29,7 @@ public abstract class AbsLiveViewHolder extends AbsViewHolder implements View.On findViewById(R.id.et_input).setOnClickListener(this); findViewById(R.id.btn_msg).setOnClickListener(this); mRedPoint = (TextView) findViewById(R.id.red_point); + mRedPointPrivilege = findViewById(R.id.privilege_red_point); } diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java index f613222ae..e71075a0a 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java @@ -91,8 +91,6 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { } - - @Override protected int getLayoutId() { return R.layout.view_live_audience; @@ -459,6 +457,9 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { */ public void openRoleDialog() { LiveRoleDialogFragment fragment = new LiveRoleDialogFragment(); + Bundle bundle = new Bundle(); + bundle.putBoolean("showRed", mRedPointPrivilege.getVisibility() == View.VISIBLE); + fragment.setArguments(bundle); fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveRoleDialogFragment"); } diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index 981f40e02..8f0b709af 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -66,6 +66,7 @@ import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.bean.AiAutomaticSpeechModel; import com.yunbao.common.bean.BannerBean; import com.yunbao.common.bean.BaseModel; +import com.yunbao.common.bean.FansCheckRed; import com.yunbao.common.bean.GiftModel; import com.yunbao.common.bean.GuardUserModel; import com.yunbao.common.bean.HourRank; @@ -4576,8 +4577,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis int fount = event.getNums(); mLiveChatAdapter.switchFount(fount); break; - - + case UPDATE_FANS_TASK_STATUS: + updateFansMessageRed(); + break; } } @@ -5429,11 +5431,21 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis mLiveGiftAnimPresenter.setLiveUidStream(mLiveUid, mStream); } - public void sendWelcomeFans() { - LiveChatBean chatBean = new LiveChatBean(); - chatBean.setContent("123123test1243"); - chatBean.setType(LiveChatBean.SYSTEM3_COLOR); - chatBean.setBubble("https://downs.yaoulive.com/20230322/g2_.9.png"); - insertChat(chatBean, 1); + public void updateFansMessageRed() { + if (mContext instanceof LiveAudienceActivity) { + LiveNetManager.get(mContext) + .getCheckFansLevelUpgrade(mLiveUid, new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(FansCheckRed data) { + ((LiveAudienceActivity) mContext).setShowCrownRed(data.getStatus() == 1); + + } + + @Override + public void onError(String error) { + + } + }); + } } } diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 5a61f6020..c78937083 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -520,6 +520,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.initTopBanner(); mLiveRoomViewHolder.updateTopBanner(); mLiveRoomViewHolder.setVoteData(data.getEnterRoomInfo().getVoteModel()); + mLiveRoomViewHolder.updateFansMessageRed(); isattention = Integer.parseInt(data.getEnterRoomInfo().getIsattention()); if (isattention == 0) { diff --git a/live/src/main/res/layout/dialog_live_role.xml b/live/src/main/res/layout/dialog_live_role.xml index 76ddfc6ef..99de1edf8 100644 --- a/live/src/main/res/layout/dialog_live_role.xml +++ b/live/src/main/res/layout/dialog_live_role.xml @@ -1,9 +1,10 @@ + android:layout_height="171dp" + android:background="@mipmap/img_pop_bg"> @@ -82,10 +83,31 @@ android:gravity="center" android:orientation="vertical"> - + android:layout_height="40dp"> + + + + + + + - + + + + + + + +