anonymous implementation of android.content.DialogInterface$OnDismissListener

anonymous implementation of android.content.DialogInterface$OnDismissListener

内侧泄漏信息

In com.eebbk.askhomework.content:1.10.0.0:1100000.
bfc-leakcanary:5.0.12-bugfix.

  • com.eebbk.askhomework.content.view.SecondActivity has leaked:
  • GC ROOT android.os.HandlerThread.
  • references android.os.Message.obj
  • references com.eebbk.askhomework.content.other.moduleother.function.middle.view.SyncMiddleFragment$1.this 0 ( a n o n y m o u s i m p l e m e n t a t i o n o f a n d r o i d . c o n t e n t . D i a l o g I n t e r f a c e 0 (anonymous implementation of android.content.DialogInterface 0(anonymousimplementationofandroid.content.DialogInterfaceOnDismissListener)
  • references com.eebbk.askhomework.content.other.moduleother.function.middle.view.SyncMiddleFragment.mBgGroupView
  • references androidx.constraintlayout.widget.ConstraintLayout.mContext
  • leaks com.eebbk.askhomework.content.view.SecondActivity instance

解决方法使用静态内部了+弱引用

public static class WeakDialogListener implements DialogInterface.OnDismissListener {
        private WeakReference<SyncMiddleFragment> mWeakReference ;

        public WeakDialogListener(SyncMiddleFragment fragment) {
            this.mWeakReference = new WeakReference<>(fragment);
        }

        @Override
        public void onDismiss(DialogInterface dialog) {
            if (!WeakRefUtil.isWeakRefAvailable(mWeakReference)) {
                return;
            }
            SyncMiddleFragment fragment = mWeakReference.get();
            if (fragment != null && fragment.mSubjectText != null) {
                fragment.mSubjectText.setCompoundDrawablesWithIntrinsicBounds(0, 0,
                        R.mipmap.grade_down_arraw, 0);
            }
        }
    }

使用方法:

private WeakDialogListener mWeakDialogListener = new WeakDialogListener(this);

mCatalogDialog = new MiddleCatalogDialog(mContext, mPresenter.getCatalogData());
        mCatalogDialog.setOnDismissListener(mWeakDialogListener);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值