{"action":"created","issue":{"url":"https://api.github.com/repos/clockbyte/admobadapter/issues/113","repository_url":"https://api.github.com/repos/clockbyte/admobadapter","labels_url":"https://api.github.com/repos/clockbyte/admobadapter/issues/113/labels{/name}","comments_url":"https://api.github.com/repos/clockbyte/admobadapter/issues/113/comments","events_url":"https://api.github.com/repos/clockbyte/admobadapter/issues/113/events","html_url":"https://github.com/clockbyte/admobadapter/issues/113","id":302558640,"number":113,"title":"IndexOutOfBoundException: Inconsistency detected. Invalid item position 3","user":{"login":"Shajeel-Afzal","id":3718283,"avatar_url":"https://avatars1.githubusercontent.com/u/3718283?v=4","gravatar_id":"","url":"https://api.github.com/users/Shajeel-Afzal","html_url":"https://github.com/Shajeel-Afzal","followers_url":"https://api.github.com/users/Shajeel-Afzal/followers","following_url":"https://api.github.com/users/Shajeel-Afzal/following{/other_user}","gists_url":"https://api.github.com/users/Shajeel-Afzal/gists{/gist_id}","starred_url":"https://api.github.com/users/Shajeel-Afzal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shajeel-Afzal/subscriptions","organizations_url":"https://api.github.com/users/Shajeel-Afzal/orgs","repos_url":"https://api.github.com/users/Shajeel-Afzal/repos","events_url":"https://api.github.com/users/Shajeel-Afzal/events{/privacy}","received_events_url":"https://api.github.com/users/Shajeel-Afzal/received_events","type":"User","site_admin":false},"labels":[{"id":253451833,"url":"https://api.github.com/repos/clockbyte/admobadapter/labels/help%20wanted","name":"help wanted","color":"159818","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-03-06T04:18:19Z","updated_at":"2018-03-14T07:17:44Z","closed_at":null,"author_association":"NONE","body":"**Admobadapter version or commit: 1.2.6**\r\n**Android compileSdkVersion: 27**\r\n\r\nI am getting a lot of Crash Reports in Crashlytics about IndexOutOfBoundException and users are also complaining it in the Google Play Store Reviews. I am using AdmobAdapter along with FirebaseUI library, Following is my code:\r\n\r\nmAdapter = new FirebaseRecyclerAdapter<LiveScoreModel, RecyclerView.ViewHolder>(options) {\r\n\r\n            public LiveVH mLiveVH;\r\n\r\n            @Override\r\n            protected void onBindViewHolder(RecyclerView.ViewHolder holder, int position, LiveScoreModel model) {\r\n                mLiveVH = (LiveVH) holder;\r\n                mLiveVH.setLiveMatchInfo(mAdapter.getItem(position));\r\n            }\r\n\r\n            @Override\r\n            public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {\r\n                mLiveVH = new LiveVH(LayoutInflater.from(parent.getContext()).inflate(R.layout.live_match_item, parent, false));\r\n                mLiveVH.setOnDiscussionClickListener(LiveScoreFragment.this);\r\n                mLiveVH.setOnShareClickListener(LiveScoreFragment.this);\r\n                return mLiveVH;\r\n            }\r\n\r\n            @Override\r\n            public void onDataChanged() {\r\n                super.onDataChanged();\r\n                if (mAdapter.getItemCount() == 0) {\r\n                    mStatefulLayout.showEmpty();\r\n                } else\r\n                    mStatefulLayout.showContent();\r\n            }\r\n\r\n            @Override\r\n            public void onError(DatabaseError error) {\r\n                super.onError(error);\r\n\r\n                switch (error.getCode()) {\r\n                    case DatabaseError.DISCONNECTED:\r\n                    case DatabaseError.NETWORK_ERROR:\r\n                        mStatefulLayout.showOffline();\r\n                        break;\r\n\r\n                    case DatabaseError.PERMISSION_DENIED:\r\n                        mStatefulLayout.showEmpty();\r\n                        mStatefulLayout.setEmptyText(R.string.no_permission);\r\n                        break;\r\n\r\n                    default: {\r\n                        mStatefulLayout.showEmpty();\r\n                        mStatefulLayout.setEmptyText(R.string.something_went_wrong_while_getting_scores);\r\n                    }\r\n                }\r\n            }\r\n        };\r\n\r\n           int listAdsLimit = 20;\r\n            int adsFrequency = 3\r\n            int firstAdIndex = 2\r\n\r\n            List<BannerAdPreset> adPresets = new ArrayList<>();\r\n\r\n                adPresets.add(new BannerAdPreset(getString(R.string.recyclerview_banner_ad_unit_1)));\r\n                adPresets.add(new BannerAdPreset(getString(R.string.recyclerview_banner_ad_unit_2)));\r\n                adPresets.add(new BannerAdPreset(getString(R.string.recyclerview_banner_ad_unit_4)));\r\n\r\n            mAdapterWrapper = AdmobBannerRecyclerAdapterWrapper.builder(getActivity())\r\n                    .setFirstAdIndex(firstAdIndex < 2 ? 2 : firstAdIndex)\r\n                    .setNoOfDataBetweenAds(adsFrequency < 2 ? 2 : adsFrequency)\r\n                    .setLimitOfAds(listAdsLimit <= 1 ? 3 : listAdsLimit)\r\n                    .setTestDeviceIds(((GlobalApplication) getActivity().getApplication()).getTestDeviceIds())\r\n                    .setAdPresets(adPresets)\r\n                    .setAdapter(mAdapter)\r\n                    .build();\r\n\r\n            mLiveScoreRV.setAdapter(mAdapterWrapper);\r\n\r\nAnd following is my code for click handling: \r\n\r\n```\r\nLiveScoreModel item;\r\n        if (mAdapterWrapper != null) {\r\n            final AdmobAdapterCalculator adapterCalc = mAdapterWrapper.getAdapterCalculator();\r\n            int fetchingAdsCnt = mAdapterWrapper.getFetchingAdsCount();\r\n            int sourceCnt = mAdapterWrapper.getAdapter().getItemCount();\r\n            position = adapterCalc.getOriginalContentPosition(position, fetchingAdsCnt, sourceCnt);\r\n\r\n            item = mAdapter.getItem(position);\r\n        } else {\r\n            item = mAdapter.getItem(position);\r\n        }\r\n\r\n        MatchDiscussionActivity.start(getActivity(), item.getTeam1_name(), item.getTeam2_name(),\r\n                (item.getYmid() == null || item.getYmid().isEmpty()) ? item.getMid() : item.getYmid());\r\n```\r\nAnd here is the full Crash Report:\r\n\r\n```\r\nFatal Exception: java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 3(offset:1).state:4 android.support.v7.widget.RecyclerView{63f5203 VFED..... ......ID 0,0-1080,1620 #7f0901e5 app:id/videos_fragment_recycler_view}, adapter:com.clockbyte.admobadapter.bannerads.AdmobBannerRecyclerAdapterWrapper@fabf85a, layout:android.support.v7.widget.GridLayoutManager@1805a8b, context:psl99.com.pakistan_super_league.MainActivity@70f2109\r\n       at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5654)\r\n       at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5589)\r\n       at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5585)\r\n       at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2231)\r\n       at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:556)\r\n       at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1518)\r\n       at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:610)\r\n       at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)\r\n       at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3670)\r\n       at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3129)\r\n       at android.view.View.measure(View.java:19759)\r\n       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)\r\n       at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)\r\n       at android.view.View.measure(View.java:19759)\r\n       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)\r\n       at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)\r\n       at android.view.View.measure(View.java:19759)\r\n       at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1632)\r\n       at android.view.View.measure(View.java:19759)\r\n       at android.widget.LinearLayout.measureVertical(LinearLayout.java:911)\r\n       at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)\r\n       at android.view.View.measure(View.java:19759)\r\n       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)\r\n       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)\r\n       at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)\r\n       at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)\r\n       at android.view.View.measure(View.java:19759)\r\n       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)\r\n       at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)\r\n       at android.view.View.measure(View.java:19759)\r\n       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)\r\n       at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:719)\r\n       at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:91)\r\n       at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1361)\r\n       at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:789)\r\n       at android.view.View.measure(View.java:19759)\r\n       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)\r\n       at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)\r\n       at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)\r\n       at android.view.View.measure(View.java:19759)\r\n       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)\r\n       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)\r\n       at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)\r\n       at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)\r\n       at android.view.View.measure(View.java:19759)\r\n       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)\r\n       at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)\r\n       at android.view.View.measure(View.java:19759)\r\n       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)\r\n       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)\r\n       at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)\r\n       at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)\r\n       at android.view.View.measure(View.java:19759)\r\n       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)\r\n       at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)\r\n       at com.android.internal.policy.DecorView.onMeasure(DecorView.java:690)\r\n       at android.view.View.measure(View.java:19759)\r\n       at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2313)\r\n       at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1400)\r\n       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1649)\r\n       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1288)\r\n       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6359)\r\n       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:873)\r\n       at android.view.Choreographer.doCallbacks(Choreographer.java:685)\r\n       at android.view.Choreographer.doFrame(Choreographer.java:621)\r\n       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:859)\r\n       at android.os.Handler.handleCallback(Handler.java:754)\r\n       at android.os.Handler.dispatchMessage(Handler.java:95)\r\n       at android.os.Looper.loop(Looper.java:163)\r\n       at android.app.ActivityThread.main(ActivityThread.java:6342)\r\n       at java.lang.reflect.Method.invoke(Method.java)\r\n       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)\r\n       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)\r\n```\r\nAnd these are the devices on which it is happening the most:\r\n\r\nYou can see it yourself here: http://crashes.to/s/f002ea5b038\r\n<img width=\"1140\" alt=\"screen shot 2018-03-06 at 9 24 57 am\" src=\"https://user-images.githubusercontent.com/3718283/37013978-426994fe-211f-11e8-8f45-f63c04305686.png\">\r\n"},"comment":{"url":"https://api.github.com/repos/clockbyte/admobadapter/issues/comments/372926591","html_url":"https://github.com/clockbyte/admobadapter/issues/113#issuecomment-372926591","issue_url":"https://api.github.com/repos/clockbyte/admobadapter/issues/113","id":372926591,"user":{"login":"kot331107","id":22342895,"avatar_url":"https://avatars3.githubusercontent.com/u/22342895?v=4","gravatar_id":"","url":"https://api.github.com/users/kot331107","html_url":"https://github.com/kot331107","followers_url":"https://api.github.com/users/kot331107/followers","following_url":"https://api.github.com/users/kot331107/following{/other_user}","gists_url":"https://api.github.com/users/kot331107/gists{/gist_id}","starred_url":"https://api.github.com/users/kot331107/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kot331107/subscriptions","organizations_url":"https://api.github.com/users/kot331107/orgs","repos_url":"https://api.github.com/users/kot331107/repos","events_url":"https://api.github.com/users/kot331107/events{/privacy}","received_events_url":"https://api.github.com/users/kot331107/received_events","type":"User","site_admin":false},"created_at":"2018-03-14T07:17:44Z","updated_at":"2018-03-14T07:17:44Z","author_association":"CONTRIBUTOR","body":"@Shajeel-Afzal any update?"}}
{"actor":{"display_login":"kot331107"}}