From 89ed3f5121ef02cd248341775731ec25b60fcc91 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Fri, 9 Sep 2022 13:36:01 +0800 Subject: [PATCH] update --- app/build.gradle | 2 + .../java/com/shayu/phonelive/AppContext.java | 4 + .../com/shayu/phonelive/NeverCrashUtils.java | 4 +- common/build.gradle | 2 + .../yunbao/common/glide/ImageLoadUtils.java | 64 +++++++++ .../yunbao/common/utils/SVGAViewUtils.java | 31 +++++ dependencies.gradle | 2 + .../live/activity/ZhuangBanActivity.java | 3 +- .../yunbao/live/adapter/LiveUserAdapter.java | 130 ++++-------------- .../live/adapter/UserMicInfoAdapter.java | 3 +- .../live/adapter/UserMoreInfoAdapter.java | 3 +- .../dialog/LiveGiveHotDialogFragment.java | 3 +- .../live/dialog/LiveUserDialogFragment.java | 3 +- .../presenter/LiveEnterRoomAnimPresenter.java | 5 +- .../live/presenter/LiveGiftAnimPresenter.java | 4 +- .../live/views/LiveAudienceViewHolder.java | 9 +- .../yunbao/live/views/LiveRoomViewHolder.java | 3 +- .../live/views/PortraitLiveManager.java | 4 +- .../PDLiveConversationListActivity.java | 3 +- .../yunbao/main/activity/RewardActivity.java | 3 +- .../main/activity/ZhuangBanActivity.java | 3 +- .../main/adapter/MainHomeLiveAdapter.java | 3 +- .../yunbao/main/adapter/MainListAdapter.java | 7 +- .../views/MainHomeLiveWeekItemViewHolder.java | 3 +- .../yunbao/main/views/MainMeViewHolder.java | 3 +- .../yunbao/main/views/MainMeViewHolder1.java | 3 +- .../main/views/UserHomeViewHolder2.java | 3 +- 27 files changed, 181 insertions(+), 129 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/glide/ImageLoadUtils.java create mode 100644 common/src/main/java/com/yunbao/common/utils/SVGAViewUtils.java diff --git a/app/build.gradle b/app/build.gradle index 2896af99a..cbb426cb0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -111,5 +111,7 @@ dependencies { api project(':video') annotationProcessor rootProject.ext.dependencies["arouter-compiler"] + implementation rootProject.ext.dependencies["leakcanary"] + } diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index fdb5dfb3f..74bf73508 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -3,6 +3,7 @@ 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; @@ -30,6 +31,8 @@ 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; @@ -120,6 +123,7 @@ public class AppContext extends CommonAppContext { super.onCreate(); //注册全局异常捕获 //registerError(); + ImageLoadUtils.initImageLoader(this); sInstance = this; L.setDeBug(BuildConfig.DEBUG); AppEventsLogger.activateApp(this); diff --git a/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java b/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java index 00a795770..cd6a9a9bc 100644 --- a/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java +++ b/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java @@ -94,8 +94,9 @@ public class NeverCrashUtils { if (isDebugMode()) { Log.e(TAG, "未捕获的主线程异常行为", e); } + e.printStackTrace(); Toast.makeText(application, "发生闪退", Toast.LENGTH_SHORT).show(); - FileUtil.saveStringToFile(new File(application.getDir("files", Context.MODE_PRIVATE).getAbsolutePath()),throwableToString(e),"error.log"); + // FileUtil.saveStringToFile(new File(application.getDir("files", Context.MODE_PRIVATE).getAbsolutePath()),throwableToString(e),"error.log"); getMainCrashHandler().mainException(Looper.getMainLooper().getThread(), e); } } @@ -106,6 +107,7 @@ public class NeverCrashUtils { if (isDebugMode()) { Log.e(TAG, "未捕获的子线程异常行为", e); } + e.printStackTrace(); Toast.makeText(application, "发生闪退", Toast.LENGTH_SHORT).show(); FileUtil.saveStringToFile(new File(application.getDir("files", Context.MODE_PRIVATE).getAbsolutePath()),throwableToString(e),"error.log"); getMainCrashHandler().mainException(Looper.getMainLooper().getThread(), e); diff --git a/common/build.gradle b/common/build.gradle index eb03a2177..6e39ec1eb 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -128,6 +128,8 @@ dependencies { //鲁班 api rootProject.ext.dependencies["Luban"] + //图片加载器,可以压缩图 + api rootProject.ext.dependencies["imageloader"] //一个Picker控件,选择日期,城市用 api files('libs/AndroidPicker-1.5.6.jar') diff --git a/common/src/main/java/com/yunbao/common/glide/ImageLoadUtils.java b/common/src/main/java/com/yunbao/common/glide/ImageLoadUtils.java new file mode 100644 index 000000000..78a07eb6c --- /dev/null +++ b/common/src/main/java/com/yunbao/common/glide/ImageLoadUtils.java @@ -0,0 +1,64 @@ +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); + } + }); + + } + +} diff --git a/common/src/main/java/com/yunbao/common/utils/SVGAViewUtils.java b/common/src/main/java/com/yunbao/common/utils/SVGAViewUtils.java new file mode 100644 index 000000000..4e63d6ebf --- /dev/null +++ b/common/src/main/java/com/yunbao/common/utils/SVGAViewUtils.java @@ -0,0 +1,31 @@ +package com.yunbao.common.utils; + +import com.opensource.svgaplayer.SVGACallback; +import com.opensource.svgaplayer.SVGAImageView; + +public class SVGAViewUtils { + public static void playEndClear(SVGAImageView svga){ + svga.setCallback(new SVGACallback() { + @Override + public void onPause() { + + } + + @Override + public void onFinished() { + svga.clear(); + } + + @Override + public void onRepeat() { + + } + + @Override + public void onStep(int i, double v) { + + } + }); + svga.startAnimation(); + } +} diff --git a/dependencies.gradle b/dependencies.gradle index 48d15d066..e1345a60d 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -30,6 +30,8 @@ ext { "arouter" : 'com.alibaba:arouter-api:1.5.2',//ARouter "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', ] diff --git a/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java b/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java index 8cfc7ae1d..125848530 100644 --- a/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java @@ -39,6 +39,7 @@ import com.yunbao.common.Constants; import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.L; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; @@ -160,7 +161,7 @@ public class ZhuangBanActivity extends AbsActivity { SVGADrawable drawable = new SVGADrawable(videoItem); svga.setImageDrawable(drawable); svga.setLoops(1); - svga.startAnimation(); + SVGAViewUtils.playEndClear(svga); } @Override diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveUserAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveUserAdapter.java index afd597792..0520cebbb 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveUserAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveUserAdapter.java @@ -1,36 +1,43 @@ package com.yunbao.live.adapter; -import android.content.Context; -import android.graphics.drawable.Drawable; -import androidx.annotation.NonNull; -import androidx.core.content.ContextCompat; -import androidx.recyclerview.widget.RecyclerView; +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.CommonAppConfig; import com.yunbao.common.Constants; -import com.yunbao.live.R; -import com.yunbao.common.bean.LevelBean; -import com.yunbao.live.bean.LiveUserGiftBean; 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; +import com.yunbao.live.R; +import com.yunbao.live.bean.LiveUserGiftBean; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; -import static android.text.TextUtils.isEmpty; - /** * Created by cxf on 2018/10/10. */ @@ -103,7 +110,7 @@ public class LiveUserAdapter extends RecyclerView.Adapter { public Vh(View itemView) { super(itemView); mWrap = (ImageView) itemView.findViewById(R.id.wrap); - gift_svga = (SVGAImageView)itemView.findViewById(R.id.gift_svga); + gift_svga = (SVGAImageView) itemView.findViewById(R.id.gift_svga); mAvatar = (ImageView) itemView.findViewById(R.id.avatar); mIcon = (ImageView) itemView.findViewById(R.id.icon); mGuardIcon = (ImageView) itemView.findViewById(R.id.guard_icon); @@ -114,37 +121,12 @@ public class LiveUserAdapter extends RecyclerView.Adapter { itemView.setTag(position); if (payload == null) { - ImgLoader.displayAvatar(mContext, userBean.getAvatar(), mAvatar); - LevelBean levelBean = CommonAppConfig.getInstance().getLevel(userBean.getLevel()); -// if (levelBean != null) { -// ImgLoader.display(mContext, levelBean.getThumbIcon(), mIcon); -// } + // ImgLoader.displayAvatar(mContext, userBean.getAvatar(), mAvatar); + ImageLoadUtils.loadUrl(userBean.getAvatar(),32,32,mAvatar); } - int guardType = userBean.getGuardType(); -// if (guardType == Constants.GUARD_TYPE_NONE) { -// if (mIcon.getVisibility() != View.VISIBLE) { -// mIcon.setVisibility(View.VISIBLE); -// } -// if (mGuardIcon.getVisibility() == View.VISIBLE) { -// mGuardIcon.setVisibility(View.INVISIBLE); -// } -// } else { -// if (mIcon.getVisibility() == View.VISIBLE) { -// mIcon.setVisibility(View.INVISIBLE); -// } -// if (mGuardIcon.getVisibility() != View.VISIBLE) { -// mGuardIcon.setVisibility(View.VISIBLE); -// } -// if (guardType == Constants.GUARD_TYPE_DAY) { -// mGuardIcon.setImageDrawable(mGuardDrawable0); -// }else if (guardType == Constants.GUARD_TYPE_MONTH) { -// mGuardIcon.setImageDrawable(mGuardDrawable1); -// } else if (guardType == Constants.GUARD_TYPE_YEAR) { -// mGuardIcon.setImageDrawable(mGuardDrawable2); -// } -// } - if(userBean.getDress()!=null){ - if(userBean.getDress().getAvatar_frame().contains("svga")) { + + if (userBean.getDress() != null) { + if (userBean.getDress().getAvatar_frame().contains("svga")) { try { new SVGAParser(mContext).parse(new URL(userBean.getDress().getAvatar_frame()), new SVGAParser.ParseCompletion() { @@ -152,7 +134,7 @@ public class LiveUserAdapter extends RecyclerView.Adapter { public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); gift_svga.setImageDrawable(drawable); - gift_svga.startAnimation(); + SVGAViewUtils.playEndClear(gift_svga); } @Override @@ -162,25 +144,10 @@ public class LiveUserAdapter extends RecyclerView.Adapter { } catch (MalformedURLException e) { e.printStackTrace(); } - }else{ - ImgLoader.display(mContext,userBean.getDress().getAvatar_frame(), gift_svga); + } else { + ImgLoader.display(mContext, userBean.getDress().getAvatar_frame(), gift_svga); } } -// if (position == 0) { -// if (userBean.hasContribution()) { -// mWrap.setImageResource(R.mipmap.icon_live_user_list_1); -// } -// } else if (position == 1) { -// if (userBean.hasContribution()) { -// mWrap.setImageResource(R.mipmap.icon_live_user_list_2); -// } -// } else if (position == 2) { -// if (userBean.hasContribution()) { -// mWrap.setImageResource(R.mipmap.icon_live_user_list_3); -// } -// } else { -// mWrap.setImageDrawable(null); -// } } } @@ -216,49 +183,6 @@ public class LiveUserAdapter extends RecyclerView.Adapter { } } -// public void insertItem(LiveUserGiftBean userBean) { -// if (userBean == null) { -// return; -// } -// int position = findItemPosition(userBean.getId()); -// if (position >= 0) { -// return; -// } -// int size = mList.size(); -// mList.add(userBean); -// notifyDataSetChanged(); -//// notifyItemInserted(size); -// } -// -// public void insertList(List list) { -// for (int i = 0; i < list.size(); i++) { -// } -// if (mList != null && list != null && list.size() > 0) { -// int position = mList.size(); -// mList.addAll(list); -// notifyItemRangeInserted(position, mList.size()); -// } -// } - -// /** -// * 守护信息发生变化 -// */ -// public void onGuardChanged(String uid, int guardType) { -// if (!isEmpty(uid)) { -// for (int i = 0, size = mList.size(); i < size; i++) { -// LiveUserGiftBean bean = mList.get(i); -// if (uid.equals(bean.getId())) { -// if (bean.getGuardType() != guardType) { -// Log.d("onGuardChanged",""+bean.getGuardType()); -// bean.setGuardType(guardType); -// notifyItemChanged(i, Constants.PAYLOAD); -// } -// break; -// } -// } -// } -// } - public void clear() { if (mList != null) { mList.clear(); diff --git a/live/src/main/java/com/yunbao/live/adapter/UserMicInfoAdapter.java b/live/src/main/java/com/yunbao/live/adapter/UserMicInfoAdapter.java index 3b515a346..f01e0bab5 100644 --- a/live/src/main/java/com/yunbao/live/adapter/UserMicInfoAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/UserMicInfoAdapter.java @@ -21,6 +21,7 @@ import com.yunbao.common.bean.LevelBean; import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.utils.CommonIconUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.bean.MicUserBean; @@ -96,7 +97,7 @@ public class UserMicInfoAdapter extends RefreshAdapter { public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); gift_svga.setImageDrawable(drawable); - gift_svga.startAnimation(); + SVGAViewUtils.playEndClear(gift_svga); } @Override 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 148ea8aab..75ed12e3f 100644 --- a/live/src/main/java/com/yunbao/live/adapter/UserMoreInfoAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/UserMoreInfoAdapter.java @@ -28,6 +28,7 @@ import com.yunbao.common.bean.UserBean; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.utils.CommonIconUtil; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.bean.LiveUserGiftBean; @@ -252,7 +253,7 @@ public class UserMoreInfoAdapter extends RefreshAdapter { public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); gift_svga.setImageDrawable(drawable); - gift_svga.startAnimation(); + SVGAViewUtils.playEndClear(gift_svga); } @Override diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGiveHotDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveGiveHotDialogFragment.java index e9f556b54..b82f1e3c8 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGiveHotDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGiveHotDialogFragment.java @@ -31,6 +31,7 @@ import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.utils.CommonIconUtil; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.bean.HotBean; @@ -218,7 +219,7 @@ public class LiveGiveHotDialogFragment extends AbsDialogFragment { public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); viewHolder.gift_svga.setImageDrawable(drawable); - viewHolder.gift_svga.startAnimation(); + SVGAViewUtils.playEndClear(viewHolder.gift_svga); } @Override diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java index 864dec6fe..48b056bcc 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java @@ -36,6 +36,7 @@ import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.utils.CommonIconUtil; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; @@ -368,7 +369,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); gift_svga.setImageDrawable(drawable); - gift_svga.startAnimation(); + SVGAViewUtils.playEndClear(gift_svga); } @Override diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java index 71090e1d6..023586bed 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java @@ -39,6 +39,7 @@ import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.GifCacheUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.live.R; import com.yunbao.live.bean.LiveChatBean; @@ -310,7 +311,7 @@ public class LiveEnterRoomAnimPresenter { SVGARect rect = svgaVideoEntity.getVideoSize(); enter_room_svg_small.setVideoItem(svgaVideoEntity); enter_room_svg_small.setLoops(1); - enter_room_svg_small.startAnimation(); + SVGAViewUtils.playEndClear(enter_room_svg_small); } } else { if (mSVGImageView != null) { @@ -318,7 +319,6 @@ public class LiveEnterRoomAnimPresenter { SVGARect rect = svgaVideoEntity.getVideoSize(); mSVGImageView.setVideoItem(svgaVideoEntity); mSVGImageView.setLoops(1); - mSVGImageView.startAnimation(); mSVGImageView.setCallback(new SVGACallback() { @Override public void onPause() { @@ -343,6 +343,7 @@ public class LiveEnterRoomAnimPresenter { } }); + mSVGImageView.startAnimation(); } } mIsAnimating = false; 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 84e7e2713..a9759841c 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java @@ -592,6 +592,7 @@ public class LiveGiftAnimPresenter { if (mHandler != null) { mHandler.sendEmptyMessageDelayed(WHAT_GIF, diffTime); } + mSVGAImageView.clear(); } @Override @@ -614,6 +615,7 @@ public class LiveGiftAnimPresenter { if (diffTime < 0) { diffTime = 0; } + mSVGAImageViewFront.clear(); // if (mHandler != null) { // mHandler.sendEmptyMessageDelayed(WHAT_GIF_All_SERVER, diffTime); // } @@ -1224,7 +1226,6 @@ public class LiveGiftAnimPresenter { resizeSvgaImageView(rect.getWidth(), rect.getHeight()); mSvgaPlayTime = System.currentTimeMillis(); mSVGAImageView.setVideoItem(svgaVideoEntity); - mSVGAImageView.startAnimation(); mSVGAImageView.setCallback(new SVGACallback() { @Override public void onPause() { @@ -1254,6 +1255,7 @@ public class LiveGiftAnimPresenter { } }); + mSVGAImageView.startAnimation(); } } diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java index 3a96bd73d..96c4d00fc 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java @@ -37,6 +37,7 @@ import com.yunbao.common.http.HttpClient; import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; @@ -125,7 +126,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); svga_new_user_gif.setImageDrawable(drawable); - svga_new_user_gif.startAnimation(); + SVGAViewUtils.playEndClear(svga_new_user_gif); } @Override @@ -144,7 +145,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { SVGADrawable drawable = new SVGADrawable(videoItem); svga_new_user_double.setImageDrawable(drawable); svga_new_user_double.setBackgroundResource(R.mipmap.black_bg); - svga_new_user_double.startAnimation(); + SVGAViewUtils.playEndClear(svga_new_user_double); } @Override @@ -161,7 +162,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); svga_new_user_follow.setImageDrawable(drawable); - svga_new_user_follow.startAnimation(); + SVGAViewUtils.playEndClear(svga_new_user_follow); } @Override @@ -248,7 +249,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { @Override public void onFinished() { - + svga_station_horn.clear(); } @Override diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index b4f57a372..6561b2579 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -72,6 +72,7 @@ import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.StringUtil; @@ -356,7 +357,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); mSVGAImageView.setImageDrawable(drawable); - mSVGAImageView.startAnimation(); + SVGAViewUtils.playEndClear(mSVGAImageView); } @Override diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 0047042d2..89c848c3b 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -34,6 +34,7 @@ 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; @@ -239,7 +240,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null); //直播间背景 - ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack); + //ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack); + ImageLoadUtils.loadUrlToBlur(mContext,mLiveBean.getAvatar(),400,600,liveBack); mask.setVisibility(View.VISIBLE); mLivePlayViewHolder.setCover(data.getThumb()); mLivePlayViewHolder.play(data.getPull()); diff --git a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java index 447f42024..97ef35e76 100644 --- a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java @@ -46,6 +46,7 @@ import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.ProcessResultUtil; import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.live.activity.LiveAudienceActivity; @@ -145,7 +146,7 @@ public class PDLiveConversationListActivity extends AbsActivity implements View. public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); guidSvga.setImageDrawable(drawable); - guidSvga.startAnimation(); + SVGAViewUtils.playEndClear(guidSvga); } @Override diff --git a/main/src/main/java/com/yunbao/main/activity/RewardActivity.java b/main/src/main/java/com/yunbao/main/activity/RewardActivity.java index 471eedd95..6766a96d1 100644 --- a/main/src/main/java/com/yunbao/main/activity/RewardActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/RewardActivity.java @@ -44,6 +44,7 @@ import com.yunbao.common.utils.GifCacheUtil; import com.yunbao.common.utils.L; import com.yunbao.common.utils.ProcessImageUtil; import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.main.R; @@ -187,7 +188,7 @@ public class RewardActivity extends AbsActivity { SVGADrawable drawable = new SVGADrawable(videoItem); svga.setImageDrawable(drawable); svga.setLoops(1); - svga.startAnimation(); + SVGAViewUtils.playEndClear(svga); } @Override diff --git a/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java b/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java index 30f1b3e1a..6b7a895e0 100644 --- a/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java @@ -35,6 +35,7 @@ import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.GifCacheUtil; import com.yunbao.common.utils.L; import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.main.R; @@ -192,7 +193,7 @@ public class ZhuangBanActivity extends AbsActivity { SVGADrawable drawable = new SVGADrawable(videoItem); svga.setImageDrawable(drawable); svga.setLoops(1); - svga.startAnimation(); + SVGAViewUtils.playEndClear(svga); } @Override diff --git a/main/src/main/java/com/yunbao/main/adapter/MainHomeLiveAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MainHomeLiveAdapter.java index 74bd1d236..e06415ee2 100644 --- a/main/src/main/java/com/yunbao/main/adapter/MainHomeLiveAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeLiveAdapter.java @@ -28,6 +28,7 @@ import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.bean.WeekListBean; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.live.bean.LiveBean; import com.yunbao.main.R; import com.yunbao.main.views.MainHomeLiveItemViewHolder; @@ -205,7 +206,7 @@ public class MainHomeLiveAdapter extends RefreshAdapter { public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); week_svga.setImageDrawable(drawable); - week_svga.startAnimation(); + SVGAViewUtils.playEndClear(week_svga); Log.e("MainHomeLiveAdapter", position + " ***************" + "onComplete"); } diff --git a/main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java index 026336a26..4eac2b55f 100644 --- a/main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java @@ -23,6 +23,7 @@ import com.yunbao.common.custom.MyRadioButton; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.utils.CommonIconUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.main.R; @@ -281,7 +282,7 @@ public class MainListAdapter extends RefreshAdapter { public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); svga1.setImageDrawable(drawable); - svga1.startAnimation(); + SVGAViewUtils.playEndClear(svga1); } @Override @@ -347,7 +348,7 @@ public class MainListAdapter extends RefreshAdapter { public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); svga2.setImageDrawable(drawable); - svga2.startAnimation(); + SVGAViewUtils.playEndClear(svga2); } @Override @@ -426,7 +427,7 @@ public class MainListAdapter extends RefreshAdapter { public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); svga3.setImageDrawable(drawable); - svga3.startAnimation(); + SVGAViewUtils.playEndClear(svga3); } @Override diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeLiveWeekItemViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeLiveWeekItemViewHolder.java index 6b9fa0235..a60493099 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeLiveWeekItemViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeLiveWeekItemViewHolder.java @@ -18,6 +18,7 @@ import com.opensource.svgaplayer.SVGAParser; import com.opensource.svgaplayer.SVGAVideoEntity; import com.yunbao.common.bean.WeekListBean; import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.live.bean.LiveBean; import com.yunbao.main.R; @@ -66,7 +67,7 @@ public class MainHomeLiveWeekItemViewHolder extends RecyclerView.ViewHolder { public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); weekSvga.setImageDrawable(drawable); - weekSvga.startAnimation(); + SVGAViewUtils.playEndClear(weekSvga); weekSvga.setClearsAfterStop(false); } diff --git a/main/src/main/java/com/yunbao/main/views/MainMeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainMeViewHolder.java index 4217724c5..e850af254 100644 --- a/main/src/main/java/com/yunbao/main/views/MainMeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainMeViewHolder.java @@ -39,6 +39,7 @@ import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.AbsMainViewHolder; import com.yunbao.common.views.weight.ViewClicksAntiShake; @@ -312,7 +313,7 @@ public class MainMeViewHolder extends AbsMainViewHolder implements OnItemClickLi public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); gift_svga.setImageDrawable(drawable); - gift_svga.startAnimation(); + SVGAViewUtils.playEndClear(gift_svga); } @Override diff --git a/main/src/main/java/com/yunbao/main/views/MainMeViewHolder1.java b/main/src/main/java/com/yunbao/main/views/MainMeViewHolder1.java index 379c0bc59..db8a1620c 100644 --- a/main/src/main/java/com/yunbao/main/views/MainMeViewHolder1.java +++ b/main/src/main/java/com/yunbao/main/views/MainMeViewHolder1.java @@ -29,6 +29,7 @@ import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.views.AbsMainViewHolder; import com.yunbao.live.activity.LiveRecordActivity; import com.yunbao.live.activity.RoomManageActivity; @@ -266,7 +267,7 @@ public class MainMeViewHolder1 extends AbsMainViewHolder implements OnItemClickL public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); gift_svga.setImageDrawable(drawable); - gift_svga.startAnimation(); + SVGAViewUtils.playEndClear(gift_svga); } @Override diff --git a/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java b/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java index 95368d061..65dfd5afb 100644 --- a/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java +++ b/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java @@ -42,6 +42,7 @@ import com.yunbao.common.http.HttpCallback; import com.yunbao.common.utils.CommonIconUtil; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; @@ -467,7 +468,7 @@ public class UserHomeViewHolder2 extends AbsLivePageViewHolder implements LiveSh public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); gift_svga.setImageDrawable(drawable); - gift_svga.startAnimation(); + SVGAViewUtils.playEndClear(gift_svga); } @Override