{"id":18763715,"url":"https://github.com/inloop/localmessagemanager","last_synced_at":"2025-04-13T04:32:47.140Z","repository":{"id":77722263,"uuid":"70165199","full_name":"inloop/LocalMessageManager","owner":"inloop","description":"Simpler to use and faster alternative to LocalBroadcastManager","archived":false,"fork":false,"pushed_at":"2017-03-02T13:50:01.000Z","size":149,"stargazers_count":40,"open_issues_count":1,"forks_count":12,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-26T21:45:55.415Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","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/inloop.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-10-06T15:06:30.000Z","updated_at":"2024-09-25T09:49:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"87ecc611-0eaa-486b-8c53-329487ecd3f1","html_url":"https://github.com/inloop/LocalMessageManager","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inloop%2FLocalMessageManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inloop%2FLocalMessageManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inloop%2FLocalMessageManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inloop%2FLocalMessageManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inloop","download_url":"https://codeload.github.com/inloop/LocalMessageManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248664175,"owners_count":21141909,"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-11-07T18:27:11.640Z","updated_at":"2025-04-13T04:32:47.119Z","avatar_url":"https://github.com/inloop.png","language":"Java","readme":"LocalMessageManager\n================\n\nUsed for efficient and simple delivery of messages within you application. It's an alternative to [LocalBroadcastManager](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager.html).\n\n- Simple to use\n- Can send any arbitrary object (doesn't need to be Parceable / Serializable / Bundle)\n- Very efficient - objects are pooled and no new instances are created during delivery\n- Uses standard Android Handler for message delivery\n- Messages are always delivered to the main UI thread\n- No Context needed\n- Lightweight - just one main class ([LocalMessageManager](https://github.com/inloop/LocalMessageManager/blob/master/library/src/main/java/eu/inloop/localmessagemanager/LocalMessageManager.java))\n\n\nComparision with LocalBroadcastManager\n--------\n- Less complex code (compare with [LocalBroadcastManager source](https://github.com/android/platform_frameworks_support/blob/master/v4/java/android/support/v4/content/LocalBroadcastManager.java))\n- No need to use a Bundle to transfer the data and add unnecessary string keys\n- Doesn't create any new instances, less impact on Garbage Collector \n- No need to define IntentFilters / Actions\n- Less error prone due to more straighforward API\n\n\nHow to implement\n--------\n\nYou can **send a message** from anywhere. If you don't need any parameters, just use:\n```java\nLocalMessageManager.getInstance().send(R.id.msg_sample_event);\n```\n(The message ID is an integer. You can use simple constants or Android IDs or anything else).\n\nIf you want to send an arbitrary object:\n```java\nLocalMessageManager.getInstance().send(R.id.msg_sample_event, new MyCustomObject());\n```\n\n(you can also send a simple integer argument or a Bundle)\n\n**Register receiver**. In case of an Activity this is usually onStart(), or onCreate(). \nYou can also put this code into your base activity or fragment.\n```java\nLocalMessageManager.getInstance().addListener(this);\n```\nYou can listen to all events or add only a listener to a specific message ID.\n\n**Unregister receiver**. In case of an Activity this is usually in onStop() or onDestroy(). \nYou can also put this code into your base activity or fragment.\n```java\nLocalMessageManager.getInstance().removeListener(this);\n```\n\n**Create a listener** or let your class implement `LocalMessageCallback`.\n```java\n@Override\npublic void handleMessage(@NonNull final LocalMessage msg) {\n    switch (msg.getId()) {\n        case R.id.msg_sample_event : {\n            mTextView.setText(\"Received simple event\");\n        }\n        break;\n    }\n}\n```\n\nDownload\n--------\n\nGrab via Gradle:\n```groovy\ncompile 'eu.inloop:localmessagemanager:0.1.7'\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finloop%2Flocalmessagemanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finloop%2Flocalmessagemanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finloop%2Flocalmessagemanager/lists"}