修复直播间点击三个点--更多设置--举报闪退的问题(网速慢一点的情况下)

This commit is contained in:
老皮 2024-09-23 13:14:08 +08:00
parent 0646c2c6a7
commit d79dba045d
2 changed files with 88 additions and 9 deletions

View File

@ -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<LiveReportBean> 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();
}

View File

@ -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<LiveReportBean> 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<LiveReportBean> 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;
}
}