novoda/download-manager


A library that handles long-running downloads, handling the network interactions and retrying downloads automatically after failures

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.novoda:download-manager:2.3.4'
	}
	dependencies {
		implementation("com.github.novoda:download-manager:2.3.4")
	}
	<dependency>
	    <groupId>com.github.novoda</groupId>
	    <artifactId>download-manager</artifactId>
	    <version>2.3.4</version>
	</dependency>

                            
    libraryDependencies += "com.github.novoda" % "download-manager" % "2.3.4"
        
        

                            
    :dependencies [[com.github.novoda/download-manager "2.3.4"]]
        
        

Readme


download-manager CI status Download from BintrayApache 2.0 Licence

A library that handles long-running downloads, handling the network interactions and retrying downloads automatically after failures. Clients can request downloads in batches, receiving a single notification for all of the files allocated to a batch while being able to retrieve the single files after downloads complete.

Adding to your project

To start using this library, add these lines to the build.gradle of your project:

repositories {
    jcenter()
}

dependencies {
    compile 'com.novoda:download-manager:<latest-version>'
}

Simple usage

  1. Create a DownloadManager:
DownloadManager downloadManager = DownloadManagerBuilder
        .newInstance(this, handler, R.mipmap.ic_launcher_round)
        .withLogHandle(new DemoLogHandle())
        .withStorageRequirementRules(StorageRequirementRuleFactory.createByteBasedRule(TWO_HUNDRED_MB_IN_BYTES))
        .build();
  1. Create a Batch of files to download:
Batch batch = Batch.with(primaryStorageWithDownloadsSubpackage, DownloadBatchIdCreator.createSanitizedFrom("batch_id_1"), "batch one title")
        .downloadFrom("http://ipv4.download.thinkbroadband.com/5MB.zip").saveTo("foo/bar", "local-filename-5mb.zip").withIdentifier(DownloadFileIdCreator.createFrom("file_id_1")).apply()
        .downloadFrom("http://ipv4.download.thinkbroadband.com/10MB.zip").apply()
        .build();
  1. Schedule the batch for download:
downloadManager.download(batch);

Snapshots

CI status Download from Bintray

Snapshot builds from develop are automatically deployed to a repository that is not synced with JCenter. To consume a snapshot build add an additional maven repo as follows:

repositories {
    maven {
        url 'https://dl.bintray.com/novoda-oss/snapshots/'
    }
}

You can find the latest snapshot version following this link.

Contributing

We always welcome people to contribute new features or bug fixes, here is how.

If you have a problem, check the Issues Page first to see if we are already working on it.