{"id":17996323,"url":"https://github.com/razerdp/photocontents","last_synced_at":"2025-03-26T04:30:36.068Z","repository":{"id":152927049,"uuid":"74949827","full_name":"razerdp/PhotoContents","owner":"razerdp","description":"// 一个适用于AbsListView或者RecyclerView的仿朋友圈九宫格控件，针对View的复用做了二次缓存，减少创建View次数和减少measure/layout次数。","archived":false,"fork":false,"pushed_at":"2020-09-25T12:43:37.000Z","size":21293,"stargazers_count":86,"open_issues_count":5,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-21T05:21:55.818Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/razerdp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-11-28T07:50:34.000Z","updated_at":"2023-03-10T05:16:59.000Z","dependencies_parsed_at":"2024-02-01T15:28:28.181Z","dependency_job_id":"ac2c4914-5249-4a69-ad9b-e5fd9cfd16b6","html_url":"https://github.com/razerdp/PhotoContents","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/razerdp%2FPhotoContents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/razerdp%2FPhotoContents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/razerdp%2FPhotoContents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/razerdp%2FPhotoContents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/razerdp","download_url":"https://codeload.github.com/razerdp/PhotoContents/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245589108,"owners_count":20640225,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-29T21:14:16.154Z","updated_at":"2025-03-26T04:30:35.479Z","avatar_url":"https://github.com/razerdp.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 朋友圈图片容器\n\n[ ![Download](https://api.bintray.com/packages/razerdp/maven/PhotoContents/images/download.svg) ](https://bintray.com/razerdp/maven/PhotoContents/_latestVersion)\n\n\n针对AbsListView或者RecyclerView来进行View的二级缓存，采取的是adapter模式以及观察者。\n\n实现原理实际上很简单，大致如下：\n\n众所周知，RecyclerView或者AbsListview的复用机制都是利用一个数组来缓存view组，在创建View的时候获取出来并传到adapter\n当一个View移出屏幕的时候，它会被放到池里面，在下一个view(viewType相同)时，会取出\n而取出的View实际上childView等是不变的，因此我们可以利用这个机制，在更新时，将所有view都缓存\n然后对比出该view更新前后的不同进行addView\n\n又因为我们知道addView/removeView会造成requestLayout从而重新走了一遍measure和layout，所以为了避免这个情况\n我们使用了`attachViewToParent`和`detachAllViewsFromParent`这两个仅针对数组操作的方法来避免这个问题。\n\n当然目前来说这个控件还只是一个初步版本，后续如果有时间我会慢慢优化的。\n\nps，本控件初衷是为了我的另一个项目[一起撸个朋友圈吧](https://github.com/razerdp/FriendCircle)服务，大部分的更新都会在那里提交，如果您需要获取新的更新信息，可以通过另一个项目获知。\n\n\n# Preview:\n![](https://github.com/razerdp/PhotoContents/blob/master/art/preview.gif)\n\n# Download  [ ![Download](https://api.bintray.com/packages/razerdp/maven/PhotoContents/images/download.svg) ](https://bintray.com/razerdp/maven/PhotoContents/_latestVersion)\n\n**Step 1.**\n\nAdd the dependency\n\n```xml\n\tdependencies {\n\t        compile 'com.github.razerdp:PhotoContents:{最新版}'  //最新版看上方Jcenter标签\n\t}\n```\n\n\n### Update log\n\n - 2019/12/10\n    + 增加复用池拦截器，允许自行添加复用池逻辑\n - 2019/07/08\n    + 重构\n - 2017/02/20\n    + 修复点击后点击空白页面响应了之前的点击事件的问题\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frazerdp%2Fphotocontents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frazerdp%2Fphotocontents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frazerdp%2Fphotocontents/lists"}