调整Glide设置高宽的方法

隐藏直播间右侧贵族头条之类的view
取消首页进入密码房输入密码,不然会弹两次密码输入框
密码输入框响应取消按钮
This commit is contained in:
zlzw 2022-09-27 17:38:12 +08:00
parent 79a4c560df
commit 51c6ed3456
6 changed files with 72 additions and 125 deletions

View File

@ -13,6 +13,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.target.SimpleTarget; import com.bumptech.glide.request.target.SimpleTarget;
@ -44,26 +45,12 @@ public class ImgLoader {
if (!contextIsExist(context)) { if (!contextIsExist(context)) {
return; return;
} }
Glide.with(context) RequestBuilder<Drawable> builder = Glide.with(context)
.asBitmap() .load(url);
.load(url) if (width != -1 && height != -1) {
.skipMemoryCache(SKIP_MEMORY_CACHE) builder = builder.override(width, height);
.into(new CustomTarget<Bitmap>() { }
@Override builder.into(imageView);
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> 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) {
}
});
} }
public static void display2(Context context, String url, ImageView 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) Glide.get(context)
.clearMemory(); .clearMemory();
} }
public static void display2(Context context, String url, ImageView imageView, int width, int height) { public static void display2(Context context, String url, ImageView imageView, int width, int height) {
if (!contextIsExist(context)) { if (!contextIsExist(context)) {
return; return;
} }
Glide.with(context) RequestBuilder<Drawable> builder = Glide.with(context)
.asBitmap()
.load(url) .load(url)
.placeholder(imageView.getDrawable())
.dontAnimate() .dontAnimate()
.skipMemoryCache(SKIP_MEMORY_CACHE) .placeholder(imageView.getDrawable());
.into(new CustomTarget<Bitmap>() { if (width != -1 && height != -1) {
@Override builder = builder.override(width, height);
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { }
if (width == -1 || height == -1) { builder.into(imageView);
imageView.setImageBitmap(resource);
} else {
Bitmap bitmap = ThumbnailUtils.extractThumbnail(resource, width, height);
imageView.setImageBitmap(bitmap);
}
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
} }
public static void display2(Context context, int url, ImageView imageView) { public static void display2(Context context, int url, ImageView imageView) {
@ -129,27 +103,14 @@ public class ImgLoader {
if (imageView == null) { if (imageView == null) {
return; return;
} }
Glide.with(context)
.asBitmap() RequestBuilder<Drawable> builder = Glide.with(context)
.load(url) .load(url)
.error(errorRes) .error(errorRes);
.skipMemoryCache(SKIP_MEMORY_CACHE) if (width != -1 && height != -1) {
.into(new CustomTarget<Bitmap>() { builder = builder.override(width, height);
@Override }
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { builder.into(imageView);
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) {
}
});
} }
public static void displayWithError(Context context, int url, ImageView imageView, int errorRes) { public static void displayWithError(Context context, int url, ImageView imageView, int errorRes) {
@ -173,27 +134,14 @@ public class ImgLoader {
if (!contextIsExist(context)) { if (!contextIsExist(context)) {
return; return;
} }
Glide.with(context)
.asBitmap() RequestBuilder<Drawable> builder = Glide.with(context)
.load(url) .load(url)
.error(R.mipmap.icon_avatar_placeholder) .error(R.mipmap.icon_avatar_placeholder);
.skipMemoryCache(SKIP_MEMORY_CACHE) if (width != -1 && height != -1) {
.into(new CustomTarget<Bitmap>() { builder = builder.override(width, height);
@Override }
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { builder.into(imageView);
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) {
}
});
} }
public static void displayAvatar(Context context, int url, ImageView 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) { 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) if (callback != null)
callback.onLoadFailed(); callback.onLoadFailed();
} else { } else {
@ -329,27 +277,14 @@ public class ImgLoader {
if (!contextIsExist(context)) { if (!contextIsExist(context)) {
return; return;
} }
Glide.with(context)
.asBitmap() RequestBuilder<Drawable> builder = Glide.with(context)
.load(url) .load(url)
.skipMemoryCache(SKIP_MEMORY_CACHE) .apply(RequestOptions.bitmapTransform(sBlurTransformation));
.apply(RequestOptions.bitmapTransform(sBlurTransformation)) if (width != -1 && height != -1) {
.into(new CustomTarget<Bitmap>() { builder = builder.override(width, height);
@Override }
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { builder.into(imageView);
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) {
}
});
} }
/** /**
@ -363,26 +298,14 @@ public class ImgLoader {
if (!contextIsExist(context)) { if (!contextIsExist(context)) {
return; return;
} }
Glide.with(context).asBitmap().load(url) RequestBuilder<Drawable> builder = Glide.with(context)
.skipMemoryCache(SKIP_MEMORY_CACHE) .load(url)
.apply(RequestOptions.bitmapTransform(new BlurTransformation(20))) .apply(RequestOptions.bitmapTransform(new BlurTransformation(20)))
.placeholder(R.mipmap.live_bg) .placeholder(R.mipmap.live_bg);
.into(new CustomTarget<Bitmap>() { if (width != -1 && height != -1) {
@Override builder = builder.override(width, height);
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { }
if (width == -1 || height == -1) { builder.into(imageView);
imageView.setImageBitmap(resource);
} else {
Bitmap bitmap = ThumbnailUtils.extractThumbnail(resource, width, height);
imageView.setImageBitmap(bitmap);
}
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
} }
private static boolean contextIsExist(Context context) { private static boolean contextIsExist(Context context) {

View File

@ -857,6 +857,7 @@ public class LiveGiftAnimPresenter {
mIvLook.setVisibility(View.VISIBLE); mIvLook.setVisibility(View.VISIBLE);
mGifGiftTipGroupAllServer.setAlpha(1f); mGifGiftTipGroupAllServer.setAlpha(1f);
mGifGiftTipGroupAllServer.setVisibility(View.VISIBLE);
mGifGiftTipShowAnimatorAllServer.start(); mGifGiftTipShowAnimatorAllServer.start();
AllMsgTextRender.render(mContext, mGifGiftTipAllServer, mTempGifGiftBean.getGiftIcon(), mTempGifGiftBean.getUserNiceName(), mAncherName, mTempGifGiftBean.getGiftName(), 1, mWindowManager, ""); AllMsgTextRender.render(mContext, mGifGiftTipAllServer, mTempGifGiftBean.getGiftIcon(), mTempGifGiftBean.getUserNiceName(), mAncherName, mTempGifGiftBean.getGiftName(), 1, mWindowManager, "");
@ -912,6 +913,7 @@ public class LiveGiftAnimPresenter {
mAncherName = bean.getAncherName(); mAncherName = bean.getAncherName();
mGifGiftTipGroupBuyGuard.setAlpha(1f); mGifGiftTipGroupBuyGuard.setAlpha(1f);
mGifGiftTipGroupBuyGuard.setVisibility(View.VISIBLE);
mGifGiftTipShowAnimatorBuyGuard.start(); mGifGiftTipShowAnimatorBuyGuard.start();
AllMsgTextRender.render(mContext, mGifGiftTipBuyGuard, "", mTempGifGiftBean.getUserNiceName(), mAncherName, "", 2, mWindowManager, mTempGifGiftBean.getGuardType()); 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")); Spanned spanned = Html.fromHtml(text, null, new HtmlTagHandler("myfont"));
mGifGiftTipBuyZuoji.setText(spanned); mGifGiftTipBuyZuoji.setText(spanned);
mGifGiftTipBuyZuoji.setSelected(false); mGifGiftTipBuyZuoji.setSelected(false);
mGifGiftTipBuyZuoji.setVisibility(View.VISIBLE);
mGifGiftTipBuyZuoji.postDelayed(new Runnable() { mGifGiftTipBuyZuoji.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -993,7 +996,7 @@ public class LiveGiftAnimPresenter {
} }
} }
}, delayMarqueen); }, delayMarqueen);
mGifGiftTipGroupBuyLiangName.setVisibility(View.VISIBLE);
mGifGiftTipGroupBuyLiangName.setAlpha(1f); mGifGiftTipGroupBuyLiangName.setAlpha(1f);
mGifGiftTipShowAnimatorBuyLiangName.start(); mGifGiftTipShowAnimatorBuyLiangName.start();
} }
@ -1039,6 +1042,7 @@ public class LiveGiftAnimPresenter {
mGifGiftTipGroupBuyVip.setAlpha(1f); mGifGiftTipGroupBuyVip.setAlpha(1f);
if (bean.getAvatar() != null && bean.getAvatar().equals("1")) { if (bean.getAvatar() != null && bean.getAvatar().equals("1")) {
mGifGiftTipGroupBuyVip.setVisibility(View.VISIBLE);
mGifGiftTipShowAnimatorBuyVip.start(); mGifGiftTipShowAnimatorBuyVip.start();
AllMsgTextRender.render(mContext, mGifGiftTipBuyVip, "", mTempGifGiftBean.getUserNiceName(), mAncherName, bean.getNobilityname(), 3, mWindowManager, bean.getOpentype()); AllMsgTextRender.render(mContext, mGifGiftTipBuyVip, "", mTempGifGiftBean.getUserNiceName(), mAncherName, bean.getNobilityname(), 3, mWindowManager, bean.getOpentype());
@ -1069,6 +1073,7 @@ public class LiveGiftAnimPresenter {
mGifGiftTipAllServer.setSelected(false); mGifGiftTipAllServer.setSelected(false);
mIvLook.setVisibility(View.GONE); mIvLook.setVisibility(View.GONE);
mGifGiftTipGroupAllServer.setAlpha(1f); mGifGiftTipGroupAllServer.setAlpha(1f);
mGifGiftTipGroupAllServer.setVisibility(View.VISIBLE);
mGifGiftTipShowAnimatorAllServer.start(); mGifGiftTipShowAnimatorAllServer.start();
AllMsgTextRender.render(mContext, mGifGiftTipAllServer, "", bean.getVipName(), "", "", 4, mWindowManager, ""); AllMsgTextRender.render(mContext, mGifGiftTipAllServer, "", bean.getVipName(), "", "", 4, mWindowManager, "");
@ -1111,6 +1116,7 @@ public class LiveGiftAnimPresenter {
Log.e("--> ", "v115"); Log.e("--> ", "v115");
mGifGiftTip.setText(getGiftWordsContent1()); mGifGiftTip.setText(getGiftWordsContent1());
mGifGiftTipGroup.setAlpha(1f); mGifGiftTipGroup.setAlpha(1f);
mGifGiftTipGroup.setVisibility(View.VISIBLE);
mGifGiftTipShowAnimator.start(); mGifGiftTipShowAnimator.start();
if (mHandler != null) { if (mHandler != null) {
mHandler.sendEmptyMessageDelayed(WHAT_GIF, 4000); mHandler.sendEmptyMessageDelayed(WHAT_GIF, 4000);
@ -1166,6 +1172,7 @@ public class LiveGiftAnimPresenter {
if (!mIsSameRoom) { if (!mIsSameRoom) {
mGifGiftTip.setText(getGiftWordsContent1()); mGifGiftTip.setText(getGiftWordsContent1());
mGifGiftTipGroup.setAlpha(1f); mGifGiftTipGroup.setAlpha(1f);
mGifGiftTipGroup.setVisibility(View.VISIBLE);
mGifGiftTipShowAnimator.start(); mGifGiftTipShowAnimator.start();
} }

View File

@ -1,5 +1,6 @@
package com.yunbao.live.presenter; package com.yunbao.live.presenter;
import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;
@ -106,7 +107,14 @@ public class LiveRoomCheckLivePresenter {
* 前往密码房间 * 前往密码房间
*/ */
private void forwardPwdRoom() { 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 @Override
public void onConfirmClick(Dialog dialog, String content) { public void onConfirmClick(Dialog dialog, String content) {
if (TextUtils.isEmpty(content)) { if (TextUtils.isEmpty(content)) {

View File

@ -216,7 +216,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mCover.setVisibility(View.VISIBLE); mCover.setVisibility(View.VISIBLE);
} }
} }
mPlayer.stopPlay(); if(mPlayer!=null) {
mPlayer.stopPlay();
}
stopPlay2(); stopPlay2();
} }

View File

@ -948,6 +948,7 @@
<LinearLayout <LinearLayout
android:id="@+id/gif_gift_tip_group" android:id="@+id/gif_gift_tip_group"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:visibility="gone"
android:layout_height="26dp" android:layout_height="26dp"
android:layout_below="@id/hour_rank_layout" android:layout_below="@id/hour_rank_layout"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
@ -986,6 +987,7 @@
android:id="@+id/gif_gift_tip_group_all_server" android:id="@+id/gif_gift_tip_group_all_server"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="36dp" android:layout_height="36dp"
android:visibility="gone"
android:translationX="500dp"> android:translationX="500dp">
<LinearLayout <LinearLayout
@ -1058,6 +1060,7 @@
<FrameLayout <FrameLayout
android:id="@+id/gif_gift_tip_group_buy_guard" android:id="@+id/gif_gift_tip_group_buy_guard"
android:layout_width="match_parent" android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="36dp" android:layout_height="36dp"
android:translationX="500dp"> android:translationX="500dp">
@ -1132,6 +1135,7 @@
android:id="@+id/gif_gift_tip_group_buy_zuoji" android:id="@+id/gif_gift_tip_group_buy_zuoji"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="30dp" android:layout_height="30dp"
android:visibility="gone"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginTop="100dp" android:layout_marginTop="100dp"
android:translationX="500dp"> android:translationX="500dp">
@ -1183,6 +1187,7 @@
android:id="@+id/gif_gift_tip_group_buy_liang_name" android:id="@+id/gif_gift_tip_group_buy_liang_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="30dp" android:layout_height="30dp"
android:visibility="gone"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginTop="135dp" android:layout_marginTop="135dp"
android:translationX="500dp"> android:translationX="500dp">
@ -1233,6 +1238,7 @@
<FrameLayout <FrameLayout
android:id="@+id/gif_gift_tip_group_buy_vip" android:id="@+id/gif_gift_tip_group_buy_vip"
android:layout_width="match_parent" android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="36dp" android:layout_height="36dp"
android:translationX="500dp"> android:translationX="500dp">

View File

@ -74,7 +74,8 @@ public class CheckLivePresenter {
forwardNormalRoom(); forwardNormalRoom();
break; break;
case Constants.LIVE_TYPE_PWD: case Constants.LIVE_TYPE_PWD:
forwardPwdRoom(); //forwardPwdRoom();
forwardLiveAudienceActivity();
break; break;
case Constants.LIVE_TYPE_PAY: case Constants.LIVE_TYPE_PAY:
case Constants.LIVE_TYPE_TIME: case Constants.LIVE_TYPE_TIME: