新增搜索主播等级标志,

This commit is contained in:
18401019693 2022-11-30 09:44:37 +08:00
parent 6f2a893a4e
commit 5cc521d93c
7 changed files with 162 additions and 67 deletions

View File

@ -195,6 +195,10 @@ public class CommonHttpUtil {
JSONArray levelArray = obj.getJSONArray("level_new");
new NewLevelManager(context).UpDataLevel(levelArray.toJSONString());
}
if (obj.containsKey("levelanchor_new")) {//缓存等级数据
JSONArray levelArray = obj.getJSONArray("levelanchor_new");
new NewLevelManager(context).UpAnchorDataLevel(levelArray.toJSONString());
}
} catch (Exception e) {
String error = "info[0]:" + info[0] + "\n\n\n" + "Exception:" + e.getClass() + "---message--->" + e.getMessage();
ErrorActivity.forward("GetConfig接口返回数据异常", error);

View File

@ -15,7 +15,9 @@ import java.util.List;
*/
public class NewLevelManager extends BaseCacheManager {
private final String KEY_USER_LEVEL = "keyUserLevel";
private final String KEY_ANCHOR_LEVEL = "keyAnchorLevel";
private List<NewLevelModel> newLevelModels = new ArrayList<>();
private List<NewLevelModel> keyAnchorLevel = new ArrayList<>();
public NewLevelManager(Context context) {
super(context);
@ -41,5 +43,24 @@ public class NewLevelManager extends BaseCacheManager {
return getList(KEY_USER_LEVEL, new TypeToken<List<NewLevelModel>>() {
}.getType());
}
/**
* 缓存等级图标
*
* @param json
*/
public void UpAnchorDataLevel(String json) {
newLevelModels = new Gson().fromJson(json, new TypeToken<List<NewLevelModel>>() {
}.getType());
put(KEY_ANCHOR_LEVEL, newLevelModels);
}
/**
* 获取等级数据
*
* @return
*/
public List<NewLevelModel> getNewAnchorLevelModels() {
return getList(KEY_ANCHOR_LEVEL, new TypeToken<List<NewLevelModel>>() {
}.getType());
}
}

View File

@ -1,5 +1,8 @@
package com.yunbao.live.views;
import static com.lzy.okgo.utils.HttpUtils.runOnUiThread;
import static cn.rongcloud.rtc.core.RendererCommon.ScalingType.SCALE_ASPECT_FILL;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
@ -17,6 +20,7 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.alibaba.fastjson.JSON;
import com.lzy.okserver.OkDownload;
import com.lzy.okserver.download.DownloadTask;
import com.tencent.live2.V2TXLiveDef;
@ -30,12 +34,12 @@ import com.yunbao.common.http.HttpClient;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.MicStatusManager;
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.live.activity.LiveActivity;
import com.yunbao.common.utils.MicStatusManager;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@ -66,9 +70,6 @@ import cn.rongcloud.rtc.base.RCRTCParamsType;
import cn.rongcloud.rtc.base.RCRTCRoomType;
import cn.rongcloud.rtc.base.RTCErrorCode;
import static cn.rongcloud.rtc.core.RendererCommon.ScalingType.SCALE_ASPECT_FILL;
import static com.lzy.okgo.utils.HttpUtils.runOnUiThread;
public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
private static final String TAG = "LivePlayViewHolder";
@ -79,7 +80,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
private RelativeLayout mPkContainer;
public static TXCloudVideoView mVideoView;
private View mLoading;
private View mLoading,mLoading2;
private ImageView mCover;
private boolean mPaused;//是否切后台了
private boolean mStarted;//是否开始了播放
@ -115,7 +116,6 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
}
@Override
protected int getLayoutId() {
return R.layout.view_live_play_ksy;
@ -133,6 +133,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
ry_view = (FrameLayout) findViewById(R.id.ry_view);
leave = (ImageView) findViewById(R.id.leave);
mLoading = findViewById(R.id.loading);
mLoading2 = findViewById(R.id.loading2);
mCover = (ImageView) findViewById(R.id.cover);
ScreenDimenUtil util = ScreenDimenUtil.getInstance();
int mScreenWdith = util.getScreenWdith();
@ -147,16 +148,29 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
@Override
public void hideCover() {
if (mCover != null) {
mCover.animate().alpha(0).setDuration(500).start();
}
// if (mCover != null) {
// if (mCover.getVisibility()==View.VISIBLE){
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// mCover.setVisibility(View.GONE);
// mLoading2.setVisibility(View.GONE);
// }
// },200);
// }
//
//
// }
}
@Override
public void setCover(String coverUrl) {
if (mCover != null) {
ImgLoader.displayBlur(mContext, coverUrl, mCover);
}
// if (mCover != null) {
// mCover.setVisibility(View.VISIBLE);
// mLoading2.setVisibility(View.VISIBLE);
// ImgLoader.displayBlurLive(mContext, coverUrl, mCover, 400, 600);
//
// }
}
@Override
@ -174,6 +188,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
params1.topMargin = 0;
ry_view.setLayoutParams(params1);
ry_view.requestLayout();
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params2.topMargin = 0;
mCover.setLayoutParams(params2);
mCover.requestLayout();
} else {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
@ -189,8 +208,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
params1.addRule(RelativeLayout.ALIGN_TOP);
ry_view.setLayoutParams(params1);
ry_view.requestLayout();
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = DpUtil.dp2px(270);
params2.topMargin = DpUtil.dp2px(120);
mCover.setLayoutParams(params2);
mCover.requestLayout();
}
hideCover();
}
/**
@ -226,7 +249,6 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
if (TextUtils.isEmpty(url) || mVideoView == null) {
return;
}
//mPlayer.setCacheParams(1.0f, 5.0f);
mVideoView.clearLastFrame(true);
mPlayer.setObserver(new V2TXLivePlayerObserver() {
String TAG = "播放流";
@ -295,11 +317,14 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
break;
case 5:
buffer.append("完成");
break;
}
buffer.append("|");
}
//Log.i(TAG, "onStatisticsUpdate: " + JSON.toJSONString(statistics) + " |当前下载数 : " + OkDownload.getInstance().getTaskMap().size() + buffer);
hideCover();
Log.i(TAG, "onStatisticsUpdate: " + JSON.toJSONString(statistics) + " |当前下载数 : " + OkDownload.getInstance().getTaskMap().size() + buffer);
if (statistics.fps == 0) {
OkDownload.getInstance().pauseAll();
} else {
@ -324,7 +349,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
});
purl = url;
mPlayer.startPlay(url);
int V2TXLiveCode = mPlayer.startPlay(url);
onPrepared();
}
@ -394,7 +419,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
params1.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params1.topMargin = 0;
ry_view.requestLayout();
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params2.topMargin = 0;
mCover.setLayoutParams(params2);
mCover.requestLayout();
} else {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = vHeight;
@ -407,8 +436,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params1.addRule(RelativeLayout.ALIGN_TOP);
ry_view.requestLayout();
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = DpUtil.dp2px(270);
params2.topMargin = DpUtil.dp2px(120);
mCover.setLayoutParams(params2);
mCover.requestLayout();
}
hideCover();
}
@Override
@ -611,7 +644,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
rcrtcRoom = null;
MicStatusManager.getInstance().clear();
ToastUtil.show("已成功退出語音連麥");
if(onMicCallback!=null){
if (onMicCallback != null) {
onMicCallback.onMikUpdate();
}
}
@ -825,7 +858,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
Log.e("ry", "切换成功");
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
if(onMicCallback!=null){
if (onMicCallback != null) {
onMicCallback.onMikUpdate();
}
//遍历远端用户列表
@ -854,7 +887,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
@Override
public void onSuccess() {
Log.e("ry", "订阅资源成功");
MicStatusManager.getInstance().setMicData(MicStatusManager.MIC_TYPE_OPEN,LiveActivity.mLiveUid);
MicStatusManager.getInstance().setMicData(MicStatusManager.MIC_TYPE_OPEN, LiveActivity.mLiveUid);
AudioManager audioManager = (AudioManager) contexts.getSystemService(Context.AUDIO_SERVICE);
RCRTCEngine.getInstance().enableSpeaker(true);
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);

View File

@ -269,9 +269,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack, 400, 600);
//ImageLoadUtils.loadUrlToBlur(mContext,mLiveBean.getAvatar(),400,600,liveBack);
mask.setVisibility(View.VISIBLE);
mLivePlayViewHolder.setLiveBean(data);
mLivePlayViewHolder.setCover(data.getThumb());
mLivePlayViewHolder.play(data.getPull());
mLivePlayViewHolder.setLiveBean(mLiveBean);
mLivePlayViewHolder.setCover(mLiveBean.getAvatar());
mLivePlayViewHolder.play(mLiveBean.getPull());
mLivePlayViewHolder.setOnMicCallback(new LiveRoomPlayViewHolder.OnMicCallback() {
@Override
public void onMikUpdate() {

View File

@ -1,41 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:animateLayoutChanges="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
android:layout_height="match_parent">
<com.tencent.rtmp.ui.TXCloudVideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent" />
<ImageView
android:id="@+id/leave"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:scaleType="centerCrop"
android:src="@mipmap/zslk"
android:visibility="gone"
android:scaleType="centerCrop"/>
android:visibility="gone" />
<RelativeLayout
android:id="@+id/pk_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/live_top"
>
android:layout_marginTop="@dimen/live_top">
<com.yunbao.live.custom.MyFrameLayout4
android:id="@+id/left_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
/>
android:layout_marginBottom="20dp" />
<com.yunbao.live.custom.MyFrameLayout4
android:id="@+id/right_container"
@ -51,34 +48,43 @@
android:id="@+id/small_container"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="120dp"
app:mfl3_ratio="0.25"
/>
app:mfl3_ratio="0.25" />
<ProgressBar
android:id="@+id/loading"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:indeterminateBehavior="repeat"
android:indeterminateDrawable="@drawable/anim_loading"
android:indeterminateOnly="true"
android:visibility="invisible"
/>
<FrameLayout
android:id="@+id/ry_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/cover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
/>
android:scaleType="centerCrop" />
<FrameLayout android:id="@+id/ry_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ProgressBar
android:id="@+id/loading"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginTop="240dp"
android:layout_centerHorizontal="true"
android:indeterminateBehavior="repeat"
android:indeterminateDrawable="@drawable/anim_loading"
android:indeterminateOnly="true"
android:visibility="invisible" />
<ProgressBar
android:id="@+id/loading2"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginTop="240dp"
android:layout_centerHorizontal="true"
android:indeterminateBehavior="repeat"
android:indeterminateDrawable="@drawable/anim_loading"
android:indeterminateOnly="true"
android:visibility="invisible" />
</RelativeLayout>

View File

@ -15,17 +15,21 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.bean.LevelBean;
import com.yunbao.common.bean.NewLevelModel;
import com.yunbao.common.bean.SearchModel;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.manager.NewLevelManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.WordsTypeUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.main.R;
import com.yunbao.main.event.JumpUserHomeEvent;
import com.yunbao.common.utils.WordsTypeUtil;
import java.util.List;
public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
private ImageView avatar, isLive, sex, focusOn, contribute;
private TextView nickName;
private TextView nickName, leave;
private LinearLayout nickLayout;
private RelativeLayout avatarLayout;
private SearchModel model;
@ -41,6 +45,7 @@ public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
super(itemView);
avatar = itemView.findViewById(R.id.avatar);
isLive = itemView.findViewById(R.id.is_live);
leave = itemView.findViewById(R.id.leave);
sex = itemView.findViewById(R.id.sex);
focusOn = itemView.findViewById(R.id.focus_on);
nickName = itemView.findViewById(R.id.nick_name);
@ -76,11 +81,21 @@ public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
}
isLive.setVisibility(View.GONE);
} else {
LevelBean anchorLevelBean = CommonAppConfig.getInstance().getAnchorLevel(Integer.parseInt(model.getLevelAnchor()));
if (anchorLevelBean != null) {
ImgLoader.display(isLive.getContext(), CommonAppConfig.getInstance().HOST + anchorLevelBean.getThumb(), contribute);
List<NewLevelModel> models = new NewLevelManager(itemView.getContext()).getNewAnchorLevelModels();
int anchorLevel = 0;
if (!TextUtils.isEmpty(model.getLevelAnchor())) {
anchorLevel = Integer.parseInt(model.getLevelAnchor());
String imgUrl = "";
for (NewLevelModel newLevelModel : models) {
if (newLevelModel.getLeveMin() <= anchorLevel && anchorLevel <= newLevelModel.getLeveMax()) {
imgUrl = newLevelModel.getThumb();
}
isLive.setVisibility(model.getIslive() == 0 ? View.GONE : View.VISIBLE);
}
leave.setText(model.getLevelAnchor());
ImgLoader.display(itemView.getContext(), imgUrl, contribute);
}
}
if (model.getSex() == 2) {

View File

@ -13,8 +13,8 @@
<com.yunbao.common.views.weight.ClipPathCircleImage
android:id="@+id/avatar"
android:layout_width="55dp"
android:scaleType="centerCrop"
android:layout_height="55dp" />
android:layout_height="55dp"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/is_live"
@ -52,11 +52,27 @@
android:layout_height="19dp"
android:src="@mipmap/icon_sex_female_1" />
<FrameLayout
android:layout_width="55dp"
android:layout_height="19dp">
<ImageView
android:id="@+id/contribute"
android:layout_width="55dp"
android:layout_height="19dp" />
<TextView
android:id="@+id/leave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:layout_gravity="center_vertical"
android:layout_marginStart="28dp"
android:textStyle="bold"
android:textSize="10sp" />
</FrameLayout>
</LinearLayout>
</LinearLayout>