退出Activity时清理bitmap
退出LiveActivity时,清理SVGA 新增检测到触发未捕获异常闪退时,直接退出不再重新加载 优化一处LiveActivity所持有的静态view,防止内存泄漏 更新SVGAPlayer库
This commit is contained in:
@@ -24,6 +24,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.LifeCycleListener;
|
||||
import com.yunbao.common.utils.ClickUtil;
|
||||
|
||||
@@ -136,6 +137,7 @@ public abstract class AbsActivity extends AppCompatActivity {
|
||||
mLifeCycleListeners.clear();
|
||||
mLifeCycleListeners = null;
|
||||
}
|
||||
ImgLoader.clearMemory(this);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,18 @@ package com.yunbao.common.utils;
|
||||
import com.opensource.svgaplayer.SVGACallback;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SVGAViewUtils {
|
||||
public static void playEndClear(SVGAImageView svga,boolean isClear){
|
||||
private final static List<SVGAImageView> SVGA_CACHE = new ArrayList<>();
|
||||
|
||||
public static void playEndClear(SVGAImageView svga, boolean isClear) {
|
||||
if (!isClear) {
|
||||
if (!SVGA_CACHE.contains(svga)) {
|
||||
SVGA_CACHE.add(svga);
|
||||
}
|
||||
}
|
||||
svga.setCallback(new SVGACallback() {
|
||||
@Override
|
||||
public void onPause() {
|
||||
@@ -14,7 +24,7 @@ public class SVGAViewUtils {
|
||||
@Override
|
||||
public void onFinished() {
|
||||
//动画结束后调用clear释放资源
|
||||
if(isClear) {
|
||||
if (isClear) {
|
||||
svga.clear();
|
||||
}
|
||||
}
|
||||
@@ -31,7 +41,21 @@ public class SVGAViewUtils {
|
||||
});
|
||||
svga.startAnimation();
|
||||
}
|
||||
public static void playEndClear(SVGAImageView svga){
|
||||
playEndClear(svga,true);
|
||||
|
||||
public synchronized static void clearSVGA() {
|
||||
for (SVGAImageView view : SVGA_CACHE) {
|
||||
try {
|
||||
if (view != null) {
|
||||
view.clear();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
SVGA_CACHE.clear();
|
||||
}
|
||||
|
||||
public static void playEndClear(SVGAImageView svga) {
|
||||
playEndClear(svga, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user