This commit is contained in:
zlzw 2022-09-09 15:20:59 +08:00
parent 89ed3f5121
commit dd39064ca5
10 changed files with 187 additions and 109 deletions

View File

@ -3,18 +3,14 @@ package com.shayu.phonelive;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.net.Uri;
import android.net.http.HttpResponseCache;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.adjust.sdk.Adjust;
import com.adjust.sdk.AdjustConfig;
@ -31,16 +27,12 @@ import com.tencent.imsdk.v2.V2TIMUserInfo;
import com.yunbao.common.BuildConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
import com.yunbao.common.glide.ImageLoadUtils;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.manager.imrongcloud.InstructorSendReward;
import com.yunbao.common.manager.imrongcloud.InstructorSendRewardProvider;
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
import com.yunbao.common.manager.imrongcloud.RecommendLiveRoom;
import com.yunbao.common.utils.FileUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.views.RecommendLiveRoomProvider;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
import com.yunbao.common.utils.L;
@ -52,8 +44,6 @@ import com.yunbao.main.activity.MsgSettActivity;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import io.rong.imkit.config.RongConfigCenter;
@ -123,7 +113,7 @@ public class AppContext extends CommonAppContext {
super.onCreate();
//注册全局异常捕获
//registerError();
ImageLoadUtils.initImageLoader(this);
// ImageLoadUtils.initImageLoader(this);
sInstance = this;
L.setDeBug(BuildConfig.DEBUG);
AppEventsLogger.activateApp(this);

View File

@ -395,7 +395,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setBackgroundColor(0xffffffff);
mImageViewList.add(imageView);
ImgLoader.display(mContext, mAdList.get(i).getUrl(), imageView);
ImgLoader.display(mContext, mAdList.get(i).getUrl(), imageView,480,960);
}
for (int i = imgSize - 1; i >= 0; i--) {
mContainer.addView(mImageViewList.get(i));
@ -553,7 +553,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
public void onDataUserInfoEvent(DataUserInfoEvent event) {
if (event.isUpDataSuccess()) {
//融云连接服务器
RongcloudIMManager.connectIM(this);
RongcloudIMManager.connectIM(getApplication());
forwardMainActivity();
} else {
releaseVideo();

View File

@ -128,8 +128,6 @@ dependencies {
//
api rootProject.ext.dependencies["Luban"]
//
api rootProject.ext.dependencies["imageloader"]
//Picker控件
api files('libs/AndroidPicker-1.5.6.jar')

View File

@ -1,64 +0,0 @@
package com.yunbao.common.glide;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.ImageSize;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import jp.wasabeef.glide.transformations.BlurTransformation;
public class ImageLoadUtils {
public static void initImageLoader(Context context) {
ImageLoader imageLoader = ImageLoader.getInstance();
ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(context)
.diskCache(new UnlimitedDiskCache(context.getCacheDir()))
.diskCacheSize(50 * 1024 * 1024)
.diskCacheFileCount(100)
.memoryCache(new LruMemoryCache(2 * 1024 * 1024))
.memoryCacheSize(2 * 1024 * 1024)
.build();
imageLoader.init(configuration);
}
private static ImageLoader getLoader() {
return ImageLoader.getInstance();
}
private static DisplayImageOptions getDisplayImageOptions() {
return new DisplayImageOptions.Builder()
.bitmapConfig(Bitmap.Config.RGB_565)
.build();
}
public static void loadUrl(String url, int width, int height, ImageView imageView) {
//ImageSize size = new ImageSize(width, height);
//getLoader().displayImage(url,imageView,size);
}
public static void loadUrlToBlur(Context context,String url,int width,int height,ImageView imageView){
getLoader().loadImage(url,new ImageSize(width,height),getDisplayImageOptions(),new SimpleImageLoadingListener(){
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
super.onLoadingComplete(imageUri, view, loadedImage);
Glide.with(context).asBitmap().load(loadedImage)
.skipMemoryCache(false)
.apply(RequestOptions.bitmapTransform( new BlurTransformation(25)))
.into(imageView);
}
});
}
}

View File

@ -2,7 +2,9 @@ package com.yunbao.common.glide;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.media.ThumbnailUtils;
import android.net.Uri;
import android.widget.ImageView;
@ -11,6 +13,7 @@ import androidx.annotation.Nullable;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import com.yunbao.common.R;
@ -32,36 +35,113 @@ public class ImgLoader {
sBlurTransformation = new BlurTransformation(25);
}
public static void display(Context context, String url, ImageView imageView) {
display(context, url, imageView, -1, -1);
}
public static void display(Context context, String url, ImageView imageView, int width, int height) {
if (!contextIsExist(context)) {
return;
}
Glide.with(context).asDrawable().load(url).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView);
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) {
}
});
}
public static void display2(Context context, String url, ImageView imageView) {
display2(context, url, imageView, -1, -1);
}
public static void display2(Context context, String url, ImageView imageView, int width, int height) {
if (!contextIsExist(context)) {
return;
}
Glide.with(context).asDrawable().load(url).placeholder(imageView.getDrawable()).dontAnimate().skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView);
Glide.with(context)
.asBitmap()
.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) {
}
});
}
public static void display2(Context context, int url, ImageView imageView) {
if (!contextIsExist(context)) {
return;
}
Glide.with(context).asDrawable().load(url).placeholder(imageView.getDrawable()).dontAnimate().skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView);
Glide.with(context)
.asDrawable()
.load(url)
.placeholder(imageView.getDrawable())
.dontAnimate()
.skipMemoryCache(SKIP_MEMORY_CACHE)
.into(imageView);
}
public static void displayWithError(Context context, String url, ImageView imageView, int errorRes) {
displayWithError(context, url, imageView, errorRes, -1, -1);
}
public static void displayWithError(Context context, String url, ImageView imageView, int errorRes, int width, int height) {
if (!contextIsExist(context)) {
return;
}
if (imageView == null) {
return;
}
Glide.with(context).asDrawable().load(url).error(errorRes).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView);
Glide.with(context)
.asBitmap()
.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) {
}
});
}
public static void displayWithError(Context context, int url, ImageView imageView, int errorRes) {
@ -78,8 +158,34 @@ public class ImgLoader {
if (!contextIsExist(context)) {
return;
}
displayWithError(context, url, imageView, R.mipmap.icon_avatar_placeholder);
displayAvatar(context, url, imageView, -1, -1);
}
public static void displayAvatar(Context context, String url, ImageView imageView, int width, int height) {
if (!contextIsExist(context)) {
return;
}
Glide.with(context)
.asBitmap()
.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) {
}
});
}
public static void displayAvatar(Context context, int url, ImageView imageView) {
@ -94,14 +200,22 @@ public class ImgLoader {
if (!contextIsExist(context)) {
return;
}
Glide.with(context).asDrawable().load(file).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView);
Glide.with(context)
.asDrawable()
.load(file)
.skipMemoryCache(SKIP_MEMORY_CACHE)
.into(imageView);
}
public static void display(Context context, int res, ImageView imageView) {
if (!contextIsExist(context)) {
return;
}
Glide.with(context).asDrawable().load(res).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView);
Glide.with(context)
.asDrawable()
.load(res)
.skipMemoryCache(SKIP_MEMORY_CACHE)
.into(imageView);
}
/**
@ -111,7 +225,11 @@ public class ImgLoader {
if (!contextIsExist(context)) {
return;
}
Glide.with(context).asDrawable().load(Uri.fromFile(new File(videoPath))).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView);
Glide.with(context)
.asDrawable()
.load(Uri.fromFile(new File(videoPath)))
.skipMemoryCache(SKIP_MEMORY_CACHE)
.into(imageView);
}
/**
@ -121,7 +239,11 @@ public class ImgLoader {
if (!contextIsExist(context)) {
return;
}
Glide.with(context).asGif().load(videoPath).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView);
Glide.with(context)
.asGif()
.load(videoPath)
.skipMemoryCache(SKIP_MEMORY_CACHE)
.into(imageView);
}
public static void displayDrawable(Context context, String url, final DrawableCallback callback) {
@ -158,27 +280,67 @@ public class ImgLoader {
* 显示模糊的毛玻璃图片
*/
public static void displayBlur(Context context, String url, ImageView imageView) {
displayBlur(context, url, imageView, -1, -1);
}
public static void displayBlur(Context context, String url, ImageView imageView, int width, int height) {
if (!contextIsExist(context)) {
return;
}
Glide.with(context).asDrawable().load(url)
Glide.with(context)
.asBitmap()
.load(url)
.skipMemoryCache(SKIP_MEMORY_CACHE)
.apply(RequestOptions.bitmapTransform(sBlurTransformation))
.into(imageView);
.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) {
}
});
}
/**
* 显示模糊的毛玻璃图片
*/
public static void displayBlurLive(Context context, String url, ImageView imageView) {
displayBlurLive(context, url, imageView, -1, -1);
}
public static void displayBlurLive(Context context, String url, ImageView imageView, int width, int height) {
if (!contextIsExist(context)) {
return;
}
Glide.with(context).asDrawable().load(url)
Glide.with(context).asBitmap().load(url)
.skipMemoryCache(SKIP_MEMORY_CACHE)
.apply(RequestOptions.bitmapTransform(new BlurTransformation(100)))
.placeholder(R.mipmap.live_bg)
.into(imageView);
.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) {
}
});
}
private static boolean contextIsExist(Context context) {

View File

@ -8,6 +8,7 @@ import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.ms.banner.holder.BannerViewHolder;
import com.yunbao.common.bean.BannerBean;
import com.yunbao.common.glide.ImgLoader;
public class CustomViewHolder implements BannerViewHolder<BannerBean> {
@ -20,7 +21,8 @@ public class CustomViewHolder implements BannerViewHolder<BannerBean> {
);
imageView.setLayoutParams(params);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
Glide.with(context).load(data.getImageUrl()).into(imageView);
//Glide.with(context).load(data.getImageUrl()).into(imageView);
ImgLoader.display(context,data.getImageUrl(),imageView,600,170);
return imageView;
}

View File

@ -31,7 +31,6 @@ ext {
"arouter-compiler" : 'com.alibaba:arouter-compiler:1.2.2',
"blank-utilcode" : 'com.blankj:utilcode:1.25.9',
"leakcanary" : 'com.squareup.leakcanary:leakcanary-android:2.9.1',
"imageloader" : 'com.nostra13.universalimageloader:universal-image-loader:1.9.5',
]

View File

@ -3,30 +3,22 @@ package com.yunbao.live.adapter;
import static android.text.TextUtils.isEmpty;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.media.ThumbnailUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.opensource.svgaplayer.SVGACallback;
import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImageLoadUtils;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.SVGAViewUtils;
@ -121,8 +113,8 @@ public class LiveUserAdapter extends RecyclerView.Adapter<LiveUserAdapter.Vh> {
itemView.setTag(position);
if (payload == null) {
// ImgLoader.displayAvatar(mContext, userBean.getAvatar(), mAvatar);
ImageLoadUtils.loadUrl(userBean.getAvatar(),32,32,mAvatar);
ImgLoader.displayAvatar(mContext, userBean.getAvatar(), mAvatar,16,16);
// ImageLoadUtils.loadUrl(userBean.getAvatar(),32,32,mAvatar);
}
if (userBean.getDress() != null) {

View File

@ -34,7 +34,6 @@ import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.custom.MyViewPager;
import com.yunbao.common.event.FollowEvent;
import com.yunbao.common.glide.ImageLoadUtils;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.CommonHttpUtil;
@ -240,8 +239,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
//直播间背景
//ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack);
ImageLoadUtils.loadUrlToBlur(mContext,mLiveBean.getAvatar(),400,600,liveBack);
ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack,400,600);
//ImageLoadUtils.loadUrlToBlur(mContext,mLiveBean.getAvatar(),400,600,liveBack);
mask.setVisibility(View.VISIBLE);
mLivePlayViewHolder.setCover(data.getThumb());
mLivePlayViewHolder.play(data.getPull());

View File

@ -72,7 +72,7 @@ public class MainHomeLiveItemViewHolder extends RecyclerView.ViewHolder {
.load(bean.getContent_pic_size_three())
.into(liveType);
}
ImgLoader.display(itemView.getContext(), bean.getThumb(), mCover);
ImgLoader.display(itemView.getContext(), bean.getThumb(), mCover,300,300);
bgs.setVisibility(View.VISIBLE);
pkico.setVisibility(View.GONE);
pkAvatar.setVisibility(View.GONE);