From a66a32038c3b1f3d70e546080f3067e94d606661 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Tue, 8 Nov 2022 11:38:20 +0800 Subject: [PATCH] update --- .../com/yunbao/common/utils/NobleUtil.java | 2 +- .../live/dialog/LiveUserDialogFragment.java | 86 +++++++++++++++++-- .../yunbao/live/views/LiveRoomViewHolder.java | 2 +- .../main/res/layout/dialog_new_live_user.xml | 2 +- 4 files changed, 83 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/utils/NobleUtil.java b/common/src/main/java/com/yunbao/common/utils/NobleUtil.java index 40a7d458d..868b3984a 100644 --- a/common/src/main/java/com/yunbao/common/utils/NobleUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/NobleUtil.java @@ -32,6 +32,6 @@ public class NobleUtil { case 6:return "皇帝"; case 7:return "超皇"; } - return ""; + return "未开通"; } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java index a918c7249..9224bd156 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java @@ -1,6 +1,7 @@ package com.yunbao.live.dialog; import android.app.Dialog; +import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Bundle; @@ -102,6 +103,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On private TextView mPraise; private TextView mSignDesc; private TextView mNobleVal; + private TextView mReport; private ImageView mFollowImage; private ImageView mSex; private ImageView good_nub_ico; @@ -109,7 +111,9 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On private ImageView mLiveIcon2; private ImageView mNoble; private ImageView mAvatar; + private ImageView shawl; private UserBean mUserBean; + private boolean mFollowing; GifImageView btn_live; SVGAImageView gift_svga; @@ -165,7 +169,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On } else if (mType == TYPE_AUD_AUD) { bottomView = inflater.inflate(R.layout.dialog_live_user_bottom_1, mBottomContainer, false); } else if (mType == TYPE_ANC_AUD) { - bottomView = inflater.inflate(R.layout.dialog_live_user_bottom_2, mBottomContainer, false); + bottomView = inflater.inflate(R.layout.dialog_live_user_bottom_1, mBottomContainer, false); } else if (mType == TYPE_AUD_SELF) { bottomView = inflater.inflate(R.layout.dialog_live_user_bottom_3, mBottomContainer, false); } @@ -207,6 +211,8 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On mSignDesc = mRootView.findViewById(R.id.sign); mAvatar = mRootView.findViewById(R.id.avatar); mNobleVal = mRootView.findViewById(R.id.noble_val); + shawl = (ImageView) mRootView.findViewById(R.id.shawl); + mReport = mRootView.findViewById(R.id.btn_report); } private void initListener() { @@ -216,6 +222,8 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On // gotoLive(mToUid); } }); + mAvatar.setOnClickListener(this); + mReport.setOnClickListener(this); } private void loadData() { @@ -251,6 +259,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On } private void showData(String data) { + ToastUtil.show(mLiveUid+"="+mToUid); Log.i(TAG, "showData: " + data); JSONObject obj = JSON.parseObject(data); mUserBean = JSON.toJavaObject(obj, UserBean.class); @@ -271,11 +280,11 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On LevelBean levelBean; if (mLiveUid.equals(mUserBean.getId())) { levelBean = CommonAppConfig.getInstance().getAnchorLevel(mUserBean.getLevelAnchor()); - userLv.setText("Lv."+mUserBean.getLevelAnchor() ); + userLv.setText("Lv." + mUserBean.getLevelAnchor()); mLvDesc.setText(R.string.live_user_level_anchor); } else { levelBean = CommonAppConfig.getInstance().getLevel(mUserBean.getLevel()); - userLv.setText("Lv."+mUserBean.getLevel()); + userLv.setText("Lv." + mUserBean.getLevel()); mLvDesc.setText(R.string.live_user_card_level); } new LiveTextRender().getLevelImage(mContext, levelBean.getLevel(), new ImgLoader.DrawableCallback() { @@ -296,14 +305,19 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On } else { mNoble.setVisibility(View.INVISIBLE); } - mFansVal.setText(WordUtil.getString(R.string.fans)+":"+mUserBean.getFans()); + mFansVal.setText(WordUtil.getString(R.string.fans) + ":" + mUserBean.getFans()); mSignDesc.setText(mUserBean.getSignature()); mNobleVal.setText(NobleUtil.nobleIdToStringName(Integer.parseInt(mUserBean.getNoble_id()))); ImgLoader.displayAvatar(mContext, obj.getString("avatar"), mAvatar); + mFollowing = obj.getIntValue("isattention") == 1; + updateFollow(); //装扮相关 JSONObject dress = obj.getJSONObject("dress"); + if (dress.getJSONArray("wraps").size() >= 1) { + JSONObject display = (JSONObject) dress.getJSONArray("wraps").get(0); + ImgLoader.display(mContext, display.getString("display_src"), shawl); + } if (dress.getJSONArray("avatar_frame").size() == 1) { - JSONObject ico = (JSONObject) dress.getJSONArray("avatar_frame").get(0); if (ico.getString("effect_src") != null) { if (ico.getString("effect_src").contains("svga")) { @@ -334,9 +348,69 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On } + private void updateFollow() { + if (mFollowText != null) { + mFollowText.setText(mFollowing ? R.string.following : R.string.follow); + if (mFollowing) { + mFollowText.setTextColor(Color.parseColor("#B1B1B1")); + } else { + mFollowText.setTextColor(Color.parseColor("#FA6400")); + } + } + if (mFollowImage != null) { + if (mFollowing) { + mFollowImage.setVisibility(View.GONE); + } else { + mFollowImage.setVisibility(View.VISIBLE); + } + } + } + + /** + * 关注 + */ + private void setAttention() { + CommonHttpUtil.setAttention(mToUid, new CommonCallback() { + + @Override + public void callback(Integer isAttention) { + mFollowing = isAttention == 1; + updateFollow(); + if (isAttention == 1 && mLiveUid.equals(mToUid)) {//关注了主播 + ((LiveActivity) mContext).sendSystemMessage( + CommonAppConfig.getInstance().getUserBean().getUserNiceName() + WordUtil.getString(R.string.live_follow_anchor)); + } + } + }); + } + + /** + * 跳转到个人主页 + */ + private void forwardHomePage() { + dismiss(); + Constants.mStream = mStream; + RouteUtil.forwardUserHome(mContext, mToUid, true, mLiveUid, 0); + } + + /** + * 举报 + */ + private void report() { + LiveReportActivity.forward(mContext, mToUid); + } @Override public void onClick(View v) { - + int i = v.getId(); + if (i == R.id.btn_follow) { + setAttention(); + } else if (i == R.id.btn_home_page) { + forwardHomePage(); + } else if (i == R.id.btn_report) { + report(); + } else if (i == R.id.avatar) { + forwardHomePage(); + } } } 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 d2fa2e27d..79bad907b 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -2411,7 +2411,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis */ public void showUserDialog(String toUid) { if (!TextUtils.isEmpty(mLiveUid) && !TextUtils.isEmpty(toUid)) { - LiveOldUserDialogFragment fragment = new LiveOldUserDialogFragment(); + LiveUserDialogFragment fragment = new LiveUserDialogFragment(); Bundle bundle = new Bundle(); bundle.putString(Constants.LIVE_UID, mLiveUid); bundle.putString(Constants.STREAM, mStream); diff --git a/live/src/main/res/layout/dialog_new_live_user.xml b/live/src/main/res/layout/dialog_new_live_user.xml index 65c09bd95..0f8d3fa1a 100644 --- a/live/src/main/res/layout/dialog_new_live_user.xml +++ b/live/src/main/res/layout/dialog_new_live_user.xml @@ -8,7 +8,7 @@