diff --git a/app/build.gradle b/app/build.gradle index f0660033f..f838876d8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -87,6 +87,7 @@ android { } debug { signingConfig signingConfigs.release + debuggable true } } lintOptions { @@ -111,6 +112,8 @@ 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 15fb2f802..f1a7fa8bf 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -4,16 +4,13 @@ import android.app.Activity; import android.app.ActivityManager; import android.content.Context; 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; @@ -50,8 +47,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; 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/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java b/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java index 8f3d5c965..6bfaea32b 100644 --- a/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java +++ b/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java @@ -386,7 +386,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)); @@ -544,7 +544,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(); diff --git a/build.gradle b/build.gradle index a2d26b2a5..c23bf76cb 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ apply from: "dependencies.gradle" buildscript { - ext.kotlin_version = '1.4.32' + ext.kotlin_version = '1.6.20' repositories { maven { url "https://mvn.mob.com/android" } maven { url 'https://maven.aliyun.com/repository/public' } @@ -16,10 +16,10 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.5.4' + classpath 'com.android.tools.build:gradle:4.0.2' //一键压缩png工具 - classpath 'com.chenenyu:img-optimizer:1.1.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32" + classpath 'com.chenenyu:img-optimizer:1.3.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20" classpath 'com.google.gms:google-services:4.3.3' } diff --git a/common/build.gradle b/common/build.gradle index 00c597925..2ec9736ae 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -104,7 +104,9 @@ dependencies { api rootProject.ext.dependencies["gif-drawable"] //svga播放器 - api rootProject.ext.dependencies["SVGAPlayer"] + //api rootProject.ext.dependencies["SVGAPlayer"] + implementation 'com.squareup.wire:wire-runtime:4.4.1' + api files('libs/library-release.aar') //七牛云存储 api rootProject.ext.dependencies["qiniu-sdk"] diff --git a/common/libs/library-release.aar b/common/libs/library-release.aar new file mode 100644 index 000000000..d4695eb68 Binary files /dev/null and b/common/libs/library-release.aar differ 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 fc8455924..02c5da4a2 100644 --- a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java +++ b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java @@ -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.text.TextUtils; import android.widget.ImageView; @@ -13,6 +15,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; @@ -33,36 +36,120 @@ 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() { + @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) { + + } + }); } public static void display2(Context context, String url, ImageView imageView) { + display2(context, url, imageView, -1, -1); + } + + /** + * 手动清空内存 + */ + 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).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() { + @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) { + + } + }); } 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() { + @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) { + + } + }); } public static void displayWithError(Context context, int url, ImageView imageView, int errorRes) { @@ -79,8 +166,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() { + @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) { + + } + }); } public static void displayAvatar(Context context, int url, ImageView imageView) { @@ -95,14 +208,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); } /** @@ -112,7 +233,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); } /** @@ -122,7 +247,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) { @@ -190,27 +319,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() { + @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) { + + } + }); } /** * 显示模糊的毛玻璃图片 */ 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))) + .apply(RequestOptions.bitmapTransform(new BlurTransformation(20))) .placeholder(R.mipmap.live_bg) - .into(imageView); + .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) { + + } + }); } private static boolean contextIsExist(Context context) { 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..e28e03ce9 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/utils/SVGAViewUtils.java @@ -0,0 +1,32 @@ +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() { + //动画结束后调用clear释放资源 + svga.clear(); + } + + @Override + public void onRepeat() { + + } + + @Override + public void onStep(int i, double v) { + + } + }); + svga.startAnimation(); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/CustomViewHolder.java b/common/src/main/java/com/yunbao/common/views/CustomViewHolder.java index 3e650f583..b52810567 100644 --- a/common/src/main/java/com/yunbao/common/views/CustomViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/CustomViewHolder.java @@ -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 { @@ -20,7 +21,8 @@ public class CustomViewHolder implements BannerViewHolder { ); 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; } diff --git a/dependencies.gradle b/dependencies.gradle index 097766920..3a028a4df 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -15,7 +15,7 @@ ext { "glide-transformations": 'jp.wasabeef:glide-transformations:3.1.1',//一个基于Glide的transformation库,拥有裁剪,着色,模糊,滤镜等多种转换效果 "roundedimageview" : 'com.makeramen:roundedimageview:2.3.0', //带圆角,边框的的ImageView "gif-drawable" : 'pl.droidsonroids.gif:android-gif-drawable:1.2.23',//gif库,播放礼物gif用 - "SVGAPlayer" : 'com.github.yyued:SVGAPlayer-Android:2.6.0', //svga播放器 + "SVGAPlayer" : 'com.github.yyued:SVGAPlayer-Android:2.6.1', //svga播放器 "qiniu-sdk" : 'com.qiniu:qiniu-android-sdk:7.2.1',//七牛云存储 // "tencent-cosxml" : 'com.tencent.qcloud:cosxml:5.4.13',//腾讯云存储 // "tencent-wechat-sdk" : 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+',//微信sdk,支付登录分享 @@ -29,6 +29,7 @@ ext { "Luban" : 'top.zibin:Luban:1.1.8',//鲁班压缩图片 "arouter" : 'com.alibaba:arouter-api:1.5.2',//ARouter "arouter-compiler" : 'com.alibaba:arouter-compiler:1.2.2', + "leakcanary" : 'com.squareup.leakcanary:leakcanary-android:2.9.1', "blank-utilcode" : 'com.blankj:utilcode:1.30.0', ] diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f55729f8f..9276a5849 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,5 +3,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index f3f7a146d..b517f1e34 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -36,6 +36,7 @@ import com.yunbao.common.bean.UserBean; import com.yunbao.common.dialog.EffectsSettingsDialog; import com.yunbao.common.dialog.LiveChargeDialogFragment; import com.yunbao.common.event.FollowEvent; +import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; @@ -474,6 +475,7 @@ public class LiveAudienceActivity extends LiveActivity { @Override protected void onDestroy() { super.onDestroy(); + ImgLoader.clearMemory(this); overridePendingTransition(0, 0); Bus.getOff(this); L.e("LiveAudienceActivity-------onDestroy------->"); 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 a968068da..aa66c34ba 100644 --- a/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java @@ -38,6 +38,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; @@ -184,7 +185,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..aa12c832b 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,35 @@ package com.yunbao.live.adapter; +import static android.text.TextUtils.isEmpty; + import android.content.Context; import android.graphics.drawable.Drawable; -import androidx.annotation.NonNull; -import androidx.core.content.ContextCompat; -import androidx.recyclerview.widget.RecyclerView; - import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.RecyclerView; + 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.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 +102,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 +113,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,64,64); + // 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 +126,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 +136,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 +175,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 6e40da6d6..3129f972e 100644 --- a/live/src/main/java/com/yunbao/live/adapter/UserMoreInfoAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/UserMoreInfoAdapter.java @@ -30,6 +30,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.common.utils.ToastUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; @@ -261,7 +262,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 cd0f8f6e1..cdc1577d8 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 c7c87f475..a157b1f6f 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java @@ -20,12 +20,14 @@ import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.ViewFlipper; +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.common.bean.MsgModel; import com.yunbao.common.bean.NewPeopleInfo; import com.yunbao.common.event.MessageIMEvent; import com.yunbao.common.glide.ImgLoader; @@ -35,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; @@ -123,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 @@ -142,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 @@ -159,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 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 39509a455..8cc344c6b 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -74,6 +74,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; @@ -369,7 +370,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 a4f57025c..f4c833e52 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -240,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,400,600); + //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/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index 233a017aa..9315a1754 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -141,7 +141,7 @@ import kotlin.Unit; @Route(path = RouteUtil.PATH_MAIN) public class MainActivity extends AbsActivity implements MainAppBarLayoutListener { - public static RelativeLayout rt_main_tab; + public RelativeLayout rt_main_tab; private ViewGroup mRootView; private TabButtonGroup mTabButtonGroup; private ViewPager mViewPager; @@ -1100,7 +1100,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene mMainHomeCommunityViewHolder.mValueCallback2 = null; } - public static void isClose(String isClose) { + public void isClose(String isClose) { if ("0".equals(isClose)) { isTabClose = true; rt_main_tab.setVisibility(View.INVISIBLE); 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 03ad42728..77fed05c4 100644 --- a/main/src/main/java/com/yunbao/main/activity/RewardActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/RewardActivity.java @@ -46,6 +46,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; @@ -223,7 +224,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 37ec7c66d..fe0365787 100644 --- a/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java @@ -38,6 +38,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; @@ -211,8 +212,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 6f8522cd8..101073957 100644 --- a/main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java @@ -24,6 +24,7 @@ import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.utils.CommonIconUtil; import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.main.R; @@ -287,7 +288,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 @@ -362,7 +363,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 @@ -437,7 +438,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/FloatBannerView.java b/main/src/main/java/com/yunbao/main/views/FloatBannerView.java index 8c9230469..673593b1a 100644 --- a/main/src/main/java/com/yunbao/main/views/FloatBannerView.java +++ b/main/src/main/java/com/yunbao/main/views/FloatBannerView.java @@ -35,6 +35,9 @@ public class FloatBannerView extends FrameLayout { private Handler bannerHandler = new Handler(); private int index = 0; private String Uid; + //小图标没必要用高清原图,压缩至x32可以节约内存 + private final int iconWidth=32; + private final int iconHeight=32; public FloatBannerView(Context context) { super(context); @@ -76,9 +79,9 @@ public class FloatBannerView extends FrameLayout { } list.clear(); list.addAll(mList); - ImgLoader.displayAvatar(getContext(), list.get(0).getAvatar(), clipImage3); - ImgLoader.displayAvatar(getContext(), list.get(1).getAvatar(), clipImage2); - ImgLoader.displayAvatar(getContext(), list.get(2).getAvatar(), clipImage1); + ImgLoader.displayAvatar(getContext(), list.get(0).getAvatar(), clipImage3,iconWidth,iconHeight); + ImgLoader.displayAvatar(getContext(), list.get(1).getAvatar(), clipImage2,iconWidth,iconHeight); + ImgLoader.displayAvatar(getContext(), list.get(2).getAvatar(), clipImage1,iconWidth,iconHeight); bannerHandler.post(mFlipRunnable); }); @@ -107,8 +110,8 @@ public class FloatBannerView extends FrameLayout { float targetX = bannerLayout2.getX() - bannerLayout3.getX(); float targetY = bannerLayout2.getY() - bannerLayout3.getY(); bannerLayout3.setVisibility(GONE); - ImgLoader.displayAvatar(getContext(), list.get(next).getAvatar(), clipImage3); - ImgLoader.displayAvatar(getContext(), list.get(next).getAvatar(), clipImage2); + ImgLoader.displayAvatar(getContext(), list.get(next).getAvatar(), clipImage3,iconWidth,iconHeight); + ImgLoader.displayAvatar(getContext(), list.get(next).getAvatar(), clipImage2,iconWidth,iconHeight); TranslateAnimation animationTranslate = new TranslateAnimation(0, -targetX / 1.2f, 0, -targetY / 1.2f); ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 1.2f, 1f, 1.2f); AnimationSet animationSet1 = new AnimationSet(true); @@ -122,7 +125,7 @@ public class FloatBannerView extends FrameLayout { public void onAnimationStart(Animation animation) { int show = finalNext + 1; - ImgLoader.displayAvatar(getContext(), list.get(show >= list.size() ? 0 : show).getAvatar(), clipImage1); + ImgLoader.displayAvatar(getContext(), list.get(show >= list.size() ? 0 : show).getAvatar(), clipImage1,iconWidth,iconHeight); } @Override @@ -154,7 +157,7 @@ public class FloatBannerView extends FrameLayout { @Override public void onAnimationEnd(Animation animation) { - ImgLoader.displayAvatar(getContext(), list.get(finalNext).getAvatar(), clipImage4); + ImgLoader.displayAvatar(getContext(), list.get(finalNext).getAvatar(), clipImage4,iconWidth,iconHeight); index = index + 1; bannerHandler.postDelayed(mFlipRunnable, delayMillis); bannerLayout3.clearAnimation(); diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java index 82e3b5758..93418bf16 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java @@ -255,7 +255,9 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl @JavascriptInterface public void isCloseNavigation(String isClose) { - MainActivity.isClose(isClose); + if(nowMainActivity!=null) { + nowMainActivity.isClose(isClose); + } } @JavascriptInterface diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeLiveItemViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeLiveItemViewHolder.java index 673cd154a..d21ab7e8e 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeLiveItemViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeLiveItemViewHolder.java @@ -76,7 +76,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); 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 881f54078..35c9897c5 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 40ed33972..c377410a3 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