{"id":25352660,"url":"https://github.com/mutkuensert/downloader","last_synced_at":"2025-10-29T21:31:16.768Z","repository":{"id":182159381,"uuid":"668044572","full_name":"mutkuensert/Downloader","owner":"mutkuensert","description":"An Android downloader library supported with notifications.","archived":false,"fork":false,"pushed_at":"2023-09-06T07:07:40.000Z","size":89,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-09-06T08:25:47.651Z","etag":null,"topics":["android","android-development","android-download","android-downloader","android-library","android-notifications"],"latest_commit_sha":null,"homepage":"","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/mutkuensert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-18T22:29:00.000Z","updated_at":"2023-09-06T08:25:47.651Z","dependencies_parsed_at":"2023-07-18T23:42:26.099Z","dependency_job_id":null,"html_url":"https://github.com/mutkuensert/Downloader","commit_stats":null,"previous_names":["mutkuensert/downloader"],"tags_count":9,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutkuensert%2FDownloader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutkuensert%2FDownloader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutkuensert%2FDownloader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutkuensert%2FDownloader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mutkuensert","download_url":"https://codeload.github.com/mutkuensert/Downloader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238895164,"owners_count":19548554,"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","android-development","android-download","android-downloader","android-library","android-notifications"],"created_at":"2025-02-14T18:57:11.612Z","updated_at":"2025-10-29T21:31:10.499Z","avatar_url":"https://github.com/mutkuensert.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Downloader\n\n## Table of Contents\n* [About The Library](#about-the-library)\n* [Adding The Dependency](#adding-the-dependency)\n* [How to Use](#how-to-use)\n* [License](#license)\n* [Contact](#contact)\n\n## About The Library\nWith this library you can easily download the files in urls and show the download progress in notifications.\nFor the example implementation of this library, you can look at my [Pixabay Search Engine](https://github.com/mutkuensert/Pixabay-Search-Engine) project on Github.\n\n## Adding The Dependency\nAdd jitpack into the repositories\n\n```gradle\nmaven { url 'https://jitpack.io' }\n```\n\nAdd the dependency in build.gradle file.\n```gradle\nimplementation 'com.github.mutkuensert:downloader:v2.3.1'\n```\n\n**You can also add the library locally. To do that:**\n\nClone the project.\n\nRun in the terminal:\n```gradle\n./gradlew build\n```\nFind generated aar file under build folder and copy \u0026 paste it into your project. You can create a directory called \"libs\" under your app module and paste the file into there.\nThen you can add the dependency:\n\n```gradle\nimplementation files('libs/Downloader.aar')\n```\n\n## How to Use\nIf you use Hilt in your project, you can initialize Downloader class like below. You should also implement a CoroutineScope and inject it. You mustn't provide it as a singleton.\n\n```kotlin\n@Module\n@InstallIn(SingletonComponent::class)\nobject DownloaderModule {\n\n    @Provides\n    fun providesDownloader(scope: CoroutineScope, @ApplicationContext context: Context): Downloader {\n        return Downloader.Builder(context, scope)\n            .setNotificationsActive(true) //Default is false.\n            .build()\n    }\n}\n```\nThe notifications can be customized:\n```kotlin\nval downloader = Downloader.Builder()\n    .context(context)\n    .scope(scope)\n    .setNotificationsActive(true)\n    .build()\n\ndownloader.notificationBuilder.setAutoCancel(false)\n\nreturn downloader\n```\n\nInject the downloader somewhere, for example a ViewModel:\n```kotlin\n@HiltViewModel\nclass MyViewModel @Inject constructor(\n    ...,\n    val downloader: Downloader,\n) : ViewModel() { }\n```\nInitialize activity result launcher in a Fragment or an Activity:\n```kotlin\nviewModel.downloader.initActivityResultLauncher {\n            registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -\u003e\n                if (result.resultCode == Activity.RESULT_OK) {\n                    val uri = result.data?.data\n\n                    if (uri != null) this.writeToFile(uri)\n                }\n            }\n        }\n```\n\nThe library uses functions of its own to extract the file name and file format from the url.\nIf a custom extractor is needed different from these default ones, you must set them:\n```kotlin\ndownloader.setFileFormatExtractor { url -\u003e\n            url.substringAfterLast(\".\").substringBefore(\"?\")\n        }\n```\n\n```kotlin\ndownloader.setFileNameExtractor { url -\u003e\n    url.substringAfterLast(\"/\").substringBefore(\".\")\n}\n```\n\nFinally, you can download the file on the url:\n```kotlin\ndownloader.downloadUrl(url)\n```\n\nNotification and internet permissions have to be added in the manifest file.\n\n## License\n```xml\nCopyright 2022 Mustafa Utku Ensert\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\n## Contact\n[ensertyazilim@gmail.com](#)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmutkuensert%2Fdownloader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmutkuensert%2Fdownloader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmutkuensert%2Fdownloader/lists"}