diff --git a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java index 490a9d61d..ccc77a95f 100644 --- a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java +++ b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java @@ -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); diff --git a/common/src/main/java/com/yunbao/common/manager/NewLevelManager.java b/common/src/main/java/com/yunbao/common/manager/NewLevelManager.java index 1972cef00..919da14af 100644 --- a/common/src/main/java/com/yunbao/common/manager/NewLevelManager.java +++ b/common/src/main/java/com/yunbao/common/manager/NewLevelManager.java @@ -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 newLevelModels = new ArrayList<>(); + private List 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>() { }.getType()); } + /** + * 缓存等级图标 + * + * @param json + */ + public void UpAnchorDataLevel(String json) { + newLevelModels = new Gson().fromJson(json, new TypeToken>() { + }.getType()); + put(KEY_ANCHOR_LEVEL, newLevelModels); + } + /** + * 获取等级数据 + * + * @return + */ + public List getNewAnchorLevelModels() { + return getList(KEY_ANCHOR_LEVEL, new TypeToken>() { + }.getType()); + } } diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index eed08e737..7bb2a6f38 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -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;//是否开始了播放 @@ -87,7 +88,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { public static ImageView leave; private boolean mPausedPlay;//是否被动暂停了播放 - public int landscape; //1h 2s + public int landscape; //1h 2s public static Context contexts; public V2TXLivePlayer mPlayer; public static FrameLayout ry_view; @@ -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); 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 fb83f8566..85036ea1c 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -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() { diff --git a/live/src/main/res/layout/view_live_play_ksy.xml b/live/src/main/res/layout/view_live_play_ksy.xml index a9d4c4e45..b136c4bc5 100644 --- a/live/src/main/res/layout/view_live_play_ksy.xml +++ b/live/src/main/res/layout/view_live_play_ksy.xml @@ -1,41 +1,38 @@ - + android:layout_height="match_parent"> + android:layout_height="match_parent" /> + android:visibility="gone" /> + android:layout_marginTop="@dimen/live_top"> + android:layout_marginBottom="20dp" /> + app:mfl3_ratio="0.25" /> - + + + android:scaleType="centerCrop" /> - - + + \ No newline at end of file diff --git a/main/src/main/java/com/yunbao/main/views/SearchResultsViewHolder.java b/main/src/main/java/com/yunbao/main/views/SearchResultsViewHolder.java index fe269ffa3..4b88cace8 100644 --- a/main/src/main/java/com/yunbao/main/views/SearchResultsViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/SearchResultsViewHolder.java @@ -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 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(); + } + } + leave.setText(model.getLevelAnchor()); + ImgLoader.display(itemView.getContext(), imgUrl, contribute); } - isLive.setVisibility(model.getIslive() == 0 ? View.GONE : View.VISIBLE); + } if (model.getSex() == 2) { diff --git a/main/src/main/res/layout/view_search_results_item_holder.xml b/main/src/main/res/layout/view_search_results_item_holder.xml index e3c11a58a..ca95a0eb7 100644 --- a/main/src/main/res/layout/view_search_results_item_holder.xml +++ b/main/src/main/res/layout/view_search_results_item_holder.xml @@ -13,8 +13,8 @@ + android:layout_height="55dp" + android:scaleType="centerCrop" /> - - + android:layout_height="19dp"> + + + + + + +