新增搜索主播等级标志,

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"); JSONArray levelArray = obj.getJSONArray("level_new");
new NewLevelManager(context).UpDataLevel(levelArray.toJSONString()); 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) { } catch (Exception e) {
String error = "info[0]:" + info[0] + "\n\n\n" + "Exception:" + e.getClass() + "---message--->" + e.getMessage(); String error = "info[0]:" + info[0] + "\n\n\n" + "Exception:" + e.getClass() + "---message--->" + e.getMessage();
ErrorActivity.forward("GetConfig接口返回数据异常", error); ErrorActivity.forward("GetConfig接口返回数据异常", error);

View File

@ -15,7 +15,9 @@ import java.util.List;
*/ */
public class NewLevelManager extends BaseCacheManager { public class NewLevelManager extends BaseCacheManager {
private final String KEY_USER_LEVEL = "keyUserLevel"; private final String KEY_USER_LEVEL = "keyUserLevel";
private final String KEY_ANCHOR_LEVEL = "keyAnchorLevel";
private List<NewLevelModel> newLevelModels = new ArrayList<>(); private List<NewLevelModel> newLevelModels = new ArrayList<>();
private List<NewLevelModel> keyAnchorLevel = new ArrayList<>();
public NewLevelManager(Context context) { public NewLevelManager(Context context) {
super(context); super(context);
@ -41,5 +43,24 @@ public class NewLevelManager extends BaseCacheManager {
return getList(KEY_USER_LEVEL, new TypeToken<List<NewLevelModel>>() { return getList(KEY_USER_LEVEL, new TypeToken<List<NewLevelModel>>() {
}.getType()); }.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; 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.app.Dialog;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
@ -17,6 +20,7 @@ import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import com.alibaba.fastjson.JSON;
import com.lzy.okserver.OkDownload; import com.lzy.okserver.OkDownload;
import com.lzy.okserver.download.DownloadTask; import com.lzy.okserver.download.DownloadTask;
import com.tencent.live2.V2TXLiveDef; 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.DialogUitl;
import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.common.utils.ScreenDimenUtil;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R; import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveActivity;
import com.yunbao.common.utils.MicStatusManager;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; 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.RCRTCRoomType;
import cn.rongcloud.rtc.base.RTCErrorCode; 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 { public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
private static final String TAG = "LivePlayViewHolder"; private static final String TAG = "LivePlayViewHolder";
@ -79,7 +80,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
private RelativeLayout mPkContainer; private RelativeLayout mPkContainer;
public static TXCloudVideoView mVideoView; public static TXCloudVideoView mVideoView;
private View mLoading; private View mLoading,mLoading2;
private ImageView mCover; private ImageView mCover;
private boolean mPaused;//是否切后台了 private boolean mPaused;//是否切后台了
private boolean mStarted;//是否开始了播放 private boolean mStarted;//是否开始了播放
@ -115,7 +116,6 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
} }
@Override @Override
protected int getLayoutId() { protected int getLayoutId() {
return R.layout.view_live_play_ksy; return R.layout.view_live_play_ksy;
@ -133,6 +133,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
ry_view = (FrameLayout) findViewById(R.id.ry_view); ry_view = (FrameLayout) findViewById(R.id.ry_view);
leave = (ImageView) findViewById(R.id.leave); leave = (ImageView) findViewById(R.id.leave);
mLoading = findViewById(R.id.loading); mLoading = findViewById(R.id.loading);
mLoading2 = findViewById(R.id.loading2);
mCover = (ImageView) findViewById(R.id.cover); mCover = (ImageView) findViewById(R.id.cover);
ScreenDimenUtil util = ScreenDimenUtil.getInstance(); ScreenDimenUtil util = ScreenDimenUtil.getInstance();
int mScreenWdith = util.getScreenWdith(); int mScreenWdith = util.getScreenWdith();
@ -147,16 +148,29 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
@Override @Override
public void hideCover() { public void hideCover() {
if (mCover != null) { // if (mCover != null) {
mCover.animate().alpha(0).setDuration(500).start(); // if (mCover.getVisibility()==View.VISIBLE){
} // new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// mCover.setVisibility(View.GONE);
// mLoading2.setVisibility(View.GONE);
// }
// },200);
// }
//
//
// }
} }
@Override @Override
public void setCover(String coverUrl) { public void setCover(String coverUrl) {
if (mCover != null) { // if (mCover != null) {
ImgLoader.displayBlur(mContext, coverUrl, mCover); // mCover.setVisibility(View.VISIBLE);
} // mLoading2.setVisibility(View.VISIBLE);
// ImgLoader.displayBlurLive(mContext, coverUrl, mCover, 400, 600);
//
// }
} }
@Override @Override
@ -174,6 +188,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
params1.topMargin = 0; params1.topMargin = 0;
ry_view.setLayoutParams(params1); ry_view.setLayoutParams(params1);
ry_view.requestLayout(); 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 { } else {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
@ -189,8 +208,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
params1.addRule(RelativeLayout.ALIGN_TOP); params1.addRule(RelativeLayout.ALIGN_TOP);
ry_view.setLayoutParams(params1); ry_view.setLayoutParams(params1);
ry_view.requestLayout(); 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) { if (TextUtils.isEmpty(url) || mVideoView == null) {
return; return;
} }
//mPlayer.setCacheParams(1.0f, 5.0f);
mVideoView.clearLastFrame(true); mVideoView.clearLastFrame(true);
mPlayer.setObserver(new V2TXLivePlayerObserver() { mPlayer.setObserver(new V2TXLivePlayerObserver() {
String TAG = "播放流"; String TAG = "播放流";
@ -295,11 +317,14 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
break; break;
case 5: case 5:
buffer.append("完成"); buffer.append("完成");
break; break;
} }
buffer.append("|"); 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) { if (statistics.fps == 0) {
OkDownload.getInstance().pauseAll(); OkDownload.getInstance().pauseAll();
} else { } else {
@ -324,7 +349,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
}); });
purl = url; purl = url;
mPlayer.startPlay(url); int V2TXLiveCode = mPlayer.startPlay(url);
onPrepared(); onPrepared();
} }
@ -394,7 +419,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
params1.height = RelativeLayout.LayoutParams.MATCH_PARENT; params1.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params1.topMargin = 0; params1.topMargin = 0;
ry_view.requestLayout(); 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 { } else {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = vHeight; params.height = vHeight;
@ -407,8 +436,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params1.addRule(RelativeLayout.ALIGN_TOP); params1.addRule(RelativeLayout.ALIGN_TOP);
ry_view.requestLayout(); 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 @Override

View File

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

View File

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

View File

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

View File

@ -13,8 +13,8 @@
<com.yunbao.common.views.weight.ClipPathCircleImage <com.yunbao.common.views.weight.ClipPathCircleImage
android:id="@+id/avatar" android:id="@+id/avatar"
android:layout_width="55dp" android:layout_width="55dp"
android:scaleType="centerCrop" android:layout_height="55dp"
android:layout_height="55dp" /> android:scaleType="centerCrop" />
<ImageView <ImageView
android:id="@+id/is_live" android:id="@+id/is_live"
@ -52,11 +52,27 @@
android:layout_height="19dp" android:layout_height="19dp"
android:src="@mipmap/icon_sex_female_1" /> android:src="@mipmap/icon_sex_female_1" />
<FrameLayout
android:layout_width="55dp"
android:layout_height="19dp">
<ImageView <ImageView
android:id="@+id/contribute" android:id="@+id/contribute"
android:layout_width="55dp" android:layout_width="55dp"
android:layout_height="19dp" /> 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>
</LinearLayout> </LinearLayout>