fix:修复一处内存泄漏问题

This commit is contained in:
zlzw 2022-10-17 15:10:03 +08:00
parent 5f44473c49
commit 09f74c3881

View File

@ -1,5 +1,7 @@
package com.shayu.phonelive; package com.shayu.phonelive;
import static com.yunbao.live.socket.SocketClient.mSocketHandler;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.content.Context; import android.content.Context;
@ -29,24 +31,23 @@ import com.yunbao.common.BuildConfig;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext; import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.manager.imrongcloud.InstructorSendReward; import com.yunbao.common.manager.imrongcloud.InstructorSendReward;
import com.yunbao.common.manager.imrongcloud.InstructorSendRewardProvider; import com.yunbao.common.manager.imrongcloud.InstructorSendRewardProvider;
import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.common.manager.imrongcloud.MessageIMManager;
import com.yunbao.common.manager.imrongcloud.RecommendLiveRoom; 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.manager.imrongcloud.RongcloudIMManager;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.SpUtil;
import com.yunbao.live.socket.SocketRyClient; import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.utils.LiveImDeletUtil; import com.yunbao.live.utils.LiveImDeletUtil;
import com.yunbao.live.views.PortraitLiveManager; import com.yunbao.live.views.PortraitLiveManager;
import com.yunbao.live.views.RecommendLiveRoomProvider;
import com.yunbao.main.activity.MsgSettActivity; import com.yunbao.main.activity.MsgSettActivity;
import org.greenrobot.eventbus.EventBus;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
@ -59,10 +60,6 @@ import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.MessageContent; import io.rong.imlib.model.MessageContent;
import io.rong.message.TextMessage; import io.rong.message.TextMessage;
import static com.yunbao.live.socket.SocketClient.mSocketHandler;
import org.greenrobot.eventbus.EventBus;
//import cn.tillusory.sdk.TiSDK; //import cn.tillusory.sdk.TiSDK;
//import com.squareup.leakcanary.LeakCanary; //import com.squareup.leakcanary.LeakCanary;
@ -101,7 +98,12 @@ public class AppContext extends CommonAppContext {
@Override @Override
public void onActivityDestroyed(@NonNull Activity activity) { public void onActivityDestroyed(@NonNull Activity activity) {
activities.remove(activity); for (WeakReference<Activity> reference : activities) {
if(reference.get()==activity){
activities.remove(reference);
return;
}
}
} }
@Override @Override