From 0f2fbeb1147bc69c56fb09620d0cd4598f7e59ca Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Wed, 2 Nov 2022 14:20:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=B2=89=E4=B8=9D=E5=9B=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/bean/IMLoginModel.java | 2 +- config.gradle | 8 +- .../live/adapter/UserMoreInfoAdapter.java | 2 +- .../com/yunbao/live/utils/LiveTextRender.java | 82 ++++++++++++++----- .../main/res/layout/item_user_more_info.xml | 6 +- 5 files changed, 70 insertions(+), 30 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java b/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java index e7cbf396a..05dac447d 100644 --- a/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java +++ b/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java @@ -687,7 +687,7 @@ public class IMLoginModel extends BaseModel { * @return */ public boolean anchorUserType() { - return TextUtils.equals("C", usersType); + return !TextUtils.equals("C", usersType); } public IMLoginModel setUsersType(String usersType) { diff --git a/config.gradle b/config.gradle index 42071dc0e..c7985d37c 100644 --- a/config.gradle +++ b/config.gradle @@ -4,15 +4,15 @@ ext { buildToolsVersion: "28.0.3", minSdkVersion : 21, targetSdkVersion : 31, - versionCode : 304, + versionCode : 305, versionName : "6.4.4" ] 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", @@ -27,6 +27,6 @@ ext { // true表示谷歌支付 false isGooglePlay : true, //是否上报异常日志 - isUploadLog : true + isUploadLog : false ] } \ No newline at end of file diff --git a/live/src/main/java/com/yunbao/live/adapter/UserMoreInfoAdapter.java b/live/src/main/java/com/yunbao/live/adapter/UserMoreInfoAdapter.java index 353a5c301..16c39a661 100644 --- a/live/src/main/java/com/yunbao/live/adapter/UserMoreInfoAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/UserMoreInfoAdapter.java @@ -280,7 +280,7 @@ public class UserMoreInfoAdapter extends RefreshAdapter { mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex())); if (levelBean != null) { - new LiveTextRender().getLevelImage(mContext, levelBean.getLevel(), false, new ImgLoader.DrawableCallback() { + new LiveTextRender().getLevelImage(mContext, levelBean.getLevel(), new ImgLoader.DrawableCallback() { @Override public void onLoadSuccess(Drawable drawable) { ImgLoader.display2(mContext, drawable, mLevel); 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 ebc3a7ddd..7bab7e143 100644 --- a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java +++ b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java @@ -37,6 +37,7 @@ import com.yunbao.common.bean.LevelBean; import com.yunbao.common.bean.MsgModel; import com.yunbao.common.custom.VerticalImageSpan; import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.utils.BitmapUtil; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.WordUtil; @@ -46,6 +47,14 @@ import com.yunbao.live.bean.LiveChatBean; import java.util.HashMap; import java.util.Map; +import io.reactivex.Observable; +import io.reactivex.ObservableEmitter; +import io.reactivex.ObservableOnSubscribe; +import io.reactivex.Observer; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.Disposable; +import io.reactivex.schedulers.Schedulers; + /** * Created by cxf on 2018/10/11. */ @@ -270,7 +279,7 @@ public class LiveTextRender { Drawable drawable = getMedalImage(bean); if (drawable != null) { builder.append(" "); - drawable.setBounds(0, 0, DpUtil.dp2px(42), DpUtil.dp2px(14)); + drawable.setBounds(0, 0, DpUtil.dp2px(44), DpUtil.dp2px(17)); builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); index += 2; } @@ -380,36 +389,38 @@ public class LiveTextRender { }); } + private ImgLoader.DrawableCallback mCallback; + /** * 等级设置 * * @return */ - public void getLevelImage(Context mContext, int userLevel, boolean anchorUserType, ImgLoader.DrawableCallback callback) { - - String imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv1_bg.png" : "https://downs.yaoulive.com/level/user_lv1_bg.png"; + public void getLevelImage(Context mContext, int userLevel, ImgLoader.DrawableCallback callback) { + mCallback = callback; + String imgUrl = "https://downs.yaoulive.com/level/user_lv1_bg.png"; if (0 < userLevel && userLevel < 10) { - imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv1_bg.png" : "https://downs.yaoulive.com/level/user_lv1_bg.png"; + imgUrl = "https://downs.yaoulive.com/level/user_lv1_bg.png"; } else if (9 < userLevel && userLevel < 20) { - imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv10_bg.png" : "https://downs.yaoulive.com/level/user_lv10_bg.png"; + imgUrl = "https://downs.yaoulive.com/level/user_lv10_bg.png"; } else if (19 < userLevel && userLevel < 30) { - imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_l20_bg.png" : "https://downs.yaoulive.com/level/user_lv20_bg.png"; + imgUrl = "https://downs.yaoulive.com/level/user_lv20_bg.png"; } else if (29 < userLevel && userLevel < 40) { - imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv30_bg.png" : "https://downs.yaoulive.com/level/user_lv30_bg.png"; + imgUrl = "https://downs.yaoulive.com/level/user_lv30_bg.png"; } else if (39 < userLevel && userLevel < 50) { - imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv40_bg.png" : "https://downs.yaoulive.com/level/user_lv40_bg.png"; + imgUrl = "https://downs.yaoulive.com/level/user_lv40_bg.png"; } else if (49 < userLevel && userLevel < 60) { - imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv50_bg.png" : "https://downs.yaoulive.com/level/user_lv50_bg.png"; + imgUrl = "https://downs.yaoulive.com/level/user_lv50_bg.png"; } else if (59 < userLevel && userLevel < 70) { - imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv60_bg.png" : "https://downs.yaoulive.com/level/user_lv60_bg.png"; + imgUrl = "https://downs.yaoulive.com/level/user_lv60_bg.png"; } else if (69 < userLevel && userLevel < 80) { - imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv70_bg.png" : "https://downs.yaoulive.com/level/user_lv70_bg.png"; + imgUrl = "https://downs.yaoulive.com/level/user_lv70_bg.png"; } else if (79 < userLevel && userLevel < 90) { - imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv80_bg.png" : "https://downs.yaoulive.com/level/user_lv80_bg.png"; + imgUrl = "https://downs.yaoulive.com/level/user_lv80_bg.png"; } else if (89 < userLevel && userLevel < 100) { - imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv90_bg.png" : "https://downs.yaoulive.com/level/user_lv90_bg.png"; + imgUrl = "https://downs.yaoulive.com/level/user_lv90_bg.png"; } else if (99 < userLevel && userLevel < 110) { - imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv100_bg.png" : "https://downs.yaoulive.com/level/user_lv100_bg.png"; + 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) { @@ -418,11 +429,38 @@ public class LiveTextRender { Glide.with(mContext).asBitmap().load(imgUrl).into(new CustomTarget() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) { - ; - BitmapDrawable drawable = new BitmapDrawable(AddTimeWatermark(resource, String.valueOf(userLevel))); - if (callback != null) { - callback.onLoadSuccess(drawable); - } + Observable.create(new ObservableOnSubscribe() { + @Override + public void subscribe(ObservableEmitter emitter) throws Exception { + emitter.onNext(AddTimeWatermark(resource, String.valueOf(userLevel))); + } + }).subscribeOn(Schedulers.newThread()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Observer() { + @Override + public void onSubscribe(Disposable d) { + + } + + @Override + public void onNext(Bitmap bitmap) { + BitmapDrawable drawable = new BitmapDrawable(bitmap); + if (callback != null) { + callback.onLoadSuccess(drawable); + } + } + + @Override + public void onError(Throwable e) { + + } + + @Override + public void onComplete() { + + } + }); + } @Override @@ -434,6 +472,8 @@ public class LiveTextRender { }); } + + private void renderTMP(Context context, final TextView textView, final LiveChatBean bean) { final LevelBean levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel()); @@ -454,7 +494,7 @@ public class LiveTextRender { } } else { if (textView != null) { - getLevelImage(context, bean.getLevel(), bean.isAnchor(), new ImgLoader.DrawableCallback() { + getLevelImage(context, bean.getLevel(), new ImgLoader.DrawableCallback() { @Override public void onLoadSuccess(Drawable drawable) { SpannableStringBuilder builder = createPrefix(drawable, bean); diff --git a/live/src/main/res/layout/item_user_more_info.xml b/live/src/main/res/layout/item_user_more_info.xml index f0dcd474d..c4ff1de19 100644 --- a/live/src/main/res/layout/item_user_more_info.xml +++ b/live/src/main/res/layout/item_user_more_info.xml @@ -120,12 +120,12 @@ + android:layout_height="18dp" />