{"id":21574630,"url":"https://github.com/jintin/bindingextension","last_synced_at":"2025-04-10T16:13:44.648Z","repository":{"id":48037356,"uuid":"322025638","full_name":"Jintin/BindingExtension","owner":"Jintin","description":"Android ViewBinding extension to provide simpler usage in Activity, Fragment and ViewHolder.","archived":false,"fork":false,"pushed_at":"2024-08-01T13:20:43.000Z","size":179,"stargazers_count":29,"open_issues_count":2,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T14:06:32.002Z","etag":null,"topics":["activity","android","fragment","viewbinding"],"latest_commit_sha":null,"homepage":"https://devlibrary.withgoogle.com/products/android/repos/Jintin-BindingExtension","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jintin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"Jintin","open_collective":null,"ko_fi":"Jintin","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-12-16T15:36:04.000Z","updated_at":"2024-08-01T12:54:34.000Z","dependencies_parsed_at":"2024-08-01T13:15:05.753Z","dependency_job_id":null,"html_url":"https://github.com/Jintin/BindingExtension","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/Jintin%2FBindingExtension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jintin%2FBindingExtension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jintin%2FBindingExtension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jintin%2FBindingExtension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jintin","download_url":"https://codeload.github.com/Jintin/BindingExtension/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248251582,"owners_count":21072691,"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":["activity","android","fragment","viewbinding"],"created_at":"2024-11-24T12:10:36.271Z","updated_at":"2025-04-10T16:13:44.625Z","avatar_url":"https://github.com/Jintin.png","language":"Kotlin","funding_links":["https://patreon.com/Jintin","https://ko-fi.com/Jintin","https://www.buymeacoffee.com/jintin"],"categories":[],"sub_categories":[],"readme":"# BindingExtension\n\n[![CircleCI](https://circleci.com/gh/Jintin/BindingExtension.svg?style=shield)](https://circleci.com/gh/Jintin/BindingExtension)\n[![jitpack](https://jitpack.io/v/Jintin/BindingExtension.svg)](https://jitpack.io/#Jintin/BindingExtension)\n\nViewBinding is an amazing tool for Android but it's not so fit in Android development as we still have to do some config. BindingExtension is built to provide a simpler usage.\n\n## Install\n\nAdd [Jitpack](https://jitpack.io/) repository to your root `build.grable`:\n```groovy\nallprojects {\n  repositories {\n    ...\n    maven { url 'https://jitpack.io' }\n  }\n}\n```\n\nThen add dependency in your module `build.gradle`:\n```groovy\ndependencies {\n  implementation 'com.github.jintin:BindingExtension:3.1.0'\n}\n```\n\n## Usage\n\nFirst of all, BindingExtension using refelction a lot to link many things internally in order to provide simple usage.\nTo prevent having trouble with proguard, please remember to exclude `ViewBinding` related method in your proguard-rules file like this:\n\n```\n-keepclassmembers class * implements androidx.viewbinding.ViewBinding {\n     public static ** inflate(...);\n}\n```\n\n### Activity\n\nExtend from `BindingActivity` with your `ViewBinding` type then you can use `binding` directly after calling `super.onCreate(savedInstanceState)` and you don't have to call `setContentView` anymore:\n\n```kotlin\nclass MainActivity : BindingActivity\u003cActivityMainBinding\u003e() {\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n\n        binding.label.setText(R.string.activity_label)\n    }\n}\n```\n\n### Fragment\n\nExtend from `BindingFragment` with your `ViewBinding` type then you can use `binding` directly after `super.onCreateView(inflater, container, savedInstanceState)` is called:\n\n```kotlin\nclass MainFragment : BindingFragment\u003cFragmentMainBinding\u003e() {\n\n    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {\n        super.onViewCreated(view, savedInstanceState)\n\n        binding.button.setOnClickListener {\n            binding.button.setText(R.string.fragment_label)\n        }\n    }\n}\n```\n\n### ViewHolder\n\nBindingExtension provide an extension function for `ViewGroup`, you can call `ViewGroup.toBinding()` in `onCreateViewHolder` to get your desire type of `ViewBinding`.\nAnd `ViewHolder` can than access `ViewBinding` directly without further transformation.\n\n```kotlin\n// inside adapter\noverride fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {\n    return MainViewHolder(parent.toBinding())\n}\n\n// ViewHolder\nclass MainViewHolder(private val binding: AdapterMainBinding) :\n    RecyclerView.ViewHolder(binding.root) {\n\n    fun bind(data: String) {\n        binding.name.text = data\n    }\n}\n\n```\n\nYou can go to ./app module for more information.\n## Contributing\nBug reports and pull requests are welcome on GitHub at [https://github.com/Jintin/BindingExtension](https://github.com/Jintin/BindingExtension).\n\n[![Buy Me A Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/jintin)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjintin%2Fbindingextension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjintin%2Fbindingextension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjintin%2Fbindingextension/lists"}