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 β’ π οΈ 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 |
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'
}
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")
}
Java | Kotlin |
---|---|
PicFly.get(context)
.load("https://example.com/image.jpg")
.into(imageView); |
PicFly.get(context)
.load("https://example.com/image.jpg")
.into(imageView) |
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) |
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) |
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);
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