diff --git a/common/src/main/java/com/yunbao/common/utils/CommonIconUtil.java b/common/src/main/java/com/yunbao/common/utils/CommonIconUtil.java index 391d7873b..2b6deafd9 100644 --- a/common/src/main/java/com/yunbao/common/utils/CommonIconUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/CommonIconUtil.java @@ -11,5 +11,8 @@ public class CommonIconUtil { public static int getSexIcon(int key) { return key == 1 ? R.mipmap.icon_sex_male_1 : R.mipmap.icon_sex_female_1; } + public static int getSexIconForUserCard(int key) { + return key == 1 ? R.mipmap.user_card_man : R.mipmap.user_card_woman; + } } diff --git a/common/src/main/res/mipmap-mdpi/good_nub.png b/common/src/main/res/mipmap-mdpi/good_nub.png index 8c586bd75..52c9ae234 100644 Binary files a/common/src/main/res/mipmap-mdpi/good_nub.png and b/common/src/main/res/mipmap-mdpi/good_nub.png differ diff --git a/common/src/main/res/mipmap-mdpi/user_card_id.png b/common/src/main/res/mipmap-mdpi/user_card_id.png new file mode 100644 index 000000000..d2aff3c99 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/user_card_id.png differ diff --git a/common/src/main/res/mipmap-mdpi/user_card_man.png b/common/src/main/res/mipmap-mdpi/user_card_man.png new file mode 100644 index 000000000..6bf8269f3 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/user_card_man.png differ diff --git a/common/src/main/res/mipmap-mdpi/user_card_woman.png b/common/src/main/res/mipmap-mdpi/user_card_woman.png new file mode 100644 index 000000000..1a869f675 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/user_card_woman.png differ diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 0c7d1c2fa..413db6e14 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -702,6 +702,9 @@ 立即支付 使用者等級 主播等級 + 用户等級 + 貴族等級 + 榮譽墻 連接已斷開,請重新開播 空空如也 聊天 @@ -947,4 +950,5 @@ 聊聊天 想在其他APP上方也顯示小窗,\n可前往設置進行授權。 恭喜 %s 在幸運天使中抽中 %s!下一個幸運天使就是你哦! + 守護團%s人 diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveOldUserDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveOldUserDialogFragment.java new file mode 100644 index 000000000..f979a9dd7 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/LiveOldUserDialogFragment.java @@ -0,0 +1,810 @@ +package com.yunbao.live.dialog; + +import android.app.Dialog; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.text.TextUtils; +import android.util.Log; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.core.content.ContextCompat; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.opensource.svgaplayer.SVGADrawable; +import com.opensource.svgaplayer.SVGAImageView; +import com.opensource.svgaplayer.SVGAParser; +import com.opensource.svgaplayer.SVGAVideoEntity; +import com.tencent.imsdk.v2.V2TIMCallback; +import com.tencent.imsdk.v2.V2TIMManager; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.Constants; +import com.yunbao.common.bean.LevelBean; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.bean.UserBean; +import com.yunbao.common.dialog.AbsDialogFragment; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.interfaces.CommonCallback; +import com.yunbao.common.utils.CommonIconUtil; +import com.yunbao.common.utils.DialogUitl; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.SVGAViewUtils; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.WordUtil; +import com.yunbao.live.R; +import com.yunbao.live.activity.LiveActivity; +import com.yunbao.live.activity.LiveReportActivity; +import com.yunbao.live.bean.ImpressBean; +import com.yunbao.live.custom.MyTextView; +import com.yunbao.live.event.LiveRoomChangeEvent; +import com.yunbao.live.http.LiveHttpConsts; +import com.yunbao.live.http.LiveHttpUtil; +import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; +import com.yunbao.live.utils.LiveTextRender; +import com.yunbao.live.views.LiveRoomViewHolder; + +import org.greenrobot.eventbus.EventBus; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +import io.rong.imlib.IRongCoreCallback; +import io.rong.imlib.IRongCoreEnum; +import io.rong.imlib.chatroom.base.RongChatRoomClient; +import pl.droidsonroids.gif.GifImageView; + +/** + * Created by cxf on 2018/10/15. + * 直播间个人资料弹窗 + */ + +public class LiveOldUserDialogFragment extends AbsDialogFragment implements View.OnClickListener { + + private static final int TYPE_AUD_AUD = 1;//观众点别的观众 + private static final int TYPE_ANC_AUD = 2;//主播点观众 + private static final int TYPE_AUD_ANC = 3;//观众点主播 + private static final int TYPE_AUD_SELF = 4;//观众点自己 + private static final int TYPE_ANC_SELF = 5;//主播点自己 + + private static final int SETTING_ACTION_SELF = 0;//设置 自己点自己 + private static final int SETTING_ACTION_AUD = 30;//设置 普通观众点普通观众 或所有人点超管 + private static final int SETTING_ACTION_ADM = 40;//设置 房间管理员点普通观众 + private static final int SETTING_ACTION_SUP = 60;//设置 超管点主播 + private static final int SETTING_ACTION_ANC_AUD = 501;//设置 主播点普通观众 + private static final int SETTING_ACTION_ANC_ADM = 502;//设置 主播点房间管理员 + private ViewGroup mBottomContainer; + private ImageView mAvatar; + private ImageView mLevelAnchor; + private ImageView mLevel; + private TextView mLevelText; + private TextView mLevelAnchorText; + private ImageView mSex; + private TextView mName; + private TextView mID; + private TextView mCity; + private LinearLayout mImpressGroup; + private TextView mFollow; + private TextView mSign; + private TextView mFans; + private TextView mConsume;//消费 + private TextView mVotes;//收入 + private TextView mConsumeTip; + private TextView mVotesTip; + private String mLiveUid; + private String mStream; + private String mAvatarUrl; + private String mToUid; + private TextView mFollowText; + private ImageView mFollowImage; + private int mType; + private int mAction; + private String mToName;//对方的名字 + private UserBean mUserBean; + private boolean mFollowing; + private Drawable mFollowDrawable; + private Drawable mUnFollowDrawable; + SVGAImageView gift_svga; + LinearLayout ry_view; + ImageView medalIco1, shawl; + ImageView ry_ico1, ry_ico2, ry_ico3, ry_ico4, good_nub_ico; + View no_gz; + GifImageView btn_live; + + @Override + protected int getLayoutId() { + return R.layout.dialog_live_user; + } + + @Override + protected int getDialogStyle() { + return R.style.dialog2; + } + + @Override + protected boolean canCancel() { + return true; + } + + private LiveRoomCheckLivePresenter mCheckLivePresenter; + + private void gotoLive(String live_id) { + DialogUitl.showSimpleDialog(mContext, "是否確認前往對方直播間?", new DialogUitl.SimpleCallback() { + @Override + public void onConfirmClick(Dialog dialog, String content) { + RongChatRoomClient.getInstance().quitChatRoom("g" + mLiveUid, new IRongCoreCallback.OperationCallback() { + @Override + public void onSuccess() { + Log.i("tx", "退出成功"); + //连接socket + LiveHttpUtil.qBackRoom(mLiveUid, mStream, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + + } + }); + } + + @Override + public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) { + + } + }); + V2TIMManager.getInstance().quitGroup("g" + mLiveUid, new V2TIMCallback() { + @Override + public void onSuccess() { + + Log.i("tx", "退出成功" + mLiveUid); + //连接socket + LiveHttpUtil.qBackRoom(mLiveUid, mStream, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + + } + }); + } + + @Override + public void onError(int code, String desc) { + Log.i("tx", "退出失败"); + } + }); + LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); + + if (mCheckLivePresenter == null) { + mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, new LiveRoomCheckLivePresenter.ActionListener() { + @Override + public void onLiveRoomChanged(LiveBean liveBean, int liveType, int liveTypeVal, int liveSdk) { + if (liveBean == null) { + return; + } + LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null); +// if (mFromLiveRoom) { +// ((UserHomeActivity) mContext).onBackPressed(); + dismiss(); + EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, liveTypeVal)); +// } else { +// LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk); +// } + } + }); + } + mCheckLivePresenter.checkLive(liveBean); + } + } + }); + + + } + }); + } + + @Override + protected void setWindowAttributes(Window window) { + WindowManager.LayoutParams params = window.getAttributes(); + window.setWindowAnimations(R.style.bottomToTopAnim); + params.width = WindowManager.LayoutParams.MATCH_PARENT; + params.height = WindowManager.LayoutParams.WRAP_CONTENT; + params.gravity = Gravity.BOTTOM; + window.setAttributes(params); + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + Bundle bundle = getArguments(); + if (bundle == null) { + return; + } + mLiveUid = bundle.getString(Constants.LIVE_UID); + mToUid = bundle.getString(Constants.TO_UID); + if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mToUid)) { + return; + } + mStream = bundle.getString(Constants.STREAM); + //头像边框 + gift_svga = (SVGAImageView) mRootView.findViewById(R.id.gift_svga); + + btn_live = mRootView.findViewById(R.id.btn_live); + btn_live.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + gotoLive(mToUid); + } + }); + + mBottomContainer = mRootView.findViewById(R.id.bottom_container); + ry_view = (LinearLayout) mRootView.findViewById(R.id.ry_view); + no_gz = (View) mRootView.findViewById(R.id.no_gz); + ry_ico1 = (ImageView) mRootView.findViewById(R.id.ry_ico1); + good_nub_ico = (ImageView) mRootView.findViewById(R.id.good_nub_ico); + ry_ico2 = (ImageView) mRootView.findViewById(R.id.ry_ico2); + ry_ico3 = (ImageView) mRootView.findViewById(R.id.ry_ico3); + ry_ico4 = (ImageView) mRootView.findViewById(R.id.ry_ico4); + mAvatar = (ImageView) mRootView.findViewById(R.id.avatar); + mLevelAnchor = (ImageView) mRootView.findViewById(R.id.anchor_level); + mLevel = (ImageView) mRootView.findViewById(R.id.level); + shawl = (ImageView) mRootView.findViewById(R.id.shawl); + mLevelText = mRootView.findViewById(R.id.level_text); + mLevelAnchorText = mRootView.findViewById(R.id.level_anchor_text); + mSex = (ImageView) mRootView.findViewById(R.id.sex); + mName = (TextView) mRootView.findViewById(R.id.name); + mID = (TextView) mRootView.findViewById(R.id.id_val); + mCity = (TextView) mRootView.findViewById(R.id.city); + mSign = mRootView.findViewById(R.id.sign); + mImpressGroup = (LinearLayout) mRootView.findViewById(R.id.impress_group); + mFollow = (TextView) mRootView.findViewById(R.id.follow); + mFans = (TextView) mRootView.findViewById(R.id.fans); + mConsume = (TextView) mRootView.findViewById(R.id.consume); + mVotes = (TextView) mRootView.findViewById(R.id.votes); + mConsumeTip = (TextView) mRootView.findViewById(R.id.consume_tip); + mVotesTip = (TextView) mRootView.findViewById(R.id.votes_tip); + medalIco1 = (ImageView) mRootView.findViewById(R.id.medal_ico1); + mAvatar.setOnClickListener(this); + // mRootView.findViewById(R.id.btn_close).setOnClickListener(this); + getType(); + LayoutInflater inflater = LayoutInflater.from(mContext); + View bottomView = null; + if (mType == TYPE_AUD_ANC) { + if (mImpressGroup.getVisibility() != View.VISIBLE) { + mImpressGroup.setVisibility(View.VISIBLE); + } + bottomView = inflater.inflate(R.layout.dialog_live_user_bottom_1, mBottomContainer, false); + } 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); + } else if (mType == TYPE_AUD_SELF) { + bottomView = inflater.inflate(R.layout.dialog_live_user_bottom_3, mBottomContainer, false); + } + if (bottomView != null) { + mFollowDrawable = ContextCompat.getDrawable(mContext, R.mipmap.icon_user_home_follow_1); + mUnFollowDrawable = ContextCompat.getDrawable(mContext, R.mipmap.icon_user_home_follow_0); + mBottomContainer.addView(bottomView); + mFollowText = bottomView.findViewById(R.id.follow_text); + mFollowImage = (ImageView) findViewById(R.id.follow_img); + View btnFollow = bottomView.findViewById(R.id.btn_follow); + if (btnFollow != null) { + btnFollow.setOnClickListener(this); + } + View btnPriMsg = bottomView.findViewById(R.id.btn_pri_msg); + if (btnPriMsg != null) { + btnPriMsg.setOnClickListener(this); + } + View btnHomePage = bottomView.findViewById(R.id.btn_home_page); + if (btnHomePage != null) { + btnHomePage.setOnClickListener(this); + } + } + loadData(); + } + + private void getType() { + String uid = CommonAppConfig.getInstance().getUid(); + if (mToUid.equals(mLiveUid)) { + if (mLiveUid.equals(uid)) {//主播点自己 + mType = TYPE_ANC_SELF; + } else {//观众点主播 + mType = TYPE_AUD_ANC; + } + } else { + if (mLiveUid.equals(uid)) {//主播点观众 + mType = TYPE_ANC_AUD; + } else { + if (mToUid.equals(uid)) {//观众点自己 + mType = TYPE_AUD_SELF; + } else {//观众点别的观众 + mType = TYPE_AUD_AUD; + } + } + } + } + + private void loadData() { + LiveHttpUtil.getLiveUser(mToUid, mLiveUid, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + showData(info[0]); + } + } + }); + } + + private void showData(String data) { + JSONObject obj = JSON.parseObject(data); + mUserBean = JSON.toJavaObject(obj, UserBean.class); + if (mUserBean.getIslive().equals("1")) { + btn_live.setVisibility(View.VISIBLE); + } else { + btn_live.setVisibility(View.GONE); + } + + //装扮相关 + JSONObject dress = obj.getJSONObject("dress"); + + 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")) { + + try { + new SVGAParser(mContext).parse(new URL(ico.getString("effect_src")), new SVGAParser.ParseCompletion() { + @Override + public void onComplete(SVGAVideoEntity videoItem) { + SVGADrawable drawable = new SVGADrawable(videoItem); + gift_svga.setImageDrawable(drawable); + SVGAViewUtils.playEndClear(gift_svga); + } + + @Override + public void onError() { + } + }); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } else { + Log.e("eee", ico.getString("effect_src")); + ImgLoader.display(mContext, ico.getString("effect_src"), gift_svga); + } + } + } + + medalIco1.setVisibility(View.GONE); + no_gz.setVisibility(View.GONE); + if (dress.getJSONArray("medal").size() >= 1) { + JSONObject display = (JSONObject) dress.getJSONArray("medal").get(0); + if (display.getString("display_src") != null) { + ImgLoader.display(mContext, display.getString("display_src"), medalIco1); + medalIco1.setVisibility(View.VISIBLE); + no_gz.setVisibility(View.VISIBLE); + } + } + if (dress.getJSONArray("wraps").size() >= 1) { + JSONObject display = (JSONObject) dress.getJSONArray("wraps").get(0); + ImgLoader.display(mContext, display.getString("display_src"), shawl); + } + + JSONObject display = (JSONObject) dress.getJSONArray("medal").get(0); + + if (dress.getJSONArray("medal_no") != null) { + Log.e("tag", dress.getJSONArray("medal_no").size() + ""); + ry_view.setVisibility(View.VISIBLE); + JSONObject ry1 = (JSONObject) dress.getJSONArray("medal_no").get(0); + ImgLoader.display(mContext, ry1.get("display_src").toString(), ry_ico1); + ry_ico1.setVisibility(View.VISIBLE); + + if (dress.getJSONArray("medal_no").size() >= 2) { + JSONObject ry2 = (JSONObject) dress.getJSONArray("medal_no").get(1); + ImgLoader.display(mContext, ry2.get("display_src").toString(), ry_ico2); + ry_ico2.setVisibility(View.VISIBLE); + } + if (dress.getJSONArray("medal_no").size() >= 3) { + JSONObject ry3 = (JSONObject) dress.getJSONArray("medal_no").get(2); + ImgLoader.display(mContext, ry3.get("display_src").toString(), ry_ico3); + ry_ico3.setVisibility(View.VISIBLE); + } + + if (dress.getJSONArray("medal_no").size() >= 4) { + JSONObject ry4 = (JSONObject) dress.getJSONArray("medal_no").get(3); + ImgLoader.display(mContext, ry4.get("display_src").toString(), ry_ico4); + ry_ico4.setVisibility(View.VISIBLE); + } + + + } else { + ry_view.setVisibility(View.GONE); + } + + CommonAppConfig appConfig = CommonAppConfig.getInstance(); + + if (mUserBean.getGoodnum() != null && !mUserBean.getGoodnum().equals("")) { + good_nub_ico.setVisibility(View.VISIBLE); + mID.setText("ID:" + mUserBean.getGoodnum()); + } else { + good_nub_ico.setVisibility(View.GONE); + mID.setText(mUserBean.getLiangNameTip()); + } + mToName = obj.getString("user_nicename"); + mName.setText(mToName); + mCity.setText(obj.getString("city")); + ImgLoader.displayAvatar(mContext, obj.getString("avatar"), mAvatar); + mAvatarUrl = obj.getString("avatar"); + int levelAnchor = obj.getIntValue("level_anchor"); + int level = obj.getIntValue("level"); + mSign.setText(obj.getString("signature")); + LevelBean anchorLevelBean = appConfig.getAnchorLevel(obj.getIntValue("level_anchor")); + if (anchorLevelBean != null) { + ImgLoader.display(mContext, anchorLevelBean.getBgIcon(), mLevelAnchor); + } + LevelBean levelBean = appConfig.getLevel(obj.getIntValue("level")); + if (levelBean != null) { + ImgLoader.display(mContext, levelBean.getBgIcon(), mLevel); + } + mLevelAnchorText.setText(String.valueOf(levelAnchor)); + mLevelText.setText(String.valueOf(level)); + mSex.setImageResource(CommonIconUtil.getSexIcon(obj.getIntValue("sex"))); + mFollow.setText(new LiveTextRender().renderLiveUserDialogData(obj.getLongValue("follows"))); + mFans.setText(new LiveTextRender().renderLiveUserDialogData(obj.getLongValue("fans"))); + mConsume.setText(new LiveTextRender().renderLiveUserDialogData(obj.getLongValue("consumption"))); + mVotes.setText(new LiveTextRender().renderLiveUserDialogData(obj.getLongValue("votestotal"))); + mConsumeTip.setText(WordUtil.getString(R.string.live_user_send) + appConfig.getCoinName()); + mVotesTip.setText(WordUtil.getString(R.string.live_user_get) + appConfig.getVotesName()); + if (mType == TYPE_AUD_ANC) { + showImpress(obj.getString("label")); + } + mFollowing = obj.getIntValue("isattention") == 1; + if (mFollowText != null) { + mFollowText.setText(mFollowing ? WordUtil.getString(R.string.following) : WordUtil.getString(R.string.follow)); + } + if (mFollowImage != null) { + mFollowImage.setImageDrawable(mFollowing ? mFollowDrawable : mUnFollowDrawable); + } + mAction = obj.getIntValue("action"); + if (mAction == SETTING_ACTION_AUD) {//设置 普通观众点普通观众 或所有人点超管 + View btnReport = mRootView.findViewById(R.id.btn_report); + btnReport.setVisibility(View.VISIBLE); + btnReport.setOnClickListener(this); + } else if (mAction == SETTING_ACTION_ADM//设置 房间管理员点普通观众 + || mAction == SETTING_ACTION_SUP//设置 超管点主播 + || mAction == SETTING_ACTION_ANC_AUD//设置 主播点普通观众 + || mAction == SETTING_ACTION_ANC_ADM) {//设置 主播点房间管理员 + View btnSetting = mRootView.findViewById(R.id.btn_setting); + btnSetting.setVisibility(View.VISIBLE); + btnSetting.setOnClickListener(this); + } + } + + private void showImpress(String impressJson) { + List list = JSON.parseArray(impressJson, ImpressBean.class); + if (list.size() > 2) { + list = list.subList(0, 2); + } + LayoutInflater inflater = LayoutInflater.from(mContext); + for (int i = 0, size = list.size(); i < size; i++) { + MyTextView myTextView = (MyTextView) inflater.inflate(R.layout.view_impress_item_2, mImpressGroup, false); + ImpressBean bean = list.get(i); + bean.setCheck(1); + myTextView.setBean(bean); + mImpressGroup.addView(myTextView); + } + TextView textView = (TextView) inflater.inflate(R.layout.view_impress_item_add, mImpressGroup, false); + textView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + addImpress(); + } + }); + mImpressGroup.addView(textView); + } + + + /** + * 添加主播印象 + */ + private void addImpress() { + dismiss(); + ((LiveActivity) mContext).openAddImpressWindow(mLiveUid); + } + + @Override + public void onClick(View v) { + int i = v.getId(); + if (i == R.id.btn_close) { + dismiss(); + + } else if (i == R.id.btn_follow) { + setAttention(); + + } else if (i == R.id.btn_pri_msg) { + openChatRoomWindow(); + + } else if (i == R.id.btn_home_page) { + forwardHomePage(); + + } else if (i == R.id.btn_setting) { + setting(); + + } else if (i == R.id.btn_report) { + report(); + + } else if (i == R.id.avatar) { + forwardHomePage(); + } + } + + /** + * 打开私信聊天窗口 + */ + private void openChatRoomWindow() { + if (mUserBean != null) { + dismiss(); +// ToastUtil.show("私聊暫不可用"); +// if (!mToUid.equals(CommonAppConfig.getInstance().getUid())) { +// SystemMessageActivity.forward(mContext, "-1", mToUid, mToName, mAvatarUrl); +// } + + ((LiveActivity) mContext).openChatListWindow(); + } + } + + /** + * 关注 + */ + private void setAttention() { + CommonHttpUtil.setAttention(mToUid, mAttentionCallback); + } + + private CommonCallback mAttentionCallback = new CommonCallback() { + + @Override + public void callback(Integer isAttention) { + mFollowing = isAttention == 1; + if (mFollowText != null) { + mFollowText.setText(mFollowing ? R.string.following : R.string.follow); + } + if (mFollowImage != null) { + mFollowImage.setImageDrawable(mFollowing ? mFollowDrawable : mUnFollowDrawable); + } + 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); +// String url = HtmlConfig.PERSONAL + "?touid=" + mToUid + "&&isHomePage=1" + "&&fromType=0"; +// Constants.myUrl = url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken(); + } + + /** + * 举报 + */ + private void report() { + LiveReportActivity.forward(mContext, mToUid); + } + + /** + * 设置 + *

+ * 某个大神说,角色是权限的集合。。 + *

+ * 理论上,角色的权限应该有服务端以数组或集合的形式返回,这样可以在后台动态配置某种角色的权限,而不是这样口头约定写死。。。 + * 然而,是服务端这样做的,我也很无奈。。。也许他们不知道如何做成动态配置的吧。。 + *

+ * 我一直想通过不断重构把代码写的像艺术品,然而,最近发现,这完全是多此一举,自讨苦吃。。是我太天真了。。 + * 下面是我发现的一篇文章,说的非常好,也点醒了我。。如果你们发现当前代码写的太烂,不堪入目的话,请阅读下面的文章。 + *

+ * https://www.jianshu.com/p/71521541cd25?utm_campaign=haruki&utm_content=note&utm_medium=reader_share&utm_source=weixin_timeline&from=timeline + */ + private void setting() { + List list = new ArrayList<>(); + switch (mAction) { + case SETTING_ACTION_ADM://设置 房间管理员点普通观众 + list.add(R.string.live_setting_kick); +// list.add(R.string.live_setting_gap); + list.add(R.string.live_setting_gap_2); + break; + case SETTING_ACTION_SUP://设置 超管点主播 + list.add(R.string.live_setting_close_live); + list.add(R.string.live_setting_close_live_2); + list.add(R.string.live_setting_forbid_account); + break; + case SETTING_ACTION_ANC_AUD://设置 主播点普通观众 + list.add(R.string.live_setting_kick); +// list.add(R.string.live_setting_gap); + list.add(R.string.live_setting_gap_2); + list.add(R.string.live_setting_admin); + list.add(R.string.live_setting_admin_list); + break; + case SETTING_ACTION_ANC_ADM://设置 主播点房间管理员 + list.add(R.string.live_setting_kick); +// list.add(R.string.live_setting_gap); + list.add(R.string.live_setting_gap_2); + list.add(R.string.live_setting_admin_cancel); + list.add(R.string.live_setting_admin_list); + break; + } + + DialogUitl.showStringArrayDialog(mContext, list.toArray(new Integer[list.size()]), mArrayDialogCallback); + } + + private DialogUitl.StringArrayDialogCallback mArrayDialogCallback = new DialogUitl.StringArrayDialogCallback() { + @Override + public void onItemClick(String text, int tag) { + if (tag == R.string.live_setting_kick) { + kick(); + + } else if (tag == R.string.live_setting_gap) {//永久禁言->改成三天禁言 + setShutUp(); + + } else if (tag == R.string.live_setting_gap_2) {//本场禁言 + setShutUp2(); + + } else if (tag == R.string.live_setting_admin || tag == R.string.live_setting_admin_cancel) { + setAdmin(); + + } else if (tag == R.string.live_setting_admin_list) { + adminList(); + + } else if (tag == R.string.live_setting_close_live) { + closeLive(); + + } else if (tag == R.string.live_setting_forbid_account) { + forbidAccount(); + + } else if (tag == R.string.live_setting_close_live_2) {//禁用直播 + closeLive2(); + } + } + }; + + /** + * 查看管理员列表 + */ + private void adminList() { + dismiss(); + ((LiveActivity) mContext).openAdminListWindow(); + } + + /** + * 踢人 + */ + private void kick() { + LiveHttpUtil.kicking(mLiveUid, mToUid, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + ((LiveActivity) mContext).kickUser(mToUid, mToName); + } else { + ToastUtil.show(msg); + } + } + }); + } + + /** + * 永久禁言->改成三天禁言 + */ + private void setShutUp() { + LiveHttpUtil.setShutUp(mLiveUid, "0", 0, mToUid, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + ((LiveActivity) mContext).setShutUp(mToUid, mToName, 0); + } else { + ToastUtil.show(msg); + } + } + }); + } + + /** + * 本场禁言 + */ + private void setShutUp2() { + LiveHttpUtil.setShutUp(mLiveUid, mStream, 1, mToUid, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + ((LiveActivity) mContext).setShutUp(mToUid, mToName, 1); + } else { + ToastUtil.show(msg); + } + } + }); + } + + + /** + * 设置或取消管理员 + */ + private void setAdmin() { + LiveHttpUtil.setAdmin(mLiveUid, mToUid, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + int res = JSON.parseObject(info[0]).getIntValue("isadmin"); + if (res == 1) {//被设为管理员 + mAction = SETTING_ACTION_ANC_ADM; + } else {//被取消管理员 + mAction = SETTING_ACTION_ANC_AUD; + } + ((LiveActivity) mContext).sendSetAdminMessage(res, mToUid, mToName); + } + } + }); + } + + + /** + * 超管关闭直播间 + */ + private void closeLive() { + dismiss(); + LiveHttpUtil.superCloseRoom(mLiveUid, 0, mSuperCloseRoomCallback); + } + + /** + * 超管关闭直播间并禁止主播直播 + */ + private void closeLive2() { + dismiss(); + LiveHttpUtil.superCloseRoom(mLiveUid, 1, mSuperCloseRoomCallback); + } + + /** + * 超管关闭直播间并禁用主播账户 + */ + private void forbidAccount() { + dismiss(); + LiveHttpUtil.superCloseRoom(mLiveUid, 2, mSuperCloseRoomCallback); + } + + private HttpCallback mSuperCloseRoomCallback = new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + ToastUtil.show(JSON.parseObject(info[0]).getString("msg")); + ((LiveActivity) mContext).superCloseRoom(); + } else { + ToastUtil.show(msg); + } + } + }; + + @Override + public void onDestroy() { + LiveHttpUtil.cancel(LiveHttpConsts.GET_LIVE_USER); + if (mAvatar != null) { + ImgLoader.clear(mContext, mAvatar); + mAvatar.setImageDrawable(null); + } + mAvatar = null; + super.onDestroy(); + } +} 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 fc82e3358..d22945541 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java @@ -3,7 +3,9 @@ package com.yunbao.live.dialog; import android.app.Dialog; import android.graphics.drawable.Drawable; import android.os.Bundle; + import androidx.core.content.ContextCompat; + import android.text.TextUtils; import android.util.Log; import android.view.Gravity; @@ -26,6 +28,7 @@ import com.tencent.imsdk.v2.V2TIMCallback; import com.tencent.imsdk.v2.V2TIMManager; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; +import com.yunbao.common.bean.FansMedalBean; import com.yunbao.common.bean.LevelBean; import com.yunbao.common.bean.UserBean; import com.yunbao.common.dialog.AbsDialogFragment; @@ -70,6 +73,7 @@ import pl.droidsonroids.gif.GifImageView; */ public class LiveUserDialogFragment extends AbsDialogFragment implements View.OnClickListener { + private String TAG = "用户弹窗"; private static final int TYPE_AUD_AUD = 1;//观众点别的观众 private static final int TYPE_ANC_AUD = 2;//主播点观众 @@ -84,46 +88,30 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On private static final int SETTING_ACTION_ANC_AUD = 501;//设置 主播点普通观众 private static final int SETTING_ACTION_ANC_ADM = 502;//设置 主播点房间管理员 private ViewGroup mBottomContainer; - private ImageView mAvatar; - private ImageView mLevelAnchor; - private ImageView mLevel; - private TextView mLevelText; - private TextView mLevelAnchorText; - private ImageView mSex; + private String mLiveUid; + private String mToUid; + private String mStream; + private int mType; + private TextView mFollowText; private TextView mName; private TextView mID; - private TextView mCity; - private LinearLayout mImpressGroup; - private TextView mFollow; - private TextView mSign; - private TextView mFans; - private TextView mConsume;//消费 - private TextView mVotes;//收入 - private TextView mConsumeTip; - private TextView mVotesTip; - private String mLiveUid; - private String mStream; - private String mAvatarUrl; - private String mToUid; - private TextView mFollowText; + private TextView userLv; + private TextView mLvDesc; + private TextView mFansVal; private ImageView mFollowImage; - private int mType; - private int mAction; - private String mToName;//对方的名字 + private ImageView mSex; + private ImageView good_nub_ico; + private ImageView mLiveIcon; + private ImageView mLiveIcon2; + private ImageView mNoble; private UserBean mUserBean; - private boolean mFollowing; - private Drawable mFollowDrawable; - private Drawable mUnFollowDrawable; - SVGAImageView gift_svga; - LinearLayout ry_view; - ImageView medalIco1, shawl; - ImageView ry_ico1, ry_ico2, ry_ico3, ry_ico4, good_nub_ico; - View no_gz; GifImageView btn_live; + SVGAImageView gift_svga; + @Override protected int getLayoutId() { - return R.layout.dialog_live_user; + return R.layout.dialog_new_live_user; } @Override @@ -138,80 +126,6 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On private LiveRoomCheckLivePresenter mCheckLivePresenter; - private void gotoLive(String live_id) { - DialogUitl.showSimpleDialog(mContext, "是否確認前往對方直播間?", new DialogUitl.SimpleCallback() { - @Override - public void onConfirmClick(Dialog dialog, String content) { - RongChatRoomClient.getInstance().quitChatRoom("g" + mLiveUid, new IRongCoreCallback.OperationCallback() { - @Override - public void onSuccess() { - Log.i("tx", "退出成功"); - //连接socket - LiveHttpUtil.qBackRoom(mLiveUid, mStream, new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - - } - }); - } - - @Override - public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) { - - } - }); - V2TIMManager.getInstance().quitGroup("g" + mLiveUid, new V2TIMCallback() { - @Override - public void onSuccess() { - - Log.i("tx", "退出成功" + mLiveUid); - //连接socket - LiveHttpUtil.qBackRoom(mLiveUid, mStream, new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - - } - }); - } - - @Override - public void onError(int code, String desc) { - Log.i("tx", "退出失败"); - } - }); - LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0 && info.length > 0) { - LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); - - if (mCheckLivePresenter == null) { - mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, new LiveRoomCheckLivePresenter.ActionListener() { - @Override - public void onLiveRoomChanged(LiveBean liveBean, int liveType, int liveTypeVal, int liveSdk) { - if (liveBean == null) { - return; - } - LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null); -// if (mFromLiveRoom) { -// ((UserHomeActivity) mContext).onBackPressed(); - dismiss(); - EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, liveTypeVal)); -// } else { -// LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk); -// } - } - }); - } - mCheckLivePresenter.checkLive(liveBean); - } - } - }); - - - } - }); - } @Override protected void setWindowAttributes(Window window) { @@ -236,53 +150,12 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On return; } mStream = bundle.getString(Constants.STREAM); - //头像边框 - gift_svga = (SVGAImageView) mRootView.findViewById(R.id.gift_svga); - - btn_live = mRootView.findViewById(R.id.btn_live); - btn_live.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - gotoLive(mToUid); - } - }); - - mBottomContainer = mRootView.findViewById(R.id.bottom_container); - ry_view = (LinearLayout) mRootView.findViewById(R.id.ry_view); - no_gz = (View) mRootView.findViewById(R.id.no_gz); - ry_ico1 = (ImageView) mRootView.findViewById(R.id.ry_ico1); - good_nub_ico = (ImageView) mRootView.findViewById(R.id.good_nub_ico); - ry_ico2 = (ImageView) mRootView.findViewById(R.id.ry_ico2); - ry_ico3 = (ImageView) mRootView.findViewById(R.id.ry_ico3); - ry_ico4 = (ImageView) mRootView.findViewById(R.id.ry_ico4); - mAvatar = (ImageView) mRootView.findViewById(R.id.avatar); - mLevelAnchor = (ImageView) mRootView.findViewById(R.id.anchor_level); - mLevel = (ImageView) mRootView.findViewById(R.id.level); - shawl = (ImageView) mRootView.findViewById(R.id.shawl); - mLevelText = mRootView.findViewById(R.id.level_text); - mLevelAnchorText = mRootView.findViewById(R.id.level_anchor_text); - mSex = (ImageView) mRootView.findViewById(R.id.sex); - mName = (TextView) mRootView.findViewById(R.id.name); - mID = (TextView) mRootView.findViewById(R.id.id_val); - mCity = (TextView) mRootView.findViewById(R.id.city); - mSign = mRootView.findViewById(R.id.sign); - mImpressGroup = (LinearLayout) mRootView.findViewById(R.id.impress_group); - mFollow = (TextView) mRootView.findViewById(R.id.follow); - mFans = (TextView) mRootView.findViewById(R.id.fans); - mConsume = (TextView) mRootView.findViewById(R.id.consume); - mVotes = (TextView) mRootView.findViewById(R.id.votes); - mConsumeTip = (TextView) mRootView.findViewById(R.id.consume_tip); - mVotesTip = (TextView) mRootView.findViewById(R.id.votes_tip); - medalIco1 = (ImageView) mRootView.findViewById(R.id.medal_ico1); - mAvatar.setOnClickListener(this); - // mRootView.findViewById(R.id.btn_close).setOnClickListener(this); getType(); + initView(); + initListener(); LayoutInflater inflater = LayoutInflater.from(mContext); View bottomView = null; if (mType == TYPE_AUD_ANC) { - if (mImpressGroup.getVisibility() != View.VISIBLE) { - mImpressGroup.setVisibility(View.VISIBLE); - } bottomView = inflater.inflate(R.layout.dialog_live_user_bottom_1, mBottomContainer, false); } else if (mType == TYPE_AUD_AUD) { bottomView = inflater.inflate(R.layout.dialog_live_user_bottom_1, mBottomContainer, false); @@ -292,8 +165,6 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On bottomView = inflater.inflate(R.layout.dialog_live_user_bottom_3, mBottomContainer, false); } if (bottomView != null) { - mFollowDrawable = ContextCompat.getDrawable(mContext, R.mipmap.icon_user_home_follow_1); - mUnFollowDrawable = ContextCompat.getDrawable(mContext, R.mipmap.icon_user_home_follow_0); mBottomContainer.addView(bottomView); mFollowText = bottomView.findViewById(R.id.follow_text); mFollowImage = (ImageView) findViewById(R.id.follow_img); @@ -313,6 +184,42 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On loadData(); } + private void initView() { + gift_svga = (SVGAImageView) mRootView.findViewById(R.id.gift_svga); + btn_live = mRootView.findViewById(R.id.btn_live); + mBottomContainer = mRootView.findViewById(R.id.bottom_container); + mSex = (ImageView) mRootView.findViewById(R.id.sex); + mName = (TextView) mRootView.findViewById(R.id.name); + mID = (TextView) mRootView.findViewById(R.id.id_val); + good_nub_ico = (ImageView) mRootView.findViewById(R.id.good_nub_ico); + userLv = mRootView.findViewById(R.id.lv_val); + mLvDesc = mRootView.findViewById(R.id.lv_desc); + mLiveIcon = mRootView.findViewById(R.id.user_card_lv_icon); + mLiveIcon2 = mRootView.findViewById(R.id.live_icon); + mNoble = mRootView.findViewById(R.id.user_card_noble); + mFansVal = mRootView.findViewById(R.id.fans_val); + } + + private void initListener() { + btn_live.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + // gotoLive(mToUid); + } + }); + } + + private void loadData() { + LiveHttpUtil.getLiveUser(mToUid, mLiveUid, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + showData(info[0]); + } + } + }); + } + private void getType() { String uid = CommonAppConfig.getInstance().getUid(); if (mToUid.equals(mLiveUid)) { @@ -334,18 +241,8 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On } } - private void loadData() { - LiveHttpUtil.getLiveUser(mToUid, mLiveUid, new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0 && info.length > 0) { - showData(info[0]); - } - } - }); - } - private void showData(String data) { + Log.i(TAG, "showData: " + data); JSONObject obj = JSON.parseObject(data); mUserBean = JSON.toJavaObject(obj, UserBean.class); if (mUserBean.getIslive().equals("1")) { @@ -353,457 +250,53 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On } else { btn_live.setVisibility(View.GONE); } + mName.setText(obj.getString("user_nicename")); + if (mUserBean.getGoodnum() != null && !mUserBean.getGoodnum().equals("")) { + good_nub_ico.setVisibility(View.VISIBLE); + mID.setText(mUserBean.getGoodnum()); + } else { + good_nub_ico.setVisibility(View.GONE); + mID.setText(mUserBean.getId()); + } + mSex.setImageResource(CommonIconUtil.getSexIconForUserCard(obj.getIntValue("sex"))); + LevelBean levelBean; + if (mLiveUid.equals(mUserBean.getId())) { + levelBean = CommonAppConfig.getInstance().getAnchorLevel(mUserBean.getLevelAnchor()); + userLv.setText(mUserBean.getLevelAnchor() + ""); + mLvDesc.setText(R.string.live_user_level_anchor); + } else { + levelBean = CommonAppConfig.getInstance().getLevel(mUserBean.getLevel()); + userLv.setText(mUserBean.getLevel() + ""); + mLvDesc.setText(R.string.live_user_card_level); + } + new LiveTextRender().getLevelImage(mContext, levelBean.getLevel(), new ImgLoader.DrawableCallback() { + @Override + public void onLoadSuccess(Drawable drawable) { + ImgLoader.display2(mContext, drawable, mLiveIcon); + } + @Override + public void onLoadFailed() { + + } + }); + ImgLoader.display(mContext, levelBean.getBgIcon(), mLiveIcon2); + FansMedalBean fansMedalBean = CommonAppConfig.getInstance().getAnchorFansMedal(obj.getIntValue("medal_level")); + if (fansMedalBean != null) { + ImgLoader.display(mContext, fansMedalBean.getThumb(), mNoble); + } else { + mNoble.setVisibility(View.INVISIBLE); + } + mFansVal.setText(mUserBean.getFans()+""); //装扮相关 JSONObject dress = obj.getJSONObject("dress"); - 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")) { - - try { - new SVGAParser(mContext).parse(new URL(ico.getString("effect_src")), new SVGAParser.ParseCompletion() { - @Override - public void onComplete(SVGAVideoEntity videoItem) { - SVGADrawable drawable = new SVGADrawable(videoItem); - gift_svga.setImageDrawable(drawable); - SVGAViewUtils.playEndClear(gift_svga); - } - - @Override - public void onError() { - } - }); - } catch (MalformedURLException e) { - e.printStackTrace(); - } - } else { - Log.e("eee", ico.getString("effect_src")); - ImgLoader.display(mContext, ico.getString("effect_src"), gift_svga); - } - } - } - - medalIco1.setVisibility(View.GONE); - no_gz.setVisibility(View.GONE); - if (dress.getJSONArray("medal").size() >= 1) { - JSONObject display = (JSONObject) dress.getJSONArray("medal").get(0); - if (display.getString("display_src") != null) { - ImgLoader.display(mContext, display.getString("display_src"), medalIco1); - medalIco1.setVisibility(View.VISIBLE); - no_gz.setVisibility(View.VISIBLE); - } - } - if (dress.getJSONArray("wraps").size() >= 1) { - JSONObject display = (JSONObject) dress.getJSONArray("wraps").get(0); - ImgLoader.display(mContext, display.getString("display_src"), shawl); - } - - JSONObject display = (JSONObject) dress.getJSONArray("medal").get(0); - - if (dress.getJSONArray("medal_no") != null) { - Log.e("tag", dress.getJSONArray("medal_no").size() + ""); - ry_view.setVisibility(View.VISIBLE); - JSONObject ry1 = (JSONObject) dress.getJSONArray("medal_no").get(0); - ImgLoader.display(mContext, ry1.get("display_src").toString(), ry_ico1); - ry_ico1.setVisibility(View.VISIBLE); - - if (dress.getJSONArray("medal_no").size() >= 2) { - JSONObject ry2 = (JSONObject) dress.getJSONArray("medal_no").get(1); - ImgLoader.display(mContext, ry2.get("display_src").toString(), ry_ico2); - ry_ico2.setVisibility(View.VISIBLE); - } - if (dress.getJSONArray("medal_no").size() >= 3) { - JSONObject ry3 = (JSONObject) dress.getJSONArray("medal_no").get(2); - ImgLoader.display(mContext, ry3.get("display_src").toString(), ry_ico3); - ry_ico3.setVisibility(View.VISIBLE); - } - - if (dress.getJSONArray("medal_no").size() >= 4) { - JSONObject ry4 = (JSONObject) dress.getJSONArray("medal_no").get(3); - ImgLoader.display(mContext, ry4.get("display_src").toString(), ry_ico4); - ry_ico4.setVisibility(View.VISIBLE); - } - - - } else { - ry_view.setVisibility(View.GONE); - } - - CommonAppConfig appConfig = CommonAppConfig.getInstance(); - - if (mUserBean.getGoodnum() != null && !mUserBean.getGoodnum().equals("")) { - good_nub_ico.setVisibility(View.VISIBLE); - mID.setText("ID:" + mUserBean.getGoodnum()); - } else { - good_nub_ico.setVisibility(View.GONE); - mID.setText(mUserBean.getLiangNameTip()); - } - mToName = obj.getString("user_nicename"); - mName.setText(mToName); - mCity.setText(obj.getString("city")); - ImgLoader.displayAvatar(mContext, obj.getString("avatar"), mAvatar); - mAvatarUrl = obj.getString("avatar"); - int levelAnchor = obj.getIntValue("level_anchor"); - int level = obj.getIntValue("level"); - mSign.setText(obj.getString("signature")); - LevelBean anchorLevelBean = appConfig.getAnchorLevel(obj.getIntValue("level_anchor")); - if (anchorLevelBean != null) { - ImgLoader.display(mContext, anchorLevelBean.getBgIcon(), mLevelAnchor); - } - LevelBean levelBean = appConfig.getLevel(obj.getIntValue("level")); - if (levelBean != null) { - ImgLoader.display(mContext, levelBean.getBgIcon(), mLevel); - } - mLevelAnchorText.setText(String.valueOf(levelAnchor)); - mLevelText.setText(String.valueOf(level)); - mSex.setImageResource(CommonIconUtil.getSexIcon(obj.getIntValue("sex"))); - mFollow.setText(new LiveTextRender().renderLiveUserDialogData(obj.getLongValue("follows"))); - mFans.setText(new LiveTextRender().renderLiveUserDialogData(obj.getLongValue("fans"))); - mConsume.setText(new LiveTextRender().renderLiveUserDialogData(obj.getLongValue("consumption"))); - mVotes.setText(new LiveTextRender().renderLiveUserDialogData(obj.getLongValue("votestotal"))); - mConsumeTip.setText(WordUtil.getString(R.string.live_user_send) + appConfig.getCoinName()); - mVotesTip.setText(WordUtil.getString(R.string.live_user_get) + appConfig.getVotesName()); - if (mType == TYPE_AUD_ANC) { - showImpress(obj.getString("label")); - } - mFollowing = obj.getIntValue("isattention") == 1; - if (mFollowText != null) { - mFollowText.setText(mFollowing ? WordUtil.getString(R.string.following) : WordUtil.getString(R.string.follow)); - } - if (mFollowImage != null) { - mFollowImage.setImageDrawable(mFollowing ? mFollowDrawable : mUnFollowDrawable); - } - mAction = obj.getIntValue("action"); - if (mAction == SETTING_ACTION_AUD) {//设置 普通观众点普通观众 或所有人点超管 - View btnReport = mRootView.findViewById(R.id.btn_report); - btnReport.setVisibility(View.VISIBLE); - btnReport.setOnClickListener(this); - } else if (mAction == SETTING_ACTION_ADM//设置 房间管理员点普通观众 - || mAction == SETTING_ACTION_SUP//设置 超管点主播 - || mAction == SETTING_ACTION_ANC_AUD//设置 主播点普通观众 - || mAction == SETTING_ACTION_ANC_ADM) {//设置 主播点房间管理员 - View btnSetting = mRootView.findViewById(R.id.btn_setting); - btnSetting.setVisibility(View.VISIBLE); - btnSetting.setOnClickListener(this); - } } - private void showImpress(String impressJson) { - List list = JSON.parseArray(impressJson, ImpressBean.class); - if (list.size() > 2) { - list = list.subList(0, 2); - } - LayoutInflater inflater = LayoutInflater.from(mContext); - for (int i = 0, size = list.size(); i < size; i++) { - MyTextView myTextView = (MyTextView) inflater.inflate(R.layout.view_impress_item_2, mImpressGroup, false); - ImpressBean bean = list.get(i); - bean.setCheck(1); - myTextView.setBean(bean); - mImpressGroup.addView(myTextView); - } - TextView textView = (TextView) inflater.inflate(R.layout.view_impress_item_add, mImpressGroup, false); - textView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - addImpress(); - } - }); - mImpressGroup.addView(textView); - } - - - /** - * 添加主播印象 - */ - private void addImpress() { - dismiss(); - ((LiveActivity) mContext).openAddImpressWindow(mLiveUid); - } @Override public void onClick(View v) { - int i = v.getId(); - if (i == R.id.btn_close) { - dismiss(); - } else if (i == R.id.btn_follow) { - setAttention(); - - } else if (i == R.id.btn_pri_msg) { - openChatRoomWindow(); - - } else if (i == R.id.btn_home_page) { - forwardHomePage(); - - } else if (i == R.id.btn_setting) { - setting(); - - } else if (i == R.id.btn_report) { - report(); - - } else if (i == R.id.avatar) { - forwardHomePage(); - } - } - - /** - * 打开私信聊天窗口 - */ - private void openChatRoomWindow() { - if (mUserBean != null) { - dismiss(); -// ToastUtil.show("私聊暫不可用"); -// if (!mToUid.equals(CommonAppConfig.getInstance().getUid())) { -// SystemMessageActivity.forward(mContext, "-1", mToUid, mToName, mAvatarUrl); -// } - - ((LiveActivity) mContext).openChatListWindow(); - } - } - - /** - * 关注 - */ - private void setAttention() { - CommonHttpUtil.setAttention(mToUid, mAttentionCallback); - } - - private CommonCallback mAttentionCallback = new CommonCallback() { - - @Override - public void callback(Integer isAttention) { - mFollowing = isAttention == 1; - if (mFollowText != null) { - mFollowText.setText(mFollowing ? R.string.following : R.string.follow); - } - if (mFollowImage != null) { - mFollowImage.setImageDrawable(mFollowing ? mFollowDrawable : mUnFollowDrawable); - } - 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); -// String url = HtmlConfig.PERSONAL + "?touid=" + mToUid + "&&isHomePage=1" + "&&fromType=0"; -// Constants.myUrl = url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken(); - } - - /** - * 举报 - */ - private void report() { - LiveReportActivity.forward(mContext, mToUid); - } - - /** - * 设置 - *

- * 某个大神说,角色是权限的集合。。 - *

- * 理论上,角色的权限应该有服务端以数组或集合的形式返回,这样可以在后台动态配置某种角色的权限,而不是这样口头约定写死。。。 - * 然而,是服务端这样做的,我也很无奈。。。也许他们不知道如何做成动态配置的吧。。 - *

- * 我一直想通过不断重构把代码写的像艺术品,然而,最近发现,这完全是多此一举,自讨苦吃。。是我太天真了。。 - * 下面是我发现的一篇文章,说的非常好,也点醒了我。。如果你们发现当前代码写的太烂,不堪入目的话,请阅读下面的文章。 - *

- * https://www.jianshu.com/p/71521541cd25?utm_campaign=haruki&utm_content=note&utm_medium=reader_share&utm_source=weixin_timeline&from=timeline - */ - private void setting() { - List list = new ArrayList<>(); - switch (mAction) { - case SETTING_ACTION_ADM://设置 房间管理员点普通观众 - list.add(R.string.live_setting_kick); -// list.add(R.string.live_setting_gap); - list.add(R.string.live_setting_gap_2); - break; - case SETTING_ACTION_SUP://设置 超管点主播 - list.add(R.string.live_setting_close_live); - list.add(R.string.live_setting_close_live_2); - list.add(R.string.live_setting_forbid_account); - break; - case SETTING_ACTION_ANC_AUD://设置 主播点普通观众 - list.add(R.string.live_setting_kick); -// list.add(R.string.live_setting_gap); - list.add(R.string.live_setting_gap_2); - list.add(R.string.live_setting_admin); - list.add(R.string.live_setting_admin_list); - break; - case SETTING_ACTION_ANC_ADM://设置 主播点房间管理员 - list.add(R.string.live_setting_kick); -// list.add(R.string.live_setting_gap); - list.add(R.string.live_setting_gap_2); - list.add(R.string.live_setting_admin_cancel); - list.add(R.string.live_setting_admin_list); - break; - } - - DialogUitl.showStringArrayDialog(mContext, list.toArray(new Integer[list.size()]), mArrayDialogCallback); - } - - private DialogUitl.StringArrayDialogCallback mArrayDialogCallback = new DialogUitl.StringArrayDialogCallback() { - @Override - public void onItemClick(String text, int tag) { - if (tag == R.string.live_setting_kick) { - kick(); - - } else if (tag == R.string.live_setting_gap) {//永久禁言->改成三天禁言 - setShutUp(); - - } else if (tag == R.string.live_setting_gap_2) {//本场禁言 - setShutUp2(); - - } else if (tag == R.string.live_setting_admin || tag == R.string.live_setting_admin_cancel) { - setAdmin(); - - } else if (tag == R.string.live_setting_admin_list) { - adminList(); - - } else if (tag == R.string.live_setting_close_live) { - closeLive(); - - } else if (tag == R.string.live_setting_forbid_account) { - forbidAccount(); - - } else if (tag == R.string.live_setting_close_live_2) {//禁用直播 - closeLive2(); - } - } - }; - - /** - * 查看管理员列表 - */ - private void adminList() { - dismiss(); - ((LiveActivity) mContext).openAdminListWindow(); - } - - /** - * 踢人 - */ - private void kick() { - LiveHttpUtil.kicking(mLiveUid, mToUid, new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0) { - ((LiveActivity) mContext).kickUser(mToUid, mToName); - } else { - ToastUtil.show(msg); - } - } - }); - } - - /** - * 永久禁言->改成三天禁言 - */ - private void setShutUp() { - LiveHttpUtil.setShutUp(mLiveUid, "0", 0, mToUid, new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0) { - ((LiveActivity) mContext).setShutUp(mToUid, mToName, 0); - } else { - ToastUtil.show(msg); - } - } - }); - } - - /** - * 本场禁言 - */ - private void setShutUp2() { - LiveHttpUtil.setShutUp(mLiveUid, mStream, 1, mToUid, new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0) { - ((LiveActivity) mContext).setShutUp(mToUid, mToName, 1); - } else { - ToastUtil.show(msg); - } - } - }); - } - - - /** - * 设置或取消管理员 - */ - private void setAdmin() { - LiveHttpUtil.setAdmin(mLiveUid, mToUid, new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0 && info.length > 0) { - int res = JSON.parseObject(info[0]).getIntValue("isadmin"); - if (res == 1) {//被设为管理员 - mAction = SETTING_ACTION_ANC_ADM; - } else {//被取消管理员 - mAction = SETTING_ACTION_ANC_AUD; - } - ((LiveActivity) mContext).sendSetAdminMessage(res, mToUid, mToName); - } - } - }); - } - - - /** - * 超管关闭直播间 - */ - private void closeLive() { - dismiss(); - LiveHttpUtil.superCloseRoom(mLiveUid, 0, mSuperCloseRoomCallback); - } - - /** - * 超管关闭直播间并禁止主播直播 - */ - private void closeLive2() { - dismiss(); - LiveHttpUtil.superCloseRoom(mLiveUid, 1, mSuperCloseRoomCallback); - } - - /** - * 超管关闭直播间并禁用主播账户 - */ - private void forbidAccount() { - dismiss(); - LiveHttpUtil.superCloseRoom(mLiveUid, 2, mSuperCloseRoomCallback); - } - - private HttpCallback mSuperCloseRoomCallback = new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0) { - ToastUtil.show(JSON.parseObject(info[0]).getString("msg")); - ((LiveActivity) mContext).superCloseRoom(); - } else { - ToastUtil.show(msg); - } - } - }; - - @Override - public void onDestroy() { - LiveHttpUtil.cancel(LiveHttpConsts.GET_LIVE_USER); - if (mAvatar != null) { - ImgLoader.clear(mContext, mAvatar); - mAvatar.setImageDrawable(null); - } - mAvatar = null; - super.onDestroy(); } } 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 28b94428a..d2fa2e27d 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -125,6 +125,7 @@ import com.yunbao.live.dialog.LiveFaceUnityDialogFragment; import com.yunbao.live.dialog.LiveFansMedalDialogFragment; import com.yunbao.live.dialog.LiveGameDialogFragment; import com.yunbao.live.dialog.LiveHDDialogFragment; +import com.yunbao.live.dialog.LiveOldUserDialogFragment; import com.yunbao.live.dialog.LiveUserDialogFragment; import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience; import com.yunbao.live.event.LiveAudienceEvent; @@ -2410,7 +2411,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis */ public void showUserDialog(String toUid) { if (!TextUtils.isEmpty(mLiveUid) && !TextUtils.isEmpty(toUid)) { - LiveUserDialogFragment fragment = new LiveUserDialogFragment(); + LiveOldUserDialogFragment fragment = new LiveOldUserDialogFragment(); Bundle bundle = new Bundle(); bundle.putString(Constants.LIVE_UID, mLiveUid); bundle.putString(Constants.STREAM, mStream); diff --git a/live/src/main/res/drawable/background_ff63c1.xml b/live/src/main/res/drawable/background_ff63c1.xml new file mode 100644 index 000000000..6004c4a80 --- /dev/null +++ b/live/src/main/res/drawable/background_ff63c1.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/live/src/main/res/drawable/bg_user_card_fans.xml b/live/src/main/res/drawable/bg_user_card_fans.xml new file mode 100644 index 000000000..60ab9e052 --- /dev/null +++ b/live/src/main/res/drawable/bg_user_card_fans.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_user_card_guard.xml b/live/src/main/res/drawable/bg_user_card_guard.xml new file mode 100644 index 000000000..bcfe90830 --- /dev/null +++ b/live/src/main/res/drawable/bg_user_card_guard.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_user_card_honor.xml b/live/src/main/res/drawable/bg_user_card_honor.xml new file mode 100644 index 000000000..7ad95101b --- /dev/null +++ b/live/src/main/res/drawable/bg_user_card_honor.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_user_card_lv.xml b/live/src/main/res/drawable/bg_user_card_lv.xml new file mode 100644 index 000000000..3190220a6 --- /dev/null +++ b/live/src/main/res/drawable/bg_user_card_lv.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/dialog_live_user_bottom_1.xml b/live/src/main/res/layout/dialog_live_user_bottom_1.xml index 94900faef..f3a185349 100644 --- a/live/src/main/res/layout/dialog_live_user_bottom_1.xml +++ b/live/src/main/res/layout/dialog_live_user_bottom_1.xml @@ -1,56 +1,19 @@ + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + android:background="#eeeeee" /> + android:orientation="horizontal"> - - - - - - - - - - - - + android:orientation="horizontal"> + android:src="@mipmap/icon_user_home_msg" /> + android:textSize="13sp" /> @@ -90,22 +50,20 @@ android:id="@+id/btn_home_page" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" - > + android:layout_weight="1"> + android:orientation="horizontal"> + android:visibility="gone" /> + android:textSize="16sp" + android:textStyle="bold" /> + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/dialog_new_live_user.xml b/live/src/main/res/layout/dialog_new_live_user.xml new file mode 100644 index 000000000..4e03956bc --- /dev/null +++ b/live/src/main/res/layout/dialog_new_live_user.xml @@ -0,0 +1,432 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/mipmap-mdpi/icon_user_card_follow.png b/live/src/main/res/mipmap-mdpi/icon_user_card_follow.png new file mode 100644 index 000000000..39b6ca9f3 Binary files /dev/null and b/live/src/main/res/mipmap-mdpi/icon_user_card_follow.png differ diff --git a/main/src/main/java/com/yunbao/main/activity/LoginActivity.java b/main/src/main/java/com/yunbao/main/activity/LoginActivity.java index 489a950e0..efc7bd235 100644 --- a/main/src/main/java/com/yunbao/main/activity/LoginActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/LoginActivity.java @@ -25,6 +25,7 @@ import com.blankj.utilcode.util.GsonUtils; import com.fm.openinstall.OpenInstall; import com.fm.openinstall.listener.AppInstallAdapter; import com.fm.openinstall.model.AppData; +import com.lzy.okgo.model.Response; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppContext; import com.yunbao.common.Constants; @@ -39,6 +40,7 @@ import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; +import com.yunbao.common.http.JsonBean; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.NoviceInstructorManager; @@ -336,6 +338,13 @@ public class LoginActivity extends AbsActivity { finish(); } + + @Override + public void onError(Response response) { + super.onError(response); + String message = response.message(); + System.out.println(">>>>>"+message); + } }); } diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index 527df2269..4ac27b9b8 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -489,7 +489,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene public void run() { if (IMLoginManager.get(mContext).isHint()) { HintDialog fragment = new HintDialog(); - fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "HintDialog"); + fragment.show(((FragmentActivity) MainActivity.this).getSupportFragmentManager(), "HintDialog"); fragment.setListener(new HintDialog.HintListener() { @Override public void requestPermission() {