Question regarding onDestroyView()
david-perez opened this issue · comments
@Override
public void onDestroyView() {
itemsPresenter.unbindView(this);
if (unbinder != null) {
unbinder.unbind();
}
super.onDestroyView();
}
Excerpt from here.
AS code inspection warns that if (unbinder != null)
condition is always true
. As the unbinder is tied to the activity/fragment lifecycle, and we don't modify the unbinder
anywhere, I don't see how it may become null
.
Also, we need to unbind the view from the presenter every time onDestroyView()/onDestroy()
is called on activities/fragments. Couldn't we hold a reference to a generic Presenter
in BaseActivity/BaseFragment
to call super()
and avoid having to write this method every single time?
AFAIK Findbugs complained about this one line and I just added that null check.
Any comments about the second part of my question?
Second part: yes you can do it in base classes, but personally I just don't
like such inheritance behavior, it makes code implicit.
Also, for example at the moment I use MVVM at work and our app has old
parts in MVP and new in MVVM, since our base classes does not know about
MVP or MVVM we don't have problems with using two different design patterns
in one project :)
On 31 Aug 2016 10:57 am, "david-perez" notifications@github.com wrote:
Any comments about the second part of my question?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#199 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA7B3O69aasszC4PO0s_bkxeiItiEhq4ks5qlTP7gaJpZM4JxEHv
.
Yeah, me too! Planned to do after vacation
On 1 Sep 2016 1:21 am, "david-perez" notifications@github.com wrote:
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#199 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA7B3Iv6zytjpxbvbNFqgCttH0aqRT4vks5qlgyBgaJpZM4JxEHv
.