{"id":13989471,"url":"https://github.com/skyfe79/AndroidChannel","last_synced_at":"2025-07-22T10:32:42.529Z","repository":{"id":137746173,"uuid":"43043974","full_name":"skyfe79/AndroidChannel","owner":"skyfe79","description":"AndroidChannel is helper library for thread communication between mainthread and workerthread","archived":false,"fork":false,"pushed_at":"2016-04-30T11:40:14.000Z","size":144,"stargazers_count":79,"open_issues_count":0,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-04T23:35:03.765Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skyfe79.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}},"created_at":"2015-09-24T04:04:51.000Z","updated_at":"2024-12-07T14:39:08.000Z","dependencies_parsed_at":"2024-01-15T16:51:41.983Z","dependency_job_id":null,"html_url":"https://github.com/skyfe79/AndroidChannel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/skyfe79/AndroidChannel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyfe79%2FAndroidChannel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyfe79%2FAndroidChannel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyfe79%2FAndroidChannel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyfe79%2FAndroidChannel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skyfe79","download_url":"https://codeload.github.com/skyfe79/AndroidChannel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyfe79%2FAndroidChannel/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266475475,"owners_count":23934970,"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-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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-08-09T13:01:40.724Z","updated_at":"2025-07-22T10:32:42.204Z","avatar_url":"https://github.com/skyfe79.png","language":"Java","readme":"[![Android Gems](http://www.android-gems.com/badge/skyfe79/AndroidChannel.svg?branch=master)](http://www.android-gems.com/lib/skyfe79/AndroidChannel)\n\r\n# AndroidChannel\n\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-AndroidChannel-green.svg?style=flat)](https://android-arsenal.com/details/1/2547)\n\nAndroidChannel is helper library for inter thread communication between main thread and worker thread. AndroidChannel uses HandlerThread for inter thread communication.\n\n\n\n## Setup Gradle\n\n```groovy\ndependencies {\n\t...\n    compile 'kr.pe.burt.android.lib:androidchannel:0.0.4'\n}\n```\n\n## Example\n\n### AndroidChannel-ProgressLayout\n\nI have reimplemented [ProgressLayout](https://github.com/iammert/ProgressLayout) by using AndroidChannel for example. You can check out souce code at [AndroidChannel-ProgressLayout](example/AndroidChannel-ProgressLayout). It shows how to use AndroidChannel when you want to implement a custom animatable view.\n\n### Ping-Pong \n\nYou can make a channel between main thread and worker thread easily.\n\n```java\nchannel = new AndroidChannel(new AndroidChannel.UiCallback() {\n    @Override\n    public boolean handleUiMessage(Message msg) {\n\n        if(msg.what == PING) {\n            Log.d(\"TAG\", \"PING\");\n            channel.toWorker().sendEmptyMessageDelayed(PONG, 1000);\n        }\n        return false;\n    }\n}, new AndroidChannel.WorkerCallback() {\n    @Override\n    public boolean handleWorkerMessage(Message msg) {\n\n        if(msg.what == PONG) {\n            Log.d(\"TAG\", \"PONG\");\n            channel.toUI().sendEmptyMessageDelayed(PING, 1000);\n        }\n        return false;\n    }\n});\nchannel.toUI().sendEmptyMessage(PING);\n```\n\n### Timer\n\nIf you use AndroidChannel, You can make Timer more easily. I already make Timer class for you. You can just use it. If you want to know how to implement Timer class, you just read [souce code](https://github.com/skyfe79/AndroidChannel/blob/master/androidchannel/src/main/java/kr/pe/burt/android/lib/androidchannel/Timer.java) in the package.\n\n```java\ntimer = new Timer(1000, new Timer.OnTimer() {\n    int count = 0;\n    @Override\n    public void onTime(Timer timer) {\n        count++;\n        textView.setText(\"count : \" + count);\n    }\n});\ntimer.start();\t\n```\n\nYou can also stop the timer like this.\n\n```java\n@Override\npublic boolean onTouchEvent(MotionEvent event) {\n    if(event.getAction() == MotionEvent.ACTION_UP) {\n        if(timer.isAlive()) {\n            timer.stop();\n        } else {\n            timer.start();\n        }\n    }\n    return super.onTouchEvent(event);\n}\n```\n\n## APIs\n\n* channel.open()\n * Use open() method to open channel. If you created a channel by Channel constructor, it is automatically open the channel by default. \n* channel.close() \n * Use close() method to close channel. close() method removes callbacks and messages in the message queue.\n* channel.toUI() \n * toUI() method returns main thread handler. If you want to send messages to ui thread you should use toUI() method.\n* channel.toWorker()\n * toWorker() method returns worker thread handler. If you want to send messages to worker thread you should use toWorker() method.    \t\n\n## MIT License\n\nThe MIT License\n\nCopyright © 2015 Sungcheol Kim, http://github.com/skyfe79/AndroidChannel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","funding_links":[],"categories":["Java","etc"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskyfe79%2FAndroidChannel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskyfe79%2FAndroidChannel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskyfe79%2FAndroidChannel/lists"}