diff --git a/common/src/main/java/com/yunbao/common/http/base/CheckLiveCallBack.java b/common/src/main/java/com/yunbao/common/http/base/CheckLiveCallBack.java index 56e1d2067..ee90bcb57 100644 --- a/common/src/main/java/com/yunbao/common/http/base/CheckLiveCallBack.java +++ b/common/src/main/java/com/yunbao/common/http/base/CheckLiveCallBack.java @@ -26,5 +26,5 @@ public interface CheckLiveCallBack { * * @param error */ - void onError(String error); + void onError(String error,int code); } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 7631dc829..a42aa216a 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -426,12 +426,12 @@ public class LiveNetManager { } } else { if (callBack != null) { - callBack.onError(listResponseModel.getData().getMsg()); + callBack.onError(listResponseModel.getData().getMsg(), listResponseModel.getData().getCode()); } } } else { if (callBack != null) { - callBack.onError(listResponseModel.getData().getMsg()); + callBack.onError(listResponseModel.getData().getMsg(), listResponseModel.getData().getCode()); } } } @@ -440,7 +440,7 @@ public class LiveNetManager { public void accept(Throwable throwable) throws Exception { Log.e("异常", "checkLive: ", throwable); if (callBack != null) { - callBack.onError(throwable.getMessage()); + callBack.onError(throwable.getMessage(), -1008611); } } }).isDisposed(); diff --git a/common/src/main/java/com/yunbao/common/utils/LiveRoomCheckLivePresenter.java b/common/src/main/java/com/yunbao/common/utils/LiveRoomCheckLivePresenter.java index 6c7d2d6f3..a3eb49433 100644 --- a/common/src/main/java/com/yunbao/common/utils/LiveRoomCheckLivePresenter.java +++ b/common/src/main/java/com/yunbao/common/utils/LiveRoomCheckLivePresenter.java @@ -43,8 +43,9 @@ public class LiveRoomCheckLivePresenter { * @param context 上下文 * @param liveUid 直播间ID * @param stream + * @param isPk 是否是pk时点击头像打开弹窗后跳转来的 */ - public LiveRoomCheckLivePresenter(Context context, String liveUid, String stream, NewActionListener actionListener) { + public LiveRoomCheckLivePresenter(Context context, String liveUid, String stream, NewActionListener actionListener,boolean... isPk) { mContext = context; LiveNetManager.get(context) .checkLive(liveUid, stream, new CheckLiveCallBack() { @@ -106,9 +107,14 @@ public class LiveRoomCheckLivePresenter { } @Override - public void onError(String error) { - Log.e("直播间异常", "onError: " + error); - Bus.get().post(new LiveErrorEvent()); + public void onError(String error,int code) { + Log.e("直播间异常", "onError: " + error + " code = " + code); + if (code == 1004 && isPk != null && isPk.length > 0 && isPk[0]) { + // 1004 为用户被踢过,不能进入直播间但是不能随机再进入别的直播间 + Log.e("直播间异常", "onError: " + error + " code = " + code); + }else { + Bus.get().post(new LiveErrorEvent()); + } ToastUtil.show(error); } }); diff --git a/live/src/main/java/com/yunbao/live/activity/LiveReportActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveReportActivity.java index 6be9e8cf9..137c8453d 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveReportActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveReportActivity.java @@ -80,16 +80,18 @@ public class LiveReportActivity extends AbsActivity implements LiveReportAdapter mRecyclerView.setHasFixedSize(true); mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); mKeyBoardHeightUtil = new KeyBoardHeightUtil(mContext, findViewById(android.R.id.content), this); + mAdapter = new LiveReportAdapter(mContext); + if (mRecyclerView != null) { + mRecyclerView.setAdapter(mAdapter); + } LiveHttpUtil.getLiveReportList(new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { if (code == 0) { List list = JSON.parseArray(Arrays.toString(info), LiveReportBean.class); - mAdapter = new LiveReportAdapter(mContext, list); mAdapter.setActionListener(LiveReportActivity.this); - if (mRecyclerView != null) { - mRecyclerView.setAdapter(mAdapter); - } + mAdapter.setData(list); + if (mKeyBoardHeightUtil != null) { mKeyBoardHeightUtil.start(); } diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveReportAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveReportAdapter.java index 052e063fa..bc65cadbf 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveReportAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveReportAdapter.java @@ -1,5 +1,7 @@ package com.yunbao.live.adapter; +import android.annotation.SuppressLint; +import android.app.Activity; import android.content.Context; import android.graphics.drawable.Drawable; import androidx.annotation.NonNull; @@ -52,14 +54,92 @@ public class LiveReportAdapter extends RecyclerView.Adapter { private int photoIndex = 0; private File mFile1, mFile2, mFile3; + + + public LiveReportAdapter(Context context, List list) { - mContext = context; + /* mContext = context; mList = list; mInflater = LayoutInflater.from(context); mCheckedDrawable = ContextCompat.getDrawable(context, R.mipmap.icon_cash_radio_1); mUnCheckedDrawable = ContextCompat.getDrawable(context, R.mipmap.icon_cash_radio_0); mCheckedPosition = -1; + imageUtilInit();*/ + mOnClickListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + Object tag = v.getTag(); + if (tag == null) { + return; + } + int position = (int) tag; + LiveReportBean bean = mList.get(position - 1); + if (mCheckedPosition == position) { + bean.setChecked(false); + notifyItemChanged(position, Constants.PAYLOAD); + mCheckedPosition = -1; + mCurVideoReportBean = null; + } else { + if (mCheckedPosition >= 0) { + mList.get(mCheckedPosition - 1).setChecked(false); + notifyItemChanged(mCheckedPosition, Constants.PAYLOAD); + } + bean.setChecked(true); + notifyItemChanged(position, Constants.PAYLOAD); + mCheckedPosition = position; + mCurVideoReportBean = bean; + } + } + }; + mReportListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + if (v.getId() == R.id.btn_report){ + if (mFootVh != null) { + mFootVh.submit(); + } + }else if (v.getId() == R.id.photo1){ + photoIndex = 0; + if (mFootVh != null) { + mFootVh.showAddPhoto(); + } + } + else if (v.getId() == R.id.photo2){ + photoIndex = 1; + if (mFootVh != null) { + mFootVh.showAddPhoto(); + } + } + else if (v.getId() == R.id.photo3){ + photoIndex = 2; + if (mFootVh != null) { + mFootVh.showAddPhoto(); + } + } + + } + }; + } + + + public void setActionListener(ActionListener actionListener) { + mActionListener = actionListener; + } + + @SuppressLint("NotifyDataSetChanged") + public void setData(List list) { + mList = list; + notifyDataSetChanged(); + } + + public LiveReportAdapter(Activity context) { + this.mContext = context; + mInflater = LayoutInflater.from(context); + mCheckedDrawable = ContextCompat.getDrawable(context, R.mipmap.icon_cash_radio_1); + mUnCheckedDrawable = ContextCompat.getDrawable(context, R.mipmap.icon_cash_radio_0); + mCheckedPosition = -1; imageUtilInit(); + mOnClickListener = new View.OnClickListener() { @Override public void onClick(View v) { @@ -196,7 +276,7 @@ public class LiveReportAdapter extends RecyclerView.Adapter { @Override public int getItemCount() { - return mList.size() + 2; + return mList == null ? 0 : mList.size() + 2; } class HeadVh extends RecyclerView.ViewHolder { @@ -272,7 +352,4 @@ public class LiveReportAdapter extends RecyclerView.Adapter { void onReportClick(LiveReportBean bean, String text,File file1,File file2,File file3); } - public void setActionListener(ActionListener actionListener) { - mActionListener = actionListener; - } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java index 8e23a8a9c..cfd746637 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java @@ -681,7 +681,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On public void onCheckError(String contextError) { } - }); + },true); } } }); diff --git a/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java b/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java index d7917ade1..4bcc60620 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java @@ -201,6 +201,8 @@ public class SocketSwClient { SocketReceiveBean received = JSON.parseObject(socketMsg, SocketReceiveBean.class); JSONObject map = received.getMsg().getJSONObject(0); + L.e("收到IM数据--->" + map.toString()); + String ct=""; switch (map.getString("_method_")) { //用户连麦