{"action":"opened","issue":{"url":"https://api.github.com/repos/ShamylZakariya/StickyHeaders/issues/23","repository_url":"https://api.github.com/repos/ShamylZakariya/StickyHeaders","labels_url":"https://api.github.com/repos/ShamylZakariya/StickyHeaders/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/ShamylZakariya/StickyHeaders/issues/23/comments","events_url":"https://api.github.com/repos/ShamylZakariya/StickyHeaders/issues/23/events","html_url":"https://github.com/ShamylZakariya/StickyHeaders/issues/23","id":170587224,"number":23,"title":"IndexOutOfBoundsException: onBindItemViewHolder","user":{"login":"rusmichal","id":15652344,"avatar_url":"https://avatars.githubusercontent.com/u/15652344?v=3","gravatar_id":"","url":"https://api.github.com/users/rusmichal","html_url":"https://github.com/rusmichal","followers_url":"https://api.github.com/users/rusmichal/followers","following_url":"https://api.github.com/users/rusmichal/following{/other_user}","gists_url":"https://api.github.com/users/rusmichal/gists{/gist_id}","starred_url":"https://api.github.com/users/rusmichal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rusmichal/subscriptions","organizations_url":"https://api.github.com/users/rusmichal/orgs","repos_url":"https://api.github.com/users/rusmichal/repos","events_url":"https://api.github.com/users/rusmichal/events{/privacy}","received_events_url":"https://api.github.com/users/rusmichal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-11T07:42:00Z","updated_at":"2016-08-11T07:42:00Z","closed_at":null,"body":"I found one issue\r\n\r\n```\r\n@Override\r\n    public void onBindItemViewHolder(ItemViewHolder viewHolder, int sectionIndex, int itemIndex, int itemType) {\r\n        int sectionPosition = includeHeader ? sectionIndex - 1 : sectionIndex;\r\n        switch (itemType) {\r\n            case ITEM_HEADER:\r\n               ...\r\n                break;\r\n            case ITEM_TILE:\r\n                initTile((FeedViewHolder) viewHolder, feedDataProviders.get(sectionPosition).getTileViewModelList().get(itemIndex), sectionPosition);\r\n                break;\r\n            case ITEM_FOOTER:\r\n                ...\r\n                break;\r\n            default:\r\n                break;\r\n        }\r\n    }\r\n```\r\n\r\nWhere `feedDataProviders` is `List<FeedDataProvider>`. `FeedDataProvider` has list of custom objects `TileViewModel`.\r\n\r\nI got `IndexOutOfBoundsException: Invalid index 0, size is 0` in line `initTile()` because `getTileViewModelList()` return empty list and `itemIndex` is 0. I think if `getNumberOfItemsInSection` return 0 then is should not called the `onBindItemViewHolder` right?\r\n\r\n```\r\n@Override\r\n    public int getNumberOfItemsInSection(int sectionIndex) {\r\n        if((includeHeader && sectionIndex == 0) || (includeFooter && sectionIndex == getNumberOfSections() - 1)) {\r\n            return 1;\r\n        }\r\n        return feedDataProviders.get(includeHeader ? sectionIndex - 1 : sectionIndex).getTileViewModelList().size();\r\n    }\r\n```\r\n "}}
{"actor":{"display_login":"rusmichal"}}