Giter VIP home page Giter VIP logo

pixel's Introduction

Pixel

pixel

Maven Central CircleCI Codacy Badge

Kotlin Version

A lightweight image loading library for Android backed by Kotlin Coroutines.

Optimal: Pixel performs optimizations with memory & disk caching, downsampling the image in memory by image view size (pixel by pixel), re-using Bitmaps, automatically pause/cancel requests (Signature requests), and more.

Light: Pixel adds less than ~100 methods for now to your APK, which is considerably less than Glide,Fresco,Picasso and Coil.

Easy to use: Pixel's API uses Kotlin's language features and classic design for simplicity and minimal boilerplate.

Modern: Pixel is Kotlin-first and interoperable with Java.

Features

  • Signature Loads
  • Image Loading (For now image loading from network is supported only)
  • Modern (Kotlin Co-routines for structured concurrency and low latency)
  • Reliable (No 3rd party library used)
  • Supports JAVA

Why to use ?

  • It only downloads the image per width and height of image view per pixel hence the name and pauses all loads when UI is not available.
  • Signature Download (Same image download with same requested width and height will cancel previous such download in progress)
  • Synchronous load cancellation.
  • UI Responsive.

Download

Gradle

implementation 'io.github.mmobin789.pixel:pixel:1.0.0-alpha'

Gradle Kotlin DSL

implementation("io.github.mmobin789.pixel:pixel:1.0.0-alpha")

Maven

<dependency>
  <groupId>io.github.mmobin789.pixel</groupId>
  <artifactId>pixel</artifactId>
  <version>1.0.0-alpha</version>
  <type>aar</type>
</dependency>

Documentation

For complete usage in Kotlin and Java clone the project in Android Studio and run the sample app included.

Load an Image

Pixel.load("https://images.unsplash.com/photo-1492684223066-81342ee5ff30?ixlib=rb-1.2.1&auto=format&fit=crop&w=1000&q=80", iv)

Load an Image with options

 //Loads an image with a placeholder resource.
Pixel.load("image path", iv3, PixelOptions.Builder().setPlaceholderResource(R.drawable.ic_loading_android).build())

/**Loads an image of 30x30 pixels with a placeholder resource.
For best result, know the size of image from source and don't provide size less than size of image view
**/
Pixel.load("image path", holder.iv, PixelOptions.Builder().setPlaceholderResource(R.drawable.ic_loading_android)
.setImageSize(30, 30).build())

Configure memory and disk cache

// Set image memory cache to 48MBS
 PixelConfiguration.setImageMemoryCacheSize(48)
 
// Set Disk cache to 512MBS
 PixelConfiguration.setDiskCacheSize(512)
 
// Clear image cache
 PixelConfiguration.clearImageCache()
 
  

Logging

// Enable logging behavior
PixelConfiguration.setLoggingEnabled(true)

// Disable logging behavior (Default)
PixelConfiguration.setLoggingEnabled(false)

Requirements

  • Min SDK 23
  • Compile SDK 30+

R8 / Proguard

Pixel is completely compatible with R8 and doesn't require adding any extra rules.

If you use Proguard, you may need to add rules for Coroutines

Details

Read more on medium.

Releases

See release notes here.

In-Development

This library is maintained and under development as new features are periodically added.

Issues

Issues can be reported here.

Inspiration

The idea of employing Kotlin Coroutines that drive the working of this library partly came from Coil.

Co-Creator

Malik Dawar

License

Copyright 2020 Pixel Contributors

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

https://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.

pixel's People

Contributors

mmobin789 avatar dependabot-preview[bot] avatar dependabot[bot] avatar malikdawar avatar

Stargazers

Roman avatar

Watchers

James Cloos 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.