{"id":13645226,"url":"https://github.com/czy1121/update","last_synced_at":"2025-05-14T13:06:00.514Z","repository":{"id":199057652,"uuid":"74761224","full_name":"czy1121/update","owner":"czy1121","description":"清晰灵活简单易用的应用更新库","archived":false,"fork":false,"pushed_at":"2024-12-13T09:10:16.000Z","size":551,"stargazers_count":1829,"open_issues_count":1,"forks_count":338,"subscribers_count":40,"default_branch":"master","last_synced_at":"2025-04-13T10:03:45.588Z","etag":null,"topics":["android","easy","flexible","simple","update"],"latest_commit_sha":null,"homepage":null,"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/czy1121.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2016-11-25T13:36:05.000Z","updated_at":"2025-04-12T13:01:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"62873d3a-ca6d-485b-8ecc-398313b2a7cc","html_url":"https://github.com/czy1121/update","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"6db76bb25c36ebd91c493758bb9d48c522e27575"},"previous_names":["czy1121/update"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czy1121%2Fupdate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czy1121%2Fupdate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czy1121%2Fupdate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czy1121%2Fupdate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/czy1121","download_url":"https://codeload.github.com/czy1121/update/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254149947,"owners_count":22022851,"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":["android","easy","flexible","simple","update"],"created_at":"2024-08-02T01:02:31.575Z","updated_at":"2025-05-14T13:06:00.443Z","avatar_url":"https://github.com/czy1121.png","language":"Kotlin","readme":"# update\n\n清晰灵活简单易用的应用更新库\n\n\n- 支持断点续传\n- 支持强制安装：不安装无法使用app\n- 支持静默更新：不提示用户直接下载安装\n- 支持可忽略该版本：忽略后不再提示用户更新该版本\n- 支持在通知栏显示下载进度，可监听下载进度\n- 支持自定义更新查询\n- 支持自定义下载\n- 支持自定义提示对话框\n\n![screenshot](screenshot.png)\n\n## 引入\n\n``` groovy\nrepositories {\n    maven { url \"https://gitee.com/ezy/repo/raw/cosmo/\"}\n}\ndependencies {\n    implementation \"me.reezy.cosmo:update:0.10.0\"\n}\n```\n\n## Usage\n\n``` java\n// 设置更新信息源\nUpdateManager.setChecker(\"http://yourdomain.com/path\")\n```\n\n``` kotlin\n// 查询更新\nUpdateManager.check(context)\n```\n\n``` kotlin\n// 在设置界面点击检查更新：默认无新版本时不会提示用户\nUpdateManager.check(activity) {\n    Toast.makeText(this, it.getFullMessage(this), Toast.LENGTH_LONG).show()\n}\n```\n\n``` kotlin \n\n// 自定义更新对话框\nUpdateManager.check(activity, onPrompt = { agent -\u003e\n    UpdatePromptDialog(activity, agent).show()\n})\n```\n\n``` kotlin\n// 清除已经下载好了的包\nUpdateManager.clean(context);\n```\n\n整个更新流程很简单，具体请看 UpdateExecutor\n\n```\nwhen {\n    // 没有新版本 -\u003e 返回结果\n    !info.hasUpdate -\u003e returnResult(UpdateResult(UpdateResult.UPDATE_NO_NEWER))\n    // 强制更新 -\u003e 提示用户更新，不显示[取消][忽略]按钮\n    info.isForce -\u003e prompt(info, task)\n    // 静默更新 -\u003e 不提示用户直接更新\n    info.isSilent -\u003e update(info, task)\n    // 不可忽略的版本 -\u003e 提示用户更新，不显示[忽略]按钮\n    !info.isIgnorable -\u003e prompt(info, task)\n    // 该版本已经被忽略 -\u003e 返回结果\n    info.isIgnored -\u003e returnResult(UpdateResult(UpdateResult.UPDATE_IGNORED))\n    // 提示用户更新\n    else -\u003e prompt(info, task)\n}\n```\n\nUpdateInfo\n\n```kotlin\ndata class UpdateInfo(\n    // 是否有新版本\n    val hasUpdate: Boolean = false,\n\n    // 是否强制安装：为true时不安装无法使用app\n    val isForce: Boolean = false,\n\n    // 是否静默更新：不提示用户直接下载安装\n    val isSilent: Boolean = false,\n\n    // 是否可忽略该版本：忽略后不再提示用户更新该版本\n    val isIgnorable: Boolean = false,\n\n    // 是否在通知栏显示下载进度：为true时显示\n    val isShowNotification: Boolean = true,\n\n    // 更新内容文案\n    val updateContent: String = \"\",\n\n    // 新包下载地址\n    val url: String = \"\",\n\n    // 新包哈希值\n    val hash: String = \"\",\n)\n```\n\n## LICENSE\n\nThe Component is open-sourced software licensed under the [Apache license](LICENSE).","funding_links":[],"categories":["升级更新"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczy1121%2Fupdate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fczy1121%2Fupdate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczy1121%2Fupdate/lists"}