Closed mhdatie closed 7 years ago
Right now custom views do a simple check to use the appropriate RxLifecycle...would be nice to move this a generic helper
This answer on stack overflow explains how to access a Fragment from a custom view: http://stackoverflow.com/a/20304367/2898754
The logic in e2b6099 should provide a cleaner approach because we are referencing interfaces and dealing directly with views and presenters.
ContentView
is extended by both the views of Activities and Fragments that are part of a component. The interface methodgetContentContext()
returns aBaseContextView
which calls eithergetBaseActivity()
orgetBaseFragment()
, which are implemented by the base activity/fragment, depending on the implementing view class.ContentSubView
is implemented by custom views that are used as part of activity or fragment layouts and are part of a sub-component. It extendsContentView
. The methodsetBaseContextView(BaseContextView baseContextView)
helps identify whether the custom view is part of an Activity or a Fragment for the RxLifeCycle, since Android'sgetContext()
can never be a Fragment.BaseContextView
is only implemented byBaseActivity
andBaseFragment
, as well as 'SettingsActivity' which isn't part of a component.BaseView
is extended by all views.Adding
BasePresenter
interface to makeregisterForEvents()
andunregisterForEvents
available in all sub presenters.WARNING: Initial commit is not tested yet