{"id":18918939,"url":"https://github.com/fernandospr/android-navigation-abandon-fragment","last_synced_at":"2025-10-30T11:09:36.050Z","repository":{"id":70832345,"uuid":"246019174","full_name":"fernandospr/android-navigation-abandon-fragment","owner":"fernandospr","description":"Demonstrate a solution to call custom fragment logic when abandoning a fragment by pressing back or navigateUp.","archived":false,"fork":false,"pushed_at":"2020-03-09T11:52:47.000Z","size":125,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-01T08:05:56.452Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/fernandospr.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":"2020-03-09T11:35:17.000Z","updated_at":"2020-07-24T11:45:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"eacf348e-a182-47bc-8011-dfbbccabcfdb","html_url":"https://github.com/fernandospr/android-navigation-abandon-fragment","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fernandospr/android-navigation-abandon-fragment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandospr%2Fandroid-navigation-abandon-fragment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandospr%2Fandroid-navigation-abandon-fragment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandospr%2Fandroid-navigation-abandon-fragment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandospr%2Fandroid-navigation-abandon-fragment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fernandospr","download_url":"https://codeload.github.com/fernandospr/android-navigation-abandon-fragment/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandospr%2Fandroid-navigation-abandon-fragment/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281793988,"owners_count":26562617,"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","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-08T10:34:22.436Z","updated_at":"2025-10-30T11:09:36.033Z","avatar_url":"https://github.com/fernandospr.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# android-navigation-abandon-fragment\n\nThis is a demo project to demonstrate a solution to call custom optional logic in your fragments when pressing back or navigateUp.\n\nThe demo contains three fragments:\n* **AFragment**\n* **BFragment**\n* **CFragment**\n\n**AFragment** and **CFragment** implement the `onAbandon()` method from the `AbandonListener` interface.\nWhen pressing back or navigateUp, before going back, it'll call the `onAbandon()` method of the corresponding fragment, if the fragment implements the interface, otherwise it'll do nothing.\n\nIn this demo project, both fragments just print their class name.\n\n### Adding a New Fragment\n\n1. Create a new fragment.\n2. Add the new fragment to the navigation graph file: **nav_graph.xml**.\n3. Add an action to reach the new fragment in the navigation graph.\n4. Implement the navigation in the **MainActivity.kt** file.\n5. If you want to perform custom logic in your new fragment when the user presses back or navigateUp, just implement the `AbandonListener` interface.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffernandospr%2Fandroid-navigation-abandon-fragment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffernandospr%2Fandroid-navigation-abandon-fragment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffernandospr%2Fandroid-navigation-abandon-fragment/lists"}