All Projects → majidgolshadi → Android Download Manager Pro

majidgolshadi / Android Download Manager Pro

Licence: mit
Android/Java download manager library help you to download files in parallel mechanism in some chunks.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Android Download Manager Pro

Redrun
✨🐌 🐎✨ fastest npm scripts runner
Stars: ✭ 85 (-94.58%)
Mutual labels:  parallel
Yabox
Yet another black-box optimization library for Python
Stars: ✭ 103 (-93.43%)
Mutual labels:  parallel
Mpm
CB-Geo High-Performance Material Point Method
Stars: ✭ 115 (-92.67%)
Mutual labels:  parallel
Floops.jl
Fast sequential, threaded, and distributed for-loops for Julia—fold for humans™
Stars: ✭ 96 (-93.88%)
Mutual labels:  parallel
Parallel Process
🏃 Run multiple processes simultaneously
Stars: ✭ 102 (-93.49%)
Mutual labels:  parallel
Rxdownloader
An Rx wrapper for Download Manager in Android
Stars: ✭ 107 (-93.18%)
Mutual labels:  downloadmanager
Updater
基于DownloadManager封装的更新器,使用超简单!
Stars: ✭ 82 (-94.77%)
Mutual labels:  downloadmanager
Redo
Smaller, easier, more powerful, and more reliable than make. An implementation of djb's redo.
Stars: ✭ 1,589 (+1.34%)
Mutual labels:  parallel
Doazureparallel
A R package that allows users to submit parallel workloads in Azure
Stars: ✭ 102 (-93.49%)
Mutual labels:  parallel
React Native Workers
Do heavy data process outside of your UI JS thread.
Stars: ✭ 114 (-92.73%)
Mutual labels:  parallel
Scroll
Scroll - making scrolling through buffers fun since 2016
Stars: ✭ 100 (-93.62%)
Mutual labels:  parallel
Root
The official repository for ROOT: analyzing, storing and visualizing big data, scientifically
Stars: ✭ 1,377 (-12.18%)
Mutual labels:  parallel
Index
Metarhia educational program index 📖
Stars: ✭ 2,045 (+30.42%)
Mutual labels:  parallel
Docker Jdownloader
JDownloader 2 Docker Image (Multiarch) - Passed 40M Downloads
Stars: ✭ 85 (-94.58%)
Mutual labels:  downloadmanager
Razzle
✨ Create server-rendered universal JavaScript applications with no configuration
Stars: ✭ 10,547 (+572.64%)
Mutual labels:  parallel
Napajs
Napa.js: a multi-threaded JavaScript runtime
Stars: ✭ 8,945 (+470.47%)
Mutual labels:  parallel
Highs
Linear optimization software
Stars: ✭ 107 (-93.18%)
Mutual labels:  parallel
Nimble
Stars: ✭ 121 (-92.28%)
Mutual labels:  parallel
Bach
Compose your async functions with elegance.
Stars: ✭ 117 (-92.54%)
Mutual labels:  parallel
Pandarallel
A simple and efficient tool to parallelize Pandas operations on all available CPUs
Stars: ✭ 1,887 (+20.34%)
Mutual labels:  parallel

Android Arsenal The MIT License

Android-Download-Manager

Android/Java download manager library help you to download files in parallel mechanism in some chunks.

Overview

This library is a download manager android/java library which developers can use in their apps and allow you to download files in parallel mechanism in some chunks and notify developers about tasks status (any download file process is a task). Each download task cross 6 stats in its lifetime.

  1. init
  2. ready
  3. downloading
  4. paused
  5. download finished
  6. end

applications states

Usage

In the first stage, you need to include these permissions in your AndroidManifest.xml file

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

After that, import com.golshadi.downloadManager package in your packages folder. So now everything is ready to start.

Let's get started

One of the important benefits of this lib is that you don't need to initialize object completely before getting any reports.

DownloadManagerPro dm = new DownloadManagerPro(Context);

to get report about tasks you can use these methods that will be introduced later on this doc:

public ReportStructure singleDownloadStatus(int token);
public List<ReportStructure> downloadTasksInSameState(int state);
public List<ReportStructure> lastCompletedDownloads();
public boolean unNotifiedChecked();
public boolean delete(int token, boolean deleteTaskFile);

Attention: in this documentation dm stands for DownloadManagerPro object

Initialize DownloadManagerPro

in order to download with this lib you need to set its basic configurations and give him a listener to poke you about tasks status.

void DownloadManagerPro.init(String saveFilePath, int maxChunk, DownloadManagerListener class)
  • String saveFilePath: folder address that you want to save your completed download task in it.
  • int maxChunk : number of maximum chunks. any task is divided into some chunks and download them in parallel. it's better not to define more than 16 chunks; but if you do it's set to 16 automatically.
  • DownloadManagerListener listenerClass in this package an interface created to report developer download tasks status. this interface includes some abstract methods that will be introduced later.

Example:

public class MyActivity extends Activity implements DownloadManagerListener {
    ...
    public void methodName() {
        ...
        // you can only pass this for context but here i want to show clearly
        DownloadManagerPro dm = new DownloadManagerPro(this.getApplicationContext());
        dm.init("downloadManager/", 12, this);
        ...
    }
    ...
}

there are three ways to define your download task, so you can define it any way you want. for example If you didn't set maximum chunks number or sd card folder address it uses your initialized values. these methods return you a task id that you can call to start or pause that task using this token.

int DownloadManagerPro.addTask(String saveName, String url, int chunk, String sdCardFolderAddress, boolean overwrite, boolean priority)

int DownloadManagerPro.addTask(String saveName, String url, String sdCardFolderAddress, boolean overwrite, boolean priority)

int DownloadManagerPro.addTask(String saveName, String url, boolean overwrite, boolean priority)
  • String saveName: defining te name of desired download file.

  • String url : Location of desired downlaod file.

  • int chunk : Number of chunks which download file has been divided into.

  • String sdCardFolder : Location of where user want to save the file.

  • boolean overwrite : Overwrite if exists another file with the same name. If true, overwrite and replace the file. If false, find new name and save it with new name.

  • boolean priority : Grant priority to more desired files to be downloaded.

  • return int task id: task token

Example:

int taskToken = dm.addTask("save_name", "http://www.site.com/video/ss.mp4", false, false);

this method usage is to start a download task. If download task doesn't get started since this task is in downloading state, it throw you an IOException. When download task start to download this lib notify you with OnDownloadStarted interface

void DownloadManagerPro.startDownload(int token) throws IOException
  • int token: It is an assigned token to each new download which is considered as download task id.

Example:

try {
        dm.startDownload(taskToekn);

    } catch (IOException e) {
        e.printStackTrace();
    }

pause a download tasks that you mention and when that task paused this lib notify you with OnDownloadPaused interface

void DownloadManagerPro.pauseDownload(int token)
  • int token: It is an assigned token to each new download which is considered as download task id.

Example:

dm.pauseDownload(taskToekn);

StartQueueDownload method create a queue sort on what you want and start download queue tasks with downloadTaskPerTime number simultaneously. If download tasks are running in queue and you try to start it again it throws a QueueDownloadInProgressException exception.

void DownloadManagerPro.StartQueueDownload(int downloadTaskPerTime, int sortType) throws QueueDownloadInProgressException
  • int downloadTaskPerTime: the number of task that can be downloaded simultaneously

  • int sortType: Grant priority to more desired files to be downloaded.

  • QueueSort.HighPriority : only high priority

  • QueueSort.LowPriority : only low priority

  • QueueSort.HighToLowPriority : sort queue from high to low priority

  • QueueSort.LowToHighPriority : sort queue from low to high priority

  • QueueSort.earlierFirst : sort queue from earlier to oldest tasks

  • QueueSort.oldestFirst : sort queue from old to earlier tasks

Example:

try {
        dm.startQueueDownload(3, QueueSort.oldestFirst);

    } catch (QueueDownloadInProgressException e) {
        e.printStackTrace();
    }

this method pauses queue download and if no queue download was started it throws a QueueDownloadNotStartedException exception.

void DownloadManagerPro.pauseQueueDownload()throws QueueDownloadNotStartedException

Example:

try {
        dm.pauseQueueDownload();

    } catch (QueueDownloadNotStartedException e){
        e.printStackTrace();
    }

Report

In this section we are working with reports since we need to get tasks status and some useful information about those status.


It reports task download information in "ReportStructure" style using a token (download task id) and finally returns the statue of that token.

ReportStruct DownloadManagerPro.SingleDownloadStatus(int token)
  • int token: task token

  • return ReportStructure object and it has a method to convert these info to json

  • int id: task token

  • String name: file name that will be saved on your sdCard

  • int state: download state number

  • String url: file download link

  • long fileSize: downloaded bytes

  • boolean resumable: download link is resumable or not

  • String type: file MIME

  • int chunks: task chunks number

  • double percent: downloaded file percent

  • long downloadLength: size that will get from your sd card after it completely download

  • String saveAddress: save file address

  • boolean priority: true if task was high priority

Example:

ReportStructure report = dm.singleDownloadStatus(taskToken);

It's a report method for returning the list of download task in same state that developers want.

List DownloadManagerPro.downloadTasksInSameState(int state)
  • int state: any download in it's life time across 6 state.
  • TaskState.INIT: task intruduce for library and gave you token back but it didn't started yet.
  • TaskState.READY: download task data fetch from its URL and it's ready to start.
  • TaskState.DOWNLOADING: download task in downloading process.
  • TaskState.PAUSED: download task in puase state. If in middle of downloading process internet disconnected; task goes to puase state and you can start it later
  • TaskState.DOWNLOAD_FINISHED: download task downloaded completely but their chunks did not rebuild.
  • TaskState.END: after rebuild download task chunks, task goes to this state and notified developer with OnDownloadCompleted(long taskToken) interface

Example:

List<ReportStructure> report = dm.downloadTasksInSameState(TaskState.INIT);

This method returns list of last completed Download tasks in "ReportStructure" style, developers can use it for notifying whether the task is completed or not.

List DownloadManagerPro.lastCompletedTasks()
  • return List : list of completed download from last called unNotifiedCheck() method till now.

Example:

List<ReportStructure> completedDownloadTasks = dm.lastCompletedTasks();

This method checks all un notified tasks, so in another "lastCompletedDownloads" call ,completed task does not show up again. “lastCompletedDownloads”: Shows the list of latest completed downloads. Calling this method, all of the tasks that were shown in the previous report, will be eliminated from "lastCompletedDownloads"

void DownloadManagerPro.unNotifiedCheck()

Example:

dm.unNotifiedCheck()

this method delete download task

boolean DownloadManagerPro.delete(int token, boolean deleteTaskFile)
  • int token: download task token
  • boolean deleteTaskFile: deletes download task from database and set deleteTaskFile as true, then it goes to saved folder and delete that file.

*return boolean : if delete is successfully it returns true otherwise false

Example:

dm.delete(12, false);

This method closes database connection.

void DownloadManagerPro.disConnectDB()

Example:

dm.disConnectDb();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].