调整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 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<Bitmap>() {
@Override
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) {
}
});
RequestBuilder<Drawable> 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<Drawable> builder = Glide.with(context)
.load(url)
.placeholder(imageView.getDrawable())
.dontAnimate()
.skipMemoryCache(SKIP_MEMORY_CACHE)
.into(new CustomTarget<Bitmap>() {
@Override
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) {
}
});
.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<Drawable> builder = Glide.with(context)
.load(url)
.error(errorRes)
.skipMemoryCache(SKIP_MEMORY_CACHE)
.into(new CustomTarget<Bitmap>() {
@Override
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) {
}
});
.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<Drawable> builder = Glide.with(context)
.load(url)
.error(R.mipmap.icon_avatar_placeholder)
.skipMemoryCache(SKIP_MEMORY_CACHE)
.into(new CustomTarget<Bitmap>() {
@Override
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) {
}
});
.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<Drawable> builder = Glide.with(context)
.load(url)
.skipMemoryCache(SKIP_MEMORY_CACHE)
.apply(RequestOptions.bitmapTransform(sBlurTransformation))
.into(new CustomTarget<Bitmap>() {
@Override
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) {
}
});
.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<Drawable> builder = Glide.with(context)
.load(url)
.apply(RequestOptions.bitmapTransform(new BlurTransformation(20)))
.placeholder(R.mipmap.live_bg)
.into(new CustomTarget<Bitmap>() {
@Override
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) {
}
});
.placeholder(R.mipmap.live_bg);
if (width != -1 && height != -1) {
builder = builder.override(width, height);
}
builder.into(imageView);
}
private static boolean contextIsExist(Context context) {

View File

@ -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();
}

View File

@ -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)) {

View File

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

View File

@ -948,6 +948,7 @@
<LinearLayout
android:id="@+id/gif_gift_tip_group"
android:layout_width="wrap_content"
android:visibility="gone"
android:layout_height="26dp"
android:layout_below="@id/hour_rank_layout"
android:layout_marginLeft="10dp"
@ -986,6 +987,7 @@
android:id="@+id/gif_gift_tip_group_all_server"
android:layout_width="match_parent"
android:layout_height="36dp"
android:visibility="gone"
android:translationX="500dp">
<LinearLayout
@ -1058,6 +1060,7 @@
<FrameLayout
android:id="@+id/gif_gift_tip_group_buy_guard"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="36dp"
android:translationX="500dp">
@ -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 @@
<FrameLayout
android:id="@+id/gif_gift_tip_group_buy_vip"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="36dp"
android:translationX="500dp">

View File

@ -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: