square/mortar — pull request #39 by jlabanca (2014-02-10 17:02:24+00:00)
Title: Unregister view when replaced in Presenter

Consider the following case:
1. View A in scope A calls mySingletonPresenter.takeView()
2. View B in scope B (say, a fragment or activity with a different scope) calls mySingletonPresenter.takeView()
3. scope A is destroyed

In the case above, the onDestroy() method in Presenter will nullify the view, even though View B has replaced View A. The problem is that we register a view in takeView(), but we do not unregister the view in dropView().

Since MortarScope#unregister() does not, you know, exist, we do the next best thing. We check that the registration has not been replaced before calling into the Presenter.