Skip to content

tuhinx/picfly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PicFly

A lightweight, efficient image loading library for Android

Platform Android Min SDK 24 License MIT Version 2.0.3

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
β€’ 🟫 Sepia tone
β€’ πŸ“ˆ Contrast adjustment
β€’ 🌈 Saturation adjustment
β€’ πŸŒͺ️ Hue adjustment
β€’ ↔️ Horizontal flip
β€’ ↕️ Vertical flip
β€’ πŸ› οΈ 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

πŸ†• New Features

✨ Loading UX Improvements β€’ ✨ Shimmer animated placeholder
β€’ πŸ“Έ Low-resolution thumbnail preview
β€’ πŸ–ΌοΈ BlurHash support for instant preview
πŸ–ΌοΈ Format Support β€’ 🎞️ GIF support
β€’ 🌐 Animated WebP
β€’ πŸ“ SVG vector drawable loading
β€’ πŸ“· AVIF format
β€’ πŸ“± HEIC format
🌐 Network Handling β€’ πŸ“Š Image loading progress callback
β€’ πŸ”„ Retry on failure with configurable count and delay
β€’ ⏱️ Timeout configuration
β€’ πŸ“Ά Network-aware loading (WiFi vs Mobile)
β€’ ⏸️ Pause/Resume image requests
πŸ”§ Performance Enhancements β€’ πŸ”„ Smart thumbnail β†’ full image loading
β€’ πŸ“± Scroll-based loading throttling
β€’ πŸ’Ύ Low-RAM device optimization mode
β€’ 🧠 Memory pressure detection
πŸ” Metadata & Smart Features β€’ πŸ“· EXIF metadata extraction
β€’ 🧭 Auto orientation correction
β€’ πŸ“ Image size & format detection
β€’ πŸ“ Offline cache indicator API
☁️ Cloud & Source Support β€’ πŸƒ Firebase Storage image loading
β€’ ☁️ AWS S3 support
β€’ 🏷️ Custom request headers (Auth, Token, User-Agent)
β€’ πŸ” Signed URL handling
πŸ“± UI Module Features β€’ πŸ–ΌοΈ Full-screen image viewer
β€’ 🀏 Pinch-to-zoom & double-tap zoom
β€’ βœ‹ Swipe-to-dismiss
β€’ 🎠 Image carousel
β€’ 🧩 Collage / grid builder

πŸ“¦ 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.3'
}

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.3")
}

πŸš€ Usage

Basic Usage

Java

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

Kotlin

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

With Placeholder and Error Handling

Java

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

Kotlin

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

Image Transformations

Java

// 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);

New Transformations & Features

Java

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

// Contrast
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .contrast(1.5f) // 0.0f to 4.0f
    .into(imageView);

// Saturation
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .saturation(1.2f) // 0.0f to 2.0f
    .into(imageView);

// Hue adjustment
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .hue(45f) // -180f to 180f
    .into(imageView);

// Flip horizontally
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .flipHorizontal()
    .into(imageView);

// Flip vertically
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .flipVertical()
    .into(imageView);

// Shimmer placeholder
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .enableShimmer(true)
    .into(imageView);

// Thumbnail preview
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .thumbnail(0.2f) // 20% scale thumbnail
    .into(imageView);

// BlurHash
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .blurHash("LKO2?U%2Tw=^_3WCX8WCX8WCWEM{M{")
    .into(imageView);

// Progress callback
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .progress(new ProgressCallback() {
        @Override
        public void onProgress(int percentage) {
            // Update progress bar
        }
        
        @Override
        public void onComplete() {
            // Loading complete
        }
        
        @Override
        public void onError() {
            // Loading failed
        }
    })
    .into(imageView);

// Retry with custom delay
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .retry(3, 2000) // 3 retries with 2 second delay
    .into(imageView);

// Timeout configuration
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .timeout(15000) // 15 seconds timeout
    .into(imageView);

// Custom headers
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .header("Authorization", "Bearer token123")
    .header("User-Agent", "MyApp/1.0")
    .into(imageView);

// Authentication
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .auth("Bearer", "token123")
    .into(imageView);

// EXIF auto-orientation (built-in)
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .into(imageView); // Auto-orients based on EXIF

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)

πŸ” 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);

UI Module Usage

Full-screen Image Viewer

Java

// Simple full-screen viewer
List<String> imageUrls = Arrays.asList(
    "https://example.com/image1.jpg",
    "https://example.com/image2.jpg",
    "https://example.com/image3.jpg"
);

FullscreenImageViewerActivity.start(this, imageUrls, 0); // Start at position 0

// Single image viewer
FullscreenImageViewerActivity.start(this, "https://example.com/image.jpg");

Java

// Simple full-screen viewer
String[] imageUrls = {
    "https://example.com/image1.jpg",
    "https://example.com/image2.jpg",
    "https://example.com/image3.jpg"
};

FullscreenImageViewerActivity.start(this, imageUrls, 0); // Start at position 0

// Single image viewer
FullscreenImageViewerActivity.start(this, "https://example.com/image.jpg");

// With headers
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .header("Authorization", "Bearer token123")
    .header("User-Agent", "MyApp/1.0")
    .into(imageView);

Kotlin

// Simple full-screen viewer
val imageUrls = listOf(
    "https://example.com/image1.jpg",
    "https://example.com/image2.jpg",
    "https://example.com/image3.jpg"
)

FullscreenImageViewerActivity.start(this, imageUrls, 0) // Start at position 0

// Single image viewer
FullscreenImageViewerActivity.start(this, "https://example.com/image.jpg")

// With headers
PicFly.get(context)
    .load("https://example.com/image.jpg")
    .header("Authorization", "Bearer token123")
    .header("User-Agent", "MyApp/1.0")
    .into(imageView)
// RecyclerView preloading with custom adapter
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> implements PreloadableAdapter<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