From c57486b69c4dd4a124a3ad1a32bcac1a692f6aeb Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Wed, 2 Nov 2022 18:11:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E7=AD=89?= =?UTF-8?q?=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/bean/NewLevelModel.java | 62 +++++++++++++++++++ .../yunbao/common/http/CommonHttpUtil.java | 6 ++ .../yunbao/common/manager/IMLoginManager.java | 24 +++---- .../common/manager/NewLevelManager.java | 45 ++++++++++++++ config.gradle | 4 +- .../presenter/LiveLinkMicAnchorPresenter.java | 15 +---- .../live/presenter/LiveLinkMicPresenter.java | 14 +---- .../com/yunbao/live/utils/LiveTextRender.java | 37 +++-------- .../live/views/LiveAudienceViewHolder.java | 8 +-- 9 files changed, 144 insertions(+), 71 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/bean/NewLevelModel.java create mode 100644 common/src/main/java/com/yunbao/common/manager/NewLevelManager.java diff --git a/common/src/main/java/com/yunbao/common/bean/NewLevelModel.java b/common/src/main/java/com/yunbao/common/bean/NewLevelModel.java new file mode 100644 index 000000000..4b666f6c1 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/NewLevelModel.java @@ -0,0 +1,62 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +/** + * 新用户等级牌 + */ +public class NewLevelModel extends BaseModel { + + @SerializedName("id") + private String id; + @SerializedName("levemin") + private String levemin; + @SerializedName("levemax") + private String levemax; + @SerializedName("thumb") + private String thumb; + + public String getId() { + return id; + } + + public NewLevelModel setId(String id) { + this.id = id; + return this; + } + + public String getLevemin() { + return levemin; + } + + public int getLeveMin() { + return Integer.parseInt(levemin); + } + + public int getLeveMax() { + return Integer.parseInt(levemax); + } + + public NewLevelModel setLevemin(String levemin) { + this.levemin = levemin; + return this; + } + + public String getLevemax() { + return levemax; + } + + public NewLevelModel setLevemax(String levemax) { + this.levemax = levemax; + return this; + } + + public String getThumb() { + return thumb; + } + + public NewLevelModel setThumb(String thumb) { + this.thumb = thumb; + return this; + } +} 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 8e28515e7..af8e85523 100644 --- a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java +++ b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java @@ -6,6 +6,7 @@ import android.util.Log; import com.adjust.sdk.Adjust; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.lzy.okgo.OkGo; import com.lzy.okgo.callback.StringCallback; @@ -18,6 +19,7 @@ import com.yunbao.common.bean.ConfigBean; import com.yunbao.common.event.FollowEvent; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.manager.NewLevelManager; import com.yunbao.common.utils.L; import com.yunbao.common.utils.MD5Util; import com.yunbao.common.utils.SpUtil; @@ -190,6 +192,10 @@ public class CommonHttpUtil { if (obj.containsKey("is_chat")) { IMLoginManager.get(context).initChat(String.valueOf(obj.getInteger("is_chat"))); } + if (obj.containsKey("level_new")) {//缓存等级数据 + JSONArray levelArray = obj.getJSONArray("level_new"); + new NewLevelManager(context).UpDataLevel(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/IMLoginManager.java b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java index 9a5465fcc..1346b4382 100644 --- a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java +++ b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java @@ -7,8 +7,10 @@ import android.text.TextUtils; import androidx.annotation.NonNull; +import com.cosmos.baseutil.app.AppContext; import com.google.gson.Gson; import com.lzf.easyfloat.EasyFloat; +import com.yunbao.common.CommonAppContext; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.event.DataUserInfoEvent; import com.yunbao.common.http.HttpCallback; @@ -25,18 +27,18 @@ import org.greenrobot.eventbus.EventBus; * 登录者信息管理 */ public class IMLoginManager extends BaseCacheManager { - private final static String KEY_USER_INFO = "keyUserInfo"; + private final String KEY_USER_INFO = "keyUserInfo"; private static IMLoginManager manager; private IMLoginModel userInfo; - private final static String isNewUserGif = "isNewUserGif"; - private final static String isNewUserOne = "isNewUserOne"; - private final static String GiftEffect = "giftEffect"; - private final static String MountEffect = "mountEffect"; - private final static String IS_CHAT = "isChat"; - private final static String IS_SLIDE = "isSlide"; - private final static String IS_FLOAT = "is_float"; - private final static String IS_HINT = "is_hint"; - private final static String IS_HINT2 = "is_hint2"; + private final String isNewUserGif = "isNewUserGif"; + private final String isNewUserOne = "isNewUserOne"; + private final String GiftEffect = "giftEffect"; + private final String MountEffect = "mountEffect"; + private final String IS_CHAT = "isChat"; + private final String IS_SLIDE = "isSlide"; + private final String IS_FLOAT = "is_float"; + private final String IS_HINT = "is_hint"; + private final String IS_HINT2 = "is_hint2"; public boolean isHint() { @@ -151,7 +153,7 @@ public class IMLoginManager extends BaseCacheManager { */ public static IMLoginManager get(Context context) { if (null == manager) { - manager = new IMLoginManager(context); + manager = new IMLoginManager(CommonAppContext.sInstance.getBaseContext()); } return manager; } diff --git a/common/src/main/java/com/yunbao/common/manager/NewLevelManager.java b/common/src/main/java/com/yunbao/common/manager/NewLevelManager.java new file mode 100644 index 000000000..1972cef00 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/manager/NewLevelManager.java @@ -0,0 +1,45 @@ +package com.yunbao.common.manager; + +import android.content.Context; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.yunbao.common.bean.NewLevelModel; +import com.yunbao.common.manager.base.BaseCacheManager; + +import java.util.ArrayList; +import java.util.List; + +/** + * 新粉丝牌管理 + */ +public class NewLevelManager extends BaseCacheManager { + private final String KEY_USER_LEVEL = "keyUserLevel"; + private List newLevelModels = new ArrayList<>(); + + public NewLevelManager(Context context) { + super(context); + } + + /** + * 缓存等级图标 + * + * @param json + */ + public void UpDataLevel(String json) { + newLevelModels = new Gson().fromJson(json, new TypeToken>() { + }.getType()); + put(KEY_USER_LEVEL, newLevelModels); + } + + /** + * 获取等级数据 + * + * @return + */ + public List getNewLevelModels() { + return getList(KEY_USER_LEVEL, new TypeToken>() { + }.getType()); + } + +} diff --git a/config.gradle b/config.gradle index c7985d37c..70ee56319 100644 --- a/config.gradle +++ b/config.gradle @@ -10,9 +10,9 @@ ext { manifestPlaceholders = [ //正式 - serverHost : "https://napi.yaoulive.com", +// serverHost : "https://napi.yaoulive.com", //測試 -// serverHost : "https://ceshi.yaoulive.com", + serverHost : "https://ceshi.yaoulive.com", //腾讯地图 txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB", diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicAnchorPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicAnchorPresenter.java index 47503e58a..6d001c6a8 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicAnchorPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicAnchorPresenter.java @@ -65,7 +65,7 @@ public class LiveLinkMicAnchorPresenter implements View.OnClickListener { private String mPkUid;//正在连麦的对方主播的uid private TextView mLinkMicWaitText; private int mLinkMicWaitCount;//连麦弹窗等待倒计时 - private static final int LINK_MIC_COUNT_MAX = 10; + private final int LINK_MIC_COUNT_MAX = 10; private String mLinkMicWaitString; private PopupWindow mLinkMicPopWindow; private Handler mHandler; @@ -326,23 +326,10 @@ public class LiveLinkMicAnchorPresenter implements View.OnClickListener { } if (mLiveSdk == Constants.LIVE_SDK_TX) { mLiveLinkMicPlayViewHolder = new LiveLinkMicPlayTxViewHolder(mContext, mRightContainer); - } else { -// mLiveLinkMicPlayViewHolder = new LiveLinkMicPlayKsyViewHolder(mContext, mRightContainer); } mLiveLinkMicPlayViewHolder.setOnCloseListener(mIsAnchor ? this : null); mLiveLinkMicPlayViewHolder.addToParent(); mLiveLinkMicPlayViewHolder.play(playUrl); -// if (mIsAnchor){ -// try { -// int index=playUrl.indexOf("?"); -// String subUrl= playUrl.substring(0,index); -// Log.d("subUrl",playUrl+" "+subUrl); -// mLiveLinkMicPlayViewHolder.play(subUrl); -// }catch (Exception e){e.printStackTrace();} -// }else { -// mLiveLinkMicPlayViewHolder.play(playUrl); -// } - if (mIsAnchor) { ToastUtil.show(R.string.link_mic_anchor_accept_2); ((LiveAnchorActivity) mContext).setPkBtnVisible(true); diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java index e0366aeb5..5675e9843 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java @@ -29,7 +29,6 @@ import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.bean.BannerBean; import com.yunbao.common.bean.LevelBean; -import com.yunbao.common.bean.LiveGiftBean; import com.yunbao.common.bean.UserBean; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpUtil; @@ -58,7 +57,6 @@ import com.yunbao.live.interfaces.ILiveLinkMicViewHolder; import com.yunbao.live.interfaces.LivePushListener; import com.yunbao.live.socket.SocketClient; import com.yunbao.live.socket.SocketLinkMicUtil; -import com.yunbao.live.utils.CountDownView; import com.yunbao.live.views.AbsLiveLinkMicPlayViewHolder; import com.yunbao.live.views.AbsLiveLinkMicPushViewHolder; import com.yunbao.live.views.LiveLinkMicPlayTxViewHolder; @@ -95,7 +93,7 @@ public class LiveLinkMicPresenter implements View.OnClickListener { private boolean mAcceptLinkMic;//是否接受连麦 private String mLinkMicWaitString; private int mLinkMicWaitCount;//连麦弹窗等待倒计时 - private static final int LINK_MIC_COUNT_MAX = 10; + private final int LINK_MIC_COUNT_MAX = 10; private PopupWindow mLinkMicPopWindow; private Handler mHandler; private AbsLiveLinkMicPlayViewHolder mLiveLinkMicPlayViewHolder;//连麦播放小窗口 @@ -113,14 +111,11 @@ public class LiveLinkMicPresenter implements View.OnClickListener { private List mBannerList3 = new ArrayList<>(); - public static CountDownView date; - - public static String link = ""; String gold, experience; @Subscribe(threadMode = ThreadMode.MAIN) public void onUpdata(String str) { - if ("stop_svga_new_user_double1".equals(str)) { + if ("stop_svga_new_user_double1".equals(str)) { AdjustEvent adjustEvent1 = new AdjustEvent("80lzdi"); Adjust.trackEvent(adjustEvent1); CommonHttpUtil.setAdvertisingChannels("80lzdi", new HttpCallback() { @@ -225,7 +220,6 @@ public class LiveLinkMicPresenter implements View.OnClickListener { } - public LiveLinkMicPresenter(Context context, ILiveLinkMicViewHolder linkMicViewHolder, boolean isAnchor, int liveSdk, View root) { mContext = context; EventBus.getDefault().register(this); @@ -244,7 +238,6 @@ public class LiveLinkMicPresenter implements View.OnClickListener { btnTurnTable.setOnClickListener(this); - //周星 BannerBean bannerBean = new BannerBean(); bannerBean.setImageUrl("https://downs.yaoulive.com/img/BTN_WEEKSTAR%20%281%29.png"); @@ -252,8 +245,6 @@ public class LiveLinkMicPresenter implements View.OnClickListener { mBannerList1.add(bannerBean); - - btn_onecz_event = root.findViewById(R.id.btn_onecz_event); btn_onecz_event.setOnClickListener(new View.OnClickListener() { @Override @@ -625,7 +616,6 @@ public class LiveLinkMicPresenter implements View.OnClickListener { } - //获取活动 private void getEvent() { if (btn_onecz_event != null) { diff --git a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java index 7bab7e143..29f1b6d39 100644 --- a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java +++ b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java @@ -35,9 +35,10 @@ import com.yunbao.common.Constants; import com.yunbao.common.bean.AiAutomaticSpeechModel; import com.yunbao.common.bean.LevelBean; import com.yunbao.common.bean.MsgModel; +import com.yunbao.common.bean.NewLevelModel; import com.yunbao.common.custom.VerticalImageSpan; import com.yunbao.common.glide.ImgLoader; -import com.yunbao.common.utils.BitmapUtil; +import com.yunbao.common.manager.NewLevelManager; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.WordUtil; @@ -45,6 +46,7 @@ import com.yunbao.live.R; import com.yunbao.live.bean.LiveChatBean; import java.util.HashMap; +import java.util.List; import java.util.Map; import io.reactivex.Observable; @@ -398,34 +400,14 @@ public class LiveTextRender { */ public void getLevelImage(Context mContext, int userLevel, ImgLoader.DrawableCallback callback) { mCallback = callback; + List models = new NewLevelManager(mContext).getNewLevelModels(); String imgUrl = "https://downs.yaoulive.com/level/user_lv1_bg.png"; - if (0 < userLevel && userLevel < 10) { - imgUrl = "https://downs.yaoulive.com/level/user_lv1_bg.png"; - } else if (9 < userLevel && userLevel < 20) { - imgUrl = "https://downs.yaoulive.com/level/user_lv10_bg.png"; - } else if (19 < userLevel && userLevel < 30) { - imgUrl = "https://downs.yaoulive.com/level/user_lv20_bg.png"; - } else if (29 < userLevel && userLevel < 40) { - imgUrl = "https://downs.yaoulive.com/level/user_lv30_bg.png"; - } else if (39 < userLevel && userLevel < 50) { - imgUrl = "https://downs.yaoulive.com/level/user_lv40_bg.png"; - } else if (49 < userLevel && userLevel < 60) { - imgUrl = "https://downs.yaoulive.com/level/user_lv50_bg.png"; - } else if (59 < userLevel && userLevel < 70) { - imgUrl = "https://downs.yaoulive.com/level/user_lv60_bg.png"; - } else if (69 < userLevel && userLevel < 80) { - imgUrl = "https://downs.yaoulive.com/level/user_lv70_bg.png"; - } else if (79 < userLevel && userLevel < 90) { - imgUrl = "https://downs.yaoulive.com/level/user_lv80_bg.png"; - } else if (89 < userLevel && userLevel < 100) { - imgUrl = "https://downs.yaoulive.com/level/user_lv90_bg.png"; - } else if (99 < userLevel && userLevel < 110) { - imgUrl = "https://downs.yaoulive.com/level/user_lv100_bg.png"; - } else if (109 < userLevel && userLevel < 120) { - imgUrl = "https://downs.yaoulive.com/level/user_lv110_bg.png"; - } else if (userLevel == 120) { - imgUrl = "https://downs.yaoulive.com/level/user_lv120_bg.png"; + for (NewLevelModel newLevelModel : models) { + if (newLevelModel.getLeveMin() <= userLevel && userLevel <= newLevelModel.getLeveMax()) { + imgUrl = newLevelModel.getThumb(); + } } + Glide.with(mContext).asBitmap().load(imgUrl).into(new CustomTarget() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) { @@ -473,7 +455,6 @@ public class LiveTextRender { } - private void renderTMP(Context context, final TextView textView, final LiveChatBean bean) { final LevelBean levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel()); diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java index 046653d28..d0a31a528 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java @@ -389,11 +389,11 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { } }; - public static Handler handler = new Handler(); - public static Runnable runnable; + public Handler handler = new Handler(); + public Runnable runnable; - public static Handler handler1 = new Handler(); - public static Runnable runnable1; + public Handler handler1 = new Handler(); + public Runnable runnable1; public void removeCallbacks() {