Git Product home page Git Product logo

stocker's Introduction

Stocker

stocker-image

Light weight Downloading library which manages its own Memory cache.

Stocker instance

val stocker = Stocker.Builder(applicationContext)
                .build()

Download request

stocker.fetch(ASSET_URL_AS_STRING) {(body, status, error) ->    
  if(status) {
    // Url downloaded
  }
}

To cancel the request

// Stocker fetch will return a Request object. Just pass it onto the Stocker.cancel() method. 
val request = stocker.fetch(ASSET_URL_AS_STRING) {(body, status, error) ->    
  if(status) {
    // Url downloaded
  }
}
stocker.cancel(request) // To cancel the request

Supports Image Binding

Stocker.bind(IMAGE_URL_AS_STRING, imageView)

It will download and render the image asset on the ImageView

Usage

To use Stocker Library goto the Release page and download the aar.

Stocker Advantage

Stocker manages Memory caching by default with the best fit Memory size for your device. If you want to change it you can do it the following way

val stocker = Stocker.Builder(applicationContext)
                .cacheSettings(object: CacheSettings {
                    override fun getCacheStrategy(): CacheStrategy {
                        return CacheStrategy.MEM_CACHE
                    }

                    override fun getMemCacheSize(): Int {
                        return 10 * 1024 // 10MB
                    }
                })
                .build()

No Cache

Stocker can also be configured without any caching

val stocker = Stocker.Builder(applicationContext)
                .cacheSettings(object: CacheSettings {
                    override fun getCacheStrategy(): CacheStrategy {
                        return CacheStrategy.NO_CACHE
                    }
                })
                .build()

TODO

  • Unit Testing
  • Optimizing Image binding
  • Publish to Gradle

Important

You can also read about the Design decisions about the Sample app and Library inside the relevant folders README.

stocker's People

Contributors

immathanr avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

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.