5611 lines
233 KiB
Java
5611 lines
233 KiB
Java
package com.yunbao.live.views;
|
||
|
||
import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY;
|
||
|
||
import android.app.Activity;
|
||
import android.app.Dialog;
|
||
import android.content.Context;
|
||
import android.graphics.Outline;
|
||
import android.graphics.drawable.Drawable;
|
||
import android.os.Bundle;
|
||
import android.os.CountDownTimer;
|
||
import android.os.Handler;
|
||
import android.os.Looper;
|
||
import android.os.Message;
|
||
import android.os.SystemClock;
|
||
import android.text.Html;
|
||
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.ViewOutlineProvider;
|
||
import android.view.WindowManager;
|
||
import android.view.animation.AlphaAnimation;
|
||
import android.view.animation.Animation;
|
||
import android.view.animation.AnimationSet;
|
||
import android.view.animation.AnimationUtils;
|
||
import android.view.animation.TranslateAnimation;
|
||
import android.widget.Button;
|
||
import android.widget.FrameLayout;
|
||
import android.widget.ImageView;
|
||
import android.widget.LinearLayout;
|
||
import android.widget.RelativeLayout;
|
||
import android.widget.TextView;
|
||
import android.widget.ViewFlipper;
|
||
|
||
import androidx.annotation.NonNull;
|
||
import androidx.annotation.Nullable;
|
||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||
import androidx.recyclerview.widget.RecyclerView;
|
||
|
||
import com.alibaba.fastjson.JSON;
|
||
import com.alibaba.fastjson.JSONArray;
|
||
import com.alibaba.fastjson.JSONObject;
|
||
import com.bumptech.glide.Glide;
|
||
import com.bumptech.glide.load.DataSource;
|
||
import com.bumptech.glide.load.engine.GlideException;
|
||
import com.bumptech.glide.load.resource.gif.GifDrawable;
|
||
import com.bumptech.glide.request.RequestListener;
|
||
import com.bumptech.glide.request.RequestOptions;
|
||
import com.bumptech.glide.request.target.Target;
|
||
import com.lxj.xpopup.XPopup;
|
||
import com.makeramen.roundedimageview.RoundedImageView;
|
||
import com.ms.banner.Banner;
|
||
import com.ms.banner.BannerConfig;
|
||
import com.ms.banner.listener.OnBannerClickListener;
|
||
import com.opensource.svgaplayer.SVGADrawable;
|
||
import com.opensource.svgaplayer.SVGAImageView;
|
||
import com.opensource.svgaplayer.SVGAParser;
|
||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||
import com.umeng.analytics.MobclickAgent;
|
||
import com.yunbao.common.CommonAppConfig;
|
||
import com.yunbao.common.Constants;
|
||
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;
|
||
import com.yunbao.common.bean.IMLoginModel;
|
||
import com.yunbao.common.bean.LevelBean;
|
||
import com.yunbao.common.bean.LinkMicUserBean;
|
||
import com.yunbao.common.bean.LiveAnchorCallMeModel;
|
||
import com.yunbao.common.bean.LiveAnchorSayModel;
|
||
import com.yunbao.common.bean.LiveBean;
|
||
import com.yunbao.common.bean.LiveGiftBean;
|
||
import com.yunbao.common.bean.LiveRoomActivityBanner;
|
||
import com.yunbao.common.bean.LiveRoomVoteModel;
|
||
import com.yunbao.common.bean.LiveUserGiftBean;
|
||
import com.yunbao.common.bean.LiveUserMailBoxModel;
|
||
import com.yunbao.common.bean.MsgModel;
|
||
import com.yunbao.common.bean.NewPeopleTaskModel;
|
||
import com.yunbao.common.bean.PkRankBean;
|
||
import com.yunbao.common.bean.RankHourModel;
|
||
import com.yunbao.common.bean.RedPacketInfoModel;
|
||
import com.yunbao.common.bean.RedPacketModel;
|
||
import com.yunbao.common.bean.RewardAllModel;
|
||
import com.yunbao.common.bean.StarChallengeStatusModel;
|
||
import com.yunbao.common.bean.TaskModel;
|
||
import com.yunbao.common.bean.UserBean;
|
||
import com.yunbao.common.bean.WishModel;
|
||
import com.yunbao.common.bean.XydCompleteModel;
|
||
import com.yunbao.common.event.AllServerNotifyEvent;
|
||
import com.yunbao.common.event.AnchorInfoEvent;
|
||
import com.yunbao.common.event.CustomFullServiceNotifyEvent;
|
||
import com.yunbao.common.event.HideShowEvent;
|
||
import com.yunbao.common.event.LiveRoomChangeEvent;
|
||
import com.yunbao.common.glide.ImgLoader;
|
||
import com.yunbao.common.http.API;
|
||
import com.yunbao.common.http.CommonHttpConsts;
|
||
import com.yunbao.common.http.CommonHttpUtil;
|
||
import com.yunbao.common.http.HttpCallback;
|
||
import com.yunbao.common.http.LiveHttpConsts;
|
||
import com.yunbao.common.http.LiveHttpUtil;
|
||
import com.yunbao.common.http.live.LiveNetManager;
|
||
import com.yunbao.common.interfaces.CommonCallback;
|
||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||
import com.yunbao.common.manager.IMLoginManager;
|
||
import com.yunbao.common.manager.RandomPkManager;
|
||
import com.yunbao.common.utils.AppManager;
|
||
import com.yunbao.common.utils.Bus;
|
||
import com.yunbao.common.utils.DeviceUtils;
|
||
import com.yunbao.common.utils.DialogUitl;
|
||
import com.yunbao.common.utils.DpUtil;
|
||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||
import com.yunbao.common.utils.MicStatusManager;
|
||
import com.yunbao.common.utils.RouteUtil;
|
||
import com.yunbao.common.utils.SVGAViewUtils;
|
||
import com.yunbao.common.utils.ScreenDimenUtil;
|
||
import com.yunbao.common.utils.SpUtil;
|
||
import com.yunbao.common.utils.StringUtil;
|
||
import com.yunbao.common.utils.TimeUtils;
|
||
import com.yunbao.common.utils.ToastUtil;
|
||
import com.yunbao.common.utils.WordUtil;
|
||
import com.yunbao.common.utils.formatBigNum;
|
||
import com.yunbao.common.views.AbsViewHolder;
|
||
import com.yunbao.common.views.weight.ClipPathCircleImage;
|
||
import com.yunbao.common.views.weight.FullServiceNotificationView;
|
||
import com.yunbao.common.views.weight.NobleNoticeView;
|
||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||
import com.yunbao.faceunity.FaceManager;
|
||
import com.yunbao.live.R;
|
||
import com.yunbao.live.activity.LiveActivity;
|
||
import com.yunbao.live.activity.LiveAnchorActivity;
|
||
import com.yunbao.live.activity.LiveAudienceActivity;
|
||
import com.yunbao.live.activity.LiveRyAnchorActivity;
|
||
import com.yunbao.live.activity.ZhuangBanActivity;
|
||
import com.yunbao.live.adapter.LiveChatAdapter;
|
||
import com.yunbao.live.adapter.LiveRoomFastMessageRecyclerViewAdapter;
|
||
import com.yunbao.live.adapter.LiveUserAdapter;
|
||
import com.yunbao.live.bean.DrPkbean;
|
||
import com.yunbao.live.bean.LiveBuyGuardMsgBean;
|
||
import com.yunbao.live.bean.LiveChatBean;
|
||
import com.yunbao.live.bean.LiveDanMuBean;
|
||
import com.yunbao.live.bean.LiveEnterRoomBean;
|
||
import com.yunbao.live.bean.LiveGiftPrizePoolWinBean;
|
||
import com.yunbao.live.bean.LiveLuckGiftWinBean;
|
||
import com.yunbao.live.bean.LivePKUserListBean;
|
||
import com.yunbao.live.bean.LiveReceiveGiftBean;
|
||
import com.yunbao.live.bean.LiveWishlistBean;
|
||
import com.yunbao.live.bean.WishlistItemModel;
|
||
import com.yunbao.live.custom.LiveLightView;
|
||
import com.yunbao.live.custom.RightGradual;
|
||
import com.yunbao.live.custom.TopGradual;
|
||
import com.yunbao.live.dialog.GiftWallDialog;
|
||
import com.yunbao.live.dialog.LiveContactDetailsSendGiftDialog;
|
||
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.LiveUserAnchorMailBoxWebInfoPopDialog;
|
||
import com.yunbao.live.dialog.LiveUserDialogFragment;
|
||
import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience;
|
||
import com.yunbao.live.dialog.ReceiveRendPacketPopup;
|
||
import com.yunbao.live.dialog.ResultRendPacketPopup;
|
||
import com.yunbao.live.event.LiveAnchorEvent;
|
||
import com.yunbao.live.event.LiveAudienceEvent;
|
||
import com.yunbao.live.presenter.LiveDanmuPresenter;
|
||
import com.yunbao.live.presenter.LiveEnterRoomAnimPresenter;
|
||
import com.yunbao.live.presenter.LiveGiftAnimPresenter;
|
||
import com.yunbao.live.presenter.LiveLightAnimPresenter;
|
||
import com.yunbao.live.utils.LiveRoomVoteManager;
|
||
import com.yunbao.live.utils.LiveTextRender;
|
||
import com.yunbao.live.utils.LoadDian9TuUtil;
|
||
|
||
import org.greenrobot.eventbus.EventBus;
|
||
import org.greenrobot.eventbus.Subscribe;
|
||
import org.greenrobot.eventbus.ThreadMode;
|
||
|
||
import java.lang.ref.WeakReference;
|
||
import java.net.MalformedURLException;
|
||
import java.net.URL;
|
||
import java.util.ArrayList;
|
||
import java.util.HashMap;
|
||
import java.util.List;
|
||
import java.util.Locale;
|
||
import java.util.Map;
|
||
|
||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||
import io.reactivex.schedulers.Schedulers;
|
||
import io.rong.imkit.userinfo.RongUserInfoManager;
|
||
import io.rong.imlib.RongIMClient;
|
||
import io.rong.imlib.model.Conversation;
|
||
import io.rong.imlib.model.UserInfo;
|
||
import pl.droidsonroids.gif.GifImageView;
|
||
|
||
/**
|
||
* Created by cxf on 2018/10/9.
|
||
* 直播间公共逻辑
|
||
*/
|
||
public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickListener {
|
||
|
||
public static Context Contexts;
|
||
private int mOffsetY;
|
||
private ViewGroup mRoot;
|
||
LinearLayout gif_view;
|
||
RelativeLayout chat_view;
|
||
private ImageView mAvatar;
|
||
private ImageView userMore;
|
||
private RoundedImageView userGuard;
|
||
private ImageView mLevelAnchor;
|
||
public static TextView mName;
|
||
private TextView mID;
|
||
public static View mBtnFollow;
|
||
private ImageView mViewMedal;
|
||
private TextView mVotesName;//映票名称
|
||
private TextView mVotes;
|
||
private TextView mTvMedalRank;
|
||
private TextView mGuardNum;//守护人数
|
||
private RecyclerView mUserRecyclerView;
|
||
private RecyclerView mChatRecyclerView;
|
||
private LiveUserAdapter mLiveUserAdapter;
|
||
private static LiveChatAdapter mLiveChatAdapter;
|
||
private TextView tv_avatarOther_name;
|
||
private LinearLayout goto_room_view;
|
||
private ImageView avatarOther;
|
||
private View mBtnRedPack;
|
||
public static String mLiveUid;
|
||
public static String mStream;
|
||
private LiveLightAnimPresenter mLightAnimPresenter;
|
||
private LiveEnterRoomAnimPresenter mLiveEnterRoomAnimPresenter;
|
||
private LiveDanmuPresenter mLiveDanmuPresenter;
|
||
private LiveGiftAnimPresenter mLiveGiftAnimPresenter;
|
||
private LiveRoomHandler mLiveRoomHandler;
|
||
private HttpCallback mRefreshUserListCallback;
|
||
private HttpCallback mTimeChargeCallback;
|
||
protected int mUserListInterval;//用户列表刷新时间的间隔
|
||
private GifImageView mGifImageView;
|
||
public static SVGAImageView mSVGAImageView;
|
||
private ViewGroup mLiveGiftPrizePoolContainer;
|
||
|
||
private View mBtnPrizePool;//奖池按钮
|
||
private TextView mPrizePoolLevel;//奖池等级
|
||
private int forAct;
|
||
public TextView room_hot;
|
||
public String touid, gotoroom;
|
||
public static TextView fans;
|
||
public LinearLayout fans_btn, wishListLayout, wishListLayout2, liveWksLayout;
|
||
public static View d_pk_view;
|
||
public static int isAttention = 0;//是否关注 0=没关注,
|
||
public static String mNameText;
|
||
public static String mAvatarUrl;
|
||
// public static FrameLayout ft_hot_add;
|
||
public static ImageView newMessage, atMessage;
|
||
|
||
//多人PK
|
||
static TextView time;
|
||
|
||
static TextView pkText1;
|
||
static TextView pkText2;
|
||
static TextView pkText3;
|
||
static TextView pkText4;
|
||
static TextView pkText5;
|
||
static TextView pk_text11;
|
||
static TextView pk_text22;
|
||
static TextView pk_text33;
|
||
static TextView pk_text44;
|
||
static TextView pk_text55;
|
||
|
||
static RoundedImageView avatar1;
|
||
|
||
static TextView pk1Name;
|
||
static ImageView pk1Ico;
|
||
static RelativeLayout pk1;
|
||
|
||
static RoundedImageView avatar2;
|
||
static TextView pk2Name;
|
||
static ImageView pk2Ico;
|
||
static RelativeLayout pk2;
|
||
|
||
static RoundedImageView avatar3;
|
||
static TextView pk3Name;
|
||
static ImageView pk3Ico;
|
||
static RelativeLayout pk3;
|
||
|
||
static RoundedImageView avatar4;
|
||
static TextView pk4Name;
|
||
static ImageView pk4Ico;
|
||
static RelativeLayout pk4;
|
||
|
||
static RoundedImageView avatar5;
|
||
static TextView pk5Name;
|
||
static ImageView pk5Ico;
|
||
static RelativeLayout pk5;
|
||
|
||
RelativeLayout mic_view;
|
||
RelativeLayout mic_view1;
|
||
RelativeLayout mic_view2;
|
||
|
||
static ImageView mic_ico;
|
||
static RoundedImageView mic_ico1;
|
||
static RoundedImageView mic_ico2;
|
||
|
||
private GifImageView dr_pk_end_gif;
|
||
private SVGAImageView gift_svga;
|
||
|
||
public static Handler mHandler;
|
||
private static final int WHAT_PK_TIME = 2;//pk时间变化 what
|
||
private static int mPkTimeCount;//pk时间
|
||
|
||
public static ImageView img_pk_fist_l, img_pk_fist_r;
|
||
public RoundedImageView avatar_l1, avatar_l2, avatar_l3, avatar_r1, avatar_r2, avatar_r3;
|
||
public static LivePKUserListBean livePKUserListBean;
|
||
public String uidL1, uidL2, uidL3, uidR1, uidR2, uidR3;
|
||
public RelativeLayout lt_pk_line;
|
||
|
||
public WindowManager windowManager;
|
||
// public boolean isRy = false;
|
||
private Banner mBanner1, mBanner2, mBanner3, mBanner4;
|
||
private List<BannerBean> mBannerList1 = new ArrayList<>();
|
||
private List<BannerBean> mBannerList2 = new ArrayList<>();
|
||
private List<BannerBean> mBannerList3 = new ArrayList<>();
|
||
private List<BannerBean> mBannerList4 = new ArrayList<>();
|
||
private List<BannerBean> mTopBannerList = null;
|
||
private LinearLayout btn_event2, btn_event3, btn_event4, enterRoomLeave2;
|
||
private ImageView imgEvent;
|
||
private View btnEvent;
|
||
private LinearLayout lt_trickery;
|
||
private TextView tv_trickery_time;
|
||
private FrameLayout enterRoomLeave, enterRoomBg;
|
||
private ConstraintLayout fans_enter_room_leave;
|
||
private RecyclerView fastMsgRecyclerView;
|
||
private LiveRoomFastMessageRecyclerViewAdapter fastMessageRecyclerViewAdapter;
|
||
|
||
private LiveUserGiftBean nowGuardUser;
|
||
private ViewFlipper wishListFlipper;
|
||
private List<WishlistItemModel> wishlist = new ArrayList<>();
|
||
private TextView mHourRank, mHotText;
|
||
private LinearLayout msg; //默认悬浮窗布局
|
||
private LinearLayout mAnchorLayout, hourRankLayout, liveRankPk2;
|
||
private ImageView mGoodNumberIcon;
|
||
private View msg2; //悬浮窗来私信的布局
|
||
private ConstraintLayout msgLayout; //悬浮窗
|
||
private TextView msgNumber;//悬浮窗左上角数标
|
||
private RoundedImageView msgUserIcon; //悬浮窗icon
|
||
private FullServiceNotificationView fullScreen;//全副喇叭
|
||
private NobleNoticeView noble;//全副喇叭
|
||
private FaceManager manager;
|
||
private FrameLayout pkRankLayout;
|
||
private ViewFlipper pkRankVf;
|
||
private ImageView mPkRankIcon;
|
||
private TextView mPkRankText;
|
||
private ImageView mPkRankTopIcon;
|
||
private TextView mRedVal, mBlueVal;
|
||
public String pkUid = "";
|
||
|
||
//接口整合新加参数
|
||
private GuardUserModel guardUserModel;
|
||
private static ViewFlipper flipper, wksAndGiftWall;
|
||
private TextView mRandomPkTimer;
|
||
|
||
//全服通知
|
||
private ImageView customFullServiceNotify;
|
||
|
||
//----主播说组件---//
|
||
private View mAnchorSay;
|
||
private ImageView mAnchorSayImage;
|
||
private TextView mAnchorSayText;
|
||
private ImageView mAnchorSayHide;
|
||
//----!主播说组件---//
|
||
//----投票组件---//
|
||
private LiveRoomVoteManager voteManager;
|
||
//----!投票组件---//
|
||
private Banner topBanner1, topBanner2;//心愿单&联系方式
|
||
public SVGAImageView svga_new_user_gif, svga_new_user_double, svga_new_user_follow;
|
||
private String mAnchorName;//主播名字
|
||
private boolean isHinde = false;
|
||
private boolean isFans = false;
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onUpdata(String str) {
|
||
if ("svga_new_user_gif".equals(str)) {
|
||
svga_new_user_gif();
|
||
} else if ("svga_new_user_double".equals(str)) {
|
||
svga_new_user_double();
|
||
} else if ("svga_new_user_follow".equals(str)) {
|
||
svga_new_user_follow();
|
||
} else if ("stop_svga_new_user_double".equals(str)) {
|
||
svga_new_user_double.setVisibility(View.GONE);
|
||
svga_new_user_double.stopAnimation();
|
||
svga_new_user_double.clear();
|
||
} else if ("stop_svga_new_user_follow".equals(str)) {
|
||
svga_new_user_follow.setVisibility(View.GONE);
|
||
svga_new_user_follow.stopAnimation();
|
||
svga_new_user_follow.clear();
|
||
} else if ("stop_svga_new_user_gif".equals(str)) {
|
||
svga_new_user_gif.setVisibility(View.GONE);
|
||
svga_new_user_gif.stopAnimation();
|
||
svga_new_user_gif.clear();
|
||
} else if ("name_true".equals(str)) {
|
||
if (LiveRoomViewHolder.mName != null && LiveRoomViewHolder.mName.getText().length() <= 4) {
|
||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(DpUtil.dp2px(116), DpUtil.dp2px(40));
|
||
layoutParams.setMargins(DpUtil.dp2px(80), DpUtil.dp2px(80), 0, 0);
|
||
svga_new_user_follow.setLayoutParams(layoutParams);
|
||
} else {
|
||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(DpUtil.dp2px(116), DpUtil.dp2px(40));
|
||
layoutParams.setMargins(DpUtil.dp2px(100), DpUtil.dp2px(80), 0, 0);
|
||
svga_new_user_follow.setLayoutParams(layoutParams);
|
||
}
|
||
}
|
||
|
||
if ("svga_new_user_gif".equals(str)) {
|
||
if (fastMsgRecyclerView == null) return;
|
||
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)
|
||
fastMsgRecyclerView.getLayoutParams();
|
||
params1.rightMargin = DeviceUtils.getScreenWidth((Activity) mContext) / 3;
|
||
fastMsgRecyclerView.setLayoutParams(params1);
|
||
} else if ("stop_svga_new_user_gif".equals(str)) {
|
||
if (fastMsgRecyclerView == null) return;
|
||
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)
|
||
fastMsgRecyclerView.getLayoutParams();
|
||
params1.rightMargin = 0;
|
||
fastMsgRecyclerView.setLayoutParams(params1);
|
||
} else if ("showBanner".equals(str)) {
|
||
showBanner3(bean1);
|
||
} else if ("stop_svga_new_user_double".equals(str) && mBannerList3.size() > 2) {
|
||
|
||
mBannerList3.get(2).setLink("1");
|
||
mBanner3.update(mBannerList3);
|
||
if (mBannerList3.get(0).getLink().equals("1")) {
|
||
if (mBannerList3.get(1).getLink().equals("1")) {
|
||
if (mBannerList3.get(2).getLink().equals("1")) {
|
||
btn_event3.setVisibility(View.GONE);
|
||
}
|
||
}
|
||
}
|
||
} else if ("stop_svga_new_user_follow".equals(str) && mBannerList3.size() > 1) {
|
||
mBannerList3.get(1).setLink("1");
|
||
|
||
mBanner3.update(mBannerList3);
|
||
if (mBannerList3.get(0).getLink().equals("1")) {
|
||
if (mBannerList3.get(1).getLink().equals("1")) {
|
||
if (mBannerList3.get(2).getLink().equals("1")) {
|
||
btn_event3.setVisibility(View.GONE);
|
||
}
|
||
}
|
||
}
|
||
} else if ("stop_new_user_gif".equals(str) && mBannerList3.size() > 0) {
|
||
IMLoginManager.get(mContext).setNewUserGif(false);
|
||
mBannerList3.get(0).setLink("1");
|
||
mBanner3.update(mBannerList3);
|
||
if (mBannerList3.get(0).getLink().equals("1")) {
|
||
if (mBannerList3.get(1).getLink().equals("1")) {
|
||
if (mBannerList3.get(2).getLink().equals("1")) {
|
||
btn_event3.setVisibility(View.GONE);
|
||
}
|
||
}
|
||
}
|
||
} else if ("checkNewLetter".equals(str)) {
|
||
checkNewLetter();
|
||
} else if ("exitFansGroup".equals(str)) {
|
||
setFansGroup("0");
|
||
}
|
||
}
|
||
|
||
private void svga_new_user_gif() {
|
||
svga_new_user_gif.setVisibility(View.VISIBLE);
|
||
new SVGAParser(mContext).decodeFromAssets("free_gift_tip.svga", new SVGAParser.ParseCompletion() {
|
||
@Override
|
||
public void onComplete(SVGAVideoEntity videoItem) {
|
||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||
svga_new_user_gif.setImageDrawable(drawable);
|
||
SVGAViewUtils.playEndClear(svga_new_user_gif);
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onError() {
|
||
Log.e("errqs", "errl");
|
||
}
|
||
}, null);
|
||
|
||
}
|
||
|
||
private void svga_new_user_double() {
|
||
svga_new_user_double.setVisibility(View.VISIBLE);
|
||
new SVGAParser(mContext).decodeFromAssets("double_click_tip.svga", new SVGAParser.ParseCompletion() {
|
||
@Override
|
||
public void onComplete(SVGAVideoEntity videoItem) {
|
||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||
svga_new_user_double.setImageDrawable(drawable);
|
||
svga_new_user_double.setBackgroundResource(R.mipmap.black_bg);
|
||
SVGAViewUtils.playEndClear(svga_new_user_double);
|
||
}
|
||
|
||
@Override
|
||
public void onError() {
|
||
Log.e("errqs", "errl");
|
||
}
|
||
}, null);
|
||
}
|
||
|
||
private void svga_new_user_follow() {
|
||
svga_new_user_follow.setVisibility(View.VISIBLE);
|
||
new SVGAParser(mContext).decodeFromAssets("live_follow_tip.svga", new SVGAParser.ParseCompletion() {
|
||
@Override
|
||
public void onComplete(SVGAVideoEntity videoItem) {
|
||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||
svga_new_user_follow.setImageDrawable(drawable);
|
||
SVGAViewUtils.playEndClear(svga_new_user_follow);
|
||
}
|
||
|
||
@Override
|
||
public void onError() {
|
||
Log.e("errqs", "errl");
|
||
}
|
||
}, null);
|
||
|
||
}
|
||
|
||
public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) {
|
||
super(context, parentView);
|
||
Contexts = context;
|
||
this.forAct = forActivity;
|
||
// this.isRy = isRys;
|
||
mGifImageView = gifImageView;
|
||
mSVGAImageView = svgaImageView;
|
||
mLiveGiftPrizePoolContainer = liveGiftPrizePoolContainer;
|
||
this.windowManager = windowManager;
|
||
|
||
}
|
||
|
||
public void clearList() {
|
||
mBannerList2.clear();
|
||
}
|
||
|
||
//更新连麦人
|
||
public List<String> mic_ids = new ArrayList<>();
|
||
|
||
public void updataMicList(List<LinkMicUserBean> list) {
|
||
mic_ids.clear();
|
||
updataCleanMic();
|
||
//拿到原始数据
|
||
for (int i = 0; i < list.size(); i++) {
|
||
LinkMicUserBean bean = list.get(i);
|
||
if (i == 1) {
|
||
mic_view.setVisibility(View.VISIBLE);
|
||
mic_ids.add(bean.getId());
|
||
ImgLoader.display2(Contexts, bean.getAvatar(), mic_ico);
|
||
} else if (i == 2) {
|
||
mic_view1.setVisibility(View.VISIBLE);
|
||
mic_ids.add(bean.getId());
|
||
ImgLoader.display2(Contexts, bean.getAvatar(), mic_ico1);
|
||
} else if (i == 3) {
|
||
mic_view2.setVisibility(View.VISIBLE);
|
||
mic_ids.add(bean.getId());
|
||
ImgLoader.display2(Contexts, bean.getAvatar(), mic_ico2);
|
||
}
|
||
}
|
||
mic_view.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
xz(mic_ids.get(0));
|
||
}
|
||
});
|
||
mic_view1.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
xz(mic_ids.get(1));
|
||
}
|
||
});
|
||
mic_view2.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
xz(mic_ids.get(2));
|
||
}
|
||
});
|
||
}
|
||
|
||
public void updataCleanMic() {
|
||
mic_view.setVisibility(View.INVISIBLE);
|
||
mic_view1.setVisibility(View.INVISIBLE);
|
||
mic_view2.setVisibility(View.INVISIBLE);
|
||
}
|
||
|
||
public static void paygzGif(String url, String liveid) {
|
||
if (liveid.equals(mLiveUid)) {
|
||
try {
|
||
new SVGAParser(Contexts).parse(new URL(url), new SVGAParser.ParseCompletion() {
|
||
@Override
|
||
public void onComplete(SVGAVideoEntity videoItem) {
|
||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||
mSVGAImageView.setImageDrawable(drawable);
|
||
SVGAViewUtils.playEndClear(mSVGAImageView);
|
||
}
|
||
|
||
@Override
|
||
public void onError() {
|
||
}
|
||
});
|
||
} catch (MalformedURLException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
List<XydCompleteModel> xydCompleteModels = new ArrayList<>();
|
||
|
||
public synchronized void showXydComplete(XydCompleteModel model, boolean isRunble, LiveReceiveGiftBean liveReceiveGiftBean) {
|
||
|
||
if (model.getLiveId().equals(mLiveUid)) {
|
||
if (!isRunble) {
|
||
LiveChatBean bean = new LiveChatBean();
|
||
|
||
bean.setContent(model.getMsg());
|
||
bean.setUserNiceName(model.getUserName());
|
||
bean.setAtUserName(model.getXydgiftname())
|
||
.setLevel(model.getLevel());
|
||
bean.setType(LiveChatBean.XYD_COMPLETE);
|
||
mLiveChatAdapter.insertItem(bean);
|
||
xydCompleteModels.add(model);
|
||
}
|
||
if (mLiveGiftAnimPresenter == null) {
|
||
mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager);
|
||
}
|
||
liveReceiveGiftBean.setGiftId(liveReceiveGiftBean.getGiftName());
|
||
mLiveGiftAnimPresenter.showGifGift(liveReceiveGiftBean);
|
||
|
||
|
||
}
|
||
}
|
||
|
||
private TextView sud_text_name;
|
||
private Handler sudNameHandler = new Handler();
|
||
private Runnable sudNameRunnable = new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
if (sud_text_name != null) {
|
||
sud_text_name.setVisibility(View.GONE);
|
||
}
|
||
}
|
||
};
|
||
|
||
public void setSudName(String sudName) {
|
||
sud_text_name = (TextView) findViewById(com.yunbao.common.R.id.sud_text_name);
|
||
sud_text_name.setText(WordUtil.isNewZh() ?
|
||
String.format("主播创建了【%s】房间,快来与主播同玩~", sudName) :
|
||
String.format("The anchor has created a 【%s】 room. Come and play with the anchor~", sudName));
|
||
sud_text_name.setVisibility(View.VISIBLE);
|
||
ViewClicksAntiShake.clicksAntiShake(sud_text_name, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||
@Override
|
||
public void onViewClicks() {
|
||
sud_text_name.setVisibility(View.GONE);
|
||
}
|
||
});
|
||
sudNameHandler.removeCallbacks(sudNameRunnable);
|
||
sudNameHandler.postDelayed(sudNameRunnable, 10000);
|
||
}
|
||
|
||
@Override
|
||
protected int getLayoutId() {
|
||
return R.layout.view_live_room;
|
||
}
|
||
|
||
private View sudGameMin;
|
||
|
||
public void onShowHideEvent() {
|
||
sudGameMin = findViewById(R.id.sud_game_min);
|
||
sudGameMin.setVisibility(View.VISIBLE);
|
||
ViewClicksAntiShake.clicksAntiShake(sudGameMin, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||
@Override
|
||
public void onViewClicks() {
|
||
Bus.get().post(new HideShowEvent().setClose(false));
|
||
sudGameMin.setVisibility(View.GONE);
|
||
}
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 获取下一秒钟的时间
|
||
*/
|
||
private static long getNextSecondTime() {
|
||
long now = SystemClock.uptimeMillis();
|
||
return now + (1000 - now % 1000);
|
||
}
|
||
|
||
/**
|
||
* pk时间倒计时
|
||
*/
|
||
public void changePkTime() {
|
||
Log.i("tvt", mPkTimeCount + "");
|
||
mPkTimeCount--;
|
||
if (mPkTimeCount > 0) {//
|
||
if (mHandler != null) {
|
||
time.setVisibility(View.VISIBLE);
|
||
String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
|
||
time.setText("PK時間:" + s1);
|
||
mHandler.sendEmptyMessageAtTime(WHAT_PK_TIME, getNextSecondTime());
|
||
if (mContext instanceof LiveAudienceActivity) {
|
||
((LiveAudienceActivity) mContext).setPkStatus(true);
|
||
}
|
||
}
|
||
} else {
|
||
time.setVisibility(View.GONE);
|
||
if (mHandler != null) {
|
||
mHandler.removeCallbacksAndMessages(null);
|
||
}
|
||
if (mContext instanceof LiveAudienceActivity) {
|
||
((LiveAudienceActivity) mContext).setPkStatus(false);
|
||
}
|
||
endDRGif();
|
||
}
|
||
}
|
||
|
||
private static boolean visibility = false;
|
||
|
||
// public void hotAddVisibility(boolean visibility) {
|
||
// this.visibility = visibility;
|
||
// ft_hot_add.setVisibility(visibility ? View.GONE : View.VISIBLE);
|
||
// }
|
||
|
||
public void endDRGif() {
|
||
if (dr_pk_end_gif.getVisibility() == View.GONE && isShowGif) {
|
||
dr_pk_end_gif.setVisibility(View.VISIBLE);
|
||
visibility = false;
|
||
RequestOptions options = new RequestOptions().skipMemoryCache(true);//配置
|
||
Glide.with(mContext).asGif()
|
||
.apply(options)//应用配置
|
||
.load(WordUtil.isNewZh() ? R.mipmap.drpkend : R.mipmap.drpkend_en)
|
||
.listener(new RequestListener<GifDrawable>() {
|
||
@Override
|
||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<GifDrawable> target, boolean isFirstResource) {
|
||
return false;
|
||
}
|
||
|
||
@Override
|
||
public boolean onResourceReady(GifDrawable resource, Object model, Target<GifDrawable> target, DataSource dataSource, boolean isFirstResource) {
|
||
if (resource instanceof GifDrawable) {
|
||
resource.setLoopCount(1);//只播放一次
|
||
}
|
||
//发送延时消息,通知动画结束
|
||
mHandler.sendEmptyMessageDelayed(1,
|
||
3000);
|
||
return false;
|
||
}
|
||
})
|
||
.into(dr_pk_end_gif);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
public static void UpPkBar(JSONArray obj, String uid, int time) {
|
||
|
||
ScreenDimenUtil util = ScreenDimenUtil.getInstance();
|
||
int mScreenWdith = util.getScreenWdith();
|
||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) d_pk_view.getLayoutParams();
|
||
params.height = mScreenWdith * 720 / 980;
|
||
d_pk_view.requestLayout();
|
||
|
||
d_pk_view.setVisibility(View.VISIBLE);
|
||
if (time != 0) {
|
||
mPkTimeCount = time;
|
||
mHandler.sendEmptyMessageAtTime(WHAT_PK_TIME, getNextSecondTime());
|
||
}
|
||
|
||
|
||
List<DrPkbean> old_drPkbeans = new ArrayList<>();
|
||
|
||
//拿到原始数据
|
||
for (int j = 0; j < obj.size(); j++) {
|
||
DrPkbean drPkbean = new DrPkbean();
|
||
JSONObject da = obj.getJSONObject(j);
|
||
drPkbean.setId(da.getIntValue("id"));
|
||
drPkbean.setAvatar(da.getString("avatar"));
|
||
drPkbean.setScore(da.getIntValue("score"));
|
||
drPkbean.setPaiming(da.getIntValue("paiming"));
|
||
drPkbean.setUser_nicename(da.getString("user_nicename"));
|
||
old_drPkbeans.add(drPkbean);
|
||
}
|
||
|
||
|
||
//把自己排第一
|
||
List<DrPkbean> new_drPkbeans = new ArrayList<>();
|
||
for (int j = 0; j < old_drPkbeans.size(); j++) {
|
||
DrPkbean drPkbean = new DrPkbean();
|
||
String id = old_drPkbeans.get(j).getId() + "";
|
||
if (id.equals(uid)) {
|
||
drPkbean.setId(old_drPkbeans.get(j).getId());
|
||
drPkbean.setAvatar(old_drPkbeans.get(j).getAvatar());
|
||
drPkbean.setScore(old_drPkbeans.get(j).getScore());
|
||
drPkbean.setUser_nicename(old_drPkbeans.get(j).getUser_nicename());
|
||
drPkbean.setPaiming(old_drPkbeans.get(j).getPaiming());
|
||
new_drPkbeans.add(drPkbean);
|
||
old_drPkbeans.remove(j);
|
||
}
|
||
}
|
||
|
||
//把其他的排后面
|
||
for (int j = 0; j < old_drPkbeans.size(); j++) {
|
||
DrPkbean drPkbean = new DrPkbean();
|
||
drPkbean.setId(old_drPkbeans.get(j).getId());
|
||
drPkbean.setAvatar(old_drPkbeans.get(j).getAvatar());
|
||
drPkbean.setScore(old_drPkbeans.get(j).getScore());
|
||
drPkbean.setUser_nicename(old_drPkbeans.get(j).getUser_nicename());
|
||
drPkbean.setPaiming(old_drPkbeans.get(j).getPaiming());
|
||
new_drPkbeans.add(drPkbean);
|
||
}
|
||
|
||
for (int j = 0; j < new_drPkbeans.size(); j++) {
|
||
if (j == 0) {
|
||
pkText1.setText("" + formatBigNum.formatBigNum2(new_drPkbeans.get(j).getScore() + ""));
|
||
pk_text11.setText("" + new_drPkbeans.get(j).getScore());
|
||
ImgLoader.display2(Contexts, new_drPkbeans.get(j).getAvatar(), avatar1);
|
||
pk1Name.setText(new_drPkbeans.get(j).getUser_nicename());
|
||
px(pk1Ico, new_drPkbeans.get(j).getPaiming());
|
||
} else if (j == 1) {
|
||
pkText2.setText("" + formatBigNum.formatBigNum2(new_drPkbeans.get(j).getScore() + ""));
|
||
pk_text22.setText("" + new_drPkbeans.get(j).getScore());
|
||
ImgLoader.display2(Contexts, new_drPkbeans.get(j).getAvatar(), avatar2);
|
||
pk2Name.setText(new_drPkbeans.get(j).getUser_nicename());
|
||
px(pk2Ico, new_drPkbeans.get(j).getPaiming());
|
||
} else if (j == 2) {
|
||
pkText3.setText("" + formatBigNum.formatBigNum2(new_drPkbeans.get(j).getScore() + ""));
|
||
pk_text33.setText("" + new_drPkbeans.get(j).getScore());
|
||
ImgLoader.display2(Contexts, new_drPkbeans.get(j).getAvatar(), avatar3);
|
||
pk3Name.setText(new_drPkbeans.get(j).getUser_nicename());
|
||
px(pk3Ico, new_drPkbeans.get(j).getPaiming());
|
||
} else if (j == 3) {
|
||
pkText4.setText("" + formatBigNum.formatBigNum2(new_drPkbeans.get(j).getScore() + ""));
|
||
pk_text44.setText("" + new_drPkbeans.get(j).getScore());
|
||
ImgLoader.display2(Contexts, new_drPkbeans.get(j).getAvatar(), avatar4);
|
||
pk4Name.setText(new_drPkbeans.get(j).getUser_nicename());
|
||
px(pk4Ico, new_drPkbeans.get(j).getPaiming());
|
||
} else if (j == 4) {
|
||
pkText5.setText("" + formatBigNum.formatBigNum2(new_drPkbeans.get(j).getScore() + ""));
|
||
pk_text55.setText("" + new_drPkbeans.get(j).getScore());
|
||
ImgLoader.display2(Contexts, new_drPkbeans.get(j).getAvatar(), avatar5);
|
||
pk5Name.setText(new_drPkbeans.get(j).getUser_nicename());
|
||
px(pk5Ico, new_drPkbeans.get(j).getPaiming());
|
||
}
|
||
}
|
||
|
||
|
||
if (new_drPkbeans.size() < 4) {
|
||
pkText4.setVisibility(View.GONE);
|
||
pk_text44.setVisibility(View.GONE);
|
||
pk4.setVisibility(View.GONE);
|
||
|
||
pkText5.setVisibility(View.GONE);
|
||
pk_text55.setVisibility(View.GONE);
|
||
pk5.setVisibility(View.GONE);
|
||
} else if (new_drPkbeans.size() < 5) {
|
||
pkText5.setVisibility(View.GONE);
|
||
pk_text55.setVisibility(View.GONE);
|
||
pk5.setVisibility(View.GONE);
|
||
}
|
||
|
||
avatar1.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View view) {
|
||
xz(new_drPkbeans.get(0).getId() + "");
|
||
}
|
||
});
|
||
|
||
avatar2.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View view) {
|
||
xz(new_drPkbeans.get(1).getId() + "");
|
||
}
|
||
});
|
||
|
||
avatar3.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View view) {
|
||
xz(new_drPkbeans.get(2).getId() + "");
|
||
}
|
||
});
|
||
|
||
avatar4.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View view) {
|
||
xz(new_drPkbeans.get(3).getId() + "");
|
||
}
|
||
});
|
||
|
||
avatar5.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View view) {
|
||
xz(new_drPkbeans.get(4).getId() + "");
|
||
}
|
||
});
|
||
}
|
||
|
||
private static void xz(String uid) {
|
||
LiveUserDialogFragment fragment = new LiveUserDialogFragment();
|
||
Bundle bundle = new Bundle();
|
||
bundle.putString(Constants.LIVE_UID, uid);
|
||
bundle.putString(Constants.TO_UID, uid);
|
||
fragment.setArguments(bundle);
|
||
fragment.show(((LiveActivity) Contexts).getSupportFragmentManager(), "LiveUserDialogFragment");
|
||
}
|
||
|
||
public static void px(ImageView img, int j) {
|
||
|
||
Log.i("tag", j + "");
|
||
if (j == 1) {
|
||
img.setImageResource(R.mipmap.icon_no1);
|
||
} else if (j == 2) {
|
||
img.setImageResource(R.mipmap.icon_no2);
|
||
} else if (j == 3) {
|
||
img.setImageResource(R.mipmap.icon_no3);
|
||
} else if (j == 4) {
|
||
img.setImageResource(R.mipmap.icon_no4);
|
||
} else if (j == 5) {
|
||
img.setImageResource(R.mipmap.icon_no5);
|
||
} else {
|
||
img.setImageResource(R.mipmap.icon_no1);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
@Override
|
||
public void init() {
|
||
EventBus.getDefault().register(this);
|
||
mAnchorSay = findViewById(R.id.anchor_say_layout);
|
||
mAnchorSayImage = (ImageView) findViewById(R.id.anchor_say_icon);
|
||
mAnchorSayText = (TextView) findViewById(R.id.anchor_say_text);
|
||
mAnchorSayHide = (ImageView) findViewById(R.id.anchor_say_hide);
|
||
mAnchorSayHide.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View view) {
|
||
MobclickAgent.onEvent(mContext, "live_room_goddess_say", "女神说按钮");
|
||
hideAnchorSay();
|
||
}
|
||
});
|
||
mAnchorSay.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View view) {
|
||
MobclickAgent.onEvent(mContext, "live_room_goddess_say", "女神说按钮");
|
||
|
||
}
|
||
});
|
||
svga_new_user_gif = (SVGAImageView) findViewById(R.id.svga_new_user_gif);
|
||
svga_new_user_double = (SVGAImageView) findViewById(R.id.svga_new_user_double);
|
||
svga_new_user_follow = (SVGAImageView) findViewById(R.id.svga_new_user_follow);
|
||
svga_new_user_double.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
if (mContext instanceof LiveAudienceActivity) {
|
||
((LiveAudienceActivity) mContext).light();
|
||
}
|
||
}
|
||
});
|
||
mAnchorSay.setOnLongClickListener(v -> {
|
||
|
||
return false;
|
||
});
|
||
|
||
|
||
btnEvent = findViewById(R.id.btn_event);
|
||
fullScreen = (FullServiceNotificationView) findViewById(R.id.full_screen);
|
||
noble = (NobleNoticeView) findViewById(R.id.noble);
|
||
btn_event3 = (LinearLayout) findViewById(R.id.btn_event3);
|
||
imgEvent = (ImageView) findViewById(R.id.img_event);
|
||
btn_event2 = (LinearLayout) findViewById(R.id.btn_event2);
|
||
btn_event4 = (LinearLayout) findViewById(R.id.btn_event4);
|
||
enterRoomLeave = (FrameLayout) findViewById(R.id.enter_room_leave);
|
||
fans_enter_room_leave = (ConstraintLayout) findViewById(R.id.fans_enter_room_leave);
|
||
enterRoomBg = (FrameLayout) findViewById(R.id.enter_room_bg);
|
||
enterRoomLeave2 = (LinearLayout) findViewById(R.id.enter_room_leave2);
|
||
mBanner1 = (Banner) findViewById(R.id.banner1);
|
||
time = (TextView) findViewById(R.id.time);
|
||
mBanner2 = (Banner) findViewById(R.id.banner2);
|
||
mBanner3 = (Banner) findViewById(R.id.banner3);
|
||
mBanner4 = (Banner) findViewById(R.id.banner4);
|
||
pkText1 = (TextView) findViewById(R.id.pk_text1);
|
||
pkText2 = (TextView) findViewById(R.id.pk_text2);
|
||
pkText3 = (TextView) findViewById(R.id.pk_text3);
|
||
pkText4 = (TextView) findViewById(R.id.pk_text4);
|
||
pkText5 = (TextView) findViewById(R.id.pk_text5);
|
||
|
||
pk_text11 = (TextView) findViewById(R.id.pk_text11);
|
||
pk_text22 = (TextView) findViewById(R.id.pk_text22);
|
||
pk_text33 = (TextView) findViewById(R.id.pk_text33);
|
||
pk_text44 = (TextView) findViewById(R.id.pk_text44);
|
||
pk_text55 = (TextView) findViewById(R.id.pk_text55);
|
||
|
||
d_pk_view = (View) findViewById(R.id.d_pk_view);
|
||
avatar1 = (RoundedImageView) findViewById(R.id.avatar1);
|
||
avatar2 = (RoundedImageView) findViewById(R.id.avatar2);
|
||
avatar3 = (RoundedImageView) findViewById(R.id.avatar3);
|
||
avatar4 = (RoundedImageView) findViewById(R.id.avatar4);
|
||
avatar5 = (RoundedImageView) findViewById(R.id.avatar5);
|
||
|
||
pk1Name = (TextView) findViewById(R.id.pk1_name);
|
||
pk2Name = (TextView) findViewById(R.id.pk2_name);
|
||
pk3Name = (TextView) findViewById(R.id.pk3_name);
|
||
pk4Name = (TextView) findViewById(R.id.pk4_name);
|
||
pk5Name = (TextView) findViewById(R.id.pk5_name);
|
||
|
||
|
||
pk1Ico = (ImageView) findViewById(R.id.pk1_ico);
|
||
pk2Ico = (ImageView) findViewById(R.id.pk2_ico);
|
||
pk3Ico = (ImageView) findViewById(R.id.pk3_ico);
|
||
pk4Ico = (ImageView) findViewById(R.id.pk4_ico);
|
||
pk5Ico = (ImageView) findViewById(R.id.pk5_ico);
|
||
|
||
pk1 = (RelativeLayout) findViewById(R.id.pk1);
|
||
pk2 = (RelativeLayout) findViewById(R.id.pk2);
|
||
pk3 = (RelativeLayout) findViewById(R.id.pk3);
|
||
pk4 = (RelativeLayout) findViewById(R.id.pk4);
|
||
pk5 = (RelativeLayout) findViewById(R.id.pk5);
|
||
|
||
mic_view = (RelativeLayout) findViewById(R.id.mic_view);
|
||
mic_view1 = (RelativeLayout) findViewById(R.id.mic_view1);
|
||
mic_view2 = (RelativeLayout) findViewById(R.id.mic_view2);
|
||
flipper = (ViewFlipper) findViewById(R.id.hour_rank_list);
|
||
wksAndGiftWall = (ViewFlipper) findViewById(R.id.live_wks_and_gift_wall);
|
||
mic_ico = (ImageView) findViewById(R.id.mic_ico);
|
||
newMessage = (ImageView) findViewById(R.id.new_message);
|
||
atMessage = (ImageView) findViewById(R.id.at_message);
|
||
mic_ico1 = (RoundedImageView) findViewById(R.id.mic_ico1);
|
||
mic_ico2 = (RoundedImageView) findViewById(R.id.mic_ico2);
|
||
ViewClicksAntiShake.clicksAntiShake(newMessage, () -> {
|
||
chatScrollToBottom();
|
||
newMessage.setVisibility(View.GONE);
|
||
if (atMessage.getVisibility() == View.VISIBLE) {
|
||
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) atMessage.getLayoutParams();
|
||
if (fastMsgRecyclerView.getVisibility() == View.VISIBLE) {
|
||
params1.bottomMargin = DpUtil.dp2px(38);
|
||
} else {
|
||
params1.bottomMargin = DpUtil.dp2px(8);
|
||
|
||
}
|
||
atMessage.setLayoutParams(params1);
|
||
}
|
||
});
|
||
ViewClicksAntiShake.clicksAntiShake(atMessage, () -> {
|
||
mLiveChatAdapter.scrollToAt();
|
||
atMessage.setVisibility(View.GONE);
|
||
});
|
||
dr_pk_end_gif = (GifImageView) findViewById(R.id.dr_pk_end_gif);
|
||
msg = (LinearLayout) findViewById(R.id.room_msg);
|
||
msg2 = (View) findViewById(R.id.room_msg_user);
|
||
msgNumber = (TextView) findViewById(R.id.room_msg_num);
|
||
msgUserIcon = (RoundedImageView) findViewById(R.id.room_msg_user_icon);
|
||
msgLayout = (ConstraintLayout) findViewById(R.id.room_msg_layout);
|
||
ViewClicksAntiShake.clicksAntiShake(msg, this::openChatWindow);
|
||
ViewClicksAntiShake.clicksAntiShake(msg2, this::openChatWindow);
|
||
|
||
lt_trickery = (LinearLayout) findViewById(R.id.lt_trickery);
|
||
tv_trickery_time = (TextView) findViewById(R.id.tv_trickery_time);
|
||
lt_trickery.setOnClickListener(this);
|
||
dialog = new Dialog(mContext, R.style.dialog);
|
||
|
||
mRandomPkTimer = (TextView) findViewById(R.id.random_pk_timer);
|
||
|
||
if (!SpUtil.getInstance().getBooleanValue("private_chat_message_switch")) {
|
||
msgLayout.setVisibility(View.GONE);
|
||
}
|
||
if (!IMLoginManager.get(mContext).hintChat()) {
|
||
msgLayout.setVisibility(View.VISIBLE);
|
||
}
|
||
|
||
mHandler = new Handler() {
|
||
@Override
|
||
public void handleMessage(Message msg) {
|
||
switch (msg.what) {
|
||
case WHAT_PK_TIME:
|
||
changePkTime();
|
||
break;
|
||
case 1:
|
||
isShowGif = false;
|
||
dr_pk_end_gif.setVisibility(View.GONE);
|
||
break;
|
||
}
|
||
}
|
||
};
|
||
|
||
mRoot = (ViewGroup) findViewById(R.id.root);
|
||
voteManager = new LiveRoomVoteManager(mContext, mRoot);
|
||
mAvatar = (ImageView) findViewById(R.id.avatar);
|
||
|
||
mLevelAnchor = (ImageView) findViewById(R.id.level_anchor);
|
||
mLevelAnchor = (ImageView) findViewById(R.id.level_anchor);
|
||
mLevelAnchor = (ImageView) findViewById(R.id.level_anchor);
|
||
|
||
|
||
mLevelAnchor = (ImageView) findViewById(R.id.level_anchor);
|
||
mName = (TextView) findViewById(R.id.name);
|
||
mID = (TextView) findViewById(R.id.id_val);
|
||
mBtnFollow = findViewById(R.id.btn_follow);
|
||
mViewMedal = (ImageView) findViewById(R.id.view_medal);
|
||
mVotesName = (TextView) findViewById(R.id.votes_name);
|
||
mVotes = (TextView) findViewById(R.id.votes);
|
||
mTvMedalRank = (TextView) findViewById(R.id.medal_rank_num);
|
||
mGuardNum = (TextView) findViewById(R.id.guard_num);
|
||
userMore = (ImageView) findViewById(R.id.user_more);
|
||
userGuard = (RoundedImageView) findViewById(R.id.user_guard);
|
||
gift_svga = (SVGAImageView) findViewById(R.id.gift_svga);
|
||
tv_avatarOther_name = (TextView) findViewById(R.id.tv_avatarOther_name);
|
||
room_hot = (TextView) findViewById(R.id.room_hot);
|
||
fans = (TextView) findViewById(R.id.fans);
|
||
fans_btn = (LinearLayout) findViewById(R.id.fans_btn);
|
||
wishListLayout = (LinearLayout) findViewById(R.id.wish_list_layout);
|
||
wishListLayout2 = (LinearLayout) findViewById(R.id.wish_list_layout2);
|
||
liveWksLayout = (LinearLayout) findViewById(R.id.live_wks_layout2);
|
||
mAnchorLayout = (LinearLayout) findViewById(R.id.group_1);
|
||
hourRankLayout = (LinearLayout) findViewById(R.id.hour_rank_layout2);
|
||
liveRankPk2 = (LinearLayout) findViewById(R.id.live_rank_pk2);
|
||
mGoodNumberIcon = (ImageView) findViewById(R.id.good_nub_ico);
|
||
pkRankLayout = (FrameLayout) findViewById(R.id.live_rank_pk);
|
||
pkRankVf = (ViewFlipper) findViewById(R.id.rank_pk_vf);
|
||
mPkRankTopIcon = (ImageView) findViewById(R.id.icon_pk_top);
|
||
mRedVal = (TextView) findViewById(R.id.pk_rank_red_val);
|
||
mBlueVal = (TextView) findViewById(R.id.pk_rank_blue_val);
|
||
topBanner1 = (Banner) findViewById(R.id.top_banner1);
|
||
topBanner2 = (Banner) findViewById(R.id.top_banner2);
|
||
|
||
if (LivePushTxViewHolder.mTRTCCloud != null || LivePushRyViewHolder.rtcRoom != null) {
|
||
fans_btn.setVisibility(View.GONE);
|
||
}
|
||
goto_room_view = (LinearLayout) findViewById(R.id.goto_room_view);
|
||
goto_room_view.setVisibility(View.GONE);
|
||
avatarOther = (ImageView) findViewById(R.id.avatarOther);
|
||
fans_btn.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View view) {
|
||
((LiveActivity) mContext).openFansWindow();
|
||
}
|
||
});
|
||
findViewById(R.id.hot_btn).setOnClickListener(this);
|
||
try {
|
||
ImgLoader.displayGif(mContext, R.drawable.fans_medal, mViewMedal);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
|
||
//用户头像列表
|
||
mUserRecyclerView = (RecyclerView) findViewById(R.id.user_recyclerView);
|
||
mUserRecyclerView.setHasFixedSize(true);
|
||
mUserRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
|
||
mUserRecyclerView.addItemDecoration(new RightGradual());
|
||
mLiveUserAdapter = new LiveUserAdapter(mContext);
|
||
mLiveUserAdapter.setOnItemClickListener(new OnItemClickListener<UserBean>() {
|
||
@Override
|
||
public void onItemClick(UserBean bean, int position) {
|
||
showUserDialog(bean.getId());
|
||
}
|
||
});
|
||
mUserRecyclerView.setAdapter(mLiveUserAdapter);
|
||
//聊天栏
|
||
mChatRecyclerView = (RecyclerView) findViewById(R.id.chat_recyclerView);
|
||
|
||
ScreenDimenUtil util = ScreenDimenUtil.getInstance();
|
||
int mScreenWdith = util.getScreenWdith();
|
||
|
||
gif_view = (LinearLayout) findViewById(R.id.gif_view);
|
||
chat_view = (RelativeLayout) findViewById(R.id.chat_view);
|
||
|
||
int topMargin = mScreenWdith * 720 / 960 + 210;
|
||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)
|
||
chat_view.getLayoutParams();
|
||
params.topMargin = topMargin;
|
||
chat_view.setLayoutParams(params);
|
||
|
||
|
||
RelativeLayout.LayoutParams msgLayoutLayoutParams = (RelativeLayout.LayoutParams) msgLayout.getLayoutParams();
|
||
msgLayoutLayoutParams.topMargin = topMargin + DpUtil.dp2px(50);
|
||
msgLayout.setLayoutParams(msgLayoutLayoutParams);
|
||
voteManager.setMarginPosition(topMargin + DpUtil.dp2px(50));
|
||
|
||
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)
|
||
mChatRecyclerView.getLayoutParams();
|
||
params1.topMargin = DpUtil.dp2px(65);
|
||
mChatRecyclerView.setLayoutParams(params1);
|
||
|
||
mChatRecyclerView.setHasFixedSize(true);
|
||
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
|
||
layoutManager.setOrientation(RecyclerView.VERTICAL);
|
||
layoutManager.setStackFromEnd(true);
|
||
mChatRecyclerView.setLayoutManager(layoutManager);
|
||
mChatRecyclerView.addItemDecoration(new TopGradual());
|
||
mChatRecyclerView.setItemViewCacheSize(10);
|
||
mLiveChatAdapter = new LiveChatAdapter(mContext);
|
||
mChatRecyclerView.setAdapter(mLiveChatAdapter);
|
||
mLiveChatAdapter.setOnItemClickListener(new OnItemClickListener<LiveChatBean>() {
|
||
@Override
|
||
public void onItemClick(LiveChatBean bean, int position) {
|
||
if (bean.getType() == -1) {
|
||
LiveRoomViewHolder.follow();
|
||
mLiveChatAdapter.removetItem(bean);
|
||
} else if (bean.getType() == -2) {
|
||
|
||
if (mBtnFollow.getVisibility() == View.VISIBLE && !bean.isAttention()) {
|
||
LiveRoomViewHolder.follow();
|
||
}
|
||
mLiveChatAdapter.removetItem(bean);
|
||
((LiveActivity) mContext).sendChatMessage("Hi~", null, null);
|
||
} else if (bean.getType() == -5) {
|
||
String url = CommonAppConfig.HOST + "/index.php?g=Appapi&m=Turntable&a=tricky";
|
||
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token="
|
||
+ CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
|
||
Log.i("tag", url);
|
||
Bundle bundle1 = new Bundle();
|
||
bundle1.putString("url", url);
|
||
LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
|
||
liveHDDialogFragment.setArguments(bundle1);
|
||
liveHDDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
|
||
} else if (bean.getType() == RECOMMEND_CARD_NOTIFY) {
|
||
gotoLive(bean.getMsgModel().getAnchorId());
|
||
} else if (bean.getType() == bean.STAR_CHALLENGE_UPGRADE_NOTIFY) {
|
||
gotoLive(bean.getMsgModel().getLiveUid());
|
||
} else {
|
||
showUserDialog(bean.getId());
|
||
}
|
||
}
|
||
});
|
||
|
||
mChatRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||
@Override
|
||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||
super.onScrolled(recyclerView, dx, dy);
|
||
if (mLiveChatAdapter.isSlideToBottom(recyclerView)) {
|
||
newMessage.setVisibility(View.GONE);
|
||
if (atMessage.getVisibility() == View.VISIBLE) {
|
||
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) atMessage.getLayoutParams();
|
||
if (fastMsgRecyclerView.getVisibility() == View.VISIBLE) {
|
||
params1.bottomMargin = DpUtil.dp2px(38);
|
||
} else {
|
||
params1.bottomMargin = DpUtil.dp2px(8);
|
||
|
||
}
|
||
atMessage.setLayoutParams(params1);
|
||
}
|
||
|
||
}
|
||
}
|
||
});
|
||
mBtnFollow.setOnClickListener(this);
|
||
mViewMedal.setOnClickListener(this);
|
||
findViewById(R.id.btn_close).setOnClickListener(this);
|
||
mAvatar.setOnClickListener(this);
|
||
/*//点击侧边消息按钮,自动发消息,测试用的
|
||
msg.setOnClickListener(new View.OnClickListener() {
|
||
long index = 0;
|
||
|
||
public TimerTask createTask() {
|
||
return new TimerTask() {
|
||
@Override
|
||
public void run() {
|
||
LiveChatBean bean = new LiveChatBean();
|
||
bean.setContent("test msg = " + index++);
|
||
bean.setUserNiceName("auto");
|
||
handler.post(() -> mLiveChatAdapter.insertItem(bean));
|
||
}
|
||
};
|
||
}
|
||
|
||
Handler handler = new Handler(Looper.getMainLooper());
|
||
private TimerTask task;
|
||
|
||
@Override
|
||
public void onClick(View v) {
|
||
if (task == null) {
|
||
task = createTask();
|
||
new Timer().schedule(task, 0, 1000);
|
||
} else {
|
||
task.cancel();
|
||
task = null;
|
||
}
|
||
}
|
||
});
|
||
userMore.setOnClickListener(v -> {
|
||
mLiveChatAdapter.scrollToBottom();
|
||
});*/
|
||
findViewById(R.id.btn_votes).setOnClickListener(this);
|
||
findViewById(R.id.btn_medal_rank).setOnClickListener(this);
|
||
findViewById(R.id.btn_noble).setOnClickListener(this);
|
||
findViewById(R.id.noble_seat).setOnClickListener(this);
|
||
userMore.setOnClickListener(this);
|
||
userGuard.setOnClickListener(this);
|
||
|
||
findViewById(R.id.btn_guard).setOnClickListener(this);
|
||
mBtnPrizePool = findViewById(R.id.btn_prize_pool_level);
|
||
mPrizePoolLevel = (TextView) findViewById(R.id.prize_pool_level);
|
||
mBtnPrizePool.setOnClickListener(this);
|
||
mBtnRedPack = findViewById(R.id.btn_red_pack);
|
||
mBtnRedPack.setOnClickListener(this);
|
||
if (mContext instanceof LiveAudienceActivity) {
|
||
mRoot.setOnClickListener(this);
|
||
}
|
||
mLightAnimPresenter = new LiveLightAnimPresenter(mContext, mParentView);
|
||
mLiveEnterRoomAnimPresenter = new LiveEnterRoomAnimPresenter(mContext, mContentView, mScreenWdith);
|
||
mLiveRoomHandler = new LiveRoomHandler(this);
|
||
mRefreshUserListCallback = new HttpCallback() {
|
||
@Override
|
||
public void onSuccess(int code, String msg, String[] info) {
|
||
if (code == 0 && info.length > 0) {
|
||
if (mLiveUserAdapter != null) {
|
||
JSONObject obj = JSON.parseObject(info[0]);
|
||
List<LiveUserGiftBean> list = JSON.parseArray(obj.getString("userlist"), LiveUserGiftBean.class);
|
||
mLiveUserAdapter.refreshList(list);
|
||
}
|
||
}
|
||
}
|
||
};
|
||
mTimeChargeCallback = new HttpCallback() {
|
||
@Override
|
||
public void onSuccess(int code, String msg, String[] info) {
|
||
if (mContext instanceof LiveAudienceActivity) {
|
||
final LiveAudienceActivity liveAudienceActivity = (LiveAudienceActivity) mContext;
|
||
if (code == 0) {
|
||
liveAudienceActivity.roomChargeUpdateVotes();
|
||
} else {
|
||
if (mLiveRoomHandler != null) {
|
||
mLiveRoomHandler.removeMessages(LiveRoomHandler.WHAT_TIME_CHARGE);
|
||
}
|
||
liveAudienceActivity.pausePlay();
|
||
if (code == 1008) {//余额不足
|
||
liveAudienceActivity.setCoinNotEnough(true);
|
||
DialogUitl.showSimpleDialog(mContext, mContext.getString(R.string.live_coin_not_enough), false,
|
||
new DialogUitl.SimpleCallback2() {
|
||
@Override
|
||
public void onConfirmClick(Dialog dialog, String content) {
|
||
RouteUtil.forwardMyCoin(mContext);
|
||
}
|
||
|
||
@Override
|
||
public void onCancelClick() {
|
||
liveAudienceActivity.exitLiveRoom();
|
||
}
|
||
});
|
||
}
|
||
}
|
||
}
|
||
}
|
||
};
|
||
|
||
//pk开始初始化
|
||
img_pk_fist_l = (ImageView) findViewById(R.id.img_pk_fist_l);
|
||
img_pk_fist_r = (ImageView) findViewById(R.id.img_pk_fist_r);
|
||
|
||
img_pk_fist_l.setBackgroundResource(R.mipmap.icon_red_no1);
|
||
img_pk_fist_r.setBackgroundResource(R.mipmap.icon_blue_no1);
|
||
|
||
avatar_l1 = (RoundedImageView) findViewById(R.id.avatar_l1);
|
||
avatar_l2 = (RoundedImageView) findViewById(R.id.avatar_l2);
|
||
avatar_l3 = (RoundedImageView) findViewById(R.id.avatar_l3);
|
||
avatar_r1 = (RoundedImageView) findViewById(R.id.avatar_r1);
|
||
avatar_r2 = (RoundedImageView) findViewById(R.id.avatar_r2);
|
||
avatar_r3 = (RoundedImageView) findViewById(R.id.avatar_r3);
|
||
redPacket = (FrameLayout) findViewById(R.id.red_packet);
|
||
redPacketCountdown = (TextView) findViewById(R.id.red_packet_countdown);
|
||
redSchedule = (TextView) findViewById(R.id.red_schedule);
|
||
redPacketQueue = (LinearLayout) findViewById(R.id.red_packet_queue);
|
||
openRedPacket = (TextView) findViewById(R.id.open_red_packet);
|
||
|
||
lt_pk_line = (RelativeLayout) findViewById(R.id.lt_pk_line);
|
||
clickAvatar();
|
||
|
||
// ft_hot_add = (FrameLayout) findViewById(R.id.ft_hot_add);
|
||
// img_hot_gif = (ImageView) findViewById(R.id.img_hot_gif);
|
||
findViewById(R.id.ft_hot_add).setOnClickListener(this);
|
||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.open_sidebar), () -> Bus.get().post(new LiveAudienceEvent()
|
||
.setType(LiveAudienceEvent.LiveAudienceType.SIDEBAR)));
|
||
//点击心愿单
|
||
ViewClicksAntiShake.clicksAntiShake(wishListLayout, () -> Bus.get().post(new LiveAudienceEvent()
|
||
.setType(LiveAudienceEvent.LiveAudienceType.WISH_LIST)));
|
||
|
||
mBanner1.setOutlineProvider(new ViewOutlineProvider() {
|
||
@Override
|
||
public void getOutline(View view, Outline outline) {
|
||
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10);
|
||
}
|
||
});
|
||
mBanner2.setOutlineProvider(new ViewOutlineProvider() {
|
||
@Override
|
||
public void getOutline(View view, Outline outline) {
|
||
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10);
|
||
}
|
||
});
|
||
mBanner3.setOutlineProvider(new ViewOutlineProvider() {
|
||
@Override
|
||
public void getOutline(View view, Outline outline) {
|
||
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10);
|
||
}
|
||
});
|
||
topBanner1.setOutlineProvider(new ViewOutlineProvider() {
|
||
@Override
|
||
public void getOutline(View view, Outline outline) {
|
||
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10);
|
||
}
|
||
});
|
||
topBanner2.setOutlineProvider(new ViewOutlineProvider() {
|
||
@Override
|
||
public void getOutline(View view, Outline outline) {
|
||
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10);
|
||
}
|
||
});
|
||
//打招呼消息
|
||
fastMsgRecyclerView = (RecyclerView) findViewById(R.id.room_fast_msg);
|
||
fastMsgRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
|
||
fastMessageRecyclerViewAdapter = new LiveRoomFastMessageRecyclerViewAdapter(mContext);
|
||
fastMsgRecyclerView.setAdapter(fastMessageRecyclerViewAdapter);
|
||
fastMessageRecyclerViewAdapter.setMessageListener(msg -> {
|
||
//点击的消息发送出去
|
||
((LiveActivity) mContext).sendChatMessage(msg, null, null);
|
||
fastMsgRecyclerView.setVisibility(View.GONE);
|
||
params1.bottomMargin = 0;
|
||
mChatRecyclerView.setLayoutParams(params1);
|
||
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) newMessage.getLayoutParams();
|
||
RelativeLayout.LayoutParams params3 = (RelativeLayout.LayoutParams) atMessage.getLayoutParams();
|
||
if (newMessage.getVisibility() == View.VISIBLE) {
|
||
params2.bottomMargin = DpUtil.dp2px(8);
|
||
if (atMessage.getVisibility() == View.VISIBLE) {
|
||
params3.bottomMargin = DpUtil.dp2px(38);
|
||
atMessage.setLayoutParams(params3);
|
||
}
|
||
newMessage.setLayoutParams(params2);
|
||
} else {
|
||
if (atMessage.getVisibility() == View.VISIBLE) {
|
||
params3.bottomMargin = DpUtil.dp2px(8);
|
||
atMessage.setLayoutParams(params3);
|
||
}
|
||
}
|
||
});
|
||
// mBanner2.setVisibility(View.GONE);
|
||
if (fastMsgRecyclerView.getVisibility() == View.GONE) {
|
||
params1.bottomMargin = 0;
|
||
mChatRecyclerView.setLayoutParams(params1);
|
||
}
|
||
// fastMsgRecyclerView.setItemAnimator(new DefaultItemAnimator());
|
||
//主播页面隐藏头部
|
||
if (mContext instanceof LiveRyAnchorActivity) {
|
||
findViewById(R.id.open_sidebar).setVisibility(View.GONE);
|
||
findViewById(R.id.btn_follow).setVisibility(View.GONE);
|
||
findViewById(R.id.live_rank_pk).setVisibility(View.GONE);
|
||
}
|
||
customFullServiceNotify = (ImageView) findViewById(R.id.custom_full_service_notify);
|
||
reloadIM();
|
||
// initStarChallengeStatus();
|
||
|
||
|
||
new LoadDian9TuUtil().loadDian9TuAssets2(mContext, wishListLayout2, "rectangle_new.png", 1);
|
||
|
||
}
|
||
|
||
private FrameLayout redPacket;
|
||
private TextView redPacketCountdown, redSchedule, openRedPacket;
|
||
private LinearLayout redPacketQueue;
|
||
private int redTimeCountdown = 0;
|
||
private RedPacketModel mRedPacketModel;
|
||
private Handler timeHandler = new Handler();
|
||
private Runnable timeRunnable = new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
if (redTimeCountdown > 1) {
|
||
timeHandler.postDelayed(timeRunnable, 1000);
|
||
redPacketCountdown.setText(String.format(mContext.getString(R.string.red_packet_countdown), TimeUtils.getTime(redTimeCountdown)));
|
||
redTimeCountdown = redTimeCountdown - 1;
|
||
} else {
|
||
redTimeCountdown = 0;
|
||
timeHandler.removeCallbacks(timeRunnable);
|
||
StringBuffer stringBuffer = new StringBuffer();
|
||
stringBuffer.append(mRedPacketModel.getRedPacketRemain())
|
||
.append("/")
|
||
.append(mRedPacketModel.getRedPacketQuantity());
|
||
redSchedule.setText(stringBuffer.toString());
|
||
openRedPacket.setText(String.format(mContext.getString(R.string.open_red_packet), mRedPacketModel.getRedPacketCount() + ""));
|
||
redPacketCountdown.setVisibility(View.GONE);
|
||
redPacketQueue.setVisibility(View.VISIBLE);
|
||
}
|
||
|
||
}
|
||
};
|
||
//主播倒计时调用接口
|
||
private Handler anchorTimeHandler = new Handler();
|
||
private int mCountdown;
|
||
private Runnable anchorTimeRunnable = new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
if (mCountdown > 0) {
|
||
mCountdown = mCountdown - 1;
|
||
anchorTimeHandler.postDelayed(anchorTimeRunnable, 1000);
|
||
Log.e("主播倒计时", String.format(mContext.getString(R.string.red_packet_countdown), TimeUtils.getTime(mCountdown)));
|
||
if (mCountdown == 180) {
|
||
LiveNetManager.get(mContext).
|
||
startRedPacketRobot(mLiveUid, mStream, mRedPacketModel.getRedPacketId(), new com.yunbao.common.http.base.HttpCallback<String>() {
|
||
@Override
|
||
public void onSuccess(String data) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onError(String error) {
|
||
ToastUtil.show(error);
|
||
}
|
||
});
|
||
}
|
||
} else {
|
||
redPacket.setVisibility(View.GONE);
|
||
anchorTimeHandler.removeCallbacks(anchorTimeRunnable);
|
||
LiveNetManager.get(mContext).
|
||
endRedPacket(mLiveUid, mRedPacketModel.getRedPacketId(), new com.yunbao.common.http.base.HttpCallback<String>() {
|
||
@Override
|
||
public void onSuccess(String data) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onError(String error) {
|
||
ToastUtil.show(error);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
};
|
||
|
||
/**
|
||
* 红包相关处理
|
||
*/
|
||
public void redPacketManage(RedPacketModel redPacketModel) {
|
||
anchorTimeHandler.removeCallbacks(anchorTimeRunnable);
|
||
timeHandler.removeCallbacks(timeRunnable);
|
||
mRedPacketModel = redPacketModel;
|
||
if (redPacketModel.getIsShow() == 1) {
|
||
redPacket.setVisibility(View.VISIBLE);
|
||
if (redPacketModel.getCountdown() > 180) {
|
||
redPacketQueue.setVisibility(View.GONE);
|
||
redPacketCountdown.setVisibility(View.VISIBLE);
|
||
mCountdown = redPacketModel.getCountdown();
|
||
redTimeCountdown = mCountdown - 180;
|
||
redPacketCountdown.setText(String.format(mContext.getString(R.string.red_packet_countdown), TimeUtils.getTime(redTimeCountdown)));
|
||
timeHandler.post(timeRunnable);
|
||
} else {
|
||
redTimeCountdown = 0;
|
||
redPacketQueue.setVisibility(View.VISIBLE);
|
||
redPacketCountdown.setVisibility(View.GONE);
|
||
StringBuffer stringBuffer = new StringBuffer();
|
||
stringBuffer.append(mRedPacketModel.getRedPacketRemain())
|
||
.append("/")
|
||
.append(mRedPacketModel.getRedPacketQuantity());
|
||
redSchedule.setText(stringBuffer.toString());
|
||
openRedPacket.setText(String.format(mContext.getString(R.string.open_red_packet), mRedPacketModel.getRedPacketCount() + ""));
|
||
}
|
||
if (IMLoginManager.get(mContext).getUserInfo().anchorUserType() && mContext instanceof LiveRyAnchorActivity) {
|
||
anchorTimeHandler.removeCallbacks(anchorTimeRunnable);
|
||
anchorTimeHandler.post(anchorTimeRunnable);
|
||
}
|
||
} else {
|
||
hindeRedPacket();
|
||
}
|
||
//测试点开红包
|
||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.red_packet), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||
@Override
|
||
public void onViewClicks() {
|
||
|
||
if (!(mContext instanceof LiveRyAnchorActivity)) {
|
||
LiveNetManager.get(mContext)
|
||
.redPacketInfo(mLiveUid, redPacketModel.getRedPacketId(), new com.yunbao.common.http.base.HttpCallback<RedPacketInfoModel>() {
|
||
@Override
|
||
public void onSuccess(RedPacketInfoModel data) {
|
||
if (TextUtils.equals(data.getReceiveStatus(), "0")) {
|
||
redTimeCountdown = redTimeCountdown - 1;
|
||
new XPopup.Builder(mContext)
|
||
.asCustom(new ReceiveRendPacketPopup(mContext, redTimeCountdown, mLiveUid, mStream, redPacketModel.getRedPacketId(), data, false, isFans))
|
||
.show();
|
||
} else if (TextUtils.equals(data.getReceiveStatus(), "1")) {
|
||
new XPopup.Builder(mContext)
|
||
.asCustom(new ResultRendPacketPopup(mContext, true, data.setRedPacketId(redPacketModel.getRedPacketId()), false))
|
||
.show();
|
||
} else {
|
||
if (data.getGiftModels().size() > 0) {
|
||
new XPopup.Builder(mContext)
|
||
.asCustom(new ResultRendPacketPopup(mContext, false, data.setRedPacketId(redPacketModel.getRedPacketId()), false))
|
||
.show();
|
||
} else {
|
||
new XPopup.Builder(mContext)
|
||
.asCustom(new ResultRendPacketPopup(mContext, true, data.setRedPacketId(redPacketModel.getRedPacketId()), false))
|
||
.show();
|
||
}
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onError(String error) {
|
||
ToastUtil.show(error);
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
}
|
||
});
|
||
}
|
||
|
||
public void hindeRedPacket() {
|
||
redPacket.setVisibility(View.GONE);
|
||
}
|
||
|
||
public void setRedPacketInfoModel(RedPacketInfoModel redPacket) {
|
||
new XPopup.Builder(mContext)
|
||
.asCustom(new ReceiveRendPacketPopup(mContext, 0, mLiveUid, mStream, redPacket.getRedPacketId(), redPacket, true, isFans))
|
||
.show();
|
||
}
|
||
|
||
/**
|
||
* 隐藏女神说
|
||
*/
|
||
private void hideAnchorSay() {
|
||
boolean hide = mAnchorSay.getTag() == null || (boolean) mAnchorSay.getTag();
|
||
Animation animation;
|
||
if (hide) {
|
||
animation = AnimationUtils.loadAnimation(mContext, R.anim.view_live_anchor_say_text_out);
|
||
} else {
|
||
animation = AnimationUtils.loadAnimation(mContext, R.anim.view_live_anchor_say_text_in);
|
||
}
|
||
animation.setAnimationListener(new Animation.AnimationListener() {
|
||
@Override
|
||
public void onAnimationStart(Animation animation) {
|
||
if (!hide) {
|
||
mAnchorSay.setX((float) mAnchorSayImage.getTag());
|
||
mAnchorSayImage.setVisibility(View.VISIBLE);
|
||
mAnchorSayText.setVisibility(View.VISIBLE);
|
||
mAnchorSayHide.setImageResource(R.mipmap.ic_live_anchor_say_show);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationEnd(Animation animation) {
|
||
if (hide) {
|
||
mAnchorSayImage.setTag(mAnchorSay.getX());
|
||
mAnchorSay.setX(-DpUtil.dp2px(53));
|
||
mAnchorSayImage.setVisibility(View.INVISIBLE);
|
||
mAnchorSayText.setVisibility(View.INVISIBLE);
|
||
mAnchorSayHide.setImageResource(R.mipmap.ic_live_anchor_say_hide);
|
||
}
|
||
mAnchorSay.setTag(!hide);
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationRepeat(Animation animation) {
|
||
|
||
}
|
||
});
|
||
mAnchorSay.startAnimation(animation);
|
||
}
|
||
|
||
/**
|
||
* 获取当前直播间星级
|
||
*/
|
||
private void initStarChallengeStatus() {
|
||
LiveNetManager.get(mContext)
|
||
.getStarChallengeStatus(PortraitLiveManager.liveID, new com.yunbao.common.http.base.HttpCallback<StarChallengeStatusModel>() {
|
||
@Override
|
||
public void onSuccess(StarChallengeStatusModel data1) {
|
||
showStart(data1);
|
||
Log.e("PortraitLiveManager", data1.toString());
|
||
}
|
||
|
||
@Override
|
||
public void onError(String error) {
|
||
Log.e("PortraitLiveManager", error);
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
/**
|
||
* 重置该隐藏的view
|
||
*/
|
||
public void resetViewGone() {
|
||
goto_room_view.setVisibility(View.GONE);
|
||
mPkRankTopIcon.setVisibility(View.GONE);
|
||
lt_pk_line.setVisibility(View.GONE);
|
||
time.setVisibility(View.GONE);
|
||
if (!SpUtil.getInstance().getBooleanValue("private_chat_message_switch")) {
|
||
msgLayout.setVisibility(View.GONE);
|
||
}
|
||
if (!IMLoginManager.get(mContext).hintChat()) {
|
||
msgLayout.setVisibility(View.VISIBLE);
|
||
}
|
||
AppManager.runDebugCode(() -> msgLayout.setVisibility(View.GONE));
|
||
if (d_pk_view != null) {
|
||
d_pk_view.setVisibility(View.GONE);
|
||
}
|
||
if (LivePushTxViewHolder.mTRTCCloud != null || LivePushRyViewHolder.rtcRoom != null) {
|
||
fans_btn.setVisibility(View.GONE);
|
||
}
|
||
mRedVal.setVisibility(View.GONE);
|
||
mBlueVal.setVisibility(View.GONE);
|
||
mPkRankTopIcon.setVisibility(View.GONE);
|
||
mAnchorLayout.setBackgroundResource(R.drawable.bg_live_ico);
|
||
mGoodNumberIcon.setVisibility(View.GONE);
|
||
mAnchorSay.setVisibility(View.INVISIBLE);
|
||
}
|
||
|
||
/**
|
||
* 重置数据
|
||
*/
|
||
public void resetView() {
|
||
timeHandler.removeCallbacks(timeRunnable);
|
||
anchorTimeHandler.removeCallbacks(anchorTimeRunnable);
|
||
resetViewGone();
|
||
visibility = false;
|
||
pkUidTmp = "";
|
||
mBannerList1.clear();
|
||
mBannerList2.clear();
|
||
mBannerList3.clear();
|
||
mBannerList4.clear();
|
||
if (mTopBannerList != null) {
|
||
mTopBannerList.clear();
|
||
mTopBannerList = null;
|
||
}
|
||
sayModel = null;
|
||
updataCleanMic();
|
||
// initStarChallengeStatus();
|
||
enterRoomLeave.setVisibility(View.GONE);
|
||
fans_enter_room_leave.setVisibility(View.GONE);
|
||
topBanner1.setVisibility(View.GONE);
|
||
topBanner2.setVisibility(View.GONE);
|
||
topBanner1.update(mTopBannerList);
|
||
topBanner2.update(mTopBannerList);
|
||
removeDetailView();
|
||
}
|
||
|
||
public void clearChat() {
|
||
if (mLiveChatAdapter != null) {
|
||
mLiveChatAdapter.clear();
|
||
}
|
||
}
|
||
|
||
public void clearGuardIcon() {
|
||
if (userGuard != null) {
|
||
userGuard.setImageResource(R.mipmap.img_guardian_empty);
|
||
}
|
||
}
|
||
|
||
public synchronized void showStart(StarChallengeStatusModel data) {
|
||
boolean upData = false;
|
||
if (mBannerList2 != null && mBannerList2.size() == 0) {
|
||
Log.e("PortraitLiveManager", "直接添加星级任务");
|
||
BannerBean bannerBean = new BannerBean();
|
||
bannerBean.setStart(true);
|
||
bannerBean.setModel(data);
|
||
mBannerList2.add(bannerBean);
|
||
} else {
|
||
Log.e("PortraitLiveManager", "遍历添加星级任务");
|
||
for (BannerBean bean : mBannerList2) {
|
||
if (bean.isStart()) {
|
||
Log.e("PortraitLiveManager", "更新添加星级任务");
|
||
bean.setModel(data);
|
||
upData = true;
|
||
}
|
||
}
|
||
if (!upData) {
|
||
Log.e("PortraitLiveManager", "更新添加星级任务2");
|
||
BannerBean bannerBean = new BannerBean();
|
||
bannerBean.setStart(true);
|
||
bannerBean.setModel(data);
|
||
mBannerList2.add(bannerBean);
|
||
}
|
||
}
|
||
|
||
|
||
Log.e("PortraitLiveManager", "mBanner2.isStart():::::::::::" + mBanner2.isStart());
|
||
if (mBanner2.isStart()) {
|
||
mBanner2.update(mBannerList2);
|
||
} else {
|
||
showBanner2();
|
||
}
|
||
|
||
}
|
||
|
||
public void hideFloatMsg() {
|
||
msgLayout.setVisibility(View.GONE);
|
||
}
|
||
|
||
/**
|
||
* 添加心愿单轮播he活动
|
||
*/
|
||
public void addWishListActivity(List<BannerBean> bannerModels) {
|
||
mBannerList2.addAll(bannerModels);
|
||
if (mBanner2.isStart()) {
|
||
mBanner2.update(mBannerList2);
|
||
} else {
|
||
showBanner2();
|
||
}
|
||
}
|
||
|
||
public void setRandomPkTimer(String timer) {
|
||
if (timer == null) {
|
||
mRandomPkTimer.setVisibility(View.GONE);
|
||
return;
|
||
}
|
||
mRandomPkTimer.setVisibility(View.VISIBLE);
|
||
mRandomPkTimer.setText(timer);
|
||
}
|
||
|
||
private synchronized void showBanner2() {
|
||
if (mBannerList2 != null && mBanner2 != null) {
|
||
btn_event2.setVisibility(View.VISIBLE);
|
||
if (mBannerList2.size() == 1) {
|
||
mBanner2.setAutoPlay(false)
|
||
.setPages(mBannerList2, new CustomViewHolder())
|
||
.setDelayTime(3200)
|
||
.setBannerStyle(BannerConfig.NOT_INDICATOR)
|
||
.setOnBannerClickListener(new OnBannerClickListener() {
|
||
@Override
|
||
public void onBannerClick(List datas, int p) {
|
||
if (showLoadingDialog()) {
|
||
return;
|
||
}
|
||
if (mBannerList2 != null) {
|
||
if (p >= 0 && p < mBannerList2.size()) {
|
||
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
|
||
BannerBean bean = mBannerList2.get(p);
|
||
String type = "";
|
||
StringBuffer htmlUrl = new StringBuffer();
|
||
//判断是否是星级活动
|
||
if (bean.isStart()) {
|
||
|
||
|
||
type = bean.getModel().getType();
|
||
htmlUrl.append(CommonAppConfig.HOST)
|
||
.append("/")
|
||
.append(bean.getModel().getActivityUrl())
|
||
.append(bean.getModel().getActivityUrl().contains("?") ? "&nickname=" : "?nickname=")
|
||
.append(userInfo.getUserNicename())
|
||
.append("&token=")
|
||
.append(userInfo.getToken())
|
||
.append("&anchorUid=")
|
||
.append(mLiveUid)
|
||
.append("&uid=")
|
||
.append(userInfo.getId())
|
||
.append("&k=")
|
||
.append(System.currentTimeMillis())
|
||
.append("&isZh=")
|
||
.append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||
} else {
|
||
type = bean.getShow_type();
|
||
htmlUrl.append(bean.getLink())
|
||
.append("?uid=")
|
||
.append(userInfo.getId())
|
||
.append("&token=")
|
||
.append(userInfo.getToken())
|
||
.append("&anchorUid=")
|
||
.append(mLiveUid)
|
||
.append("&t=")
|
||
.append(System.currentTimeMillis())
|
||
.append("&isZh=")
|
||
.append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||
}
|
||
if (htmlUrl.toString().contains("StarChallenge")) {
|
||
Map<String, String> map_ekv = new HashMap<String, String>();
|
||
map_ekv.put("link", htmlUrl.toString());
|
||
MobclickAgent.onEvent(mContext, "live_room_star", map_ekv);
|
||
}
|
||
if (TextUtils.equals(type, "1")) {
|
||
ZhuangBanActivity.forward(mContext, htmlUrl.toString(), false, 1);
|
||
} else {
|
||
Bundle bundle = new Bundle();
|
||
bundle.putString("url", htmlUrl.toString());
|
||
LiveHDDialogFragment fragment = new LiveHDDialogFragment();
|
||
fragment.setArguments(bundle);
|
||
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
})
|
||
.start();
|
||
} else {
|
||
mBanner2.setAutoPlay(true)
|
||
.setPages(mBannerList2, new CustomViewHolder())
|
||
.setDelayTime(3200)
|
||
.setBannerStyle(BannerConfig.NOT_INDICATOR)
|
||
.setOnBannerClickListener(new OnBannerClickListener() {
|
||
@Override
|
||
public void onBannerClick(List datas, int p) {
|
||
if (showLoadingDialog()) {
|
||
return;
|
||
}
|
||
if (mBannerList2 != null) {
|
||
if (p >= 0 && p < mBannerList2.size()) {
|
||
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
|
||
BannerBean bean = mBannerList2.get(p);
|
||
String type = "";
|
||
StringBuffer htmlUrl = new StringBuffer();
|
||
//判断是否是星级活动
|
||
if (bean.isStart()) {
|
||
type = bean.getModel().getType();
|
||
htmlUrl.append(CommonAppConfig.HOST)
|
||
.append("/")
|
||
.append(bean.getModel().getActivityUrl())
|
||
.append(bean.getModel().getActivityUrl().contains("?") ? "&nickname=" : "?nickname=")
|
||
.append(userInfo.getUserNicename())
|
||
.append("&token=")
|
||
.append(userInfo.getToken())
|
||
.append("&anchorUid=")
|
||
.append(mLiveUid)
|
||
.append("&uid=")
|
||
.append(userInfo.getId())
|
||
.append("&k=")
|
||
.append(System.currentTimeMillis())
|
||
.append("&isZh=")
|
||
.append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||
|
||
} else {
|
||
type = bean.getShow_type();
|
||
htmlUrl.append(bean.getLink())
|
||
.append(bean.getLink().contains("?") ? "&uid=" : "?uid=")
|
||
.append(userInfo.getId())
|
||
.append("&token=")
|
||
.append(userInfo.getToken())
|
||
.append("&anchorUid=")
|
||
.append(mLiveUid)
|
||
.append("&liveUid=")
|
||
.append(mLiveUid)
|
||
.append("&t=")
|
||
.append(System.currentTimeMillis())
|
||
.append("&g=Appapi&m=Wish&a=index")
|
||
.append("&isZh=")
|
||
.append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||
}
|
||
if (htmlUrl.toString().contains("StarChallenge")) {
|
||
Map<String, String> map_ekv = new HashMap<String, String>();
|
||
map_ekv.put("link", htmlUrl.toString());
|
||
MobclickAgent.onEvent(mContext, "live_room_star", map_ekv);
|
||
}
|
||
if (TextUtils.equals(type, "1")) {
|
||
ZhuangBanActivity.forward(mContext, htmlUrl.toString(), false, 1);
|
||
} else {
|
||
Bundle bundle = new Bundle();
|
||
bundle.putString("url", htmlUrl.toString());
|
||
LiveHDDialogFragment fragment = new LiveHDDialogFragment();
|
||
fragment.setArguments(bundle);
|
||
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
})
|
||
.start();
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
/**
|
||
* 刷新UI
|
||
*/
|
||
@Override
|
||
public void onResume() {
|
||
super.onResume();
|
||
reloadIM();
|
||
}
|
||
|
||
Dialog loadingDialog = null;
|
||
|
||
private boolean showLoadingDialog() {
|
||
if (loadingDialog != null && loadingDialog.isShowing()) {
|
||
return true;
|
||
}
|
||
loadingDialog = DialogUitl.loadingDialog(mContext, mContext.getString(R.string.login_wait));
|
||
loadingDialog.show();
|
||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||
if (loadingDialog != null) {
|
||
loadingDialog.dismiss();
|
||
}
|
||
loadingDialog = null;
|
||
}, 1000);
|
||
return false;
|
||
}
|
||
|
||
public void setLiveUid(String liveUid) {
|
||
mLiveUid = liveUid;
|
||
LiveHttpUtil.geteEvent(mLiveUid, new HttpCallback() {
|
||
@Override
|
||
public void onSuccess(int code, String msg, String[] info) {
|
||
if (code == 0 && imgEvent != null) {
|
||
for (String s : info) {
|
||
JSONObject obj = JSONObject.parseObject(s);
|
||
if (obj.getString("is_hidden").equals("0")) {
|
||
BannerBean bannerBean = new BannerBean();
|
||
bannerBean.setImageUrl(obj.getString("img"));
|
||
bannerBean.setLink(obj.getString("link"));
|
||
bannerBean.setShow_type(obj.getString("show_type"));
|
||
mBannerList2.add(bannerBean);
|
||
}
|
||
}
|
||
if (mBannerList2.size() > 0) {
|
||
if (mBanner2.isStart()) {
|
||
mBanner2.update(mBannerList2);
|
||
} else {
|
||
showBanner2();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
//获取心愿单列表
|
||
private void loadWishlistData() {
|
||
LiveHttpUtil.getWishList(mLiveUid, new HttpCallback() {
|
||
@Override
|
||
public void onSuccess(int code, String msg, String[] info) {
|
||
if (code == 0 && info.length > 0) {
|
||
try {
|
||
JSONObject obj = JSON.parseObject(info[0]);
|
||
String giftJson = obj.getString("wishlist");
|
||
List<LiveWishlistBean> mWishlist = JSON.parseArray(giftJson, LiveWishlistBean.class);
|
||
if (mWishlist.size() > 0) {
|
||
//心单
|
||
BannerBean bannerBean2 = new BannerBean();
|
||
bannerBean2.setImageUrl(obj.getString("img"));
|
||
bannerBean2.setLink("xyd");
|
||
mBannerList1.add(bannerBean2);
|
||
}
|
||
|
||
showBanner();
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onFinish() {
|
||
}
|
||
});
|
||
}
|
||
|
||
public void showLiveRoomActivityBanner() {
|
||
LiveNetManager.get(mContext)
|
||
.getLiveRoomActivityBanner(new com.yunbao.common.http.base.HttpCallback<List<LiveRoomActivityBanner>>() {
|
||
@Override
|
||
public void onSuccess(List<LiveRoomActivityBanner> data) {
|
||
mBannerList4.clear();
|
||
for (LiveRoomActivityBanner datum : data) {
|
||
if (datum.getHidden() == 1) {
|
||
continue;
|
||
}
|
||
BannerBean bean = new BannerBean();
|
||
bean.setActivityId(datum.getActiveId());
|
||
bean.setName(datum.getName());
|
||
bean.setLink(datum.getLink());
|
||
bean.setImageUrl(datum.getImg());
|
||
bean.setShow_type(datum.getType());
|
||
mBannerList4.add(bean);
|
||
}
|
||
showBanner4();
|
||
}
|
||
|
||
@Override
|
||
public void onError(String error) {
|
||
|
||
}
|
||
});
|
||
}
|
||
|
||
private void showBanner() {
|
||
if (mBannerList1 == null || mBannerList1.size() == 0 || mBanner1 == null) {
|
||
return;
|
||
}
|
||
mBanner1.setAutoPlay(true)
|
||
.setPages(mBannerList1, new CustomViewHolder())
|
||
.setDelayTime(3000)
|
||
.setBannerStyle(BannerConfig.NOT_INDICATOR)
|
||
.setOnBannerClickListener(new OnBannerClickListener() {
|
||
@Override
|
||
public void onBannerClick(List datas, int p) {
|
||
if (mBannerList1 != null) {
|
||
if (p >= 0 && p < mBannerList1.size()) {
|
||
BannerBean bean = mBannerList1.get(p);
|
||
if (bean != null) {
|
||
String link = bean.getLink();
|
||
if (link.equals("sc")) {
|
||
String url;
|
||
if (!"".equals(bean.getmIntoUrl()) && bean.getmIntoUrl() != null) {
|
||
url = CommonAppConfig.HOST + bean.getmIntoUrl() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
|
||
} else {
|
||
url = CommonAppConfig.HOST + "/h5/activity/firstTopUp/newUp.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
|
||
}
|
||
ZhuangBanActivity.forward(mContext, url, false, 1);
|
||
} else if (link.equals("zxb")) {
|
||
String url = CommonAppConfig.HOST + "/h5/activity/weekStar/index.html?&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
|
||
ZhuangBanActivity.forward(mContext, url, false, 1);
|
||
} else if (link.equals("xyd")) {
|
||
openWishListWindow();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
})
|
||
.start();
|
||
}
|
||
|
||
/**
|
||
* 观众打开主播的心愿单窗口
|
||
*/
|
||
public void openWishListWindow() {
|
||
LiveWishListDialogFragment4Audience fragment = new LiveWishListDialogFragment4Audience();
|
||
Bundle bundle = new Bundle();
|
||
bundle.putString(Constants.LIVE_UID, mLiveUid);
|
||
fragment.setArguments(bundle);
|
||
if (mContext instanceof LiveAudienceActivity) {
|
||
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveWishListDialogFragmentAudience");
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 初始化心愿单列表轮播
|
||
*/
|
||
public void initWishList(List<WishlistItemModel> wishlist) {
|
||
if (wishlist.size() > 0) {
|
||
this.wishlist = wishlist;
|
||
wishListLayout.setVisibility(View.VISIBLE);
|
||
} else {
|
||
wishListLayout.setVisibility(View.GONE);
|
||
}
|
||
((Activity) mContext).runOnUiThread(() -> {
|
||
wishListFlipper = (ViewFlipper) findViewById(R.id.wish_list_vf);
|
||
for (int i = 0; i < wishlist.size(); i++) {
|
||
View wish = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
|
||
wish.setTag(wishlist.get(i).getId());
|
||
ImageView wishPic = wish.findViewById(R.id.wish_pic);
|
||
TextView wishIndex = wish.findViewById(R.id.wish_index);
|
||
ImgLoader.display2(mContext, wishlist.get(i).getWishlistIcon(), wishPic);
|
||
wishIndex.setText(wishlist.get(i).getWishlistNumP());
|
||
if (wishListFlipper != null) {
|
||
wishListFlipper.addView(wish);
|
||
}
|
||
}
|
||
if (wishListFlipper != null) {
|
||
wishListFlipper.startFlipping();
|
||
}
|
||
});
|
||
}
|
||
|
||
public void initHourRank(RankHourModel model) {
|
||
if (flipper.getChildCount() > 0) {
|
||
flipper.removeAllViews();
|
||
}
|
||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DpUtil.dp2px(16), DpUtil.dp2px(16));
|
||
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||
textParams.leftMargin = DpUtil.dp2px(5);
|
||
params.leftMargin = DpUtil.dp2px(5);
|
||
View hotView = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
|
||
hotView.setTag("hotView");
|
||
View hourView = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
|
||
hourView.setTag("hourView");
|
||
ImageView hotPic = hotView.findViewById(R.id.wish_pic);
|
||
ImageView hourPic = hourView.findViewById(R.id.wish_pic);
|
||
mHotText = hotView.findViewById(R.id.wish_index);
|
||
mHourRank = hourView.findViewById(R.id.wish_index);
|
||
mHotText.setText("0");
|
||
mHotText.setLayoutParams(textParams);
|
||
mHourRank.setLayoutParams(textParams);
|
||
mHotText.setGravity(Gravity.CENTER);
|
||
mHourRank.setGravity(Gravity.CENTER);
|
||
setHourRankData(Long.parseLong(model.getRank()));
|
||
hotPic.setImageResource(R.drawable.icon_time_new);
|
||
hourPic.setImageResource(R.drawable.icon_heat_new);
|
||
hotPic.setLayoutParams(params);
|
||
hourPic.setLayoutParams(params);
|
||
flipper.addView(hotView);
|
||
flipper.addView(hourView);
|
||
flipper.startFlipping();
|
||
|
||
flipper.setOnClickListener(view -> {
|
||
|
||
MobclickAgent.onEvent(mContext, "live_room_hot", "热度按钮");
|
||
Bundle bundle = new Bundle();
|
||
String path = model.getHourchartH5Url();
|
||
if (!path.startsWith("/")) {
|
||
path = "/" + path;
|
||
}
|
||
String url = CommonAppConfig.HOST + path;
|
||
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token="
|
||
+ CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid;
|
||
bundle.putString("url", url);
|
||
bundle.putInt("height", DpUtil.dp2px(500));
|
||
bundle.putInt("show_type", 0);
|
||
bundle.putString("roomId", mLiveUid);
|
||
LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
|
||
liveHDDialogFragment.setArguments(bundle);
|
||
liveHDDialogFragment.show(((AbsActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
|
||
});
|
||
new LoadDian9TuUtil().loadDian9TuAssets2(mContext, hourRankLayout, "rectangle_new.png", 1);
|
||
}
|
||
|
||
/**
|
||
* 初始化小时榜
|
||
*/
|
||
public void initHourRankList() {
|
||
if (flipper.getChildCount() > 0) {
|
||
flipper.removeAllViews();
|
||
}
|
||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DpUtil.dp2px(16), DpUtil.dp2px(16));
|
||
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||
textParams.leftMargin = DpUtil.dp2px(5);
|
||
params.leftMargin = DpUtil.dp2px(5);
|
||
API.get().pdLiveApi(mContext).getHourChartRank(mLiveUid)
|
||
.subscribeOn(Schedulers.io())
|
||
.observeOn(AndroidSchedulers.mainThread())
|
||
.subscribe(listResponseModel -> {
|
||
List<HourRank> info = listResponseModel.getData().getInfo();
|
||
if (!info.isEmpty()) {
|
||
View hotView = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
|
||
View hourView = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
|
||
ImageView hotPic = hotView.findViewById(R.id.wish_pic);
|
||
ImageView hourPic = hourView.findViewById(R.id.wish_pic);
|
||
mHotText = hotView.findViewById(R.id.wish_index);
|
||
mHourRank = hourView.findViewById(R.id.wish_index);
|
||
mHotText.setText("0");
|
||
mHotText.setLayoutParams(textParams);
|
||
mHourRank.setLayoutParams(textParams);
|
||
mHotText.setGravity(Gravity.CENTER);
|
||
mHourRank.setGravity(Gravity.CENTER);
|
||
setHourRankData(info.get(0).getRank());
|
||
hotPic.setImageResource(R.drawable.icon_time_new);
|
||
hourPic.setImageResource(R.drawable.icon_heat_new);
|
||
hotPic.setLayoutParams(params);
|
||
hourPic.setLayoutParams(params);
|
||
flipper.addView(hotView);
|
||
flipper.addView(hourView);
|
||
flipper.startFlipping();
|
||
// flipper.setOnClickListener(view -> {
|
||
//
|
||
// });
|
||
ViewClicksAntiShake.clicksAntiShake(hotView, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||
@Override
|
||
public void onViewClicks() {
|
||
showUrlHDDialog(info.get(0).getUrl());
|
||
}
|
||
});
|
||
ViewClicksAntiShake.clicksAntiShake(hourView, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||
@Override
|
||
public void onViewClicks() {
|
||
showUrlHDDialog(info.get(0).getUrl());
|
||
}
|
||
});
|
||
|
||
|
||
}
|
||
}, Throwable::printStackTrace)
|
||
.isDisposed();
|
||
new LoadDian9TuUtil().loadDian9TuAssets2(mContext, hourRankLayout, "rectangle_new.png", 1);
|
||
}
|
||
|
||
private void showUrlHDDialog(String path) {
|
||
Bundle bundle = new Bundle();
|
||
if (!path.startsWith("/")) {
|
||
path = "/" + path;
|
||
}
|
||
String url = CommonAppConfig.HOST + path;
|
||
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token="
|
||
+ CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid
|
||
+ "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0");
|
||
bundle.putString("url", url);
|
||
bundle.putInt("height", DpUtil.dp2px(500));
|
||
bundle.putInt("show_type", 0);
|
||
bundle.putString("roomId", mLiveUid);
|
||
LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
|
||
liveHDDialogFragment.setArguments(bundle);
|
||
liveHDDialogFragment.show(((AbsActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
|
||
}
|
||
|
||
private void initPkRankView(PkRankBean bean) {
|
||
|
||
if (pkRankVf.getTag() != null) {
|
||
return;
|
||
}
|
||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DpUtil.dp2px(20), DpUtil.dp2px(22));
|
||
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||
params.leftMargin = DpUtil.dp2px(3);
|
||
textParams.setMarginStart(DpUtil.dp2px(3));
|
||
textParams.setMarginEnd(DpUtil.dp2px(2));
|
||
|
||
View hourView = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
|
||
View titleView = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
|
||
ImageView titleIcon = titleView.findViewById(R.id.wish_pic);
|
||
TextView titleText = titleView.findViewById(R.id.wish_index);
|
||
mPkRankIcon = hourView.findViewById(R.id.wish_pic);
|
||
mPkRankText = hourView.findViewById(R.id.wish_index);
|
||
mPkRankText.setLayoutParams(textParams);
|
||
mPkRankText.setGravity(Gravity.START);
|
||
ImgLoader.display(mContext, bean.getVsImgUrl(), titleIcon);
|
||
titleText.setText(R.string.PK_Ladder_Race);
|
||
titleText.setLayoutParams(textParams);
|
||
titleIcon.setLayoutParams(params);
|
||
mPkRankIcon.setLayoutParams(params);
|
||
pkRankVf.addView(titleView);
|
||
pkRankVf.addView(hourView);
|
||
pkRankVf.startFlipping();
|
||
pkRankVf.setTag("start");
|
||
pkRankLayout.setVisibility(View.VISIBLE);
|
||
}
|
||
|
||
private void initPkRank() {
|
||
initPkRank(null);
|
||
}
|
||
|
||
private String pkUidTmp = "";
|
||
|
||
public void initPkRank(String isLadders) {
|
||
//PK状态下,pkuid不能为空
|
||
if (pkUidTmp.equals(pkUid) && !StringUtil.isEmpty(pkUid)) {
|
||
return;
|
||
}
|
||
//非PK状态下,第一次调用通过
|
||
if (pkRankLayout.getTag() != null && pkRankLayout.getTag().equals(mLiveUid) && StringUtil.isEmpty(pkUid)) {
|
||
return;
|
||
}
|
||
pkRankLayout.setTag(mLiveUid);
|
||
pkUidTmp = pkUid;
|
||
pkRankLayout.setVisibility(View.GONE);
|
||
new LoadDian9TuUtil().loadDian9TuAssets2(mContext, liveRankPk2, "rectangle_new.png", 1);
|
||
mRedVal.setVisibility(View.GONE);
|
||
mBlueVal.setVisibility(View.GONE);
|
||
mPkRankTopIcon.setVisibility(View.GONE);
|
||
LiveNetManager.get(mContext)
|
||
.getRandomPk(mLiveUid, pkUid, new com.yunbao.common.http.base.HttpCallback<PkRankBean>() {
|
||
@Override
|
||
public void onSuccess(PkRankBean bean) {
|
||
if (bean != null) {
|
||
initPkRankView(bean);
|
||
if (!StringUtil.isEmpty(bean.getClickUrl())) {
|
||
|
||
|
||
pkRankVf.setOnClickListener(v -> {
|
||
MobclickAgent.onEvent(mContext, "live_room_sky", "天梯赛按钮");
|
||
Bundle bundle = new Bundle();
|
||
String path = bean.getClickUrl();
|
||
if (!path.startsWith("/") && !path.startsWith("http")) {
|
||
path = "/" + path;
|
||
}
|
||
String url = null;
|
||
if (path.startsWith("http") || path.startsWith("/http")) {
|
||
url = path;
|
||
} else {
|
||
url = CommonAppConfig.HOST + path;
|
||
}
|
||
if (!url.contains("?")) {
|
||
url += "?";
|
||
} else {
|
||
url += "&";
|
||
}
|
||
url += "uid=" + CommonAppConfig.getInstance().getUid() + "&token="
|
||
+ CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
|
||
bundle.putString("url", url);
|
||
bundle.putInt("height", DpUtil.dp2px(500));
|
||
bundle.putInt("show_type", 0);
|
||
bundle.putString("roomId", mLiveUid);
|
||
LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
|
||
liveHDDialogFragment.setArguments(bundle);
|
||
liveHDDialogFragment.show(((AbsActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
|
||
});
|
||
}
|
||
pkRankLayout.setVisibility(View.VISIBLE);
|
||
|
||
liveRankPk2.setVisibility(View.VISIBLE);
|
||
mPkRankText.setText(bean.getName());
|
||
ImgLoader.display(mContext, bean.getImg(), mPkRankIcon);
|
||
pkUidTmp = "";
|
||
if (StringUtil.isEmpty(bean.getPkTopImgUrl())) {
|
||
return;
|
||
}
|
||
if (!StringUtil.isEmpty(isLadders)) {
|
||
bean.setPkTopImgUrl(isLadders);
|
||
}
|
||
if (Integer.parseInt(bean.getRedVal()) > 2) {
|
||
mRedVal.setVisibility(View.VISIBLE);
|
||
mRedVal.setText(bean.getRedVal() + (WordUtil.isNewZh() ? "連勝" : "Win"));
|
||
}
|
||
if (Integer.parseInt(bean.getBlueVal()) > 2) {
|
||
mBlueVal.setVisibility(View.VISIBLE);
|
||
mBlueVal.setText(bean.getBlueVal() + (WordUtil.isNewZh() ? "連勝" : "Win"));
|
||
}
|
||
mPkRankTopIcon.setVisibility(View.VISIBLE);
|
||
ImgLoader.display(mContext, bean.getPkTopImgUrl(), mPkRankTopIcon);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onError(String error) {
|
||
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
|
||
pkUidTmp = "";
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
/**
|
||
* 星光值转带k的字符
|
||
*
|
||
* @param val 值
|
||
* @retur 字符串
|
||
*/
|
||
private String starlightValToString(long val) {
|
||
if (val > 1000) {
|
||
double tmp = (double) val / 1000;
|
||
return tmp + "k";
|
||
} else {
|
||
return val + "";
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 设置小时榜
|
||
*
|
||
* @param rank 小时榜
|
||
*/
|
||
public void setHourRankData(long rank) {
|
||
if (mHourRank != null) {
|
||
if (rank == 0) {
|
||
mHourRank.setText(R.string.no_rank_data);
|
||
} else {
|
||
mHourRank.setText(String.format(mContext.getString(R.string.hour_rank), formatBigNum.formatBigNum(rank + "")));
|
||
}
|
||
}
|
||
}
|
||
|
||
private void updatePkRank(PkRankBean bean) {
|
||
if (WordUtil.isNewZh()) {
|
||
mPkRankText.setText(bean.getName());
|
||
} else {
|
||
mPkRankText.setText(bean.getNewRankNameEn());
|
||
}
|
||
ImgLoader.display(mContext, bean.getImg(), mPkRankIcon);
|
||
}
|
||
|
||
/**
|
||
* 设置热度值
|
||
*
|
||
* @param hot 热度值
|
||
*/
|
||
public void setHotData(String hot) {
|
||
if (mHotText != null && !TextUtils.isEmpty(hot)) {
|
||
mHotText.setText(hot);
|
||
}
|
||
|
||
}
|
||
|
||
/**
|
||
* 更新心愿单进度
|
||
*
|
||
* @param giftId 礼物ID
|
||
* @param giftCount 礼物数量
|
||
*/
|
||
public void updataWishList(String giftId, int giftCount) {
|
||
if (!(mContext instanceof LiveAudienceActivity)) {
|
||
for (WishlistItemModel model : wishlist) {
|
||
if (TextUtils.equals(giftId, model.getLid())) {
|
||
int number = Integer.parseInt(model.getWishlistProgress()) + giftCount;
|
||
model.setWishlistProgress(String.valueOf(number));
|
||
}
|
||
}
|
||
if (wishListLayout != null) {
|
||
wishListLayout.removeAllViews();
|
||
}
|
||
initWishList(wishlist);
|
||
}
|
||
|
||
}
|
||
|
||
//点击头像
|
||
private void clickAvatar() {
|
||
livePKUserListBean = new LivePKUserListBean();
|
||
setHeadData(null);
|
||
avatar_l1.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
if (uidL1 != null && !"".equals(uidL1)) {
|
||
showUserDialog(uidL1);
|
||
}
|
||
}
|
||
});
|
||
avatar_l2.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
if (uidL2 != null && !"".equals(uidL2)) {
|
||
showUserDialog(uidL2);
|
||
}
|
||
}
|
||
});
|
||
avatar_l3.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
if (uidL3 != null && !"".equals(uidL3)) {
|
||
showUserDialog(uidL3);
|
||
}
|
||
}
|
||
});
|
||
avatar_r1.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
if (uidR1 != null && !"".equals(uidR1)) {
|
||
showUserDialog(uidR1);
|
||
}
|
||
}
|
||
});
|
||
avatar_r2.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
if (uidR2 != null && !"".equals(uidR2)) {
|
||
showUserDialog(uidR2);
|
||
}
|
||
}
|
||
});
|
||
avatar_r3.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
if (uidR3 != null && !"".equals(uidR3)) {
|
||
showUserDialog(uidR3);
|
||
}
|
||
}
|
||
});
|
||
// //点击打开周星榜
|
||
// ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.live_wks_layout),
|
||
// () -> {
|
||
//
|
||
// Bus.get().post(new LiveAudienceEvent()
|
||
// .setType(LiveAudienceEvent.LiveAudienceType.LIVE_WKS));
|
||
// });
|
||
}
|
||
|
||
public static int pkEndIndex = 0;
|
||
|
||
//PK结束,结果展示
|
||
public static void pkEndList(int result) {
|
||
if (result == 0) {
|
||
img_pk_fist_l.setBackgroundResource(R.mipmap.icon_red_no1);
|
||
img_pk_fist_r.setBackgroundResource(R.mipmap.icon_blue_no1);
|
||
} else if (result == 1) {
|
||
img_pk_fist_l.setBackgroundResource(R.mipmap.icon_red_mvp);
|
||
img_pk_fist_r.setBackgroundResource(R.mipmap.icon_blue_smvp);
|
||
} else if (result == -1) {
|
||
img_pk_fist_l.setBackgroundResource(R.mipmap.icon_red_smvp);
|
||
img_pk_fist_r.setBackgroundResource(R.mipmap.icon_blue_mvp);
|
||
}
|
||
|
||
|
||
// pkEndIndex = 1;
|
||
}
|
||
|
||
/**
|
||
* 修改连胜位置
|
||
*/
|
||
private void changeView() {
|
||
if (mRedVal.getVisibility() == View.VISIBLE) {
|
||
RelativeLayout.LayoutParams redValLayoutParams = (RelativeLayout.LayoutParams) mRedVal.getLayoutParams();
|
||
redValLayoutParams.bottomMargin = DpUtil.dp2px(60);
|
||
mRedVal.setLayoutParams(redValLayoutParams);
|
||
}
|
||
if (mBlueVal.getVisibility() == View.VISIBLE) {
|
||
RelativeLayout.LayoutParams blueValLayoutParams = (RelativeLayout.LayoutParams) mBlueVal.getLayoutParams();
|
||
blueValLayoutParams.bottomMargin = DpUtil.dp2px(60);
|
||
mBlueVal.setLayoutParams(blueValLayoutParams);
|
||
}
|
||
}
|
||
|
||
//头像显示
|
||
public void setHeadData(LivePKUserListBean bean) {
|
||
if (bean == null) return;
|
||
Log.e("更新礼物进度", bean.toString());
|
||
livePKUserListBean = bean;
|
||
String mLiveuid = LiveRoomViewHolder.mLiveUid;
|
||
if (livePKUserListBean != null) {
|
||
if (lt_pk_line.getVisibility() == View.GONE) {
|
||
ScreenDimenUtil util = ScreenDimenUtil.getInstance();
|
||
int mScreenWdith = util.getScreenWdith();
|
||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) lt_pk_line.getLayoutParams();
|
||
params.height = mScreenWdith * 720 / 1120;
|
||
lt_pk_line.requestLayout();
|
||
|
||
lt_pk_line.setVisibility(View.VISIBLE);
|
||
}
|
||
Boolean idB = true;
|
||
if (livePKUserListBean.getRed_one() != null && livePKUserListBean.getBlue_one() != null) {
|
||
if (mLiveuid.equals(livePKUserListBean.getRed_one().getLiveuid())) {
|
||
ImgLoader.display2(mContext, livePKUserListBean.getRed_one().getImg(), avatar_l1);
|
||
ImgLoader.display2(mContext, livePKUserListBean.getBlue_one().getImg(), avatar_r1);
|
||
uidL1 = livePKUserListBean.getRed_one().getUid();
|
||
uidR1 = livePKUserListBean.getBlue_one().getUid();
|
||
idB = true;
|
||
} else {
|
||
ImgLoader.display2(mContext, livePKUserListBean.getRed_one().getImg(), avatar_r1);
|
||
ImgLoader.display2(mContext, livePKUserListBean.getBlue_one().getImg(), avatar_l1);
|
||
uidR1 = livePKUserListBean.getRed_one().getUid();
|
||
uidL1 = livePKUserListBean.getBlue_one().getUid();
|
||
idB = false;
|
||
}
|
||
}
|
||
if (livePKUserListBean.getRed_two() != null && livePKUserListBean.getBlue_two() != null) {
|
||
if (idB) {
|
||
ImgLoader.display2(mContext, livePKUserListBean.getRed_two().getImg(), avatar_l2);
|
||
ImgLoader.display2(mContext, livePKUserListBean.getBlue_two().getImg(), avatar_r2);
|
||
uidL2 = livePKUserListBean.getRed_two().getUid();
|
||
uidR2 = livePKUserListBean.getBlue_two().getUid();
|
||
} else {
|
||
ImgLoader.display2(mContext, livePKUserListBean.getRed_two().getImg(), avatar_r2);
|
||
ImgLoader.display2(mContext, livePKUserListBean.getBlue_two().getImg(), avatar_l2);
|
||
uidR2 = livePKUserListBean.getRed_two().getUid();
|
||
uidL2 = livePKUserListBean.getBlue_two().getUid();
|
||
}
|
||
}
|
||
if (livePKUserListBean.getRed_three() != null && livePKUserListBean.getBlue_three() != null) {
|
||
if (idB) {
|
||
ImgLoader.display2(mContext, livePKUserListBean.getRed_three().getImg(), avatar_l3);
|
||
ImgLoader.display2(mContext, livePKUserListBean.getBlue_three().getImg(), avatar_r3);
|
||
uidL3 = livePKUserListBean.getRed_three().getUid();
|
||
uidR3 = livePKUserListBean.getBlue_three().getUid();
|
||
} else {
|
||
ImgLoader.display2(mContext, livePKUserListBean.getRed_three().getImg(), avatar_r3);
|
||
ImgLoader.display2(mContext, livePKUserListBean.getBlue_three().getImg(), avatar_l3);
|
||
uidR3 = livePKUserListBean.getRed_three().getUid();
|
||
uidL3 = livePKUserListBean.getBlue_three().getUid();
|
||
}
|
||
}
|
||
} else {
|
||
UpPkTwo();
|
||
}
|
||
}
|
||
|
||
//双人pk显示
|
||
public void UpPkTwo() {
|
||
if (lt_pk_line.getVisibility() == View.VISIBLE) return;
|
||
ScreenDimenUtil util = ScreenDimenUtil.getInstance();
|
||
int mScreenWdith = util.getScreenWdith();
|
||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) lt_pk_line.getLayoutParams();
|
||
params.height = mScreenWdith * 720 / 1120;
|
||
lt_pk_line.requestLayout();
|
||
|
||
lt_pk_line.setVisibility(View.VISIBLE);
|
||
img_pk_fist_l.setBackgroundResource(R.mipmap.icon_red_no1);
|
||
img_pk_fist_r.setBackgroundResource(R.mipmap.icon_blue_no1);
|
||
avatar_l1.setImageResource(R.mipmap.icon_sofa_red);
|
||
avatar_l2.setImageResource(R.mipmap.icon_sofa_red);
|
||
avatar_l3.setImageResource(R.mipmap.icon_sofa_red);
|
||
avatar_r1.setImageResource(R.mipmap.icon_sofa_blue);
|
||
avatar_r2.setImageResource(R.mipmap.icon_sofa_blue);
|
||
avatar_r3.setImageResource(R.mipmap.icon_sofa_blue);
|
||
|
||
uidL1 = "";
|
||
uidL2 = "";
|
||
uidL3 = "";
|
||
uidR2 = "";
|
||
uidR1 = "";
|
||
uidR3 = "";
|
||
|
||
if (RandomPkManager.getInstance().isRandomModel()) {
|
||
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START);
|
||
}
|
||
new Handler(Looper.getMainLooper()).postDelayed(this::initPkRank, 300);
|
||
}
|
||
|
||
//双人pk关闭
|
||
public void closePkTwo() {
|
||
Log.e("LiveRoomViewHolder", "closePkTwo: 隐藏PK信息" + goto_room_view.getVisibility());
|
||
mPkRankTopIcon.setVisibility(View.GONE);
|
||
lt_pk_line.setVisibility(View.GONE);
|
||
pkUid = "";
|
||
goto_room_view.setVisibility(View.GONE);
|
||
livePKUserListBean = new LivePKUserListBean();
|
||
}
|
||
|
||
/**
|
||
* 显示主播头像
|
||
*/
|
||
public void setAvatar(String url) {
|
||
if (mAvatar != null) {
|
||
mAvatarUrl = url;
|
||
ImgLoader.displayAvatar(mContext, url, mAvatar);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 显示主播等级
|
||
*/
|
||
public void setAnchorLevel(int anchorLevel) {
|
||
if (mLevelAnchor != null) {
|
||
LevelBean levelBean = CommonAppConfig.getInstance().getAnchorLevel(anchorLevel);
|
||
if (levelBean != null) {
|
||
ImgLoader.display2(mContext, levelBean.getThumbIcon(), mLevelAnchor);
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 显示用户名
|
||
*/
|
||
public void setName(String name) {
|
||
mAnchorName = name;
|
||
if (mName != null) {
|
||
|
||
mNameText = name;
|
||
if (name.length() > 4) {
|
||
name = name.substring(0, 4) + "...";
|
||
}
|
||
mName.setText(name);
|
||
EventBus.getDefault().post("name_true");
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 显示房间号
|
||
*/
|
||
public void setRoomNum(String roomNum) {
|
||
if (mID != null) {
|
||
if (roomNum.contains("ID")) {
|
||
mID.setText(roomNum);
|
||
} else {
|
||
mID.setText(String.format("ID:%s", roomNum));
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 显示直播标题
|
||
*/
|
||
public void setTitle(String title) {
|
||
}
|
||
|
||
|
||
/**
|
||
* 显示是否关注
|
||
*/
|
||
public void setAttention(int attention) {
|
||
Log.i("tssx", attention + "");
|
||
LiveAudienceActivity.isattention = attention;
|
||
isAttention = attention;
|
||
if (mBtnFollow != null) {
|
||
if (attention == 0) {
|
||
mBtnFollow.setVisibility(View.VISIBLE);
|
||
mViewMedal.setVisibility(View.GONE);
|
||
if (mLiveChatAdapter != null) {
|
||
mLiveChatAdapter.setFans("0");
|
||
}
|
||
} else {
|
||
if (mBtnFollow.getVisibility() == View.VISIBLE) {
|
||
mBtnFollow.setVisibility(View.GONE);
|
||
mViewMedal.setVisibility(View.VISIBLE);
|
||
if (mLiveChatAdapter != null) {
|
||
mLiveChatAdapter.setFans("1");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
public void showGiftWall(String toUid, boolean isAnchor, String mAnchorName, String mAvatarUrl) {
|
||
GiftWallDialog giftWallDialog = new GiftWallDialog();
|
||
Bundle bundle = new Bundle();
|
||
bundle.putString(Constants.LIVE_UID, mLiveUid);
|
||
bundle.putString(Constants.LIVE_STREAM, mStream);
|
||
bundle.putString("mAnchorName", mAnchorName);
|
||
bundle.putString("mAvatarUrl", mAvatarUrl);
|
||
bundle.putString("toUid", toUid);
|
||
bundle.putInt("isAttention", isAttention);
|
||
bundle.putBoolean("isLive", isAnchor);
|
||
bundle.putBoolean("SBW", !(mContext instanceof LiveRyAnchorActivity));
|
||
giftWallDialog.setArguments(bundle);
|
||
giftWallDialog.show(((AbsActivity) mContext).getSupportFragmentManager(), "GiftWallDialog");
|
||
|
||
}
|
||
|
||
public boolean pkHandler = true;
|
||
|
||
//左上角显示对方主播头像及昵称
|
||
public void setOtherInfo(String touids, String url, String name) {
|
||
if (!pkHandler) {
|
||
return;
|
||
}
|
||
goto_room_view.setVisibility(View.VISIBLE);
|
||
touid = touids;
|
||
pkUid = touids;
|
||
ImgLoader.displayAvatar(mContext, url, avatarOther);
|
||
tv_avatarOther_name.setText(name);
|
||
goto_room_view.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View view) {
|
||
showUserDialog(touids);
|
||
}
|
||
});
|
||
initPkRank();
|
||
|
||
if (LivePushTxViewHolder.mTRTCCloud != null) {
|
||
|
||
} else {
|
||
}
|
||
}
|
||
|
||
public void setDelOtherInfo() {
|
||
goto_room_view.setVisibility(View.GONE);
|
||
}
|
||
|
||
|
||
/**
|
||
* 显示刷新直播间用户列表
|
||
*/
|
||
public void setUserList(List<LiveUserGiftBean> list) {
|
||
if (mLiveUserAdapter != null) {
|
||
//resetUserListWidth(DpUtil.dp2px((Math.min(list.size(), 3)) * 30));
|
||
mLiveUserAdapter.refreshList(list);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 显示主播映票数
|
||
*/
|
||
public void setVotes(String votes) {
|
||
}
|
||
|
||
/**
|
||
* 显示真爱排行数量
|
||
*/
|
||
public void setMedaRankNum(String votes) {
|
||
if (mTvMedalRank != null) {
|
||
mTvMedalRank.setText(votes);
|
||
}
|
||
}
|
||
|
||
public void setHideMedalIcon(boolean hide) {
|
||
if (hide) {
|
||
mViewMedal.setVisibility(View.GONE);
|
||
} else {
|
||
mViewMedal.setVisibility(View.VISIBLE);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 显示主播守护人数
|
||
*/
|
||
public void setGuardNum(int guardNum) {
|
||
if (mGuardNum != null) {
|
||
if (guardNum > 0) {
|
||
mGuardNum.setText(mContext.getString(R.string.live_guard) + " " + guardNum);
|
||
} else {
|
||
mGuardNum.setText(R.string.main_list_no_data);
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 显示主播粉丝人数
|
||
*/
|
||
public static void setFansNum(int fansNum) {
|
||
if (fans != null) {
|
||
if (fansNum > 0) {
|
||
fans.setText(Contexts.getString(R.string.fans) + " " + fansNum);
|
||
} else {
|
||
fans.setText(Contexts.getString(R.string.fans) + " 0");
|
||
}
|
||
}
|
||
}
|
||
|
||
public void setLiveInfo(String liveUid, String stream, int userListInterval) {
|
||
mLiveUid = liveUid;
|
||
mStream = stream;
|
||
mUserListInterval = userListInterval;
|
||
//如果是主播,则隐藏粉丝勋章点击按钮
|
||
if (CommonAppConfig.getInstance().getUid().equals(mLiveUid)) {
|
||
setHideMedalIcon(true);
|
||
} else {
|
||
setHideMedalIcon(false);
|
||
}
|
||
if (IMLoginManager.get(mContext).getUserInfo().anchorUserType()) {
|
||
getIsHot();
|
||
getGuardInfo();
|
||
}
|
||
|
||
}
|
||
|
||
private void getGuardInfo() {
|
||
LiveHttpUtil.getUserList(mLiveUid, mStream, "guard", 1, new HttpCallback() {
|
||
@Override
|
||
public void onSuccess(int code, String msg, String[] info) {
|
||
if (code == 0) {
|
||
JSONObject json = JSONObject.parseObject(info[0]);
|
||
JSONArray userlist = json.getJSONArray("userlist");
|
||
if (userlist.size() != 0) {
|
||
setGuardIcon(JSONArray.parseArray(userlist.toJSONString(), LiveUserGiftBean.class).get(0));
|
||
}
|
||
}
|
||
|
||
}
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 旧接口,主播端还在用这个,暂时保留,用户端用{@link #setGuardIcon(GuardUserModel)}
|
||
*/
|
||
@Deprecated
|
||
private void setGuardIcon(LiveUserGiftBean guard) {
|
||
if (guard != null) {
|
||
nowGuardUser = guard;
|
||
ViewGroup.LayoutParams params = userGuard.getLayoutParams();
|
||
params.height = DpUtil.dp2px(30);
|
||
params.width = DpUtil.dp2px(30);
|
||
userGuard.setLayoutParams(params);
|
||
ImgLoader.displayAvatar(mContext, guard.getAvatar(), userGuard);
|
||
gift_svga.setVisibility(View.VISIBLE);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 接口整合守护展示,用户端使用
|
||
*/
|
||
public void setGuardIcon(GuardUserModel model) {
|
||
if (model != null && !TextUtils.isEmpty(model.getGuardUserAvatar())) {
|
||
guardUserModel = model;
|
||
ViewGroup.LayoutParams params = userGuard.getLayoutParams();
|
||
params.height = DpUtil.dp2px(30);
|
||
params.width = DpUtil.dp2px(30);
|
||
userGuard.setLayoutParams(params);
|
||
ImgLoader.displayAvatar(mContext, model.getGuardUserAvatar(), userGuard);
|
||
gift_svga.setVisibility(View.VISIBLE);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 设置礼物墙和周星榜
|
||
*/
|
||
public void setGiftWall(String giftWallLightenNumber, String giftWallLightenTotal) {
|
||
if (wksAndGiftWall.getChildCount() > 0) {
|
||
wksAndGiftWall.removeAllViews();
|
||
}
|
||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DpUtil.dp2px(16), DpUtil.dp2px(16));
|
||
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||
textParams.leftMargin = DpUtil.dp2px(5);
|
||
textParams.rightMargin = DpUtil.dp2px(5);
|
||
params.leftMargin = DpUtil.dp2px(5);
|
||
View weekView = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
|
||
ImageView weekViewPic = weekView.findViewById(R.id.wish_pic);
|
||
TextView week = weekView.findViewById(R.id.wish_index);
|
||
week.setLayoutParams(textParams);
|
||
week.setGravity(Gravity.CENTER);
|
||
week.setText(mContext.getString(R.string.live_wks));
|
||
weekViewPic.setImageResource(R.mipmap.live_icon_zhouxing);
|
||
weekViewPic.setLayoutParams(params);
|
||
if (!TextUtils.isEmpty(giftWallLightenNumber) && !TextUtils.isEmpty(giftWallLightenTotal)) {
|
||
StringBuffer stringBuffer = new StringBuffer();
|
||
stringBuffer.append(mContext.getString(R.string.gift_wall))
|
||
.append(giftWallLightenNumber)
|
||
.append("/")
|
||
.append(giftWallLightenTotal);
|
||
View giftWall = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
|
||
ImageView giftWallPic = giftWall.findViewById(R.id.wish_pic);
|
||
TextView giftText = giftWall.findViewById(R.id.wish_index);
|
||
giftText.setText(stringBuffer.toString());
|
||
giftText.setGravity(Gravity.CENTER);
|
||
giftText.setLayoutParams(textParams);
|
||
giftWallPic.setImageResource(R.mipmap.icon_gift_wall);
|
||
giftWallPic.setLayoutParams(params);
|
||
wksAndGiftWall.addView(giftWall);
|
||
ViewClicksAntiShake.clicksAntiShake(giftWall, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||
@Override
|
||
public void onViewClicks() {
|
||
Bus.get().post(new LiveAudienceEvent()
|
||
.setType(LiveAudienceEvent.LiveAudienceType.GIFT_WALL)
|
||
.setUid(mLiveUid)
|
||
.setVoicePress(true)
|
||
.setAvatar(mAvatarUrl)
|
||
.setUname(mAnchorName));
|
||
}
|
||
});
|
||
}
|
||
|
||
ViewClicksAntiShake.clicksAntiShake(weekView, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||
@Override
|
||
public void onViewClicks() {
|
||
MobclickAgent.onEvent(mContext, "live_room_week", "周星榜按钮");
|
||
Bus.get().post(new LiveAudienceEvent()
|
||
.setType(LiveAudienceEvent.LiveAudienceType.LIVE_WKS));
|
||
}
|
||
});
|
||
wksAndGiftWall.addView(weekView);
|
||
wksAndGiftWall.startFlipping();
|
||
new LoadDian9TuUtil().loadDian9TuAssets2(mContext, liveWksLayout, "rectangle_new.png", 1);
|
||
}
|
||
|
||
/**
|
||
* 守护信息发生变化
|
||
*/
|
||
public void onGuardInfoChanged(LiveBuyGuardMsgBean bean) {
|
||
setGuardNum(bean.getGuardNum());
|
||
}
|
||
|
||
/**
|
||
* 设置红包按钮是否可见
|
||
*/
|
||
public void setRedPackBtnVisible(boolean visible) {
|
||
if (mBtnRedPack != null) {
|
||
if (visible) {
|
||
if (mBtnRedPack.getVisibility() != View.VISIBLE) {
|
||
mBtnRedPack.setVisibility(View.VISIBLE);
|
||
}
|
||
} else {
|
||
if (mBtnRedPack.getVisibility() == View.VISIBLE) {
|
||
mBtnRedPack.setVisibility(View.INVISIBLE);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onClick(View v) {
|
||
int i = v.getId();
|
||
if (i == R.id.root) {
|
||
light();
|
||
}
|
||
if (!canClick()) {
|
||
return;
|
||
}
|
||
if (i == R.id.avatar) {
|
||
MobclickAgent.onEvent(mContext, "live_room_anchor_avatar", "点主播头像");
|
||
showAnchorUserDialog();
|
||
|
||
} else if (i == R.id.btn_follow) {
|
||
MobclickAgent.onEvent(mContext, "live_room_follow_anchor", "直播间左上角关注主播按钮");
|
||
follow();
|
||
if (((LiveAudienceActivity) mContext).getCountDownTimer() != null) {
|
||
((LiveAudienceActivity) mContext).getCountDownTimer().cancel();
|
||
}
|
||
} else if (i == R.id.view_medal) {
|
||
//点击粉丝勋章, 弹窗 开通粉丝勋章
|
||
// showFansMedalDialog(mLiveUid);
|
||
|
||
((LiveActivity) mContext).openFansWindow();
|
||
|
||
} else if (i == R.id.btn_votes) {
|
||
openContributeWindow();
|
||
} else if (i == R.id.btn_medal_rank) {
|
||
//直播间 粉丝排行榜
|
||
openMedalRankWindow();
|
||
} else if (i == R.id.btn_guard) {
|
||
((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveRyAnchorActivity);
|
||
} else if (i == R.id.btn_red_pack) {
|
||
((LiveActivity) mContext).openRedPackListWindow();
|
||
|
||
} else if (i == R.id.btn_prize_pool_level) {
|
||
((LiveActivity) mContext).openPrizePoolWindow();
|
||
} else if (i == R.id.user_more) {
|
||
MobclickAgent.onEvent(mContext, "live_room_audience_list", "直播间上面点观众列表按钮");
|
||
((LiveActivity) mContext).openUserMoreListWindow(1, false, false, mContext instanceof LiveRyAnchorActivity);
|
||
} else if (i == R.id.hot_btn) {
|
||
((LiveActivity) mContext).openUserMoreListWindow(1, false, false, mContext instanceof LiveRyAnchorActivity);
|
||
|
||
} else if (i == R.id.noble_seat) {
|
||
MobclickAgent.onEvent(mContext, "live_room_noble", "贵族按钮");
|
||
((LiveActivity) mContext).openUserMoreListWindow(1, false, true, mContext instanceof LiveRyAnchorActivity);
|
||
} else if (i == R.id.btn_close) {
|
||
// if (sudGameMin!=null&&sudGameMin.getVisibility()==View.VISIBLE) {
|
||
// new XPopup.Builder(mContext)
|
||
// .asCustom(new HintCustomPopup(mContext,
|
||
// mContext.getString(com.yunbao.common.R.string.dialog_tip),
|
||
// mContext.getString(com.yunbao.common.R.string.the_live_room))
|
||
// .setLiveOpenOk( mContext.getString(com.yunbao.common.R.string.confirm))
|
||
// .setLiveOpenCancel( mContext.getString(com.yunbao.common.R.string.cancel))
|
||
// .setCallBack(new HintCustomPopup.HintCustomCallBack() {
|
||
// @Override
|
||
// public void onSure() {
|
||
// close();
|
||
// }
|
||
//
|
||
// @Override
|
||
// public void onCancel() {
|
||
//
|
||
//
|
||
// }
|
||
// })).show();
|
||
// } else {
|
||
close();
|
||
// }
|
||
|
||
//小屏
|
||
} else if (i == R.id.btn_noble) {
|
||
((LiveActivity) mContext).openLuckGiftTip();
|
||
} else if (i == R.id.ft_hot_add) {
|
||
((LiveActivity) mContext).openHotListWindow(1);
|
||
} else if (i == R.id.user_guard) {
|
||
MobclickAgent.onEvent(mContext, "anchor_avatar_guard", "守护按钮");
|
||
// ((LiveActivity) mContext).openUserMoreListWindow(2, true);
|
||
((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveRyAnchorActivity);
|
||
}
|
||
if (i == R.id.lt_trickery) {
|
||
showTrickeryDialog();
|
||
}
|
||
|
||
}
|
||
|
||
public boolean getsudGameMin() {
|
||
return sudGameMin != null && sudGameMin.getVisibility() == View.VISIBLE;
|
||
}
|
||
|
||
/**
|
||
* 私信的切换动画
|
||
*
|
||
* @param out 隐去的view
|
||
* @param in 展示的view
|
||
*/
|
||
private void changeMsgView(View out, View in) {
|
||
if (mContext instanceof LiveRyAnchorActivity) {
|
||
return;
|
||
}
|
||
if (in.getVisibility() == View.VISIBLE) {
|
||
return;
|
||
}
|
||
Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.view_room_msg_out);
|
||
animation.setAnimationListener(new Animation.AnimationListener() {
|
||
@Override
|
||
public void onAnimationStart(Animation animation) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationEnd(Animation animation) {
|
||
out.setVisibility(View.GONE);
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationRepeat(Animation animation) {
|
||
|
||
}
|
||
});
|
||
out.startAnimation(animation);
|
||
Animation start = AnimationUtils.loadAnimation(mContext, R.anim.view_room_msg_in);
|
||
start.setAnimationListener(new Animation.AnimationListener() {
|
||
@Override
|
||
public void onAnimationStart(Animation animation) {
|
||
in.setVisibility(View.VISIBLE);
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationEnd(Animation animation) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationRepeat(Animation animation) {
|
||
|
||
}
|
||
});
|
||
in.startAnimation(start);
|
||
}
|
||
|
||
/**
|
||
* 从右侧私聊悬浮窗打开私聊界面
|
||
*/
|
||
private void openChatWindow() {
|
||
/*LiveChatListDialogFragment chat=new LiveChatListDialogFragment();
|
||
chat.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveRoomChatDialogFragment");*/
|
||
((LiveActivity) mContext).openChatListWindow();
|
||
|
||
}
|
||
|
||
/**
|
||
* 更新左上角数标
|
||
*
|
||
* @param number 数字
|
||
*/
|
||
public void onMessageIMEvent(int number) {
|
||
String num = "";
|
||
if (number != 0) {
|
||
changeMsgView(msg, msg2);
|
||
if (number > 99) {
|
||
num = "99+";
|
||
} else {
|
||
num = number + "";
|
||
}
|
||
msgNumber.setText(num);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 刷新im消息,以便更新私信悬浮窗UI
|
||
*/
|
||
public void reloadIM() {
|
||
RongIMClient.getInstance().getConversationListByPage(new RongIMClient.ResultCallback<List<Conversation>>() {
|
||
@Override
|
||
public void onSuccess(List<Conversation> conversations) {
|
||
if (conversations != null && !conversations.isEmpty()) {
|
||
for (Conversation conversation : conversations) {
|
||
if (conversation.getUnreadMessageCount() != 0) {
|
||
UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(conversation.getTargetId());
|
||
if (userInfo != null) {
|
||
ImgLoader.display2(mContext, userInfo.getPortraitUri().toString(), msgUserIcon);
|
||
}
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
changeMsgView(msg2, msg);
|
||
}
|
||
|
||
@Override
|
||
public void onError(RongIMClient.ErrorCode errorCode) {
|
||
Log.e("IM", "IM会话获取失败 = " + errorCode);
|
||
|
||
}
|
||
}, 0, 10, Conversation.ConversationType.PRIVATE);
|
||
RongIMClient.getInstance().getUnreadCount(new Conversation.ConversationType[]{Conversation.ConversationType.PRIVATE}, true, new RongIMClient.ResultCallback<Integer>() {
|
||
@Override
|
||
public void onSuccess(Integer integer) {
|
||
onMessageIMEvent(integer);
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onError(RongIMClient.ErrorCode errorCode) {
|
||
|
||
}
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 私信来消息了,刷新悬浮窗UI
|
||
*/
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void sendMessage(io.rong.imlib.model.Message bean) {
|
||
reloadIM();
|
||
}
|
||
|
||
/**
|
||
* 关注主播
|
||
*/
|
||
public static void follow() {
|
||
|
||
EventBus.getDefault().post("stop_svga_new_user_follow");
|
||
|
||
LiveHttpUtil.setFrontTask("attent", new HttpCallback() {
|
||
@Override
|
||
public void onSuccess(int code, String msg, String[] info) {
|
||
if (code == 0) {
|
||
EventBus.getDefault().post("stop_svga_new_user_follow1");
|
||
}
|
||
}
|
||
});
|
||
|
||
if (TextUtils.isEmpty(mLiveUid)) {
|
||
return;
|
||
}
|
||
if (((LiveAudienceActivity) Contexts).getCountDownTimer() != null) {
|
||
((LiveAudienceActivity) Contexts).getCountDownTimer().cancel();
|
||
}
|
||
CommonHttpUtil.setAttention(mLiveUid, new CommonCallback<Integer>() {
|
||
@Override
|
||
public void callback(Integer isAttention) {
|
||
if (isAttention == 1) {
|
||
LiveActivity.sendSystemMessage(
|
||
CommonAppConfig.getInstance().getUserBean().getUserNiceName() + Contexts.getString(R.string.live_follow_anchor));
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
//退出弹出的关注
|
||
public static void showFollowDialog(String name, String avatar, Context context) {
|
||
final Dialog dialog = new Dialog(context, R.style.dialog);
|
||
dialog.setContentView(R.layout.dialog_follow);
|
||
dialog.setCancelable(true);
|
||
dialog.setCanceledOnTouchOutside(true);
|
||
if (!TextUtils.isEmpty(avatar)) {
|
||
RoundedImageView titleView = (RoundedImageView) dialog.findViewById(R.id.avatar);
|
||
ImgLoader.display2(context, avatar, titleView);
|
||
}
|
||
if (!TextUtils.isEmpty(name)) {
|
||
TextView nameTextView = (TextView) dialog.findViewById(R.id.name);
|
||
nameTextView.setText(name);
|
||
}
|
||
|
||
dialog.findViewById(R.id.btn_confirm).setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
((LiveAudienceActivity) context).setBackIndex(1);
|
||
((LiveAudienceActivity) context).onBackPressed();
|
||
follow();
|
||
}
|
||
});
|
||
dialog.findViewById(R.id.btn_cancel).setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
((LiveAudienceActivity) context).setBackIndex(1);
|
||
((LiveAudienceActivity) context).onBackPressed();
|
||
}
|
||
});
|
||
dialog.show();
|
||
}
|
||
|
||
/**
|
||
* 退出直播间
|
||
*/
|
||
private void close() {
|
||
if (mContext instanceof LiveAudienceActivity) {
|
||
if (forAct == 1) {
|
||
//是否关注0==没关注
|
||
if (isAttention == 0) {
|
||
if (isStayRoomfive) {
|
||
showFollowDialog(mNameText, mAvatarUrl, mContext);
|
||
} else {
|
||
((LiveAudienceActivity) mContext).setBackIndex(1);
|
||
((LiveAudienceActivity) mContext).onBackPressed();
|
||
}
|
||
} else {
|
||
((LiveAudienceActivity) mContext).setBackIndex(1);
|
||
((LiveAudienceActivity) mContext).onBackPressed();
|
||
}
|
||
} else {
|
||
((LiveAudienceActivity) mContext).setBackIndex(1);
|
||
((LiveAnchorActivity) mContext).onBackPressed();
|
||
}
|
||
} else if (mContext instanceof LiveRyAnchorActivity) {
|
||
if (forAct == 1) {
|
||
//是否关注0==没关注
|
||
if (isAttention == 0) {
|
||
if (isStayRoomfive) {
|
||
showFollowDialog(mNameText, mAvatarUrl, mContext);
|
||
} else {
|
||
LiveRyAnchorActivity.backIndex = 1;
|
||
((LiveRyAnchorActivity) mContext).onBackPressed();
|
||
}
|
||
} else {
|
||
LiveRyAnchorActivity.backIndex = 1;
|
||
((LiveRyAnchorActivity) mContext).onBackPressed();
|
||
}
|
||
} else {
|
||
LiveRyAnchorActivity.backIndex = 1;
|
||
((LiveRyAnchorActivity) mContext).onBackPressed();
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 在直播间时间是否足够5分钟
|
||
*/
|
||
public static boolean isStayRoomfive = false;
|
||
|
||
public static void isStayRoom(boolean isTrue) {
|
||
isStayRoomfive = isTrue;
|
||
}
|
||
|
||
|
||
/**
|
||
* 刷新用户列表
|
||
*/
|
||
public void refreshUserList(JSONObject obj) {
|
||
List<LiveUserGiftBean> list = JSON.parseArray(obj.getString("userlist"), LiveUserGiftBean.class);
|
||
mLiveUserAdapter.refreshList(list);
|
||
}
|
||
|
||
/**
|
||
* 开始刷新用户列表
|
||
*/
|
||
public void startRefreshUserList() {
|
||
if (mLiveRoomHandler != null) {
|
||
mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_REFRESH_USER_LIST, getNextTime(mUserListInterval > 0 ? mUserListInterval : 60000));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 请求计时收费的扣费接口
|
||
*/
|
||
private void requestTimeCharge() {
|
||
if (!TextUtils.isEmpty(mLiveUid) && mTimeChargeCallback != null) {
|
||
LiveHttpUtil.cancel(LiveHttpConsts.TIME_CHARGE);
|
||
LiveHttpUtil.timeCharge(mLiveUid, mStream, mTimeChargeCallback);
|
||
startRequestTimeCharge();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 开始请求计时收费的扣费接口
|
||
*/
|
||
public void startRequestTimeCharge() {
|
||
if (mLiveRoomHandler != null) {
|
||
mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_TIME_CHARGE, getNextTime(60000));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 添加聊天消息到聊天栏
|
||
*/
|
||
public static void insertChat(LiveChatBean bean, int index) {
|
||
Constants.nowAnchorName = mName.getText().toString();
|
||
if (mLiveChatAdapter != null) {
|
||
if (index == 1) {
|
||
mLiveChatAdapter.insertItem(bean);
|
||
} else if (index == 0) {
|
||
if (bean.getId().equals(CommonAppConfig.getInstance().getUid())) {
|
||
mLiveChatAdapter.insertItem(bean);
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 播放飘心动画
|
||
*/
|
||
public void playLightAnim() {
|
||
if (mLightAnimPresenter != null) {
|
||
mLightAnimPresenter.play();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 点亮
|
||
*/
|
||
private void light() {
|
||
((LiveAudienceActivity) mContext).light();
|
||
}
|
||
|
||
public void setOffsetY(int offsetY) {
|
||
LiveLightView.sOffsetY = offsetY;
|
||
mOffsetY = offsetY;
|
||
}
|
||
|
||
/**
|
||
* 键盘高度变化
|
||
*/
|
||
public void onKeyBoardChanged(int visibleHeight, int keyBoardHeight) {
|
||
if (mRoot != null) {
|
||
if (keyBoardHeight == 0) {
|
||
mRoot.setTranslationY(0);
|
||
return;
|
||
}
|
||
if (mOffsetY == 0) {
|
||
mRoot.setTranslationY(-keyBoardHeight);
|
||
return;
|
||
}
|
||
if (mOffsetY > 0 && mOffsetY < keyBoardHeight) {
|
||
mRoot.setTranslationY(mOffsetY - keyBoardHeight);
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 聊天栏滚到最底部
|
||
*/
|
||
public void chatScrollToBottom() {
|
||
if (mLiveChatAdapter != null) {
|
||
mLiveChatAdapter.scrollToBottom();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 用户进入房间 金光一闪,坐骑动画
|
||
*/
|
||
public void onEnterRoom(LiveEnterRoomBean bean) {
|
||
if (bean == null) {
|
||
return;
|
||
}
|
||
if (mLiveEnterRoomAnimPresenter != null) {
|
||
mLiveEnterRoomAnimPresenter.enterRoom(bean);
|
||
}
|
||
room_hot.setText(formatBigNum.formatBigNum(bean.getLiveChatBean().getHot_num()));
|
||
setHotData(formatBigNum.formatBigNum(bean.getLiveChatBean().getHot_num()));
|
||
LiveUserGiftBean chatBean = bean.getUserBean();
|
||
if (chatBean != null && nowGuardUser != null) {
|
||
LiveUserGiftBean tmp = null;
|
||
if (chatBean.getGuardType() != 0 && chatBean.getGuardType() > nowGuardUser.getGuardType()) {
|
||
tmp = chatBean;
|
||
} else if (chatBean.getGuardType() != 0 && chatBean.getGuardType() == nowGuardUser.getGuardType() && chatBean.getLevel() > nowGuardUser.getLevel()) {
|
||
tmp = chatBean;
|
||
}
|
||
setGuardIcon(tmp);
|
||
if (mContext instanceof LiveAudienceActivity) {
|
||
int type = 0;
|
||
GuardUserModel model = new GuardUserModel();
|
||
if (guardUserModel != null && TextUtils.isEmpty(guardUserModel.getGuardType())) {
|
||
type = Integer.parseInt(guardUserModel.getGuardType());
|
||
}
|
||
if (chatBean.getGuardType() != 0 && chatBean.getGuardType() > type) {
|
||
model.setGuardType(String.valueOf(chatBean.getGuardType()));
|
||
model.setGuardUserAvatar(chatBean.getAvatar());
|
||
}
|
||
setGuardIcon(model);
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 用户离开房间
|
||
*
|
||
* @param bean 用户
|
||
*/
|
||
public void onExitRoom(UserBean bean) {
|
||
// getGuardInfo();
|
||
}
|
||
|
||
/**
|
||
* 显示弹幕
|
||
*/
|
||
public void showDanmu(LiveDanMuBean bean) {
|
||
if (mVotes != null) {
|
||
mVotes.setText(bean.getVotes());
|
||
}
|
||
if (mLiveDanmuPresenter == null) {
|
||
mLiveDanmuPresenter = new LiveDanmuPresenter(mContext, mParentView);
|
||
}
|
||
mLiveDanmuPresenter.showDanmu(bean);
|
||
}
|
||
|
||
/**
|
||
* 显示主播的个人资料弹窗
|
||
*/
|
||
private void showAnchorUserDialog() {
|
||
if (TextUtils.isEmpty(mLiveUid)) {
|
||
return;
|
||
}
|
||
showUserDialog(mLiveUid);
|
||
}
|
||
|
||
/**
|
||
* 显示个人资料弹窗
|
||
*/
|
||
public void showUserDialog(String toUid) {
|
||
if (!TextUtils.isEmpty(mLiveUid) && !TextUtils.isEmpty(toUid)) {
|
||
MobclickAgent.onEvent(mContext, "live_room_user_avatar", "直播间任意点用户头像");
|
||
LiveUserDialogFragment fragment = new LiveUserDialogFragment();
|
||
Bundle bundle = new Bundle();
|
||
bundle.putString(Constants.LIVE_UID, mLiveUid);
|
||
bundle.putString(Constants.STREAM, mStream);
|
||
bundle.putString(Constants.TO_UID, toUid);
|
||
fragment.setArguments(bundle);
|
||
fragment.show(((LiveActivity) mContext).getSupportFragmentManager(), "LiveUserDialogFragment");
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 显示 开通粉丝勋章 弹窗
|
||
*/
|
||
public static void showFansMedalDialog(String toUid) {
|
||
if (!TextUtils.isEmpty(mLiveUid) && !TextUtils.isEmpty(toUid)) {
|
||
if (mBtnFollow.getVisibility() == View.VISIBLE) {
|
||
LiveRoomViewHolder.follow();
|
||
}
|
||
LiveFansMedalDialogFragment fragment = new LiveFansMedalDialogFragment();
|
||
Bundle bundle = new Bundle();
|
||
bundle.putString(Constants.LIVE_UID, mLiveUid);
|
||
bundle.putString(Constants.STREAM, mStream);
|
||
bundle.putString(Constants.TO_UID, toUid);
|
||
fragment.setArguments(bundle);
|
||
fragment.show(((LiveActivity) Contexts).getSupportFragmentManager(), "LiveFansMedalDialogFragment");
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 直播间贡献榜窗口
|
||
*/
|
||
private void openContributeWindow() {
|
||
((LiveActivity) mContext).openContributeWindow();
|
||
}
|
||
|
||
/**
|
||
* 直播间粉丝排行榜榜窗口
|
||
*/
|
||
private void openMedalRankWindow() {
|
||
((LiveActivity) mContext).openMedalRankWindow();
|
||
}
|
||
|
||
|
||
/**
|
||
* 显示礼物动画
|
||
*/
|
||
public void showGiftMessage(LiveReceiveGiftBean bean) {
|
||
mVotes.setText(bean.getVotes());
|
||
room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num()));
|
||
setHotData(formatBigNum.formatBigNum(bean.getHot_num()));
|
||
mTvMedalRank.setText(bean.getMedalRankNum());
|
||
if (mLiveGiftAnimPresenter == null) {
|
||
mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager);
|
||
}
|
||
mLiveGiftAnimPresenter.showGiftAnim(bean, false);
|
||
}
|
||
|
||
/**
|
||
* 显示礼物动画 是否为主播
|
||
*/
|
||
public void showGiftMessage(LiveReceiveGiftBean bean, boolean isAncher) {
|
||
mVotes.setText(bean.getVotes());
|
||
room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num()));
|
||
setHotData(formatBigNum.formatBigNum(bean.getHot_num()));
|
||
mTvMedalRank.setText(bean.getMedalRankNum());
|
||
//开通粉丝勋章成功弹窗
|
||
if (!isAncher && bean.getMedalFirstGet() != null && bean.getMedalFirstGet().equals("1")
|
||
&& bean.getUid().equals(CommonAppConfig.getInstance().getUid())) {
|
||
((LiveAudienceActivity) mContext).openFansMedalOkWindow();
|
||
|
||
}
|
||
if (!isAncher && bean.getGiftName().equals("粉絲牌") && bean.getUid().equals(CommonAppConfig.getInstance().getUid())) {
|
||
LiveAudienceActivity.is_fans = "1";
|
||
setFansGroup("1");
|
||
}
|
||
Log.i("tvss", bean.getDrpk_status() + "是" + mLiveUid + "vsss" + bean.getRoomnum());
|
||
if (mLiveGiftAnimPresenter == null) {
|
||
mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager);
|
||
}
|
||
mLiveGiftAnimPresenter.showGiftAnim(bean, isAncher);
|
||
}
|
||
|
||
//全服通知 购买守护
|
||
public void showGuardGifMessage(LiveReceiveGiftBean bean) {
|
||
mVotes.setText(bean.getVotes());
|
||
if (mLiveGiftAnimPresenter == null) {
|
||
mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager);
|
||
}
|
||
mLiveGiftAnimPresenter.showBuyGuardGiftAnim(bean);
|
||
setHotData(bean.getHot_num());
|
||
}
|
||
|
||
//全服通知 购买坐骑
|
||
public void showBuyZuojiMessage(LiveReceiveGiftBean bean) {
|
||
if (mLiveGiftAnimPresenter == null) {
|
||
mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager);
|
||
}
|
||
mLiveGiftAnimPresenter.showBuyZuojiGiftAnim(bean);
|
||
}
|
||
|
||
public void showBuyLiangNameMessage(LiveReceiveGiftBean bean) {
|
||
if (mLiveGiftAnimPresenter == null) {
|
||
mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager);
|
||
}
|
||
mLiveGiftAnimPresenter.showBuyLiangNameGiftAnim(bean);
|
||
}
|
||
|
||
/**
|
||
* 开通贵族的全服通知
|
||
*
|
||
* @param bean
|
||
*/
|
||
public void showBuyVipMessage(LiveReceiveGiftBean bean) {
|
||
noble.setVisibility(View.VISIBLE);
|
||
switch (bean.getNobilityid()) {
|
||
|
||
case "1":
|
||
noble.setRootView(bean.getUhead(),
|
||
bean.getUname(),
|
||
bean.getAncherName(),
|
||
bean.getRoomnum())
|
||
.setRoleType(NobleNoticeView.RoleType.BARON)
|
||
.setCallBack(() -> gotoLive(bean.getRoomnum()));
|
||
break;
|
||
case "2":
|
||
noble.setRootView(bean.getUhead(),
|
||
bean.getUname(),
|
||
bean.getAncherName(),
|
||
bean.getRoomnum())
|
||
.setRoleType(NobleNoticeView.RoleType.VISCOUNT)
|
||
.setCallBack(() -> gotoLive(bean.getRoomnum()));
|
||
break;
|
||
case "3":
|
||
noble.setRootView(bean.getUhead(),
|
||
bean.getUname(),
|
||
bean.getAncherName(),
|
||
bean.getRoomnum())
|
||
.setRoleType(NobleNoticeView.RoleType.MARQUIS)
|
||
.setCallBack(() -> gotoLive(bean.getRoomnum()));
|
||
break;
|
||
case "4":
|
||
noble.setRootView(bean.getUhead(),
|
||
bean.getUname(),
|
||
bean.getAncherName(),
|
||
bean.getRoomnum())
|
||
.setRoleType(NobleNoticeView.RoleType.DUKE)
|
||
.setCallBack(() -> gotoLive(bean.getRoomnum()));
|
||
break;
|
||
case "5":
|
||
noble.setRootView(bean.getUhead(),
|
||
bean.getUname(),
|
||
bean.getAncherName(),
|
||
bean.getRoomnum())
|
||
.setRoleType(NobleNoticeView.RoleType.KING)
|
||
.setCallBack(() -> gotoLive(bean.getRoomnum()));
|
||
break;
|
||
case "6":
|
||
noble.setRootView(bean.getUhead(),
|
||
bean.getUname(),
|
||
bean.getAncherName(),
|
||
bean.getRoomnum())
|
||
.setRoleType(NobleNoticeView.RoleType.EMPEROR)
|
||
.setCallBack(() -> gotoLive(bean.getRoomnum()));
|
||
break;
|
||
case "7":
|
||
noble.setRootView(bean.getUhead(),
|
||
bean.getUname(),
|
||
bean.getAncherName(),
|
||
bean.getRoomnum())
|
||
.setRoleType(NobleNoticeView.RoleType.BETTER_EMPEROR)
|
||
.setCallBack(() -> gotoLive(bean.getRoomnum()));
|
||
break;
|
||
}
|
||
}
|
||
|
||
public void showSysMessage(LiveReceiveGiftBean bean) {
|
||
if (mLiveGiftAnimPresenter == null) {
|
||
mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager);
|
||
}
|
||
mLiveGiftAnimPresenter.showSystAnim(bean);
|
||
}
|
||
|
||
/**
|
||
* 增加主播映票数
|
||
*
|
||
* @param deltaVal 增加的映票数量
|
||
*/
|
||
public void updateVotes(String deltaVal) {
|
||
if (mVotes == null) {
|
||
return;
|
||
}
|
||
String votesVal = mVotes.getText().toString().trim();
|
||
if (TextUtils.isEmpty(votesVal)) {
|
||
return;
|
||
}
|
||
try {
|
||
double votes = Double.parseDouble(votesVal);
|
||
double addVotes = Double.parseDouble(deltaVal);
|
||
votes += addVotes;
|
||
mVotes.setText(StringUtil.format(votes));
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
|
||
public void startAnchorLiveTime() {
|
||
if (mLiveRoomHandler != null) {
|
||
mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_ANCHOR_LIVE_TIME, getNextTime(1000));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 主播开始飘心
|
||
*/
|
||
public void startAnchorLight() {
|
||
if (mLiveRoomHandler != null) {
|
||
mLiveRoomHandler.removeMessages(LiveRoomHandler.WHAT_ANCHOR_LIGHT);
|
||
mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_ANCHOR_LIGHT, getNextTime(500));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 主播checkLive
|
||
*/
|
||
public void startAnchorCheckLive() {
|
||
if (mLiveRoomHandler != null) {
|
||
mLiveRoomHandler.removeMessages(LiveRoomHandler.WHAT_ANCHOR_CHECK_LIVE);
|
||
mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_ANCHOR_CHECK_LIVE, getNextTime(60000));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 主播checkLive
|
||
*/
|
||
private void anchorCheckLive() {
|
||
if (mContext instanceof LiveAnchorActivity) {
|
||
((LiveAnchorActivity) mContext).checkLive();
|
||
startAnchorCheckLive();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 主播切后台,50秒后关闭直播
|
||
*/
|
||
public void anchorPause() {
|
||
if (mLiveRoomHandler != null) {
|
||
mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_ANCHOR_PAUSE, getNextTime(50000));
|
||
}
|
||
}
|
||
|
||
private long getNextTime(int time) {
|
||
long now = SystemClock.uptimeMillis();
|
||
if (time < 1000) {
|
||
return now + time;
|
||
}
|
||
return now + time + -now % 1000;
|
||
}
|
||
|
||
/**
|
||
* 主播切后台后又回到前台
|
||
*/
|
||
public void anchorResume() {
|
||
if (mLiveRoomHandler != null) {
|
||
mLiveRoomHandler.removeMessages(LiveRoomHandler.WHAT_ANCHOR_PAUSE);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 主播结束直播
|
||
*/
|
||
private void anchorEndLive() {
|
||
if (mContext instanceof LiveAnchorActivity) {
|
||
((LiveAnchorActivity) mContext).endLive();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 主播飘心
|
||
*/
|
||
private void anchorLight() {
|
||
if (mContext instanceof LiveAnchorActivity) {
|
||
((LiveAnchorActivity) mContext).light();
|
||
startAnchorLight();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 幸运礼物中奖
|
||
*/
|
||
public void onLuckGiftWin(LiveLuckGiftWinBean bean) {
|
||
if (mLiveGiftAnimPresenter == null) {
|
||
mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager);
|
||
}
|
||
mLiveGiftAnimPresenter.showLuckGiftWinAnim(bean);
|
||
}
|
||
|
||
/**
|
||
* 奖池中奖
|
||
*/
|
||
public void onPrizePoolWin(LiveGiftPrizePoolWinBean bean) {
|
||
if (mLiveGiftAnimPresenter == null) {
|
||
mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager);
|
||
}
|
||
mLiveGiftAnimPresenter.showPrizePoolWinAnim(bean);
|
||
}
|
||
|
||
/**
|
||
* 奖池升级
|
||
*/
|
||
public void onPrizePoolUp(String level) {
|
||
if (mLiveGiftAnimPresenter == null) {
|
||
mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager);
|
||
}
|
||
mLiveGiftAnimPresenter.showPrizePoolUp(level);
|
||
}
|
||
|
||
/**
|
||
* 显示奖池按钮
|
||
*/
|
||
public void showPrizePoolLevel(String level) {
|
||
}
|
||
|
||
|
||
/**
|
||
* 获取是否有热度卡加成
|
||
*/
|
||
public static void getIsHot() {
|
||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DpUtil.dp2px(16), DpUtil.dp2px(16));
|
||
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||
textParams.leftMargin = DpUtil.dp2px(5);
|
||
params.leftMargin = DpUtil.dp2px(5);
|
||
View hotView = LayoutInflater.from(Contexts).inflate(R.layout.view_wish_list, null);
|
||
hotView.setTag("HeatAdd");
|
||
ImageView hotPic = hotView.findViewById(R.id.wish_pic);
|
||
TextView mHotText = hotView.findViewById(R.id.wish_index);
|
||
mHotText.setText(R.string.heat_add);
|
||
hotPic.setImageResource(R.drawable.icon_heat_2);
|
||
mHotText.setLayoutParams(textParams);
|
||
hotPic.setLayoutParams(params);
|
||
flipper.addView(hotView);
|
||
ViewClicksAntiShake.clicksAntiShake(hotView, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||
@Override
|
||
public void onViewClicks() {
|
||
((LiveActivity) Contexts).openHotListWindow(1);
|
||
}
|
||
});
|
||
// ImgLoader.display2(Contexts, "https://downs.yaoulive.com/img_hot_gif.gif", img_hot_gif);
|
||
// LiveHttpUtil.isHotCard(mLiveUid, new HttpCallback() {
|
||
// @Override
|
||
// public void onSuccess(int code, String msg, String[] info) {
|
||
// if (code == 0 && info.length > 0) {
|
||
// if ("1".equals(info[0]) && !visibility) {
|
||
// ft_hot_add.setVisibility(View.VISIBLE);
|
||
// } else {
|
||
// ft_hot_add.setVisibility(View.GONE);
|
||
// }
|
||
// }
|
||
// }
|
||
// });
|
||
}
|
||
|
||
/**
|
||
* 获取是否有热度卡加成
|
||
*/
|
||
public void getIsHot(String isUseHotCard) {
|
||
if ("1".equals(isUseHotCard) && !visibility) {
|
||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DpUtil.dp2px(16), DpUtil.dp2px(16));
|
||
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||
textParams.leftMargin = DpUtil.dp2px(5);
|
||
params.leftMargin = DpUtil.dp2px(5);
|
||
View hotView = LayoutInflater.from(Contexts).inflate(R.layout.view_wish_list, null);
|
||
hotView.setTag("HeatAdd");
|
||
ImageView hotPic = hotView.findViewById(R.id.wish_pic);
|
||
TextView mHotText = hotView.findViewById(R.id.wish_index);
|
||
mHotText.setText(R.string.heat_add);
|
||
hotPic.setImageResource(R.drawable.icon_heat_2);
|
||
mHotText.setLayoutParams(textParams);
|
||
hotPic.setLayoutParams(params);
|
||
flipper.addView(hotView);
|
||
ViewClicksAntiShake.clicksAntiShake(hotView, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||
@Override
|
||
public void onViewClicks() {
|
||
((LiveActivity) Contexts).openHotListWindow(1);
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
}
|
||
|
||
public void resetUserListWidth(int width) {
|
||
ViewGroup.LayoutParams params = mUserRecyclerView.getLayoutParams();
|
||
params.width = width;
|
||
mUserRecyclerView.setLayoutParams(params);
|
||
}
|
||
|
||
public void releaseGift() {
|
||
if (mLiveGiftAnimPresenter != null) {
|
||
mLiveGiftAnimPresenter.cancelAllAnim();
|
||
}
|
||
}
|
||
|
||
public void release() {
|
||
EventBus.getDefault().unregister(this);
|
||
LiveHttpUtil.cancel(LiveHttpConsts.GET_USER_LIST);
|
||
LiveHttpUtil.cancel(LiveHttpConsts.TIME_CHARGE);
|
||
CommonHttpUtil.cancel(CommonHttpConsts.SET_ATTENTION);
|
||
if (mLiveRoomHandler != null) {
|
||
mLiveRoomHandler.release();
|
||
}
|
||
mLiveRoomHandler = null;
|
||
if (mLightAnimPresenter != null) {
|
||
mLightAnimPresenter.release();
|
||
}
|
||
if (mLiveEnterRoomAnimPresenter != null) {
|
||
mLiveEnterRoomAnimPresenter.release();
|
||
}
|
||
if (mLiveGiftAnimPresenter != null) {
|
||
mLiveGiftAnimPresenter.release();
|
||
}
|
||
mRefreshUserListCallback = null;
|
||
mTimeChargeCallback = null;
|
||
Contexts = null;
|
||
}
|
||
|
||
public void clearData() {
|
||
timeHandler.removeCallbacks(timeRunnable);
|
||
anchorTimeHandler.removeCallbacks(anchorTimeRunnable);
|
||
LiveHttpUtil.cancel(LiveHttpConsts.GET_USER_LIST);
|
||
LiveHttpUtil.cancel(LiveHttpConsts.TIME_CHARGE);
|
||
CommonHttpUtil.cancel(CommonHttpConsts.SET_ATTENTION);
|
||
if (mLiveRoomHandler != null) {
|
||
mLiveRoomHandler.removeCallbacksAndMessages(null);
|
||
}
|
||
if (mAvatar != null) {
|
||
mAvatar.setImageDrawable(null);
|
||
}
|
||
if (mLevelAnchor != null) {
|
||
mLevelAnchor.setImageDrawable(null);
|
||
}
|
||
if (mName != null) {
|
||
mName.setText("");
|
||
}
|
||
if (mID != null) {
|
||
mID.setText("");
|
||
}
|
||
if (mVotes != null) {
|
||
mVotes.setText("");
|
||
}
|
||
if (mTvMedalRank != null) {
|
||
mTvMedalRank.setText("");
|
||
}
|
||
if (mGuardNum != null) {
|
||
mGuardNum.setText("");
|
||
}
|
||
if (mLiveUserAdapter != null) {
|
||
mLiveUserAdapter.clear();
|
||
}
|
||
if (mLiveChatAdapter != null) {
|
||
mLiveChatAdapter.clear();
|
||
}
|
||
if (mLiveEnterRoomAnimPresenter != null) {
|
||
mLiveEnterRoomAnimPresenter.cancelAnim();
|
||
mLiveEnterRoomAnimPresenter.resetAnimView();
|
||
}
|
||
if (mLiveDanmuPresenter != null) {
|
||
mLiveDanmuPresenter.release();
|
||
mLiveDanmuPresenter.reset();
|
||
}
|
||
if (mLiveGiftAnimPresenter != null) {
|
||
mLiveGiftAnimPresenter.cancelAllAnim();
|
||
}
|
||
mLiveRoomHandler.removeCallbacksAndMessages(null);
|
||
}
|
||
|
||
public void setFastMessage(List<String> greetings) {
|
||
fastMsgRecyclerView.setVisibility(View.VISIBLE);
|
||
fastMessageRecyclerViewAdapter.setMessage(greetings);
|
||
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)
|
||
mChatRecyclerView.getLayoutParams();
|
||
if (greetings.size() > 0) {
|
||
params1.bottomMargin = 100;
|
||
} else {
|
||
params1.bottomMargin = 0;
|
||
}
|
||
|
||
|
||
mChatRecyclerView.setLayoutParams(params1);
|
||
}
|
||
|
||
public void setManager(FaceManager manager) {
|
||
this.manager = manager;
|
||
}
|
||
|
||
/**
|
||
* 启动美颜SDK
|
||
*/
|
||
public void startFace() {
|
||
|
||
}
|
||
|
||
/**
|
||
* 切换美颜UI
|
||
*/
|
||
public void changeFaceUnityView() {
|
||
// faceUnityView.setVisibility(faceUnityView.getVisibility() == View.GONE ? View.VISIBLE : View.GONE);
|
||
LiveFaceUnityDialogFragment fragment = new LiveFaceUnityDialogFragment(mContext);
|
||
fragment.setManager(manager);
|
||
fragment.show(((LiveActivity) mContext).getSupportFragmentManager(), "faceUi");
|
||
}
|
||
|
||
public void setAnchorGoodNumber(String goodNumber) {
|
||
if (!StringUtil.isEmpty(goodNumber) && !goodNumber.equals("0")) {
|
||
mAnchorLayout.setBackgroundResource(R.drawable.bg_live_anchor_goodnum);
|
||
|
||
if (goodNumber.contains("ID")) {
|
||
mID.setText(goodNumber);
|
||
} else {
|
||
mID.setText(String.format("ID:%s", goodNumber));
|
||
}
|
||
mGoodNumberIcon.setVisibility(View.VISIBLE);
|
||
}
|
||
}
|
||
|
||
public void dismissVote(String msg, String data) {
|
||
voteManager.endTimerTask(data);
|
||
LiveChatBean bean = new LiveChatBean();
|
||
bean.setType(LiveChatBean.SYSTEM3_COLOR);
|
||
bean.setContent(data);
|
||
mLiveChatAdapter.insertItem(bean);
|
||
}
|
||
|
||
public void setVoteData(LiveRoomVoteModel voteModel) {
|
||
Log.i("voteModel", voteModel.toString());
|
||
voteModel.setLiveUid(mLiveUid);
|
||
voteManager.setCreateVoteModel(voteModel);
|
||
}
|
||
|
||
public void openGiftDialog(String giftId) {
|
||
Bus.get().post(new LiveAudienceEvent()
|
||
.setType(LiveAudienceEvent.LiveAudienceType.GIFT_POPUP)
|
||
.setmLiveUid(mLiveUid)
|
||
.setmStream(mStream)
|
||
.setPk(false)
|
||
.setLiveGuardInfo(null)
|
||
.setmWishGiftId(giftId)
|
||
.setUname("0"));//setUname==by
|
||
}
|
||
|
||
public void setFansGroup(String isFans) {
|
||
this.isFans = isFans.equals("1");
|
||
|
||
}
|
||
|
||
|
||
private static class LiveRoomHandler extends Handler {
|
||
|
||
private LiveRoomViewHolder mLiveRoomViewHolder;
|
||
private static final int WHAT_REFRESH_USER_LIST = 1;
|
||
private static final int WHAT_TIME_CHARGE = 2;//计时收费房间定时请求接口扣费
|
||
private static final int WHAT_ANCHOR_LIVE_TIME = 3;//直播间主播计时
|
||
private static final int WHAT_ANCHOR_PAUSE = 4;//主播切后台
|
||
private static final int WHAT_ANCHOR_LIGHT = 5;//主播飘心
|
||
private static final int WHAT_ANCHOR_CHECK_LIVE = 6;//主播checkLive
|
||
|
||
public LiveRoomHandler(LiveRoomViewHolder liveRoomViewHolder) {
|
||
mLiveRoomViewHolder = new WeakReference<>(liveRoomViewHolder).get();
|
||
}
|
||
|
||
@Override
|
||
public void handleMessage(Message msg) {
|
||
if (mLiveRoomViewHolder != null) {
|
||
switch (msg.what) {
|
||
case WHAT_REFRESH_USER_LIST:
|
||
// mLiveRoomViewHolder.refreshUserList();
|
||
break;
|
||
case WHAT_TIME_CHARGE:
|
||
mLiveRoomViewHolder.requestTimeCharge();
|
||
break;
|
||
case WHAT_ANCHOR_PAUSE:
|
||
mLiveRoomViewHolder.anchorEndLive();
|
||
break;
|
||
case WHAT_ANCHOR_LIGHT:
|
||
mLiveRoomViewHolder.anchorLight();
|
||
break;
|
||
case WHAT_ANCHOR_CHECK_LIVE:
|
||
mLiveRoomViewHolder.anchorCheckLive();
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
public void release() {
|
||
removeCallbacksAndMessages(null);
|
||
mLiveRoomViewHolder = null;
|
||
}
|
||
}
|
||
|
||
public static LiveGiftBean bean1;
|
||
|
||
/**
|
||
* 初始化新人任务
|
||
*/
|
||
public void configBanner3(NewPeopleTaskModel newPeopleTask) {
|
||
TaskModel taskModel = newPeopleTask.getTask();
|
||
|
||
if (taskModel != null) {
|
||
GiftModel giftModel = newPeopleTask.getGift();
|
||
if (giftModel != null) {
|
||
RewardAllModel rewardOne = newPeopleTask.getRewardOne();
|
||
String gold = rewardOne.getGold();
|
||
String experience = rewardOne.getExperience();
|
||
bean1 = new LiveGiftBean();
|
||
bean1.setSwf(giftModel.getSwf());
|
||
bean1.setChecked(false);
|
||
bean1.setIcon(giftModel.getGifticon());
|
||
bean1.setId(Integer.parseInt(giftModel.getId()));
|
||
bean1.setName(giftModel.getGiftname());
|
||
bean1.setTag("1");
|
||
|
||
if (!IMLoginManager.get(mContext).isisNewUserOne()) {
|
||
if (TextUtils.equals(taskModel.getSendgift(), "0")) {
|
||
IMLoginManager.get(mContext).setNewUserGif(true);
|
||
EventBus.getDefault().post("svga_new_user_gif");
|
||
}
|
||
}
|
||
BannerBean banner3Bean = new BannerBean();
|
||
banner3Bean.setImageUrl("https://downs.yaoulive.com/live_Mission_box.png");
|
||
banner3Bean.setLink(taskModel.getSendgift());
|
||
mBannerList3.add(banner3Bean);
|
||
|
||
|
||
BannerBean banner3Bean1 = new BannerBean();
|
||
banner3Bean1.setImageUrl("https://downs.yaoulive.com/live_Mission_box.png");
|
||
banner3Bean1.setLink(taskModel.getAttent());
|
||
mBannerList3.add(banner3Bean1);
|
||
|
||
BannerBean banner3Bean2 = new BannerBean();
|
||
banner3Bean2.setImageUrl("https://downs.yaoulive.com/live_Mission_box.png");
|
||
banner3Bean2.setLink(taskModel.getIllumine());
|
||
mBannerList3.add(banner3Bean2);
|
||
|
||
if (TextUtils.equals(taskModel.getSendgift(), "0") && !IMLoginManager.get(mContext).isisNewUserOne()) {
|
||
showBanner3(bean1);
|
||
} else if (TextUtils.equals(taskModel.getAttent(), "0") && !IMLoginManager.get(mContext).isisNewUserOne()) {
|
||
showBanner3(bean1);
|
||
} else if (TextUtils.equals(taskModel.getIllumine(), "0") && !IMLoginManager.get(mContext).isisNewUserOne()) {
|
||
showBanner3(bean1);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
/**
|
||
* 展示新人任务 Banner
|
||
*/
|
||
private void showBanner3(LiveGiftBean bean1) {
|
||
btn_event3.setVisibility(View.GONE);
|
||
if (mBannerList3 == null || mBannerList3.size() == 0 || mBanner3 == null || bean1 == null) {
|
||
return;
|
||
}
|
||
|
||
mBanner3.setAutoPlay(true)
|
||
.setPages(mBannerList3, new Banner3CustomViewHolder())
|
||
.setDelayTime(3000)
|
||
.setBannerStyle(BannerConfig.NOT_INDICATOR)
|
||
.setOnBannerClickListener(new OnBannerClickListener() {
|
||
@Override
|
||
public void onBannerClick(List datas, int p) {
|
||
if (mBannerList3 != null) {
|
||
if (mBannerList3.get(p).getLink().equals("0")) {
|
||
if (p == 0) {
|
||
((LiveAudienceActivity) mContext).openGiftWindow("" + bean1.getId(), "1");
|
||
EventBus.getDefault().post("svga_new_user_gif");
|
||
} else if (p == 1) {
|
||
EventBus.getDefault().post("svga_new_user_follow");
|
||
} else if (p == 2) {
|
||
EventBus.getDefault().post("svga_new_user_double");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
})
|
||
.start();
|
||
}
|
||
|
||
/**
|
||
* 新版UI隐藏活动轮播入口
|
||
*/
|
||
private void showBanner4() {
|
||
btn_event4.setVisibility(View.VISIBLE);
|
||
if (mBannerList4 == null || mBannerList4.size() == 0 || mBanner4 == null) {
|
||
return;
|
||
}
|
||
for (BannerBean bean : mBannerList4) {
|
||
Log.i("debug", "showBanner4: " + bean.toString());
|
||
}
|
||
mBanner4.setAutoPlay(true)
|
||
.setPages(mBannerList4, new Banner4CustomViewHolder())
|
||
.setDelayTime(2800)
|
||
.setBannerStyle(BannerConfig.NOT_INDICATOR)
|
||
.setOnBannerClickListener(new OnBannerClickListener() {
|
||
|
||
@Override
|
||
public void onBannerClick(List datas, int p) {
|
||
if (TextUtils.equals("特惠首冲", mBannerList4.get(p).getName())) {
|
||
|
||
Map<String, String> map_ekv = new HashMap<String, String>();
|
||
map_ekv.put("link", mBannerList4.get(p).getLink());
|
||
MobclickAgent.onEvent(mContext, "live_room_first_charge", map_ekv);
|
||
}
|
||
Log.i("debug", "onBannerClick: " + mBannerList4.get(p).toString());
|
||
BannerBean bean = mBannerList4.get(p);
|
||
if (showLoadingDialog()) {
|
||
return;
|
||
}
|
||
if (bean.getActivityId() == -1) {//-1写死跳活动弹窗
|
||
Bus.get().post(new LiveAudienceEvent()
|
||
.setActivity(true)
|
||
.setType(LiveAudienceEvent.LiveAudienceType.BOTTOM_COLLECTION));
|
||
} else if (bean.getActivityId() == 0) {
|
||
openWebDialog(bean.getLink());
|
||
} else {
|
||
LiveGameDialogFragment fragment = new LiveGameDialogFragment("1".equals(bean.getShow_type()));
|
||
fragment.setActivityId(bean.getActivityId());
|
||
fragment.setRoomId(mLiveUid);
|
||
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGameDialogFragment");
|
||
}
|
||
}
|
||
|
||
|
||
private void openWebDialog(String url) {
|
||
if (!url.startsWith("http")) {
|
||
if (url.startsWith("/")) {
|
||
url = CommonAppConfig.HOST + url;
|
||
} else {
|
||
url = CommonAppConfig.HOST + "/" + url;
|
||
}
|
||
}
|
||
if (url.contains("?")) {
|
||
url += "&";
|
||
} else {
|
||
url += "?";
|
||
}
|
||
url += "uid=" + CommonAppConfig.getInstance().getUid() + "&token="
|
||
+ CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid;
|
||
Log.i("tag", url);
|
||
Bundle bundle1 = new Bundle();
|
||
bundle1.putString("url", url);
|
||
LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
|
||
liveHDDialogFragment.setArguments(bundle1);
|
||
liveHDDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
|
||
|
||
}
|
||
})
|
||
.start();
|
||
}
|
||
|
||
private int nowTime = 0;
|
||
private int openType = 0;
|
||
private boolean isClose = false;
|
||
private String nums = "0", prankid = "", content = "", name = "";
|
||
private String userNmae = "", anchorName = "", tricksterName = "";
|
||
|
||
|
||
public CountDownTimer countDownTimerTrickery = null;
|
||
|
||
/**
|
||
* 打开或者关闭整蛊
|
||
*/
|
||
public void closeAndOpenTrickery(String msgtype, int time, JSONObject jsonObject) {
|
||
nowTime = time;
|
||
tv_trickery_time.setText("" + nowTime);
|
||
openType = 0;
|
||
if ("1".equals(msgtype)) {
|
||
nums = jsonObject.getString("nums");
|
||
prankid = jsonObject.getString("prankid");
|
||
content = jsonObject.getString("content");
|
||
name = jsonObject.getString("user_nicename");
|
||
lt_trickery.setVisibility(View.VISIBLE);
|
||
lt_trickery.setBackground(mContext.getResources().getDrawable(R.mipmap.img_buoy));
|
||
isClose = false;
|
||
starTimeloud(1, time);
|
||
} else {
|
||
userNmae = jsonObject.getString("hope_nicename");
|
||
anchorName = jsonObject.getString("anchor_nicename");
|
||
tricksterName = jsonObject.getString("content");
|
||
isClose = true;
|
||
if (dialog.isShowing()) {
|
||
dialog.dismiss();
|
||
}
|
||
openType = 2;
|
||
showTrickeryDialog();
|
||
}
|
||
}
|
||
|
||
public void hopeRankTurntable() {
|
||
LiveHttpUtil.userHopePrankTurntable(mLiveUid, prankid, new HttpCallback() {
|
||
@Override
|
||
public void onSuccess(int code, String msg, String[] info) {
|
||
if (countDownTimerTrickery != null) {
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
private void starTimeloud(int type, int time) {
|
||
nowTime = time;
|
||
countDownTimerTrickery = new CountDownTimer(time * 1000, 1000) {
|
||
@Override
|
||
public void onTick(long millisUntilFinished) {
|
||
nowTime = nowTime - 1;
|
||
if (nowTime < 0) {
|
||
if (countDownTimerTrickery != null) {
|
||
countDownTimerTrickery.cancel();
|
||
}
|
||
nowTime = 0;
|
||
}
|
||
tv_trickery_time.setText("" + nowTime);
|
||
if (isClose) {
|
||
countDownTimerTrickery.cancel();
|
||
countDownTimerTrickery = null;
|
||
lt_trickery.setVisibility(View.GONE);
|
||
LiveNetManager.get(mContext).endPrankTurntable(mLiveUid, new com.yunbao.common.http.base.HttpCallback<BaseModel>() {
|
||
@Override
|
||
public void onSuccess(BaseModel data) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onError(String error) {
|
||
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
/**
|
||
*倒计时结束后调用的
|
||
*/
|
||
@Override
|
||
public void onFinish() {
|
||
tv_trickery_time.setText("0");
|
||
if (type == 1) {
|
||
lt_trickery.setBackground(mContext.getResources().getDrawable(R.mipmap.img_buoy2));
|
||
if (countDownTimerTrickery != null) {
|
||
countDownTimerTrickery.cancel();
|
||
countDownTimerTrickery = null;
|
||
}
|
||
nowTime = 0;
|
||
openType = 1;
|
||
if (dialog.isShowing()) {
|
||
dialog.dismiss();
|
||
}
|
||
starTimeloud(2, time);
|
||
} else {
|
||
lt_trickery.setVisibility(View.GONE);
|
||
timeOver();
|
||
}
|
||
}
|
||
};
|
||
countDownTimerTrickery.start();
|
||
}
|
||
|
||
public void timeOver() {
|
||
}
|
||
|
||
|
||
private Dialog dialog;
|
||
|
||
private void showTrickeryDialog() {
|
||
dialog.setContentView(R.layout.dialog_trickery);
|
||
dialog.setCancelable(true);
|
||
dialog.setCanceledOnTouchOutside(true);
|
||
|
||
TextView tv_trickster_initiator, tv_trickster_content, tv_trickery_number_zuanshi, tv_username, tv_anchorname, tv_trickster_name;
|
||
Button bt_trickster_confirm;
|
||
LinearLayout lt_trickster_salvation, lt_trickster_top, lt_trickster, lt_trickster_suc;
|
||
lt_trickster_top = (LinearLayout) dialog.findViewById(R.id.lt_trickster_top);
|
||
lt_trickster = (LinearLayout) dialog.findViewById(R.id.lt_trickster);
|
||
lt_trickster_suc = (LinearLayout) dialog.findViewById(R.id.lt_trickster_suc);
|
||
|
||
tv_trickster_initiator = (TextView) dialog.findViewById(R.id.tv_trickster_initiator);
|
||
tv_trickster_content = (TextView) dialog.findViewById(R.id.tv_trickster_content);
|
||
|
||
tv_trickery_number_zuanshi = (TextView) dialog.findViewById(R.id.tv_trickery_number_zuanshi);
|
||
|
||
bt_trickster_confirm = (Button) dialog.findViewById(R.id.bt_trickster_confirm);
|
||
lt_trickster_salvation = (LinearLayout) dialog.findViewById(R.id.lt_trickster_salvation);
|
||
|
||
tv_trickster_initiator.setText(name);
|
||
tv_trickster_content.setText(content);
|
||
tv_trickery_number_zuanshi.setText(mContext.getResources().getString(R.string.consume) + nums);
|
||
|
||
tv_username = (TextView) dialog.findViewById(R.id.tv_username);
|
||
tv_anchorname = (TextView) dialog.findViewById(R.id.tv_anchorname);
|
||
tv_trickster_name = (TextView) dialog.findViewById(R.id.tv_trickster_name);
|
||
|
||
if (openType == 0) {
|
||
lt_trickster_top.setBackground(mContext.getResources().getDrawable(R.mipmap.img_pop_zhengjou));
|
||
lt_trickster_salvation.setVisibility(View.VISIBLE);
|
||
bt_trickster_confirm.setVisibility(View.GONE);
|
||
bt_trickster_confirm.setText(mContext.getResources().getString(R.string.confirm));
|
||
lt_trickster.setVisibility(View.VISIBLE);
|
||
lt_trickster_suc.setVisibility(View.GONE);
|
||
} else if (openType == 1) {
|
||
lt_trickster_top.setBackground(mContext.getResources().getDrawable(R.mipmap.img_pop_ing));
|
||
lt_trickster_salvation.setVisibility(View.GONE);
|
||
bt_trickster_confirm.setVisibility(View.VISIBLE);
|
||
lt_trickster.setVisibility(View.VISIBLE);
|
||
lt_trickster_suc.setVisibility(View.GONE);
|
||
} else if (openType == 2) {
|
||
lt_trickster_top.setBackground(mContext.getResources().getDrawable(R.mipmap.img_pop_chenggong));
|
||
lt_trickster_salvation.setVisibility(View.GONE);
|
||
bt_trickster_confirm.setVisibility(View.VISIBLE);
|
||
bt_trickster_confirm.setText(mContext.getResources().getString(R.string.trickster_thanks));
|
||
lt_trickster.setVisibility(View.GONE);
|
||
lt_trickster_suc.setVisibility(View.VISIBLE);
|
||
|
||
tv_username.setText(userNmae);
|
||
tv_anchorname.setText(anchorName);
|
||
tv_trickster_name.setText(tricksterName);
|
||
}
|
||
bt_trickster_confirm.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
dialog.dismiss();
|
||
}
|
||
});
|
||
lt_trickster_salvation.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
if (mContext instanceof LiveRyAnchorActivity) {
|
||
dialog.dismiss();
|
||
return;
|
||
}
|
||
hopeRankTurntable();
|
||
}
|
||
});
|
||
dialog.show();
|
||
}
|
||
|
||
|
||
@Override
|
||
public void onDestroy() {
|
||
super.onDestroy();
|
||
LiveHttpUtil.cancel(LiveHttpConsts.GET_USER_LIST);
|
||
LiveHttpUtil.cancel(LiveHttpConsts.TIME_CHARGE);
|
||
CommonHttpUtil.cancel(CommonHttpConsts.SET_ATTENTION);
|
||
}
|
||
|
||
|
||
/**
|
||
* 全服喇叭
|
||
*
|
||
* @param msgModel
|
||
*/
|
||
public void showFullScreen(MsgModel msgModel) {
|
||
fullScreen.setUserNameAndUserText(msgModel.getUserName(), msgModel.getTrumpetMsg())
|
||
.setType(msgModel.getRoleType())
|
||
.setCallBack(() -> gotoLive(msgModel.getAnchorId()));
|
||
}
|
||
|
||
/**
|
||
* 前往直播间
|
||
*/
|
||
private void gotoLive(final String liveId) {
|
||
noble.setVisibility(View.GONE);
|
||
LiveHttpUtil.getLiveInfo(liveId, 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);
|
||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||
@Override
|
||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||
if (liveBean == null) {
|
||
return;
|
||
}
|
||
if (MicStatusManager.getInstance().getMicStatus() == MicStatusManager.MIC_TYPE_REQUEST) {
|
||
Bus.get().post(new LiveAudienceEvent()
|
||
.setType(LiveAudienceEvent.LiveAudienceType.LIAN_MAI)
|
||
.setMicIng(1)
|
||
.setBean(liveBean).setLiveType(liveType).setLiveTypeVal(Integer.parseInt(liveTypeVal)));
|
||
} else if (MicStatusManager.getInstance().getMicStatus() == MicStatusManager.MIC_TYPE_OPEN) {
|
||
Bus.get().post(new LiveAudienceEvent()
|
||
.setType(LiveAudienceEvent.LiveAudienceType.LIAN_MAI)
|
||
.setMicIng(2)
|
||
.setBean(liveBean).setLiveType(liveType).setLiveTypeVal(Integer.parseInt(liveTypeVal)));
|
||
} else {
|
||
if (MicStatusManager.getInstance().isMic(liveUid)) {
|
||
MicStatusManager.getInstance().showDownMicDialog(mContext);
|
||
return;
|
||
}
|
||
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)));
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onCheckError(String contextError) {
|
||
|
||
}
|
||
});
|
||
} else {
|
||
RouteUtil.forwardUserHome(mContext, liveId, 0);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
/**
|
||
* 展示新消息提示
|
||
*/
|
||
public void showNewMessage() {
|
||
if (newMessage.getVisibility() == View.VISIBLE) return;
|
||
Locale locale = mContext.getResources().getConfiguration().locale;
|
||
String language = locale.getLanguage();
|
||
ImgLoader.display(mContext, TextUtils.equals(language, "zh") ? R.mipmap.new_message_cn : R.mipmap.new_message_en, newMessage);
|
||
|
||
|
||
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) newMessage.getLayoutParams();
|
||
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) atMessage.getLayoutParams();
|
||
if (atMessage.getVisibility() == View.VISIBLE) {
|
||
|
||
|
||
if (fastMsgRecyclerView.getVisibility() == View.VISIBLE) {
|
||
params2.bottomMargin = DpUtil.dp2px(68);
|
||
} else {
|
||
params1.bottomMargin = DpUtil.dp2px(38);
|
||
}
|
||
atMessage.setLayoutParams(params2);
|
||
}
|
||
if (fastMsgRecyclerView.getVisibility() == View.VISIBLE) {
|
||
params1.bottomMargin = DpUtil.dp2px(38);
|
||
} else {
|
||
params1.bottomMargin = DpUtil.dp2px(8);
|
||
}
|
||
newMessage.setLayoutParams(params1);
|
||
newMessage.setVisibility(View.VISIBLE);
|
||
|
||
|
||
}
|
||
|
||
public void showAtMessage() {
|
||
new Handler().postDelayed(() -> {
|
||
Locale locale = mContext.getResources().getConfiguration().locale;
|
||
String language = locale.getLanguage();
|
||
ImgLoader.display(mContext, TextUtils.equals(language, "zh") ? R.mipmap.emphasis_cn : R.mipmap.emphasis_en, atMessage);
|
||
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) atMessage.getLayoutParams();
|
||
if (newMessage.getVisibility() == View.VISIBLE) {
|
||
if (fastMsgRecyclerView.getVisibility() == View.VISIBLE) {
|
||
params1.bottomMargin = DpUtil.dp2px(68);
|
||
} else {
|
||
params1.bottomMargin = DpUtil.dp2px(38);
|
||
}
|
||
} else {
|
||
if (fastMsgRecyclerView.getVisibility() == View.VISIBLE) {
|
||
params1.bottomMargin = DpUtil.dp2px(38);
|
||
} else {
|
||
params1.bottomMargin = DpUtil.dp2px(8);
|
||
}
|
||
}
|
||
|
||
atMessage.setLayoutParams(params1);
|
||
atMessage.setVisibility(View.VISIBLE);
|
||
}, 100);
|
||
|
||
}
|
||
|
||
/**
|
||
* 机器人消息
|
||
*
|
||
* @param model
|
||
*/
|
||
public void aiAutomaticSpeech(AiAutomaticSpeechModel model) {
|
||
if (mLiveChatAdapter != null) {
|
||
LiveChatBean bean = new LiveChatBean();
|
||
bean.setType(LiveChatBean.AI_AUTOMATIC_SPEECH);
|
||
bean.setAiAutomaticSpeechModel(model);
|
||
mLiveChatAdapter.insertItem(bean);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 星级挑战成功
|
||
*
|
||
* @param model
|
||
*/
|
||
public void starChallengeUpgradeNotify(MsgModel model) {
|
||
if (mLiveChatAdapter != null) {
|
||
LiveChatBean bean = new LiveChatBean();
|
||
bean.setType(LiveChatBean.STAR_CHALLENGE_UPGRADE_NOTIFY);
|
||
bean.setMsgModel(model);
|
||
mLiveChatAdapter.insertItem(bean);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 幸运天使
|
||
*/
|
||
public void luckyAngel(MsgModel model) {
|
||
if (mLiveChatAdapter != null) {
|
||
LiveChatBean bean = new LiveChatBean();
|
||
bean.setType(LiveChatBean.LUCKY_ANGEL);
|
||
bean.setMsgModel(model);
|
||
mLiveChatAdapter.insertItem(bean);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 幸运100%活动
|
||
*/
|
||
public void lucky100(MsgModel model) {
|
||
if (mLiveChatAdapter != null) {
|
||
LiveChatBean bean = new LiveChatBean();
|
||
bean.setType(LiveChatBean.LUCKY_100_CHECK);
|
||
bean.setMsgModel(model);
|
||
mLiveChatAdapter.insertItem(bean);
|
||
}
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void updateSubForAnchor(LiveAnchorEvent event) {
|
||
if (mContext instanceof LiveAudienceActivity) {
|
||
return;
|
||
}
|
||
if (event.getType() == LiveAnchorEvent.LiveAnchorType.VOTE_CREATE) {
|
||
voteManager.setCreateVoteModel((LiveRoomVoteModel) event.getObject());
|
||
} else if (event.getType() == LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_END) {
|
||
LiveRoomVoteModel voteModel = JSONObject.parseObject(event.getObject().toString(), LiveRoomVoteModel.class);
|
||
Log.i(">>>", voteModel.toString());
|
||
String content = voteModel.getResult();
|
||
if (!StringUtil.isEmpty(voteModel.getOptionText())) {
|
||
content = voteModel.getResult().replace(voteModel.getOptionText(), "<font color='#FF8E43'>" + voteModel.getOptionText() + "</font>");
|
||
}
|
||
dismissVote(voteModel.getResult(), content);
|
||
} else if (event.getType() == LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_UPDATE) {
|
||
LiveRoomVoteModel voteModel = new LiveRoomVoteModel();
|
||
JSONObject map = (JSONObject) event.getObject();
|
||
voteModel.setStatus(1);
|
||
voteModel.setLiveUid(mLiveUid);
|
||
voteModel.setContent(map.getString("question"));
|
||
voteModel.setAnswer1(map.getString("answer1"));
|
||
voteModel.setAnswer2(map.getString("answer2"));
|
||
voteModel.setAnswer1Num(map.getInteger("num1"));
|
||
voteModel.setAnswer2Num(map.getInteger("num2"));
|
||
setVoteData(voteModel);
|
||
}
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void updateSub(LiveAudienceEvent event) {
|
||
switch (event.getType()) {
|
||
case PK_RANK_UPDATE:
|
||
updatePkRank((PkRankBean) event.getObject());
|
||
break;
|
||
case PK_TWO_UPDATE_HEAD_DATA:
|
||
setHeadData(event.getLivePKUserListBean());
|
||
break;
|
||
case PK_TWO_START:
|
||
pkUid = event.getObject().toString();
|
||
UpPkTwo();
|
||
new Handler(Looper.getMainLooper()).postDelayed(this::initPkRank, 300);
|
||
break;
|
||
case PK_TWO_END:
|
||
|
||
EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", ""));
|
||
closePkTwo();
|
||
break;
|
||
case CUSTOM_FULL_SERVICE_NOTIFY:
|
||
customFullServiceNotify(event.getCustomFullServiceNotifyEvent());
|
||
break;
|
||
case PK_TIME_COUNT:
|
||
// endDRGif();
|
||
break;
|
||
case UP_PK_TWO:
|
||
pkUid = (String) event.getObject();
|
||
UpPkTwo();
|
||
break;
|
||
case CHANGE_VIEW:
|
||
changeView();
|
||
break;
|
||
case LIVE_PK_ING:
|
||
hideAnchorSayAndCallAnchor();
|
||
break;
|
||
case LIVE_PK_END:
|
||
showAnchorSayAndCallAnchor();
|
||
break;
|
||
case LIVE_FONT_SIZE:
|
||
int fount = event.getNums();
|
||
mLiveChatAdapter.switchFount(fount);
|
||
break;
|
||
case UPDATE_FANS_TASK_STATUS:
|
||
updateFansMessageRed();
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
public void wishListProgress(WishModel wishModel, String userNiceName, int level) {
|
||
if (mTopBannerList == null) {
|
||
mTopBannerList = new ArrayList<>();
|
||
}
|
||
wishListProgress = null;
|
||
WishModel model = wishModel;
|
||
if (!TextUtils.isEmpty(model.getWishlistName()) || !TextUtils.isEmpty(model.getWishlistProgress())) {
|
||
for (BannerBean bannerBean : mTopBannerList) {
|
||
if (bannerBean.getType() == 1) {
|
||
mTopBannerList.remove(bannerBean);
|
||
}
|
||
}
|
||
|
||
topBanner1.update(mTopBannerList);
|
||
topBanner2.update(mTopBannerList);
|
||
new Handler().postDelayed(new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
BannerBean bannerBean = new BannerBean();
|
||
bannerBean.setWishlistIcon(model.getWishlistIcon())
|
||
.setWishlistName(model.getWishlistName())
|
||
.setWishlistNum(model.getWishlistNum())
|
||
.setWishlistProgress(model.getWishlistProgress())
|
||
.setmLink(CommonAppConfig.HOST + "/index.php")
|
||
.setType(1);
|
||
bannerBean.setShow_type("2");
|
||
mTopBannerList.add(bannerBean);
|
||
LiveChatBean bean = new LiveChatBean();
|
||
bean.setContent(model.getLuid());
|
||
bean.setUserNiceName(userNiceName);
|
||
bean.setAtUserName(model.getWishlistName());
|
||
bean.setType(LiveChatBean.WISH_LIST_PROGRESS);
|
||
bean.setLevel(level);
|
||
mLiveChatAdapter.insertItem(bean);
|
||
if (mTopBannerList.size() == 0) {
|
||
topBanner1.setVisibility(View.GONE);
|
||
} else {
|
||
topBanner1.update(mTopBannerList);
|
||
topBanner2.update(mTopBannerList);
|
||
}
|
||
}
|
||
}, 500);
|
||
|
||
} else {
|
||
for (BannerBean bannerBean : mTopBannerList) {
|
||
if (bannerBean.getType() == 1) {
|
||
mTopBannerList.remove(bannerBean);
|
||
}
|
||
}
|
||
// LiveChatBean bean = new LiveChatBean();
|
||
// bean.setContent(model.getLuid());
|
||
// bean.setUserNiceName(userNiceName);
|
||
// bean.setAtUserName(model.getWishlistName());
|
||
// bean.setType(LiveChatBean.WISH_LIST_PROGRESS);
|
||
// mLiveChatAdapter.insertItem(bean);
|
||
if (mTopBannerList.size() == 0) {
|
||
topBanner1.setVisibility(View.GONE);
|
||
topBanner2.setVisibility(View.GONE);
|
||
} else {
|
||
topBanner1.update(mTopBannerList);
|
||
topBanner2.update(mTopBannerList);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
/**
|
||
* 全服通知
|
||
*
|
||
* @param customFullServiceNotifyEvent
|
||
*/
|
||
private void customFullServiceNotify(CustomFullServiceNotifyEvent customFullServiceNotifyEvent) {
|
||
if (customFullServiceNotifyEvent.getType() == 1) {
|
||
int duration = customFullServiceNotifyEvent.getDuration();
|
||
int handlerDuration = 0;
|
||
if (duration > 2) {
|
||
inAlphaAnimation.setDuration(1000);
|
||
outAlphaAnimation.setDuration(1000);
|
||
handlerDuration = duration - 2;
|
||
} else {
|
||
inAlphaAnimation.setDuration(500);
|
||
outAlphaAnimation.setDuration(500);
|
||
handlerDuration = duration - 1;
|
||
}
|
||
customFullServiceNotify.startAnimation(inAlphaAnimation);
|
||
customFullServiceNotify.setVisibility(View.VISIBLE);
|
||
ImgLoader.display(mContext, customFullServiceNotifyEvent.getImg(), customFullServiceNotify);
|
||
customFullHandler.postDelayed(customFullRunnable, handlerDuration * 1000);
|
||
} else {//文字通知
|
||
|
||
}
|
||
}
|
||
|
||
//渐出动画
|
||
private AlphaAnimation inAlphaAnimation = new AlphaAnimation(0, 1);
|
||
private AlphaAnimation outAlphaAnimation = new AlphaAnimation(1, 0);
|
||
private Handler customFullHandler = new Handler();
|
||
private Runnable customFullRunnable = new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
customFullServiceNotify.startAnimation(outAlphaAnimation);
|
||
//这个地方为什么要做动画的监听呢,因为隐藏和显示不一样,
|
||
//必须在动画结束之后再隐藏你的控件,这样才不会显得很突兀
|
||
outAlphaAnimation.setAnimationListener(new Animation.AnimationListener() {
|
||
@Override
|
||
public void onAnimationStart(Animation animation) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationEnd(Animation animation) {
|
||
customFullServiceNotify.setVisibility(View.GONE);
|
||
customFullHandler.removeCallbacks(customFullRunnable);
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationRepeat(Animation animation) {
|
||
|
||
}
|
||
});
|
||
|
||
|
||
}
|
||
};
|
||
private Handler countdownHandler = new Handler();
|
||
private View detailsView = null;
|
||
private FrameLayout timeTitle;
|
||
private TextView textTime;
|
||
private TextView textPkName1, textPkName2, textPkName3, textPkName4;
|
||
private TextView textGrade1, textGrade2, textGrade3, textGrade4;
|
||
private ImageView imageGrade1, imageGrade2, imageGrade3, imageGrade4;
|
||
private LinearLayout linearGrade1, linearGrade2, linearGrade3, linearGrade4;
|
||
private boolean isShowGif = false;
|
||
/**
|
||
* PK倒计时
|
||
*/
|
||
private String userId2, userId3 = "", userId4;
|
||
|
||
public void seisShowGif(boolean isShowGif) {
|
||
this.isShowGif = isShowGif;
|
||
}
|
||
|
||
public void upDataPkScore(JSONArray pkScores, int time) {
|
||
isShowGif = true;
|
||
if (detailsView == null) {
|
||
detailsView = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
|
||
timeTitle = detailsView.findViewById(R.id.time_title);
|
||
textTime = detailsView.findViewById(R.id.text_time);
|
||
linearGrade1 = detailsView.findViewById(R.id.lin_pk1);
|
||
linearGrade2 = detailsView.findViewById(R.id.lin_pk2);
|
||
linearGrade3 = detailsView.findViewById(R.id.lin_pk3);
|
||
linearGrade4 = detailsView.findViewById(R.id.lin_pk4);
|
||
textPkName1 = detailsView.findViewById(R.id.text_pk_name1);
|
||
textPkName2 = detailsView.findViewById(R.id.text_pk_name2);
|
||
textPkName3 = detailsView.findViewById(R.id.text_pk_name3);
|
||
textPkName4 = detailsView.findViewById(R.id.text_pk_name4);
|
||
textGrade1 = detailsView.findViewById(R.id.text_grade1);
|
||
textGrade2 = detailsView.findViewById(R.id.text_grade2);
|
||
textGrade3 = detailsView.findViewById(R.id.text_grade3);
|
||
textGrade4 = detailsView.findViewById(R.id.text_grade4);
|
||
imageGrade1 = detailsView.findViewById(R.id.image_grade1);
|
||
imageGrade2 = detailsView.findViewById(R.id.image_grade2);
|
||
imageGrade3 = detailsView.findViewById(R.id.image_grade3);
|
||
imageGrade4 = detailsView.findViewById(R.id.image_grade4);
|
||
linearGrade1.setVisibility(View.GONE);
|
||
linearGrade2.setVisibility(View.GONE);
|
||
linearGrade3.setVisibility(View.GONE);
|
||
linearGrade4.setVisibility(View.GONE);
|
||
mRoot.addView(detailsView);
|
||
mRoot.post(new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
int mScreenWdith = ScreenDimenUtil.getInstance().getScreenWdith();
|
||
int vHeight = mScreenWdith * 720 / 960;
|
||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) detailsView.getLayoutParams();
|
||
params.height = vHeight;
|
||
params.width = mScreenWdith;
|
||
params.topMargin = DpUtil.dp2px(105);
|
||
params.addRule(RelativeLayout.ALIGN_TOP);
|
||
detailsView.setLayoutParams(params);
|
||
}
|
||
});
|
||
|
||
|
||
}
|
||
|
||
for (int i = 0; i < pkScores.size(); i++) {
|
||
JSONObject score = pkScores.getJSONObject(i);
|
||
String userNiceName = score.getString("user_nicename");
|
||
long userScore = score.getLong("score");
|
||
String userId = score.getString("id");
|
||
int resScore = R.mipmap.icon_livepk_no1;
|
||
if (userScore == 0 && !score.containsKey("paiming")) {
|
||
resScore = R.mipmap.icon_livepk_no1;
|
||
} else {
|
||
if (score.containsKey("paiming")) {
|
||
int ranking = score.getIntValue("paiming");
|
||
switch (ranking) {
|
||
case 1:
|
||
resScore = R.mipmap.icon_livepk_no1;
|
||
break;
|
||
case 2:
|
||
resScore = R.mipmap.icon_livepk_no2;
|
||
break;
|
||
case 3:
|
||
resScore = R.mipmap.icon_livepk_no3;
|
||
break;
|
||
case 4:
|
||
resScore = R.mipmap.icon_livepk_no4;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if (i == 0) {
|
||
linearGrade1.setVisibility(View.VISIBLE);
|
||
textPkName1.setText(userNiceName);
|
||
ImgLoader.display(mContext, resScore, imageGrade1);
|
||
textGrade1.setText(String.valueOf(userScore));
|
||
|
||
} else if (i == 1) {
|
||
linearGrade2.setVisibility(View.VISIBLE);
|
||
textPkName2.setText(userNiceName);
|
||
ImgLoader.display(mContext, resScore, imageGrade2);
|
||
textGrade2.setText(String.valueOf(userScore));
|
||
userId2 = userId;
|
||
} else if (i == 2) {
|
||
if (pkScores.size() == 3) {
|
||
linearGrade4.setVisibility(View.VISIBLE);
|
||
textPkName4.setText(userNiceName);
|
||
ImgLoader.display(mContext, resScore, imageGrade4);
|
||
textGrade4.setText(String.valueOf(userScore));
|
||
userId4 = userId;
|
||
} else {
|
||
linearGrade3.setVisibility(View.VISIBLE);
|
||
textPkName3.setText(userNiceName);
|
||
ImgLoader.display(mContext, resScore, imageGrade3);
|
||
textGrade3.setText(String.valueOf(userScore));
|
||
userId3 = userId;
|
||
}
|
||
|
||
} else if (i == 3) {
|
||
linearGrade4.setVisibility(View.VISIBLE);
|
||
textPkName4.setText(userNiceName);
|
||
ImgLoader.display(mContext, resScore, imageGrade4);
|
||
textGrade4.setText(String.valueOf(userScore));
|
||
userId4 = userId;
|
||
}
|
||
}
|
||
|
||
if (time > 0) {
|
||
mPkTimeCount = time;
|
||
timeTitle.setVisibility(View.VISIBLE);
|
||
countdownHandler.postAtTime(countdownRunnable, getNextSecondTime());
|
||
}
|
||
textPkName2.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
showUserDialog(userId2);
|
||
}
|
||
});
|
||
textPkName4.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
showUserDialog(userId4);
|
||
}
|
||
});
|
||
textPkName3.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
showUserDialog(userId3);
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
private Runnable countdownRunnable = new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
mPkTimeCount--;
|
||
if (mPkTimeCount > 0) {//
|
||
String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
|
||
textTime.setText(String.format(mContext.getString(R.string.pk_time), s1));
|
||
countdownHandler.postAtTime(countdownRunnable, getNextSecondTime());
|
||
} else {
|
||
mPkTimeCount = 0;
|
||
timeTitle.setVisibility(View.GONE);
|
||
countdownHandler.removeCallbacks(countdownRunnable);
|
||
Bus.get().post(new LiveAudienceEvent()
|
||
.setType(LiveAudienceEvent.LiveAudienceType.PK_TIME_COUNT));
|
||
}
|
||
}
|
||
};
|
||
|
||
public void removeDetailView() {
|
||
|
||
if (detailsView != null) {
|
||
mRoot.removeView(detailsView);
|
||
detailsView = null;
|
||
}
|
||
mPkTimeCount = 0;
|
||
showAnchorSayAndCallAnchor();
|
||
if (mHandler != null) {
|
||
mHandler.removeMessages(WHAT_PK_TIME);
|
||
}
|
||
isShowGif = false;
|
||
if (voteManager != null) {
|
||
voteManager.hide();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 横竖屏聊天框的高度
|
||
*
|
||
* @param landscape
|
||
*/
|
||
public void changeMessageLandscape(int landscape) {
|
||
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)
|
||
mChatRecyclerView.getLayoutParams();
|
||
RelativeLayout.LayoutParams enterRoomParams = (RelativeLayout.LayoutParams) enterRoomLeave.getLayoutParams();
|
||
if (landscape == 2) {
|
||
params1.height = DpUtil.dp2px(200);
|
||
enterRoomParams.bottomMargin = -DpUtil.dp2px(65);
|
||
} else {
|
||
params1.height = DpUtil.dp2px(310);
|
||
enterRoomParams.bottomMargin = -DpUtil.dp2px(70);
|
||
}
|
||
mChatRecyclerView.setLayoutParams(params1);
|
||
|
||
enterRoomLeave.setLayoutParams(enterRoomParams);
|
||
fans_enter_room_leave.setLayoutParams(enterRoomParams);
|
||
|
||
|
||
}
|
||
|
||
|
||
public void showHighGrade(LiveUserGiftBean model) {
|
||
ImageView imageView = (ImageView) findViewById(R.id.image_view);
|
||
ClipPathCircleImage imageAvatar = (ClipPathCircleImage) findViewById(R.id.image_avatar);
|
||
TextView userName = (TextView) findViewById(R.id.user_name);
|
||
userName.setText(String.format(mContext.getString(R.string.come_hint), model.getUserNiceName()));
|
||
ImgLoader.display(mContext, model.getAvatar(), imageAvatar);
|
||
int level = model.getLevel();
|
||
if (!StringUtil.isEmpty(model.getFansEnterRoomUrl())) {
|
||
showFansGroupEnterRoom(model);
|
||
return;
|
||
}
|
||
if (level < 50) {
|
||
enterRoomLeave.setBackgroundResource(R.drawable.background_30);
|
||
enterRoomLeave2.setBackgroundResource(R.drawable.bg_30_leave);
|
||
} else if (level > 49 && level < 60) {
|
||
enterRoomLeave.setBackgroundResource(R.drawable.background_50);
|
||
enterRoomLeave2.setBackgroundResource(R.drawable.bg_50_leave);
|
||
} else if (level > 59 && level < 80) {
|
||
enterRoomLeave.setBackgroundResource(R.drawable.background_60);
|
||
enterRoomLeave2.setBackgroundResource(R.drawable.bg_60_leave);
|
||
} else if (level > 79 && level < 90) {
|
||
enterRoomLeave.setBackgroundResource(R.drawable.background_80);
|
||
enterRoomLeave2.setBackgroundResource(R.drawable.bg_80_leave);
|
||
} else if (level > 99) {
|
||
enterRoomLeave.setBackgroundResource(R.drawable.background_100);
|
||
enterRoomLeave2.setBackgroundResource(R.drawable.bg_100_leave);
|
||
}
|
||
boolean max = level > 99;
|
||
new LiveTextRender().getLiveLevelImage(mContext, model.getLevel(), max, new ImgLoader.DrawableCallback() {
|
||
@Override
|
||
public void onLoadSuccess(Drawable drawable) {
|
||
ImgLoader.display2(mContext, drawable, imageView);
|
||
}
|
||
|
||
@Override
|
||
public void onLoadFailed() {
|
||
|
||
}
|
||
});
|
||
enterRoomLeave.post(() -> {
|
||
enterRoomLeave.setVisibility(View.VISIBLE);
|
||
TranslateAnimation animationTranslate = new TranslateAnimation(DeviceUtils.getScreenWidth((Activity) mContext), 0, 0, 0);
|
||
AnimationSet animationSet1 = new AnimationSet(true);
|
||
animationSet1.addAnimation(animationTranslate);
|
||
animationSet1.setFillAfter(true);
|
||
animationSet1.setDuration(500);
|
||
animationSet1.setAnimationListener(new Animation.AnimationListener() {
|
||
@Override
|
||
public void onAnimationStart(Animation animation) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationEnd(Animation animation) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationRepeat(Animation animation) {
|
||
|
||
}
|
||
});
|
||
enterRoomLeave.startAnimation(animationSet1);
|
||
|
||
});
|
||
|
||
|
||
}
|
||
|
||
private void showFansGroupEnterRoom(LiveUserGiftBean model) {
|
||
|
||
fans_enter_room_leave.post(() -> {
|
||
TextView userName = fans_enter_room_leave.findViewById(R.id.user_name);
|
||
ImageView bg = fans_enter_room_leave.findViewById(R.id.bg);
|
||
|
||
userName.setText(Html.fromHtml(String.format("@<font color='#99D5FF'>%s</font> %s",
|
||
model.getUserNiceName(),
|
||
mContext.getString(R.string.live_fans_group_enter_room)
|
||
)));
|
||
ImgLoader.display(mContext, model.getFansEnterRoomUrl(), bg);
|
||
fans_enter_room_leave.setVisibility(View.VISIBLE);
|
||
TranslateAnimation animationTranslate = new TranslateAnimation(DeviceUtils.getScreenWidth((Activity) mContext), 0, 0, 0);
|
||
AnimationSet animationSet1 = new AnimationSet(true);
|
||
animationSet1.addAnimation(animationTranslate);
|
||
animationSet1.setFillAfter(true);
|
||
animationSet1.setDuration(500);
|
||
animationSet1.setAnimationListener(new Animation.AnimationListener() {
|
||
@Override
|
||
public void onAnimationStart(Animation animation) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationEnd(Animation animation) {
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationRepeat(Animation animation) {
|
||
|
||
}
|
||
});
|
||
fans_enter_room_leave.startAnimation(animationSet1);
|
||
});
|
||
|
||
}
|
||
|
||
/**
|
||
* 隐藏粉丝团入场提示
|
||
*/
|
||
public void hideFansGroupEnter() {
|
||
if (fans_enter_room_leave.getVisibility() == View.GONE) return;
|
||
TranslateAnimation animationTranslate = new TranslateAnimation(0, -(fans_enter_room_leave.getMeasuredWidth() + DpUtil.dp2px(6)), 0, 0);
|
||
AnimationSet animationSet1 = new AnimationSet(true);
|
||
animationSet1.addAnimation(animationTranslate);
|
||
animationSet1.setFillAfter(true);
|
||
animationSet1.setDuration(100);
|
||
animationSet1.setAnimationListener(new Animation.AnimationListener() {
|
||
@Override
|
||
public void onAnimationStart(Animation animation) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationEnd(Animation animation) {
|
||
fans_enter_room_leave.setVisibility(View.GONE);
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationRepeat(Animation animation) {
|
||
|
||
}
|
||
});
|
||
fans_enter_room_leave.startAnimation(animationSet1);
|
||
}
|
||
|
||
/**
|
||
* 隐藏高等级入场提示
|
||
*/
|
||
public void hideHighGrade() {
|
||
if (enterRoomLeave.getVisibility() == View.GONE) return;
|
||
TranslateAnimation animationTranslate = new TranslateAnimation(0, -(enterRoomLeave.getMeasuredWidth() + DpUtil.dp2px(6)), 0, 0);
|
||
AnimationSet animationSet1 = new AnimationSet(true);
|
||
animationSet1.addAnimation(animationTranslate);
|
||
animationSet1.setFillAfter(true);
|
||
animationSet1.setDuration(100);
|
||
animationSet1.setAnimationListener(new Animation.AnimationListener() {
|
||
@Override
|
||
public void onAnimationStart(Animation animation) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationEnd(Animation animation) {
|
||
enterRoomLeave.setVisibility(View.GONE);
|
||
}
|
||
|
||
@Override
|
||
public void onAnimationRepeat(Animation animation) {
|
||
|
||
}
|
||
});
|
||
enterRoomLeave.startAnimation(animationSet1);
|
||
}
|
||
|
||
LiveAnchorSayModel sayModel;
|
||
|
||
public void initAnchorSayData() {
|
||
LiveNetManager.get(mContext)
|
||
.getLivePreviewInfo(mLiveUid, new com.yunbao.common.http.base.HttpCallback<LiveAnchorSayModel>() {
|
||
@Override
|
||
public void onSuccess(LiveAnchorSayModel data) {
|
||
Log.i("女神说", "onSuccess: " + data);
|
||
sayModel = data;
|
||
LiveAnchorSayModel.LivePreview preview = data.getLivePreview();
|
||
if (preview != null) {
|
||
mAnchorSayText.setText(getText(data.getLivePreview().getContent()));
|
||
ImgLoader.display(mContext, preview.getStyleImage(), mAnchorSayImage);
|
||
if (preview.getIsShow() == 1) {
|
||
mAnchorSay.setVisibility(View.VISIBLE);
|
||
} else {
|
||
mAnchorSay.setVisibility(View.INVISIBLE);
|
||
}
|
||
} else {
|
||
mAnchorSay.setVisibility(View.INVISIBLE);
|
||
}
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onError(String error) {
|
||
|
||
}
|
||
|
||
public String getText(String content) {
|
||
int t = 4;
|
||
float len = (float) content.length() / t;
|
||
StringBuilder sb = new StringBuilder();
|
||
sb.append("\n");
|
||
for (int i = 0; i < len; i++) {
|
||
if (len - i < 1) {
|
||
sb.append(content.substring(i * t));
|
||
} else {
|
||
sb.append(content.substring(i * t, i * t + t)).append("\n");
|
||
}
|
||
}
|
||
return sb.toString();
|
||
}
|
||
});
|
||
}
|
||
|
||
public void initAnchorSay() {
|
||
if (mAnchorSay.getTag() != null) {
|
||
mAnchorSay.setX((float) mAnchorSayImage.getTag());
|
||
mAnchorSayImage.setTag(null);
|
||
mAnchorSayImage.setVisibility(View.VISIBLE);
|
||
mAnchorSayText.setVisibility(View.VISIBLE);
|
||
mAnchorSayHide.setImageResource(R.mipmap.ic_live_anchor_say_show);
|
||
}
|
||
mAnchorSay.setTag(null);
|
||
initAnchorSayData();
|
||
}
|
||
|
||
public void hideAnchorSayAndCallAnchor() {
|
||
isHinde = true;
|
||
mAnchorSay.setVisibility(View.GONE);
|
||
topBanner2.setVisibility(View.VISIBLE);
|
||
topBanner1.setVisibility(View.GONE);
|
||
}
|
||
|
||
public void showAnchorSayAndCallAnchor() {
|
||
isHinde = false;
|
||
if (mAnchorSay.getVisibility() == View.GONE &&
|
||
sayModel != null && sayModel.getLivePreview() != null &&
|
||
sayModel.getLivePreview().getIsShow() == 1
|
||
) {
|
||
Log.i("女神说", "sayModel: " + sayModel);
|
||
mAnchorSay.setVisibility(View.VISIBLE);
|
||
}
|
||
if (topBanner1.getVisibility() == View.GONE && mTopBannerList != null && !mTopBannerList.isEmpty()) {
|
||
Log.i("女神说", "mTopBannerList: " + mTopBannerList.size());
|
||
for (BannerBean bean : mTopBannerList) {
|
||
Log.i("女神说", "BannerBean: " + bean);
|
||
}
|
||
topBanner1.setVisibility(View.VISIBLE);
|
||
topBanner2.setVisibility(View.GONE);
|
||
}
|
||
}
|
||
|
||
private WishModel wishListProgress;
|
||
|
||
public LiveRoomViewHolder setWishListProgress(WishModel wishListProgress) {
|
||
this.wishListProgress = wishListProgress;
|
||
return this;
|
||
}
|
||
|
||
public void updateTopBanner() {
|
||
if (wishListProgress == null) return;
|
||
if (!TextUtils.isEmpty(wishListProgress.getWishlistName()) || !TextUtils.isEmpty(wishListProgress.getWishlistProgress())) {
|
||
if (mTopBannerList == null) {
|
||
mTopBannerList = new ArrayList<>();
|
||
}
|
||
// if(sayModel!=null&&sayModel.getLivePreview().getIsShow()==1&&sa)
|
||
if (!isHinde) {
|
||
topBanner1.setVisibility(View.VISIBLE);
|
||
}
|
||
|
||
BannerBean bannerBean = new BannerBean();
|
||
bannerBean.setWishlistIcon(wishListProgress.getWishlistIcon())
|
||
.setWishlistName(wishListProgress.getWishlistName())
|
||
.setWishlistNum(wishListProgress.getWishlistNum())
|
||
.setWishlistProgress(wishListProgress.getWishlistProgress())
|
||
.setmLink(CommonAppConfig.HOST + "/index.php")
|
||
.setType(1);
|
||
bannerBean.setShow_type("2");
|
||
if (mTopBannerList.size() == 1 || mTopBannerList.size() == 0) {
|
||
mTopBannerList.add(bannerBean);
|
||
} else {
|
||
mTopBannerList.set(1, bannerBean);
|
||
}
|
||
topBanner1.update(mTopBannerList);
|
||
topBanner2.update(mTopBannerList);
|
||
}
|
||
|
||
}
|
||
|
||
public void initTopBanner() {
|
||
checkNewLetter();
|
||
if (mTopBannerList == null) {
|
||
mTopBannerList = new ArrayList<>();
|
||
}
|
||
if (!mTopBannerList.isEmpty()) {
|
||
return;
|
||
}
|
||
topBanner1.setVisibility(View.GONE);
|
||
topBanner1.setAutoPlay(true)
|
||
.setPages(mTopBannerList, new TopBannerCustomViewHolder())
|
||
.setDelayTime(3000)
|
||
.setBannerStyle(BannerConfig.NOT_INDICATOR)
|
||
.setOnBannerClickListener(new OnBannerClickListener() {
|
||
@Override
|
||
public void onBannerClick(List datas, int position) {
|
||
if (datas.size() > 0 && mTopBannerList != null && mTopBannerList.size() > 0) {
|
||
if (mTopBannerList.get(position).getType() == TopBannerCustomViewHolder.TYPE_CALL_ANCHOR) {
|
||
MobclickAgent.onEvent(mContext, "live_room_contact", "联系方式按钮");
|
||
Dialog loading = DialogUitl.loadingDialog(mContext);
|
||
loading.show();
|
||
LiveNetManager.get(mContext)
|
||
.getContactInfo(mLiveUid, new com.yunbao.common.http.base.HttpCallback<LiveAnchorCallMeModel>() {
|
||
|
||
@Override
|
||
public void onSuccess(LiveAnchorCallMeModel data) {
|
||
if (data.getIsGet() == 1) {
|
||
new LiveUserAnchorMailBoxWebInfoPopDialog(mContext, mAnchorName, data.getLink())
|
||
.setOnDismissListener(dialog -> {
|
||
checkNewLetter();
|
||
loading.dismiss();
|
||
})
|
||
.showDialog();
|
||
return;
|
||
}
|
||
new LiveContactDetailsSendGiftDialog(mContext)
|
||
.setGiftId(data.getGiftId())
|
||
.setAnchorName(mAnchorName)
|
||
.setStream(mStream)
|
||
.setLiveUid(mLiveUid)
|
||
.setOnDismissListener(dialog1 -> {
|
||
checkNewLetter();
|
||
})
|
||
.showDialog();
|
||
loading.dismiss();
|
||
}
|
||
|
||
@Override
|
||
public void onError(String error) {
|
||
loading.dismiss();
|
||
}
|
||
});
|
||
|
||
} else {
|
||
MobclickAgent.onEvent(mContext, "live_room_wish", "心愿单按钮");
|
||
BannerBean bean = mTopBannerList.get(position);
|
||
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
|
||
String type = "";
|
||
StringBuffer htmlUrl = new StringBuffer();
|
||
htmlUrl.append(bean.getLink())
|
||
.append(bean.getLink().contains("?") ? "&uid=" : "?uid=")
|
||
.append(userInfo.getId())
|
||
.append("&token=")
|
||
.append(userInfo.getToken())
|
||
.append("&anchorUid=")
|
||
.append(mLiveUid)
|
||
.append("&liveUid=")
|
||
.append(mLiveUid)
|
||
.append("&t=")
|
||
.append(System.currentTimeMillis())
|
||
.append("&g=Appapi&m=Wish&a=index")
|
||
.append("&isZh=")
|
||
.append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||
if (TextUtils.equals(type, "1")) {
|
||
ZhuangBanActivity.forward(mContext, htmlUrl.toString(), false, 1);
|
||
} else {
|
||
Bundle bundle = new Bundle();
|
||
bundle.putString("url", htmlUrl.toString());
|
||
LiveHDDialogFragment fragment = new LiveHDDialogFragment();
|
||
fragment.setArguments(bundle);
|
||
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
})
|
||
.start();
|
||
topBanner2.setAutoPlay(true)
|
||
.setPages(mTopBannerList, new TopBannerCustomViewHolder(false))
|
||
.setDelayTime(3000)
|
||
.setBannerStyle(BannerConfig.NOT_INDICATOR)
|
||
.setOnBannerClickListener(new OnBannerClickListener() {
|
||
@Override
|
||
public void onBannerClick(List datas, int position) {
|
||
if (datas.size() > 0) {
|
||
if (position >= mTopBannerList.size()) {
|
||
position = 0;
|
||
}
|
||
if (mTopBannerList.get(position).getType() == TopBannerCustomViewHolder.TYPE_CALL_ANCHOR) {
|
||
MobclickAgent.onEvent(mContext, "live_room_contact", "联系方式按钮");
|
||
Dialog loading = DialogUitl.loadingDialog(mContext);
|
||
loading.show();
|
||
LiveNetManager.get(mContext)
|
||
.getContactInfo(mLiveUid, new com.yunbao.common.http.base.HttpCallback<LiveAnchorCallMeModel>() {
|
||
|
||
@Override
|
||
public void onSuccess(LiveAnchorCallMeModel data) {
|
||
if (data.getIsGet() == 1) {
|
||
new LiveUserAnchorMailBoxWebInfoPopDialog(mContext, mAnchorName, data.getLink())
|
||
.setOnDismissListener(dialog -> {
|
||
checkNewLetter();
|
||
loading.dismiss();
|
||
})
|
||
.showDialog();
|
||
return;
|
||
}
|
||
new LiveContactDetailsSendGiftDialog(mContext)
|
||
.setGiftId(data.getGiftId())
|
||
.setAnchorName(mAnchorName)
|
||
.setStream(mStream)
|
||
.setLiveUid(mLiveUid)
|
||
.setOnDismissListener(dialog1 -> {
|
||
checkNewLetter();
|
||
})
|
||
.showDialog();
|
||
loading.dismiss();
|
||
}
|
||
|
||
@Override
|
||
public void onError(String error) {
|
||
loading.dismiss();
|
||
}
|
||
});
|
||
|
||
} else {
|
||
MobclickAgent.onEvent(mContext, "live_room_wish", "心愿单按钮");
|
||
BannerBean bean = mTopBannerList.get(position);
|
||
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
|
||
String type = "";
|
||
StringBuffer htmlUrl = new StringBuffer();
|
||
htmlUrl.append(bean.getLink())
|
||
.append(bean.getLink().contains("?") ? "&uid=" : "?uid=")
|
||
.append(userInfo.getId())
|
||
.append("&token=")
|
||
.append(userInfo.getToken())
|
||
.append("&anchorUid=")
|
||
.append(mLiveUid)
|
||
.append("&liveUid=")
|
||
.append(mLiveUid)
|
||
.append("&t=")
|
||
.append(System.currentTimeMillis())
|
||
.append("&g=Appapi&m=Wish&a=index")
|
||
.append("&isZh=")
|
||
.append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||
if (TextUtils.equals(type, "1")) {
|
||
ZhuangBanActivity.forward(mContext, htmlUrl.toString(), false, 1);
|
||
} else {
|
||
Bundle bundle = new Bundle();
|
||
bundle.putString("url", htmlUrl.toString());
|
||
LiveHDDialogFragment fragment = new LiveHDDialogFragment();
|
||
fragment.setArguments(bundle);
|
||
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
})
|
||
.start();
|
||
updateCallMe();
|
||
}
|
||
|
||
private void updateCallMe() {
|
||
|
||
LiveNetManager.get(mContext)
|
||
.getContactInfo(mLiveUid, new com.yunbao.common.http.base.HttpCallback<LiveAnchorCallMeModel>() {
|
||
@Override
|
||
public void onSuccess(LiveAnchorCallMeModel data) {
|
||
System.out.println(">>>>> 获取联系方式:" + data);
|
||
if (data.getIsShow() == 1) {
|
||
if (!isHinde) {
|
||
topBanner1.setVisibility(View.VISIBLE);
|
||
}
|
||
BannerBean call = new BannerBean();
|
||
call.setData(data);
|
||
call.setType(TopBannerCustomViewHolder.TYPE_CALL_ANCHOR);
|
||
mTopBannerList.add(0, call);
|
||
topBanner1.update(mTopBannerList);
|
||
topBanner2.update(mTopBannerList);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onError(String error) {
|
||
System.out.println("!>>>>> 获取联系方式:" + error);
|
||
}
|
||
});
|
||
}
|
||
|
||
private void checkNewLetter() {
|
||
LiveNetManager.get(mContext).getContactMsg(new com.yunbao.common.http.base.HttpCallback<List<LiveUserMailBoxModel>>() {
|
||
@Override
|
||
public void onSuccess(List<LiveUserMailBoxModel> data) {
|
||
for (LiveUserMailBoxModel model : data) {
|
||
if (model.getIsRead() == 0 && mContext instanceof LiveAudienceActivity) {
|
||
((LiveAudienceActivity) mContext).showMsgRed(0);
|
||
return;
|
||
}
|
||
}
|
||
((LiveAudienceActivity) mContext).showMsgRed(-1);
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onError(String error) {
|
||
|
||
}
|
||
});
|
||
}
|
||
|
||
public void blindBoxAllServerNotify(AllServerNotifyEvent event) {
|
||
LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
|
||
receiveGiftBean.setBlindBox(true);
|
||
receiveGiftBean.setEvent(event);
|
||
if (mLiveGiftAnimPresenter == null) {
|
||
mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager);
|
||
}
|
||
mLiveGiftAnimPresenter.showSendGiftAnimAllServer2(receiveGiftBean);
|
||
mLiveGiftAnimPresenter.setLiveUidStream(mLiveUid, mStream);
|
||
}
|
||
|
||
public void updateFansMessageRed() {
|
||
if (mContext instanceof LiveAudienceActivity) {
|
||
LiveNetManager.get(mContext)
|
||
.getCheckFansLevelUpgrade(mLiveUid, new com.yunbao.common.http.base.HttpCallback<FansCheckRed>() {
|
||
@Override
|
||
public void onSuccess(FansCheckRed data) {
|
||
((LiveAudienceActivity) mContext).setShowCrownRed(data.getStatus() == 1);
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onError(String error) {
|
||
|
||
}
|
||
});
|
||
}
|
||
}
|
||
}
|