All Projects → oussaki → Rxdownloader

oussaki / Rxdownloader

Licence: other
- Reactive Extension Library for Android to download files

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Rxdownloader

Awesome Reactive Programming
A repository for sharing all the resources available on Reactive Programming and Reactive Systems
Stars: ✭ 163 (+307.5%)
Mutual labels:  reactive, reactive-programming, reactive-streams, reactive-extensions, reactivex
Awesome Rxjs
A collection of awesome RxJS resources
Stars: ✭ 314 (+685%)
Mutual labels:  reactive, reactive-programming, reactive-extensions, reactivex
Rx.Http
A reactive way to make HTTP Request in .NET Core 🚀
Stars: ✭ 62 (+55%)
Mutual labels:  reactivex, reactive, reactive-streams, reactive-programming
Fast Android Networking
🚀 A Complete Fast Android Networking Library that also supports HTTP/2 🚀
Stars: ✭ 5,346 (+13265%)
Mutual labels:  rxjava2, libraries, downloader, internet
assembler
Functional, type-safe, stateless reactive Java API for efficient implementation of the API Composition Pattern for querying/merging data from multiple datasources/services, with a specific focus on solving the N + 1 query problem
Stars: ✭ 102 (+155%)
Mutual labels:  reactive, reactive-streams, reactive-programming
KotlinReactiveMS
An educational project to learn reactive programming with Spring 5 and Kotlin
Stars: ✭ 33 (-17.5%)
Mutual labels:  reactive, reactive-streams, reactive-programming
Rxcombine
Bi-directional type bridging between RxSwift and Apple's Combine framework
Stars: ✭ 741 (+1752.5%)
Mutual labels:  reactive, reactive-programming, reactive-streams
RxJava-Codelab
Codelab project for demonstration of RxJava features
Stars: ✭ 44 (+10%)
Mutual labels:  reactivex, reactive, reactive-programming
netifi-quickstart-java
Project to assist you in getting started using Netifi.
Stars: ✭ 23 (-42.5%)
Mutual labels:  reactive, reactive-streams, reactive-programming
rxjava2-http
Transmit RxJava2 Flowable over http with non-blocking backpressure
Stars: ✭ 19 (-52.5%)
Mutual labels:  reactive, reactive-streams, rxjava2
Reactiveui
An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms that is inspired by functional reactive programming. ReactiveUI allows you to abstract mutable state away from your user interfaces, express the idea around a feature in one readable place and improve the testability of your application.
Stars: ✭ 6,709 (+16672.5%)
Mutual labels:  reactive-programming, reactive-extensions, reactivex
springboot-rsocketjwt-example
Example of using JWT with RSocket and Spring Boot
Stars: ✭ 26 (-35%)
Mutual labels:  reactive, reactive-streams, reactive-programming
Observable
The easiest way to observe values in Swift.
Stars: ✭ 346 (+765%)
Mutual labels:  reactive, library, libraries
Reactor Core
Non-Blocking Reactive Foundation for the JVM
Stars: ✭ 3,891 (+9627.5%)
Mutual labels:  reactive, reactive-streams, reactive-extensions
mongo-images
Ever wonder how you can create a full stack reactive application that also saves images? Well look no further! We've got Spring Webflux, Reactive Mongo Streams with GridFS, and Angular5!
Stars: ✭ 12 (-70%)
Mutual labels:  reactivex, reactive-streams, reactive-programming
reacted
Actor based reactive java framework for microservices in local and distributed environment
Stars: ✭ 17 (-57.5%)
Mutual labels:  reactive, reactive-streams, reactive-programming
Rxpy
Reactive Extensions for Python, https://rxpy.rtfd.io
Stars: ✭ 4,086 (+10115%)
Mutual labels:  reactive, reactive-extensions, reactivex
flutter-form-with-validation-BLOC
This form and validation functions are created by using the BLOC pattern with RxDart instead of using StatefulWidget
Stars: ✭ 63 (+57.5%)
Mutual labels:  reactivex, reactive-streams, reactive-programming
Pharmacist
Builds observables from events.
Stars: ✭ 221 (+452.5%)
Mutual labels:  reactivex, reactive-programming, reactive-extensions
Entwine
Testing tools and utilities for Apple's Combine framework.
Stars: ✭ 306 (+665%)
Mutual labels:  reactive, reactive-programming, reactive-streams

Reactive Downloader Library for Android

Build Status API

This library provides a simple api to download files and handle data stream in a reactive way

if you liked this library you can buy me a coffe : Buy Me a Coffee at ko-fi.com

Usage

Example:

// Create one instance 
 RxDownloader rxDownloader = new RxDownloader
                .Builder(context)
                .addFile("http://reactivex.io/assets/Rx_Logo_S.png") // you can add more urls
                .build();

// Subscribe to start downloading files 
       rxDownloader.asList()
                .subscribe(new BiConsumer<List<FileContainer>, Throwable>() {
                    @Override
                    public void accept(List<FileContainer> fileContainers, Throwable throwable) throws Exception {
                        // Do awesome things with your files

                    }
                });

Handling Progress & Error Events

There is 5 Events you can use in this library:

  * `doOnStart` : This event will be called before start downloading files.
  * `doOnProgress` : This event will publish the current progress each time a file downloaded.
  * `doOnEachSingleError` : Event called each time a file failed to download.
  * `doOnCompleteWithError` : Event called when finish all the downloads and some of the files failed to download.
  * `doOnCompleteWithSuccess` : Event called when finish downloading all the files successfully.
  • Example:
 RxDownloader rxDownloader = new RxDownloader
                .Builder(context)
                .addFile("http://reactivex.io/assets/Rx_Logo_S.png")
                .build()
                .doOnStart(() -> {
                    progressBar.setProgress(0);
                    multiline.setText("");
                    txtProgress.setText("About to start downloading");
                })
                .doOnProgress(progress -> {
                    progressBar.setProgress(progress);
                    multiline.append("\n Progress " + progress);
                    txtProgress.setText("Progress: " + progress + "%");
                })
                .doOnEachSingleError(throwable -> {
                    multiline.append("\n " + throwable.getMessage());
                })
                .doOnCompleteWithError(() -> {
                    txtProgress.setText("Download finished with error");
                })
                .doOnCompleteWithSuccess(() -> {
                    txtProgress.setText("Download finished successfully");
                });

Options :

  • Customize OkHttpClient
	 OkHttpClient ok = new OkHttpClient.Builder().connectTimeout(6,TimeUnit.SECONDS).build();
	 new RxDownloader
                .Builder(context)
                .client(ok)
                .build();
  • Customize Directory to save your files By default files will be saved in cache directory. You can just customize the directory by calling : storage(File storagePath)

  • Building list of urls methods:

    • addFile(String url): add url directly to list of urls without renaming the downloaded file.
    • addFile(String newName, String url): add url to list and renaming the file to newName, Ps: No need to write the file extension.
    • addFiles(List<String> urls): add a bulk of URL's.

Download Strategies

-MAX Strategy: will try to download all the files in case of errors it's will continue till the end.
 	 new RxDownloader
                .Builder(context)
                .strategy(DownloadStrategy.MAX)
                

-ALL Strategy: will try to download all the files but if it encountered an error it's will stop immediately.
	new RxDownloader
                .Builder(context)
                .strategy(DownloadStrategy.ALL)

Sometimes you want your files to be in a certain order, for that you can achieve that by calling the Order Method in Builder this way:

.Order(DownloadStrategy.FLAG_SEQUENTIAL)
* By default the downloader is using `FLAG_PARALLEL` to achieve more speed and performance 

Testing

You can find the tests inside the sample project in RxTest Class, Here is some examples (Using Robolectric).

  • Testing downloading with Max Strategy:
	rxDownloader = builder
                .strategy(DownloadStrategy.MAX)
                .addFile("http://fakeURL.com/error-file.jpg")  // this will trigger an error
                .build();
        TestObserver<List<FileContainer>> testObserver = rxDownloader.asList().test();
        testObserver.awaitTerminalEvent();
        testObserver
                .assertNoErrors()
                .assertValue(l -> l.size() == 3);

  • Second test, Testing with ALL Strategy:
	 rxDownloader = builder
                .strategy(DownloadStrategy.ALL)
                .addFile("http://fakeURL.com/error-file2.jpg") // this will trigger an error
                .addFile("http://reactivex.io/assets/Rx_Logo_S.png")
                .build();

        TestObserver<List<FileContainer>> testObserver = rxDownloader.asList().test();
        testObserver.awaitTerminalEvent();
        testObserver
                .assertNoErrors()
                .assertValueCount(1);

Setup

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

allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Add the dependency to your build.gradle:

dependencies {
    compile 'com.github.oussaki:RxDownloader:0.3'
}

License

Copyright 2016 Oussama Abdallah

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
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].