{"action":"created","issue":{"url":"https://api.github.com/repos/jeasonlzy/NineGridView/issues/23","repository_url":"https://api.github.com/repos/jeasonlzy/NineGridView","labels_url":"https://api.github.com/repos/jeasonlzy/NineGridView/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/jeasonlzy/NineGridView/issues/23/comments","events_url":"https://api.github.com/repos/jeasonlzy/NineGridView/issues/23/events","html_url":"https://github.com/jeasonlzy/NineGridView/issues/23","id":224087701,"node_id":"MDU6SXNzdWUyMjQwODc3MDE=","number":23,"title":"你好，在NineGridView中的onLayout方法会无限掉用。","user":{"login":"leguang","id":12870924,"node_id":"MDQ6VXNlcjEyODcwOTI0","avatar_url":"https://avatars3.githubusercontent.com/u/12870924?v=4","gravatar_id":"","url":"https://api.github.com/users/leguang","html_url":"https://github.com/leguang","followers_url":"https://api.github.com/users/leguang/followers","following_url":"https://api.github.com/users/leguang/following{/other_user}","gists_url":"https://api.github.com/users/leguang/gists{/gist_id}","starred_url":"https://api.github.com/users/leguang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leguang/subscriptions","organizations_url":"https://api.github.com/users/leguang/orgs","repos_url":"https://api.github.com/users/leguang/repos","events_url":"https://api.github.com/users/leguang/events{/privacy}","received_events_url":"https://api.github.com/users/leguang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2017-04-25T10:11:32Z","updated_at":"2018-12-24T02:20:12Z","closed_at":null,"author_association":"NONE","body":"你好，在NineGridView中的onLayout方法会无限掉用。\r\n\r\n我将NineGridView作为RecyclerView的Item，然后显示3张图片的时候，在第一次加载的时候可能没问题，但是从屏幕外滑进来后就会不停加载图片，最后跟踪定位到onLayout方法，会无限调用。现在你的源码如下：\r\n`@Override\r\n    protected void onLayout(boolean changed, int l, int t, int r, int b) {\r\n        if (mImageInfo == null) return;\r\n        int childrenCount = mImageInfo.size();\r\n        for (int i = 0; i < childrenCount; i++) {\r\n            ImageView childrenView = (ImageView) getChildAt(i);\r\n            if (mImageLoader != null) {\r\n                mImageLoader.onDisplayImage(getContext(), childrenView, mImageInfo.get(i).thumbnailUrl);\r\n            }\r\n            int rowNum = i / columnCount;\r\n            int columnNum = i % columnCount;\r\n            int left = (gridWidth + gridSpacing) * columnNum + getPaddingLeft();\r\n            int top = (gridHeight + gridSpacing) * rowNum + getPaddingTop();\r\n            int right = left + gridWidth;\r\n            int bottom = top + gridHeight;\r\n            childrenView.layout(left, top, right, bottom);\r\n        }\r\n    }`\r\n我看到你没有判断是否位置发生改变就开始布局。\r\n\r\n现在我的解决方案是写一个类，继承NineGridView，在onLayout方法里做一个判断，代码如下：\r\n`  @Override\r\n    protected void onLayout(boolean changed, int l, int t, int r, int b) {\r\n        ALog.e(\"1111111111\" + changed);\r\n        if (changed) {\r\n            super.onLayout(changed, l, t, r, b);\r\n        }\r\n    }`\r\n最后解决问题了，log也不会无限打印了。\r\n您看具体原因是出现在哪儿？\r\n"},"comment":{"url":"https://api.github.com/repos/jeasonlzy/NineGridView/issues/comments/449677530","html_url":"https://github.com/jeasonlzy/NineGridView/issues/23#issuecomment-449677530","issue_url":"https://api.github.com/repos/jeasonlzy/NineGridView/issues/23","id":449677530,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTY3NzUzMA==","user":{"login":"yungelee","id":19425298,"node_id":"MDQ6VXNlcjE5NDI1Mjk4","avatar_url":"https://avatars2.githubusercontent.com/u/19425298?v=4","gravatar_id":"","url":"https://api.github.com/users/yungelee","html_url":"https://github.com/yungelee","followers_url":"https://api.github.com/users/yungelee/followers","following_url":"https://api.github.com/users/yungelee/following{/other_user}","gists_url":"https://api.github.com/users/yungelee/gists{/gist_id}","starred_url":"https://api.github.com/users/yungelee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yungelee/subscriptions","organizations_url":"https://api.github.com/users/yungelee/orgs","repos_url":"https://api.github.com/users/yungelee/repos","events_url":"https://api.github.com/users/yungelee/events{/privacy}","received_events_url":"https://api.github.com/users/yungelee/received_events","type":"User","site_admin":false},"created_at":"2018-12-24T02:20:12Z","updated_at":"2018-12-24T02:20:12Z","author_association":"NONE","body":"[地址](https://github.com/mzule/NineGridLayout)"}}
{"actor":{"display_login":"yungelee"}}