{"action":"created","issue":{"url":"https://api.github.com/repos/ongakuer/CircleIndicator/issues/27","labels_url":"https://api.github.com/repos/ongakuer/CircleIndicator/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/ongakuer/CircleIndicator/issues/27/comments","events_url":"https://api.github.com/repos/ongakuer/CircleIndicator/issues/27/events","html_url":"https://github.com/ongakuer/CircleIndicator/issues/27","id":103889710,"number":27,"title":"Selected dot with dynamic add/remove page","user":{"login":"HappyDr0id","id":756177,"avatar_url":"https://avatars.githubusercontent.com/u/756177?v=3","gravatar_id":"","url":"https://api.github.com/users/HappyDr0id","html_url":"https://github.com/HappyDr0id","followers_url":"https://api.github.com/users/HappyDr0id/followers","following_url":"https://api.github.com/users/HappyDr0id/following{/other_user}","gists_url":"https://api.github.com/users/HappyDr0id/gists{/gist_id}","starred_url":"https://api.github.com/users/HappyDr0id/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HappyDr0id/subscriptions","organizations_url":"https://api.github.com/users/HappyDr0id/orgs","repos_url":"https://api.github.com/users/HappyDr0id/repos","events_url":"https://api.github.com/users/HappyDr0id/events{/privacy}","received_events_url":"https://api.github.com/users/HappyDr0id/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-29T23:44:11Z","updated_at":"2015-08-30T20:16:22Z","closed_at":null,"body":"First of all, thank you for sharing your work, this material circle indicator is really quite cool ;)\r\n\r\nI would like to let you an issue about the selected state of the CircleIndicator with the use of a dynamic viewpager. \r\n\r\nDespite the fact that I have to call the setViewPager() method each time I notify my adapter that the data size has changed to avoid an exception, I also have another problem which can also be bypassed by another method call.\r\n\r\nHere is the concerned use of CircleIndicator :\r\n```javascript\r\nmPagerAdapter.add(object); // dynamic add of an object\r\nmPagerAdapter.notifyDataSetChanged(); // notify the data change\r\nmPagerIndicator.setViewPager(mImagesPager); // reset the viewpager to the indicator\r\nmViewPager.setCurrentItem(0, false); // set the current item to the first position\r\nmViewPager.setCurrentItem(mPagerAdapter.getCount()-1, false); // set the current item to the wanted position (the last added object)\r\n```\r\n\r\nThe question is : why do I set the item to the position 0 just before setting it to wanted position ?\r\nBecause it permits me to avoid the following bug : the wanted position in a selected state AND also the first one.\r\nIf I directly set the wanted position, I don't know why (for the moment, I will take time to read the CircleIndicator class) but the first indicator will always be selected.\r\n\r\nThanks in advance for your answer !"},"comment":{"url":"https://api.github.com/repos/ongakuer/CircleIndicator/issues/comments/136180398","html_url":"https://github.com/ongakuer/CircleIndicator/issues/27#issuecomment-136180398","issue_url":"https://api.github.com/repos/ongakuer/CircleIndicator/issues/27","id":136180398,"user":{"login":"HappyDr0id","id":756177,"avatar_url":"https://avatars.githubusercontent.com/u/756177?v=3","gravatar_id":"","url":"https://api.github.com/users/HappyDr0id","html_url":"https://github.com/HappyDr0id","followers_url":"https://api.github.com/users/HappyDr0id/followers","following_url":"https://api.github.com/users/HappyDr0id/following{/other_user}","gists_url":"https://api.github.com/users/HappyDr0id/gists{/gist_id}","starred_url":"https://api.github.com/users/HappyDr0id/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HappyDr0id/subscriptions","organizations_url":"https://api.github.com/users/HappyDr0id/orgs","repos_url":"https://api.github.com/users/HappyDr0id/repos","events_url":"https://api.github.com/users/HappyDr0id/events{/privacy}","received_events_url":"https://api.github.com/users/HappyDr0id/received_events","type":"User","site_admin":false},"created_at":"2015-08-30T20:16:22Z","updated_at":"2015-08-30T20:16:22Z","body":"I tried your proposition, but if I don't set the ViewPager before changing the current item, it will crash. This is certainly because the indicator don't have the new positions yet.\r\n\r\n```javascript\r\njava.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setBackgroundResource(int)' on a null object reference\r\nat me.relex.circleindicator.CircleIndicator.onPageSelected(CircleIndicator.java:162)\r\nat android.support.v4.view.ViewPager.dispatchOnPageSelected(ViewPager.java:1792)\r\n```\r\n\r\nI will try to make a \"dynamic viewpager\"-ready version of CircleIndicator :)\r\n\r\nThanks for your answer !"}}