Backdrop

Replace boring backgrounds with Blurhash

BlurHash is a compact representation of a placeholder for an image.
Backdrop uses Glide and coroutines to show blured placeholder while image is loading.

How BlurHash works?

In short, BlurHash takes an image, and gives you a short string (only 20-30 characters!) that represents the placeholder for this image. You do this on the backend of your service, and store the string along with the image. When you send data to your client, you send both the URL to the image, and the BlurHash string. Your client then takes the string, and decodes it into an image that it shows while the real image is loading over the network. The string is short enough that it comfortably fits into whatever data format you use. For instance, it can easily be added as a field in a JSON object.

Installing / Getting started

Add the codes below to your root build.gradle file (not your module-level build.gradle file):

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

Next, add the dependency below to your module’s build.gradle file:

dependencies {
   implementation 'com.github.AndroidPoet:Backdrop:1.0.0'
}

You can load images with blurhash by using the Glide extension function as the following example below:.

 //create a global object from blurhash claas
 
 
 /// params lifecycleowner,context ,cache size
  val blurHash: BlurHash = BlurHash(this, this, lruSize = 20)

/// params imagelink,blurhash string, blurhash object 

imageView.loadImagewithBlurHash(
                    sampleResponse.img,
                    sampleResponse.blur,
                    blurHash
                )

Inspiration

This library was mostly inspired by BlurHashExt

Logo

(logo icon created by Freepik – Flaticon)

License

Designed and developed by 2020 AndroidPoet (Ranbir Singh)

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.

GitHub

View Github