EventBus

244 阅读1分钟

View中使用EventBus

@Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        LogUtils.e("CommentListContainer,onAttachedToWindow");
        EventBus.getDefault().register(this);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        LogUtils.e("CommentListContainer,onDetachedFromWindow");
        if(EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
    }