exallium/RxRecyclerView

No support to empty view

maadani opened this issue · 7 comments

There is no support for default empty view in case there are no items in the adapter.

Hey, thanks for the suggestion.

I'll think about the best way to support this.

For now, I'd probably use a ViewSwitcher that gets switched when the first item ADD event is sent (listening for these should be trivial since you have access to the observable wherever you create the adapter).

I'm not 100% sold that this is something that the RxRecyclerViewAdapter should do, as I think using a RecyclerView within a ViewSwitcher allows for more flexibility than I'd otherwise be able to give.

Hi,
Thanks for your prompt reply.
Keep in mind that your container might get empty after a while, which means that you would have to keep track of the #items in the container in order to display the empty view. That means anyone who would like to display an empty view will have to implement his own Container.

IMHO the preferred way is to expose a counter observable. On one hand, the adapter will use it to display an empty view (if given), and on the other hand, developers can use it to react upon specific values. For example, dynamic empty view, load more data, etc.

Thanks again,

E.

Hey,

I've got a few ideas kicking around my head at the moment. I think the biggest feature to implement here is View Types, which isn't really supported currently, which will allow for headers and footers.

I'm also cooking up (in my head) the idea of a DefaultGroupedContainer which takes an extra subinterface of Comparator (call it Group?) and is used to:

  1. Check whether or not a given item is in a given group
  2. Provide a "group key" for storage and header view creation purposes.

Perhaps the RxRecyclerViewAdapter should maintain it's own subject that emits different state events as they happen. This can be implemented by the sub-adapter as well by overriding the notify changed, notifiy added, and notify removed methods and hooking them into a subject.

As for grabbing an instance of the container, we hide it by default, because the only thing that should alter what's in the container are the Rx Event subscribers. This is by design. If you really want access to the container, you can create your subclass with the corresponding constructor and just hand it a new instance of DefaultContainer.

I'll start implementing some of this, and make sure there is functionality in line with what you are looking for in the next release.

Cheers.
Alex

Hey, just an update. I've made some very significant API changes, and will be releasing the new changes as a "2.0". you can monitor activity on master.

Hey, Empty View support has been added as of version 2.0

Please see example application in repository.

The API has changed a bit.

Hi,
Thanks for all your updates and hard work.
You have made quite a lot of changes.
I will try the new release and will let you know if anything comes up.
One last thing, Please update the Readme with the latest release in the gradle dependencies section.
Thanks again,
E.

I always forget something...

No worries, thanks for bringing things up!