Skip to content

tuhinx/picfly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PicFly Logo

PicFly

A lightweight, efficient image loading library for Android

Platform Android Min SDK 24 License MIT Version 2.0.1

Features β€’ Installation β€’ Usage β€’ Advanced β€’ License

πŸ“± Overview

PicFly is a modern image loading library for Android that provides a simple and fluent API for loading images from URLs into ImageViews. It's designed to be lightweight yet powerful, with support for caching, transformations, and more.

Sample Image

Sample image loaded with PicFly

✨ Features

πŸš€ Simple API Fluent interface with method chaining for easy use
πŸ’Ύ Memory Caching Efficient caching using LruCache
πŸ’Ώ Disk Caching Persistent caching between app sessions
πŸ–ΌοΈ Placeholder Support Show placeholder images while loading
⚠️ Error Handling Display error images when loading fails
πŸ”„ Image Transformations β€’ 🌫️ Blur with customizable radius
β€’ βšͺ Grayscale
β€’ πŸ”„ Rotate
β€’ β­• Circle crop with optional border
β€’ πŸ”˜ Rounded corners with customizable radius
β€’ 🎨 Color filter
β€’ β˜€οΈ Brightness adjustment
β€’ πŸ› οΈ Support for custom transformations
πŸ“ Image Resizing Resize images to specific dimensions
πŸ“œ RecyclerView Support Optimized for efficient image loading in RecyclerViews
⏱️ Preloading Preload images for smoother scrolling
πŸ”„ Kotlin & Java Support Works seamlessly with both languages

πŸ“¦ Installation

Gradle

Add the JitPack repository to your project-level build.gradle:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

Add the dependency to your app-level build.gradle:

dependencies {
    implementation 'com.github.tuhinx:picfly:2.0.1'
}

Kotlin DSL

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
    }
}

dependencies {
    implementation("com.github.tuhinx:picfly:2.0.1")
}

πŸš€ Usage

Basic Usage

Java Kotlin
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .into(imageView);
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .into(imageView)

With Placeholder and Error Handling

Java Kotlin
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .placeholder(R.drawable.placeholder)
    .error(R.drawable.error)
    .into(imageView);
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .placeholder(R.drawable.placeholder)
    .error(R.drawable.error)
    .into(imageView)

Image Transformations

Java Kotlin
// Grayscale
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .grayscale()
    .into(imageView);

// Blur
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .blur(15f) // Radius: 0-25
    .into(imageView);

// Circle Crop
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .circleCrop()
    .into(imageView);

// Circle Crop with Border
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .circleCrop(Color.BLACK, 4f) // Border color, width
    .into(imageView);

// Rounded Corners
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .roundedCorners(25f) // Radius
    .into(imageView);

// Color Filter
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .colorFilter(Color.RED)
    .into(imageView);

// Rotate
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .rotate(90f) // Degrees
    .into(imageView);

// Brightness
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .brightness(0.3f) // -1.0f to 1.0f
    .into(imageView);
// Grayscale
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .grayscale()
    .into(imageView)

// Blur
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .blur(15f) // Radius: 0-25
    .into(imageView)

// Circle Crop
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .circleCrop()
    .into(imageView)

// Circle Crop with Border
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .circleCrop(Color.BLACK, 4f) // Border color, width
    .into(imageView)

// Rounded Corners
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .roundedCorners(25f) // Radius
    .into(imageView)

// Color Filter
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .colorFilter(Color.RED)
    .into(imageView)

// Rotate
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .rotate(90f) // Degrees
    .into(imageView)

// Brightness
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .brightness(0.3f) // -1.0f to 1.0f
    .into(imageView)

πŸ” Advanced Usage

Image Resizing

PicFly.get(context)
    .load("https://example.com/image.jpg")
    .resize(300, 300)
    .into(imageView);

RecyclerView Integration

PicFly.get(context)
    .load("https://example.com/image.jpg")
    .into(imageView, viewHolder);

Preloading Images

PicFly.get(context)
    .load("https://example.com/image.jpg")
    .preload();

Cache Management

// Clear memory cache
PicFly.get(context).clearMemoryCache();

// Clear disk cache
PicFly.get(context).clearDiskCache();

// Clear all caches
PicFly.get(context).clearAllCaches();

RecyclerView Preloading

public class MyAdapter extends RecyclerView.Adapter<MyViewHolder>
    implements RecyclerViewPreloader.PreloadModelProvider<MyItem> {

    private List<MyItem> items;

    @Override
    public List<String> getPreloadUrls(@NonNull MyItem item) {
        return Collections.singletonList(item.getImageUrl());
    }

    @Override
    public int[] getPreloadDimensions(@NonNull MyItem item) {
        return new int[]{300, 300}; // Width, Height
    }
}

// In your activity/fragment:
RecyclerView recyclerView = findViewById(R.id.recyclerView);
MyAdapter adapter = new MyAdapter();
recyclerView.setAdapter(adapter);

// Add the preloader
RecyclerViewPreloader<MyItem> preloader = PicFly.get(this)
    .getRecyclerViewPreloader(adapter);
recyclerView.addOnScrollListener(preloader);

Custom Transformations

public class CustomTransformation implements Transformation {
    @Override
    public Bitmap transform(Bitmap source) {
        // Apply your transformation here
        return transformedBitmap;
    }

    @Override
    public String key() {
        // Return a unique key for this transformation
        return "custom_transformation";
    }
}

// Usage
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .transform(new CustomTransformation())
    .into(imageView);

πŸ“„ License

PicFly is released under the MIT License. See the LICENSE file for details.

MIT License
MIT License

Copyright (c) 2025 PicFly

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Made with ❀️ by PicFly