diff --git a/common/src/main/java/com/yunbao/common/manager/base/ACache.java b/common/src/main/java/com/yunbao/common/manager/base/ACache.java index 11fb7b2ea..3876b7f00 100644 --- a/common/src/main/java/com/yunbao/common/manager/base/ACache.java +++ b/common/src/main/java/com/yunbao/common/manager/base/ACache.java @@ -271,7 +271,6 @@ public class ACache { JSONArray obj = new JSONArray(JSONString); return obj; } catch (Exception e) { - e.printStackTrace(); return null; } } diff --git a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java index e664d4d58..180d3b080 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -25,7 +25,6 @@ import androidx.fragment.app.DialogFragment; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.blankj.utilcode.util.GsonUtils; import com.lzy.okgo.callback.Callback; import com.lzy.okgo.model.Progress; import com.lzy.okgo.model.Response; @@ -36,6 +35,7 @@ import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppContext; import com.yunbao.common.Constants; import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.UserBean; import com.yunbao.common.dialog.NotCancelableDialog; import com.yunbao.common.event.LoginInvalidEvent; @@ -55,12 +55,9 @@ import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; -import com.yunbao.common.bean.LiveBean; import com.yunbao.live.bean.LiveGuardInfo; import com.yunbao.live.bean.LiveKsyConfigBean; import com.yunbao.live.bean.LiveReceiveGiftBean; -import com.yunbao.live.bean.WishlistModel; -import com.yunbao.live.dialog.LiveBeautyDialogFragment; import com.yunbao.live.dialog.LiveLinkMicListDialogFragment; import com.yunbao.live.dialog.LiveNewFunctionDialogFragment; import com.yunbao.live.dialog.LiveNewWishListDialogFragment; @@ -71,7 +68,6 @@ import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.interfaces.LiveFunctionClickListener; import com.yunbao.live.interfaces.LivePushListener; -import com.yunbao.live.momo.BeautyManager; import com.yunbao.live.music.LiveMusicDialogFragment; import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter; import com.yunbao.live.presenter.LiveLinkMicPresenter; @@ -103,7 +99,6 @@ import io.rong.message.TextMessage; import pl.droidsonroids.gif.GifImageView; - /** * Created by cxf on 2018/10/7. * 主播直播间 @@ -142,7 +137,6 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl public static int backIndex = 0;//0=未判断,1=已判断 - @Override protected int getLayoutId() { return R.layout.activity_live_anchor; @@ -478,7 +472,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl if (mLiveReadyViewHolder != null) { mLiveReadyViewHolder.hide(); } - if(mLiveRoomViewHolder!=null){ + if (mLiveRoomViewHolder != null) { mLiveRoomViewHolder.changeFaceUnityView(); } /* LiveBeautyDialogFragment fragment = new LiveBeautyDialogFragment(); @@ -548,7 +542,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl hasGame = mGameList.size() > 0; } bundle.putBoolean(Constants.HAS_GAME, hasGame); - bundle.putInt("leave",leave); + bundle.putInt("leave", leave); bundle.putBoolean(Constants.OPEN_FLASH, mLivePushViewHolder != null && mLivePushViewHolder.isFlashOpen()); fragment.setArguments(bundle); fragment.setFunctionClickListener(this); @@ -632,6 +626,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl } if (mLiveAnchorViewHolder == null) { mLiveAnchorViewHolder = new LiveRyAnchorViewHolder(mContext, mContainer); + mLiveAnchorViewHolder.setLiveBean(mLiveBean); mLiveAnchorViewHolder.addToParent(); } mLiveBottomViewHolder = mLiveAnchorViewHolder; @@ -869,18 +864,18 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl protected void onDestroy() { LiveHttpUtil.cancel(LiveHttpConsts.ANCHOR_CHECK_LIVE); super.onDestroy(); - if(mLivePushViewHolder!=null) { + if (mLivePushViewHolder != null) { mLivePushViewHolder.onDestroy(); } - if(mLiveReadyViewHolder!=null){ + if (mLiveReadyViewHolder != null) { mLiveReadyViewHolder.onDestroy(); } - if(mLiveAnchorViewHolder!=null){ + if (mLiveAnchorViewHolder != null) { mLiveAnchorViewHolder.onDestroy(); } - mLivePushViewHolder=null; - mLiveReadyViewHolder=null; - mLiveAnchorViewHolder=null; + mLivePushViewHolder = null; + mLiveReadyViewHolder = null; + mLiveAnchorViewHolder = null; L.e("LiveAnchorActivity-------onDestroy------->"); Bus.getOff(this); } @@ -1269,6 +1264,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl L.e(TAG, content); LogUtil.print(mLogFile, content); } + @Subscribe(threadMode = ThreadMode.MAIN) public void onOpenDrawer(LiveAudienceEvent event) { Bundle bundle = new Bundle(); diff --git a/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java index f6806a611..bcad3b1dc 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java @@ -1,25 +1,53 @@ package com.yunbao.live.views; +import static com.yunbao.live.activity.LiveActivity.mLiveUid; +import static com.yunbao.live.activity.LiveRyAnchorActivity.PKing; +import static com.yunbao.live.activity.LiveRyAnchorActivity.pk_nub; +import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.START_MESSAGE; +import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.leaveDRRoom; + import android.content.Context; import android.graphics.drawable.Drawable; -import androidx.core.content.ContextCompat; +import android.os.Bundle; +import android.text.TextUtils; +import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import androidx.core.content.ContextCompat; + +import com.blankj.utilcode.util.GsonUtils; +import com.ms.banner.Banner; +import com.ms.banner.BannerConfig; +import com.ms.banner.listener.OnBannerClickListener; import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.bean.BannerBean; +import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.bean.MsgModel; +import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.ToastUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveRyAnchorActivity; +import com.yunbao.live.activity.ZhuangBanActivity; +import com.yunbao.live.bean.WishlistModel; +import com.yunbao.live.dialog.LiveHDDialogFragment; +import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.http.LiveHttpUtil; -import static com.yunbao.live.activity.LiveRyAnchorActivity.PKing; -import static com.yunbao.live.activity.LiveRyAnchorActivity.pk_nub; -import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.leaveDRRoom; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.ArrayList; +import java.util.List; /** * Created by cxf on 2018/10/9. @@ -42,6 +70,10 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder { public static LinearLayout btn_start_dr_pk, btn_start_dr_pk_view, btn_end_pk; public static TextView btn_dr_pk_nub; TextView btn_dr; + private Banner mBanner; + private LiveBean mLiveBean; + private List mBannerList = new ArrayList<>(); + private String activityUrl; public LiveRyAnchorViewHolder(Context context, ViewGroup parentView) { @@ -56,10 +88,12 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder { @Override public void init() { super.init(); + Bus.getOn(this); mDrawable0 = ContextCompat.getDrawable(mContext, R.mipmap.icon_live_func_0); mDrawable1 = ContextCompat.getDrawable(mContext, R.mipmap.icon_live_func_1); mBtnFunction = (ImageView) findViewById(R.id.btn_function); btn_dr = (TextView) findViewById(R.id.btn_dr); + mBanner = (Banner) findViewById(R.id.banner); mBtnFunction.setImageDrawable(mDrawable0); mBtnFunction.setOnClickListener(this); mBtnGameClose = findViewById(R.id.btn_close_game); @@ -107,7 +141,7 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder { @Override public void onSuccess(int code, String msg, String[] info) { leaveDRRoom(); - PKing =false; + PKing = false; } }); @@ -118,9 +152,9 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder { btn_dr.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - if(PKing == false) { + if (PKing == false) { ((LiveRyAnchorActivity) mContext).openLinkMicAnchorWindow(true); - }else{ + } else { ToastUtil.show("您已在PK中"); } } @@ -177,6 +211,12 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder { ((LiveRyAnchorActivity) mContext).closeLive(); } + @Override + public void onDestroy() { + super.onDestroy(); + Bus.getOff(this); + } + /** * 显示功能弹窗 */ @@ -259,4 +299,236 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder { LiveHttpUtil.setLinkMicEnable(mLinkMicEnable, mChangeLinkMicCallback); } + @Subscribe(threadMode = ThreadMode.MAIN) + public void updateStart(LiveAudienceEvent event) { + if (event.getType() == START_MESSAGE) { + MsgModel msgModel = event.getMsgModel(); + StarChallengeStatusModel model = new StarChallengeStatusModel(activityUrl) + .setTaskNum(msgModel.getTaskNum()) + .setTaskName1(msgModel.getTaskName1()) + .setTaskName2(msgModel.getTaskName2()) + .setStarSrc(msgModel.getStarSrc()) + .setCurrentStarVal(msgModel.getCurrentStarVal()) + .setTargetStarVal(msgModel.getTargetStarVal()) + .setAssistSrc(msgModel.getAssistSrc()) + .setTargetAssistNum(msgModel.getTargetAssistNum()) + .setCurrentAssistNum(msgModel.getCurrentAssistNum()); + Log.i("测试", "更新星级任务=" + model); + showStart(model); + } + } + + public void initStarData() { + LiveNetManager.get(mContext) + .getStarChallengeStatus(mLiveUid, new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(StarChallengeStatusModel data1) { + activityUrl = data1.getActivityUrl(); + showStart(data1); + Log.e("PortraitLiveManager", data1.toString()); + } + + @Override + public void onError(String error) { + Log.e("PortraitLiveManager", error); + } + }); + } + + public void initWishList() { + LiveHttpUtil.getWishList(mLiveBean.getUid(), new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (info.length > 0) { + String json = info[0]; + WishlistModel model = GsonUtils.fromJson(json, WishlistModel.class); + if (model != null && model.getWishlist().size() > 0) { + BannerBean bannerModel = new BannerBean(); + bannerModel.setShow_type("2"); + bannerModel.setLink(CommonAppConfig.HOST + "/index.php"); + bannerModel.setImageUrl(model.getImg()); + addWishList(bannerModel); + + } + + } + } + + @Override + public void onFinish() { + + + } + }); + } + + public synchronized void showStart(StarChallengeStatusModel data) { + boolean upData = false; + if (mBannerList != null && mBannerList.size() == 0) { + Log.e("PortraitLiveManager", "直接添加星级任务"); + BannerBean bannerBean = new BannerBean(); + bannerBean.setStart(true); + bannerBean.setModel(data); + mBannerList.add(bannerBean); + } else { + Log.e("PortraitLiveManager", "遍历添加星级任务"); + for (BannerBean bean : mBannerList) { + 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); + mBannerList.add(bannerBean); + } + } + updateBanner(mBannerList); + } + + public void addWishList(BannerBean bannerModel) { + mBannerList.add(bannerModel); + updateBanner(mBannerList); + } + + + public void showBanner() { + if (mBannerList != null && mBanner != null) { + if (mBannerList.size() == 1) { + mBanner.setAutoPlay(false) + .setPages(mBannerList, new CustomViewHolder()) + .setDelayTime(3200) + .setBannerStyle(BannerConfig.NOT_INDICATOR) + .setOnBannerClickListener(new OnBannerClickListener() { + @Override + public void onBannerClick(List datas, int p) { + if (mBannerList != null) { + if (p >= 0 && p < mBannerList.size()) { + IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo(); + BannerBean bean = mBannerList.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("&nickname=") + .append(userInfo.getUserNicename()) + .append("&token=") + .append(userInfo.getToken()) + .append("&anchorUid=") + .append(mLiveUid) + .append("&uid=") + .append(userInfo.getId()) + .append("&k=") + .append(System.currentTimeMillis()); + } 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()); + } + if (TextUtils.equals(type, "1")) { + ZhuangBanActivity.forward(mContext, htmlUrl.toString(), false); + } else { + Bundle bundle = new Bundle(); + bundle.putString("url", htmlUrl.toString()); + LiveHDDialogFragment fragment = new LiveHDDialogFragment(); + fragment.setArguments(bundle); + fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); + } + } + } + } + }) + .start(); + } else { + mBanner.setAutoPlay(true) + .setPages(mBannerList, new CustomViewHolder()) + .setDelayTime(3200) + .setBannerStyle(BannerConfig.NOT_INDICATOR) + .setOnBannerClickListener(new OnBannerClickListener() { + @Override + public void onBannerClick(List datas, int p) { + if (mBannerList != null) { + if (p >= 0 && p < mBannerList.size()) { + IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo(); + BannerBean bean = mBannerList.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("&nickname=") + .append(userInfo.getUserNicename()) + .append("&token=") + .append(userInfo.getToken()) + .append("&anchorUid=") + .append(mLiveUid) + .append("&uid=") + .append(userInfo.getId()) + .append("&k=") + .append(System.currentTimeMillis()); + } 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"); + } + if (TextUtils.equals(type, "1")) { + ZhuangBanActivity.forward(mContext, htmlUrl.toString(), false); + } else { + Bundle bundle = new Bundle(); + bundle.putString("url", htmlUrl.toString()); + LiveHDDialogFragment fragment = new LiveHDDialogFragment(); + fragment.setArguments(bundle); + fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); + } + } + } + } + }) + .start(); + } + } + } + + public void updateBanner(List list) { + mBannerList = list; + mBanner.update(list); + if (mBannerList.size() > 1) { + mBanner.setAutoPlay(true); + } + } + + public void setLiveBean(LiveBean mLiveBean) { + this.mLiveBean = mLiveBean; + showBanner(); + initStarData(); + initWishList(); + } } diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 97f534fd2..a613dcd6e 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -172,7 +172,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe private boolean mCoinNotEnough;//余额不足 private boolean mFirstConnectSocket;//是否是第一次连接成功socket private int liveBg = -1; - private int leave=-1;//是否正在休息 1为休息 0为直播 + private int leave = -1;//是否正在休息 1为休息 0为直播 private LiveImDeletUtil liveImDeletUtil; private List greetings = new ArrayList<>(); private Handler liveHandler = new Handler(); @@ -1198,7 +1198,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.startRequestTimeCharge(); } } - if (leave==1) { + if (leave == 1) { if (LivePlayRyViewHolder.leave != null) { LivePlayRyViewHolder.leave.setVisibility(View.VISIBLE); } diff --git a/live/src/main/res/layout/view_ry_live_anchor.xml b/live/src/main/res/layout/view_ry_live_anchor.xml index 07f869d36..796bfaad5 100644 --- a/live/src/main/res/layout/view_ry_live_anchor.xml +++ b/live/src/main/res/layout/view_ry_live_anchor.xml @@ -1,11 +1,20 @@ - + android:orientation="vertical"> + + - + android:gravity="center" + android:orientation="vertical"> + android:textSize="12sp" /> - + android:textSize="8sp" /> @@ -46,43 +55,44 @@ android:layout_height="wrap_content" android:orientation="horizontal"> - + - + android:textColor="#ffffffff" + android:textSize="10sp" /> - + - - + + + android:textColor="#ffb1b1b1" + android:textSize="10sp" /> - + @@ -94,8 +104,8 @@ PK" android:layout_width="50dp" android:layout_height="50dp" android:layout_gravity="right" - android:layout_marginBottom="5dp" android:layout_marginRight="10dp" + android:layout_marginBottom="5dp" android:background="@drawable/bg_live_link_mic" android:gravity="center_horizontal" android:orientation="vertical" @@ -106,7 +116,7 @@ PK" android:layout_width="30dp" android:layout_height="30dp" android:layout_marginTop="2dp" - android:src="@mipmap/icon_live_link_mic"/> + android:src="@mipmap/icon_live_link_mic" /> + android:visibility="invisible" /> + android:visibility="gone" />