I'm trying to use Mortar for a simple application that shows a list of items based on mortar-sample.
I'm using Retrofit/Gson to fetch meta-data of these items and Otto to deliver updates to the view once the items are downloaded. I'm also using Dagger for objects creation.
I've an ItemList
class that implements ListView
to disply the items in a list, and an ItemListScreen
that implements mortar.Blueprint
.
I wonder where is the best place to put the subscribing method that will update the adapter items?
Currently, I'm placing it under ItemListScreen.Presenter
but the subscribe method is never called!!
@Layout(R.layout.item_list_view)
public class ItemListScreen implements Blueprint {
...
@Singleton
public static class Presenter extends ViewPresenter<ItemListView> {
...
@Subscribe
public void onEvent(Event event){
ItemListView view = getView();
if(view == null) return;
view.showItems(event.items);
}
}
}
You don't have your presenter hopping on the bus.
bus.register(this);
Probably want to put that in the onLoad method and then unregister when the view is no longer being displayed.