{"id":15974444,"url":"https://github.com/devzwy/vbs","last_synced_at":"2025-04-04T17:12:50.559Z","repository":{"id":112155854,"uuid":"499971859","full_name":"devzwy/VBs","owner":"devzwy","description":"kotlin常用扩展函数","archived":false,"fork":false,"pushed_at":"2022-06-05T11:58:53.000Z","size":406,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T02:24:23.653Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","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/devzwy.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,"publiccode":null,"codemeta":null}},"created_at":"2022-06-05T01:15:55.000Z","updated_at":"2022-06-05T02:43:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"a362830f-eca9-46ec-89af-0ec172800d44","html_url":"https://github.com/devzwy/VBs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devzwy%2FVBs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devzwy%2FVBs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devzwy%2FVBs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devzwy%2FVBs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devzwy","download_url":"https://codeload.github.com/devzwy/VBs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217221,"owners_count":20903009,"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-07T21:41:42.351Z","updated_at":"2025-04-04T17:12:50.534Z","avatar_url":"https://github.com/devzwy.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ViewBinding\n\nkotlin常用扩展函数 自用\n\n不定时更新\n\n```kotlin\n//toast 支持 view/context\ntoastShort(\"\")\ntoastLong(\"\")\n//支持 view/context\ndp2px(100)\npx2dp(100)\n//复制文本到剪切板\ncopyToClipboard(\"1234567\")\n//读取颜色\ngetColorFromRes(R.color.black)\n//对象转json字符串\nTestData().toJson()\n//json字符串转对象\n\"{...}\".toObject(TestData::class.java).a\n//json字符串转集合-文本集合\n\"[...]\".toObjectArray\u003cString\u003e().get(0)\n//json字符串转集合-对象集合\n\"[{},{}]\".toObjectArray\u003cTestData\u003e().get(0)\n//减少if过程\nisVisibility.yes {\n    //true\n    this.visibility = View.VISIBLE\n}.otherwise {\n    //false\n    this.visibility = if (occupy == true) View.INVISIBLE else View.GONE\n}\n\n//减少if过程\nisVisibility.no {\n    //false\n    this.visibility = View.VISIBLE\n}.otherwise {\n    //true\n    this.visibility = if (occupy == true) View.INVISIBLE else View.GONE\n}\n\n```\n\n```xml\n\n\u003candroidx.appcompat.widget.AppCompatTextView vbs_isVisibility=\"@{是否显示true/false}\"\n    vbs_occupy=\"@{隐藏时是否占位}/可选\" android:layout_width=\"wrap_content\" android:layout_height=\"45dp\"\n    android:gravity=\"center_vertical\" android:textSize=\"15sp\" /\u003e\n\n\u003candroidx.appcompat.widget.AppCompatTextView vbs_richTexts=\"@{富文本配置/大小/下划线/颜色/点击事件/tag}/可选\"\nvbs_bindText=\"@{绑定文本/数字}\" android:layout_width=\"wrap_content\" android:layout_height=\"45dp\"\nandroid:gravity=\"center_vertical\" android:textSize=\"15sp\" /\u003e\n\n\n\u003candroidx.appcompat.widget.AppCompatTextView android:layout_width=\"wrap_content\"\nvbs_bindTime=\"@{date/1654401273}\" vbs_timeFormat=\"@{`yyyy-MM-dd`}/可选\"\nandroid:layout_height=\"wrap_content\" android:gravity=\"center_vertical\" android:textSize=\"15sp\" /\u003e\n\n\n\u003candroidx.appcompat.widget.AppCompatImageView vbs_bindImageData=\"@{url/resId/path}\"\nvbs_placeholderResId=\"@{placeholderResId/可选}\" android:scaleType=\"centerCrop\"\nandroid:layout_width=\"200dp\" android:layout_height=\"200dp\" android:layout_marginStart=\"5dp\" /\u003e\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevzwy%2Fvbs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevzwy%2Fvbs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevzwy%2Fvbs/lists"}