GithubHelp home page GithubHelp logo

fancydownloader's Introduction

FancyDownloader

Download Build Status

Installation

compile 'co.fitcom:fancydownloader:0.0.1'

Usage

import co.fitcom.fancydownloader.Manager;
import co.fitcom.fancydownloader.Request;
Manager downloadManager;

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Manager.init(this);
        downloadManager = Manager.getInstance();
    }

    String fileDownloadId;
    Request fileRequest = new Request("http://ipv4.download.thinkbroadband.com/20MB.zip");
            fileRequest.setListener(new DownloadListener() {
                public void onComplete(String task) {


                }

                public void onError(String task) {
                }

                public void onProgress(String task, final long currentBytes, final long totalBytes,long speed) {
                    int progress = (int) ((currentBytes * 100L) / totalBytes);
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            // Update UI
                        }
                    });
                }
            });
    fileDownloadId = downloadManager.create(fileRequest);
    downloadManager.start(fileDownloadId);

Api

Method Default Type Description
create(Request request) String Creates a download task it returns the id of the task
start(String id) void Starts a download task.
resume(String id) void Resumes a download task.
cancel(String id) void Cancels a download task.
cancelAll(String) void Cancels all download task.
pause(String id) void Pauses a download task.
pauseAll() void Pauses all download task.
init(Context context) void Initiates the download manager
getInstance() Manager Get an instance of the download manager

TODO

  • Local Notifications

fancydownloader's People

Contributors

triniwiz avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fancydownloader's Issues

Wrong implementation of okhttp callback

Your implemention of the callback for "onResponse" is wrong. You missed to handle !response.isSuccessful() case, which includes all good connections but http errors.

public void onResponse(@NonNull Call call, @NonNull final Response response) {
if (!response.isSuccessful()) {
 //Handle error
}
else {
 //Handle success
}

Bug with same filename and different extensions

Let's say I download file.mp4, this will create file.tmp and store things there temporarily. But file.mp4 also has a thumbnail, file.jpg. If I download both simultaneously, some corruption occurrs.

Possible solution: don't replace the extension, instead use file.mp4.tmp and file.jpg.tmp

Additionally, trying to download file with no extension fails completely

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.