{"id":21372933,"url":"https://github.com/wdsqjq/andlogin","last_synced_at":"2025-07-13T07:32:27.515Z","repository":{"id":61550772,"uuid":"404375298","full_name":"wdsqjq/AndLogin","owner":"wdsqjq","description":"Hook AMS + APT实现集中式登录. 详解: https://www.jianshu.com/p/7d8aed828f65","archived":false,"fork":false,"pushed_at":"2021-09-10T14:23:20.000Z","size":720,"stargazers_count":98,"open_issues_count":2,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-03-05T00:25:00.278Z","etag":null,"topics":["ams","apt","hook"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wdsqjq.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}},"created_at":"2021-09-08T14:17:45.000Z","updated_at":"2023-01-07T06:28:20.000Z","dependencies_parsed_at":"2022-10-19T22:01:00.726Z","dependency_job_id":null,"html_url":"https://github.com/wdsqjq/AndLogin","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdsqjq%2FAndLogin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdsqjq%2FAndLogin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdsqjq%2FAndLogin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdsqjq%2FAndLogin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wdsqjq","download_url":"https://codeload.github.com/wdsqjq/AndLogin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225865366,"owners_count":17536443,"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":["ams","apt","hook"],"created_at":"2024-11-22T08:24:09.651Z","updated_at":"2024-11-22T08:24:10.154Z","avatar_url":"https://github.com/wdsqjq.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# AndLogin\n\n**通过Hook AMS + APT实现集中式登录**\n\n效果如下：\n\n![preview](img/preview.gif)\n\n\n\n**优势：**\n\n1. 以非侵入性的方式将分散的登录判断逻辑集中处理，减少了代码量，提高了开发效率。\n2. 增加或删除目标页面时无需修改判断逻辑，只需增加或删除其对应注解即可，符合开闭原则，降低了耦合度\n3. 在用户登录成功后直接跳转到目标界面，保证了用户操作不被中断。\n\n![login](img/hook_login.png)\n\n**使用：**\n\n1，添加依赖\n\n```groovy\nallprojects {\n    repositories {\n        maven { url 'https://www.jitpack.io' }\n    }\n}\n\n\ndependencies {\n\timplementation 'com.github.wdsqjq.AndLogin:lib:1.0.0'\n\tkapt 'com.github.wdsqjq.AndLogin:apt_processor:1.0.0'\n}\n```\n\n2，给需要登录的Activity添加注解\n\n```kotlin\n@RequireLogin\nclass TargetActivity1 : AppCompatActivity() {\n\t...\n}\n\n@RequireLogin\nclass TargetActivity2 : AppCompatActivity() {\n\t...\n}\n```\n\n3，给登录Activity添加注解\n\n```java\n@LoginActivity\nclass LoginActivity : AppCompatActivity() {\n\t...\n}\n```\n\n4，提供判断是否登录的方法\n\n需要是一个静态方法\n\n```java\n@LoginActivity\nclass LoginActivity : AppCompatActivity() {\n\n    companion object {\n        // 该方法用于返回是否登录\n        @JudgeLogin\n        @JvmStatic\n        fun checkLogin(): Boolean {\n            return SpUtil.isLogin()\n        }\n    }\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwdsqjq%2Fandlogin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwdsqjq%2Fandlogin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwdsqjq%2Fandlogin/lists"}