From 51c6ed34561dbac3aa222528c0f36dad64c058d5 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Tue, 27 Sep 2022 17:38:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4Glide=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=AB=98=E5=AE=BD=E7=9A=84=E6=96=B9=E6=B3=95=20=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E7=9B=B4=E6=92=AD=E9=97=B4=E5=8F=B3=E4=BE=A7=E8=B4=B5?= =?UTF-8?q?=E6=97=8F=E5=A4=B4=E6=9D=A1=E4=B9=8B=E7=B1=BB=E7=9A=84view=20?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E9=A6=96=E9=A1=B5=E8=BF=9B=E5=85=A5=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E6=88=BF=E8=BE=93=E5=85=A5=E5=AF=86=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E7=84=B6=E4=BC=9A=E5=BC=B9=E4=B8=A4=E6=AC=A1=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E8=BE=93=E5=85=A5=E6=A1=86=20=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E5=93=8D=E5=BA=94=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/glide/ImgLoader.java | 165 +++++------------- .../live/presenter/LiveGiftAnimPresenter.java | 9 +- .../presenter/LiveRoomCheckLivePresenter.java | 10 +- .../live/views/LivePlayRyViewHolder.java | 4 +- live/src/main/res/layout/view_live_room.xml | 6 + .../main/presenter/CheckLivePresenter.java | 3 +- 6 files changed, 72 insertions(+), 125 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java index c814e227c..e987f4d95 100644 --- a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java +++ b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java @@ -13,6 +13,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.bumptech.glide.Glide; +import com.bumptech.glide.RequestBuilder; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.target.SimpleTarget; @@ -44,26 +45,12 @@ public class ImgLoader { if (!contextIsExist(context)) { return; } - Glide.with(context) - .asBitmap() - .load(url) - .skipMemoryCache(SKIP_MEMORY_CACHE) - .into(new CustomTarget() { - @Override - public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) { - if (width == -1 || height == -1) { - imageView.setImageBitmap(resource); - } else { - Bitmap bitmap = ThumbnailUtils.extractThumbnail(resource, width, height); - imageView.setImageBitmap(bitmap); - } - } - - @Override - public void onLoadCleared(@Nullable Drawable placeholder) { - - } - }); + RequestBuilder builder = Glide.with(context) + .load(url); + if (width != -1 && height != -1) { + builder = builder.override(width, height); + } + builder.into(imageView); } public static void display2(Context context, String url, ImageView imageView) { @@ -73,36 +60,23 @@ public class ImgLoader { /** * 手动清空内存 */ - public static void clearMemory(Context context){ + public static void clearMemory(Context context) { Glide.get(context) .clearMemory(); } + public static void display2(Context context, String url, ImageView imageView, int width, int height) { if (!contextIsExist(context)) { return; } - Glide.with(context) - .asBitmap() + RequestBuilder builder = Glide.with(context) .load(url) - .placeholder(imageView.getDrawable()) .dontAnimate() - .skipMemoryCache(SKIP_MEMORY_CACHE) - .into(new CustomTarget() { - @Override - public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) { - if (width == -1 || height == -1) { - imageView.setImageBitmap(resource); - } else { - Bitmap bitmap = ThumbnailUtils.extractThumbnail(resource, width, height); - imageView.setImageBitmap(bitmap); - } - } - - @Override - public void onLoadCleared(@Nullable Drawable placeholder) { - - } - }); + .placeholder(imageView.getDrawable()); + if (width != -1 && height != -1) { + builder = builder.override(width, height); + } + builder.into(imageView); } public static void display2(Context context, int url, ImageView imageView) { @@ -129,27 +103,14 @@ public class ImgLoader { if (imageView == null) { return; } - Glide.with(context) - .asBitmap() + + RequestBuilder builder = Glide.with(context) .load(url) - .error(errorRes) - .skipMemoryCache(SKIP_MEMORY_CACHE) - .into(new CustomTarget() { - @Override - public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) { - if (width == -1 || height == -1) { - imageView.setImageBitmap(resource); - } else { - Bitmap bitmap = ThumbnailUtils.extractThumbnail(resource, width, height); - imageView.setImageBitmap(bitmap); - } - } - - @Override - public void onLoadCleared(@Nullable Drawable placeholder) { - - } - }); + .error(errorRes); + if (width != -1 && height != -1) { + builder = builder.override(width, height); + } + builder.into(imageView); } public static void displayWithError(Context context, int url, ImageView imageView, int errorRes) { @@ -173,27 +134,14 @@ public class ImgLoader { if (!contextIsExist(context)) { return; } - Glide.with(context) - .asBitmap() + + RequestBuilder builder = Glide.with(context) .load(url) - .error(R.mipmap.icon_avatar_placeholder) - .skipMemoryCache(SKIP_MEMORY_CACHE) - .into(new CustomTarget() { - @Override - public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) { - if (width == -1 || height == -1) { - imageView.setImageBitmap(resource); - } else { - Bitmap bitmap = ThumbnailUtils.extractThumbnail(resource, width, height); - imageView.setImageBitmap(bitmap); - } - } - - @Override - public void onLoadCleared(@Nullable Drawable placeholder) { - - } - }); + .error(R.mipmap.icon_avatar_placeholder); + if (width != -1 && height != -1) { + builder = builder.override(width, height); + } + builder.into(imageView); } public static void displayAvatar(Context context, int url, ImageView imageView) { @@ -256,7 +204,7 @@ public class ImgLoader { public static void displayDrawable(Context context, String url, final DrawableCallback callback) { - if (TextUtils.isEmpty(url)||!contextIsExist(context)) { + if (TextUtils.isEmpty(url) || !contextIsExist(context)) { if (callback != null) callback.onLoadFailed(); } else { @@ -329,27 +277,14 @@ public class ImgLoader { if (!contextIsExist(context)) { return; } - Glide.with(context) - .asBitmap() + + RequestBuilder builder = Glide.with(context) .load(url) - .skipMemoryCache(SKIP_MEMORY_CACHE) - .apply(RequestOptions.bitmapTransform(sBlurTransformation)) - .into(new CustomTarget() { - @Override - public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) { - if (width == -1 || height == -1) { - imageView.setImageBitmap(resource); - } else { - Bitmap bitmap = ThumbnailUtils.extractThumbnail(resource, width, height); - imageView.setImageBitmap(bitmap); - } - } - - @Override - public void onLoadCleared(@Nullable Drawable placeholder) { - - } - }); + .apply(RequestOptions.bitmapTransform(sBlurTransformation)); + if (width != -1 && height != -1) { + builder = builder.override(width, height); + } + builder.into(imageView); } /** @@ -363,26 +298,14 @@ public class ImgLoader { if (!contextIsExist(context)) { return; } - Glide.with(context).asBitmap().load(url) - .skipMemoryCache(SKIP_MEMORY_CACHE) + RequestBuilder builder = Glide.with(context) + .load(url) .apply(RequestOptions.bitmapTransform(new BlurTransformation(20))) - .placeholder(R.mipmap.live_bg) - .into(new CustomTarget() { - @Override - public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) { - if (width == -1 || height == -1) { - imageView.setImageBitmap(resource); - } else { - Bitmap bitmap = ThumbnailUtils.extractThumbnail(resource, width, height); - imageView.setImageBitmap(bitmap); - } - } - - @Override - public void onLoadCleared(@Nullable Drawable placeholder) { - - } - }); + .placeholder(R.mipmap.live_bg); + if (width != -1 && height != -1) { + builder = builder.override(width, height); + } + builder.into(imageView); } private static boolean contextIsExist(Context context) { diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java index cdc1577d8..252bebc1d 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java @@ -857,6 +857,7 @@ public class LiveGiftAnimPresenter { mIvLook.setVisibility(View.VISIBLE); mGifGiftTipGroupAllServer.setAlpha(1f); + mGifGiftTipGroupAllServer.setVisibility(View.VISIBLE); mGifGiftTipShowAnimatorAllServer.start(); AllMsgTextRender.render(mContext, mGifGiftTipAllServer, mTempGifGiftBean.getGiftIcon(), mTempGifGiftBean.getUserNiceName(), mAncherName, mTempGifGiftBean.getGiftName(), 1, mWindowManager, ""); @@ -912,6 +913,7 @@ public class LiveGiftAnimPresenter { mAncherName = bean.getAncherName(); mGifGiftTipGroupBuyGuard.setAlpha(1f); + mGifGiftTipGroupBuyGuard.setVisibility(View.VISIBLE); mGifGiftTipShowAnimatorBuyGuard.start(); AllMsgTextRender.render(mContext, mGifGiftTipBuyGuard, "", mTempGifGiftBean.getUserNiceName(), mAncherName, "", 2, mWindowManager, mTempGifGiftBean.getGuardType()); @@ -945,6 +947,7 @@ public class LiveGiftAnimPresenter { Spanned spanned = Html.fromHtml(text, null, new HtmlTagHandler("myfont")); mGifGiftTipBuyZuoji.setText(spanned); mGifGiftTipBuyZuoji.setSelected(false); + mGifGiftTipBuyZuoji.setVisibility(View.VISIBLE); mGifGiftTipBuyZuoji.postDelayed(new Runnable() { @Override public void run() { @@ -993,7 +996,7 @@ public class LiveGiftAnimPresenter { } } }, delayMarqueen); - + mGifGiftTipGroupBuyLiangName.setVisibility(View.VISIBLE); mGifGiftTipGroupBuyLiangName.setAlpha(1f); mGifGiftTipShowAnimatorBuyLiangName.start(); } @@ -1039,6 +1042,7 @@ public class LiveGiftAnimPresenter { mGifGiftTipGroupBuyVip.setAlpha(1f); if (bean.getAvatar() != null && bean.getAvatar().equals("1")) { + mGifGiftTipGroupBuyVip.setVisibility(View.VISIBLE); mGifGiftTipShowAnimatorBuyVip.start(); AllMsgTextRender.render(mContext, mGifGiftTipBuyVip, "", mTempGifGiftBean.getUserNiceName(), mAncherName, bean.getNobilityname(), 3, mWindowManager, bean.getOpentype()); @@ -1069,6 +1073,7 @@ public class LiveGiftAnimPresenter { mGifGiftTipAllServer.setSelected(false); mIvLook.setVisibility(View.GONE); mGifGiftTipGroupAllServer.setAlpha(1f); + mGifGiftTipGroupAllServer.setVisibility(View.VISIBLE); mGifGiftTipShowAnimatorAllServer.start(); AllMsgTextRender.render(mContext, mGifGiftTipAllServer, "", bean.getVipName(), "", "", 4, mWindowManager, ""); @@ -1111,6 +1116,7 @@ public class LiveGiftAnimPresenter { Log.e("--> ", "v115"); mGifGiftTip.setText(getGiftWordsContent1()); mGifGiftTipGroup.setAlpha(1f); + mGifGiftTipGroup.setVisibility(View.VISIBLE); mGifGiftTipShowAnimator.start(); if (mHandler != null) { mHandler.sendEmptyMessageDelayed(WHAT_GIF, 4000); @@ -1166,6 +1172,7 @@ public class LiveGiftAnimPresenter { if (!mIsSameRoom) { mGifGiftTip.setText(getGiftWordsContent1()); mGifGiftTipGroup.setAlpha(1f); + mGifGiftTipGroup.setVisibility(View.VISIBLE); mGifGiftTipShowAnimator.start(); } diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveRoomCheckLivePresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveRoomCheckLivePresenter.java index e90bd6bc9..5b34a73a4 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveRoomCheckLivePresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveRoomCheckLivePresenter.java @@ -1,5 +1,6 @@ package com.yunbao.live.presenter; +import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.text.TextUtils; @@ -106,7 +107,14 @@ public class LiveRoomCheckLivePresenter { * 前往密码房间 */ private void forwardPwdRoom() { - DialogUitl.showSimpleInputDialog(mContext, WordUtil.getString(R.string.live_input_password), DialogUitl.INPUT_TYPE_NUMBER_PASSWORD, new DialogUitl.SimpleCallback() { + DialogUitl.showSimpleInputDialog(mContext, WordUtil.getString(R.string.live_input_password), DialogUitl.INPUT_TYPE_NUMBER_PASSWORD, new DialogUitl.SimpleCallback2() { + @Override + public void onCancelClick() { + if(mContext instanceof Activity) { + ((Activity) mContext).finish(); + } + } + @Override public void onConfirmClick(Dialog dialog, String content) { if (TextUtils.isEmpty(content)) { 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 bf35a945b..e3e2bcd89 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -216,7 +216,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { mCover.setVisibility(View.VISIBLE); } } - mPlayer.stopPlay(); + if(mPlayer!=null) { + mPlayer.stopPlay(); + } stopPlay2(); } diff --git a/live/src/main/res/layout/view_live_room.xml b/live/src/main/res/layout/view_live_room.xml index 0ebd7f811..5c5376f43 100644 --- a/live/src/main/res/layout/view_live_room.xml +++ b/live/src/main/res/layout/view_live_room.xml @@ -948,6 +948,7 @@ @@ -1132,6 +1135,7 @@ android:id="@+id/gif_gift_tip_group_buy_zuoji" android:layout_width="wrap_content" android:layout_height="30dp" + android:visibility="gone" android:layout_marginLeft="10dp" android:layout_marginTop="100dp" android:translationX="500dp"> @@ -1183,6 +1187,7 @@ android:id="@+id/gif_gift_tip_group_buy_liang_name" android:layout_width="wrap_content" android:layout_height="30dp" + android:visibility="gone" android:layout_marginLeft="10dp" android:layout_marginTop="135dp" android:translationX="500dp"> @@ -1233,6 +1238,7 @@ diff --git a/main/src/main/java/com/yunbao/main/presenter/CheckLivePresenter.java b/main/src/main/java/com/yunbao/main/presenter/CheckLivePresenter.java index 3584c0d98..506faf542 100644 --- a/main/src/main/java/com/yunbao/main/presenter/CheckLivePresenter.java +++ b/main/src/main/java/com/yunbao/main/presenter/CheckLivePresenter.java @@ -74,7 +74,8 @@ public class CheckLivePresenter { forwardNormalRoom(); break; case Constants.LIVE_TYPE_PWD: - forwardPwdRoom(); + //forwardPwdRoom(); + forwardLiveAudienceActivity(); break; case Constants.LIVE_TYPE_PAY: case Constants.LIVE_TYPE_TIME: