A lightweight, efficient image loading library for Android
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.
| π 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 |
| 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 β’ β’ β’ π οΈ 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 |
| β¨ 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 |
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'
}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")
}PicFly.get(context)
.load("https://example.com/image.jpg")
.into(imageView);PicFly.get(context)
.load("https://example.com/image.jpg")
.into(imageView)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)// 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);// 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// 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)PicFly.get(context)
.load("https://example.com/image.jpg")
.resize(300, 300)
.into(imageView);PicFly.get(context)
.load("https://example.com/image.jpg")
.into(imageView, viewHolder);PicFly.get(context)
.load("https://example.com/image.jpg")
.preload();// Clear memory cache
PicFly.get(context).clearMemoryCache();
// Clear disk cache
PicFly.get(context).clearDiskCache();
// Clear all caches
PicFly.get(context).clearAllCaches();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);// 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");// 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);// 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);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);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
