Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the calls of onUpdateEmptyView() #113

Closed
davideas opened this issue Jun 10, 2016 · 2 comments
Closed

Improve the calls of onUpdateEmptyView() #113

davideas opened this issue Jun 10, 2016 · 2 comments
Milestone

Comments

@davideas
Copy link
Owner

Now onUpdateEmptyView() is called if initial count is different from the final getItemCount(). It should be called based on the following changes:

  • empty > not-empty
  • not-empty > empty
@choxnox
Copy link

choxnox commented Jul 24, 2016

We have a problem in our project with this fix. When we create our adapter which extends FlexibleAdapter we display empty view because initially number of items equals to 0. However, as soon as we add our empty view this function gets called again because it's not aware our empty view is just a dummy placeholder and not the real item.

The result is that this function never gets called again. Before this fix we used to have the following and it was working great because onUpdateEmptyView was fired multiple times as items were added to the adapter:

@Override
public void onUpdateEmptyView(int size)
{
    int emptyItemCount = getItemCountOfTypes(emptyViewRes);

    if (size == 0)
    {
        EmptyItem emptyItem = new EmptyItem(emptyViewRes, emptyViewText);

        addItem(0, emptyItem);
    }
    else if (size > emptyItemCount && emptyItemCount > 0)
        removeItemsOfType(emptyViewRes);
}

@choxnox
Copy link

choxnox commented Jul 24, 2016

Ok, the "issue" was on our end because our empty view was actually an item with a special type and not separate view in the layout. We've fixed our issue by manually calling onUpdateEmptyView from within data observer we registered when creating our extended adapter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants