A library to make a mosaic with a preview of multiple images

Overview

Preview Image Collection

Introduction

Preview Image Collection is a library to draw a collage with a number of images like facebook preview album

Screenshot GIF

Install

Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:

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

Step 2. Add the dependency

dependencies {
  implementation 'com.github.AgnaldoNP:PreviewImageCollection:1.3'
}

Usage

Sample of usage

<pereira.agnaldo.previewimgcol.ImageCollectionView
    android:id="@+id/imageCollectionView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="30dp"
    app:backgroundColor="@color/colorAccent"
    app:baseRowHeight="150dp"
    app:imageMargin="1dp"
    app:pinchToZoom="true"
    app:showExternalBorderMargins="true"
    app:maxImagePerRow="3"
    app:maxRows="2" />

Options

Property Value type Default
backgroundColor color #FFFFFF
baseRowHeight dimension 150dp
imageMargin dimension 1dp
pinchToZoom boolean true
showExternalBorderMargins boolean true
maxImagePerRow integer 3
maxRows integer 3
imageScaleType enum center_crop

Programmatically

    var collectionView = findViewById(R.id.imageCollectionView)

    collectionView.maxRows = ImageCollectionView.NO_ROW_LIMITS
    collectionView.maxRows = 10

    collectionView.maxImagePerRow =3

    collectionView.imageMargin = 10

    collectionView.baseImageHeight = 150

    collectionView.mBackgroundColor = Color.WHITE

    collectionView.pinchToZoom = true

    ollectionView.showExternalBorderMargins = true

    val bitmap = ...
    collectionView.addImage(bitmap)

    val bitmap2 = ...
    collectionView.addImage(bitmap2, object : ImageCollectionView.OnImageClickListener {
        override fun onClick(bitmap: Bitmap, imageView: ImageView) {
            Toast.makeText(imageView.context, "Test Click on image ...", Toast.LENGTH_LONG).show()
        }
    })
    // or simply
    collectionView.addImage(bitmap2, { bitmap: Bitmap?, imageView: ImageView? ->
        Toast.makeText(context, "Test Click on image ...", Toast.LENGTH_LONG).show()
    })

    collectionView.setOnMoreClicked(object : ImageCollectionView.OnMoreClickListener {
        override fun onMoreClicked(bitmaps: List<Bitmap>) {
            Toast.makeText(collectionView.context, "on more clicked ", Toast.LENGTH_LONG).show()
        }
    })
    // or simply
    collectionView.setOnMoreClicked { bitmaps ->
        Toast.makeText(collectionView.context, "on more clicked ", Toast.LENGTH_LONG).show()
    }
    ImageCollectionView collectionView = (ImageCollectionView) findViewById(R.id.imageCollectionView);

    Bitmap bitmap = ...;
    imageCollectionView.addImage(bitmap);

    Bitmap bitmap2 = ...;
    imageCollectionView.addImage(bitmap, (bmp, imageView) -> {
        Toast.makeText(context, "Test Click image 08", Toast.LENGTH_LONG).show();
    });

    imageCollectionView.setOnMoreClicked(bitmaps -> {
        Toast.makeText(context, "OnMoreClicked", Toast.LENGTH_LONG).show();
    });

Contributions and Support

This project made use of Zoomy by Álvaro Blanco to enable "pinch to zoom" functionality.

Contributions are welcome. Create a new pull request in order to submit your fixes and they shall be merged after moderation. In case of any issues, bugs or any suggestions, either create a new issue or post comments in already active relevant issues

Please consider supporting me

Bitcoin URI: bitcoin:BC1Q4RT2KNSX28CA4H5YA08VF0SXMG3JPHKS6GWDXV?label=Consider%20support%20me

Bitcoin Address: bc1q4rt2knsx28ca4h5ya08vf0sxmg3jphks6gwdxv

You might also like...
Android library for the adapter view (RecyclerView, ViewPager, ViewPager2)
Android library for the adapter view (RecyclerView, ViewPager, ViewPager2)

Antonio Android library for the adapter view (RecyclerView, ViewPager, ViewPager2) Free from implementation of the adapter's boilerplate code ! Reuse

It makes a preview from an url, grabbing all the information such as title, relevant texts and images. This a version for Android of my web link preview https://github.com/LeonardoCardoso/Link-Preview
It makes a preview from an url, grabbing all the information such as title, relevant texts and images. This a version for Android of my web link preview https://github.com/LeonardoCardoso/Link-Preview

LeoCardz Link Preview for Android It makes a preview from an url, grabbing all the information such as title, relevant texts and images. Visual Exampl

It makes a preview from an url, grabbing all the information such as title, relevant texts and images. This a version for Android of my web link preview https://github.com/LeonardoCardoso/Link-Preview
It makes a preview from an url, grabbing all the information such as title, relevant texts and images. This a version for Android of my web link preview https://github.com/LeonardoCardoso/Link-Preview

LeoCardz Link Preview for Android It makes a preview from an url, grabbing all the information such as title, relevant texts and images. Visual Exampl

Make mosaic effect on android
Make mosaic effect on android

ProMosaic Make mosaic for image on android. Features Select Mode Follow finger Select rectangle Effect Mode Grid color based on original image Blur Im

Make mosaic effect on android
Make mosaic effect on android

ProMosaic Make mosaic for image on android. Features Select Mode Follow finger Select rectangle Effect Mode Grid color based on original image Blur Im

 🌏 Android/IDEA localization plugin. supports multiple languages and multiple translators.
🌏 Android/IDEA localization plugin. supports multiple languages and multiple translators.

English | 简体中文 AndroidLocalizePlugin 🌏 Android/IDEA localization plugin. supports multiple languages and multiple translators. Features Multiple tran

 A MaterialChipSetWidget is used to hold multiple chipsets 🤩 and each chipset has multiple values. 🔖
A MaterialChipSetWidget is used to hold multiple chipsets 🤩 and each chipset has multiple values. 🔖

A MaterialChipSetWidget is used to hold multiple chipsets 🤩 and each chipset has multiple values. 🔖

Awesome Image Picker library will pick images/gifs with beautiful interface. Supports image or gif, Single and Multiple Image selection.

Awesome Image Picker Awesome Image Picker library will pick images/gifs with beautiful interface. Supports image or gif, Single and Multiple Image sel

Media Picker is an Android Libary that lets you to select multiple images or video
Media Picker is an Android Libary that lets you to select multiple images or video

Media Picker Please let me know if your application go to production via this link Media Picker is an Android Libary that lets you to select multiple

Media Picker is an Android Libary that lets you to select multiple images or video
Media Picker is an Android Libary that lets you to select multiple images or video

Media Picker Please let me know if your application go to production via this link Media Picker is an Android Libary that lets you to select multiple

An Android app for Dokuz Eylul University students can make use of multiple school websites in this one app
An Android app for Dokuz Eylul University students can make use of multiple school websites in this one app

An Android app for Dokuz Eylul University students can make use of multiple school websites in this one app

On device extracting images from videos - creating video from images.

AndroidVideoTranscoder Surprisingly fast on device video transcoding. Features extracting images from video either ffmpeg or mediacodec creating video

This is an Image slider with swipes, Here we used Volley to Image load URL's from JSON! Here we make it very easy way to load images from Internet and We customized the description font style(OpenSans).

ImageSliderWithSwipes This is an Image slider with swipes, Here we used Volley to load URL's from JSON! Here we make it very easy way to load images f

Make interesting books for your kids, usint text and images from simple.wikipedia.org

Baby Book Builder Baby Book Builder is an Android app and a website for creating books to help your growing child learn. Contributing Donations Baby B

Simple and powerful library to emulate iOS's
Simple and powerful library to emulate iOS's "3D Touch" preview functionality on Android.

Android 3D Touch - PeekView iOS uses 3D Touch as a way to "peek" into full content, such as emails, pictures, web searches, etc. While they have dedic

A SeekBar suited for showing a preview of something. As seen in Google Play Movies.
A SeekBar suited for showing a preview of something. As seen in Google Play Movies.

PreviewSeekBar A SeekBar suited for showing a video preview. As seen in Google Play Movies Google Play Movies PreviewSeekBar's sample Build Add the fo

This project is focused on the sample using the API's new preview version of Android-L, use of transitions, shadows etc...

Android L preview example Description This project is focused on the sample using the API's new preview version of Android-L, use of transitions, shad

This project is focused on the sample using the API's new preview version of Android-L, use of transitions, shadows etc...

Android L preview example Description This project is focused on the sample using the API's new preview version of Android-L, use of transitions, shad

This project is focused on the sample using the API's new preview version of Android-L, use of transitions, shadows etc...

Android L preview example Description This project is focused on the sample using the API's new preview version of Android-L, use of transitions, shad

Comments
  • Reference to source files

    Reference to source files

    I have multiple jpg images that I decode to bitmaps like BitmapFactory.decodeFile(file.getPath()); before loading them into the gallery via imageCollectionView.addImage(bitmap, null, new OnImageLongClickListener...);. So far so good. Now I want to delete a specific picture, not only remove the bitmap from the gallery. I want to delete the source file (see above file.getPath()) inside a OnImageLongClickListener.
    However, I am missing a reference to the file. Is it possible to reference a jpg file loaded into the Gallery backwards?

    opened by andreasflosdorf 1
  • Any chance of a Java sample??

    Any chance of a Java sample??

    I really like this way of displaying and want to use it my own app but I don't know Kotlin. If there's any chance of a simple Java sample instead of Kotlin I'd be really grateful. I just can't seem to get this bit into Java:

    collectionView.addImage(BitmapFactory.decodeResource(resources, R.drawable.landscape_08), object : ImageCollectionView.OnImageClickListener { override fun onClick(bitmap: Bitmap, imageView: ImageView) { Toast.makeText(imageView.context, "Test Click image 08", Toast.LENGTH_LONG) .show() } } )

    opened by Pealy 1
  • Replace Bitmap with URL

    Replace Bitmap with URL

    I think you should replace HashMap<BitMap, Image> by HashMap<URL, Image>. Then you can use Glide to load BitMap from URL. Because When I have 10 Image to preview and i limit to show only 4 (+6 morer). I still have to add 10 Bitmap to but it just need 4 BitMap to enough to show. This thing may make OOM when I have many PreviewImageCollection like NewsFeed facebook.

    If I use 10 URL it just 10 String and it does not occupy memory

    Ps: My English so bad...wish you sympathize...Thank you

    opened by 0975086498 1
  • When pinchToZoom is enabled some images don't handle touch events.

    When pinchToZoom is enabled some images don't handle touch events.

    Describe the bug When pinch to zoom is enabled and all the images are set with click listeners, some images don't handle the click events. Generally, it happens to images on the right side of the collection.

    (The images with the red cross are misbehaving.) image

    opened by bartaferi 0
Owner
Agnaldo Pereira
Android Developer since 2013. Native developement with java and kotlin.
Agnaldo Pereira
Open source routing engine for OpenStreetMap. Use it as Java library or server.

GraphHopper Routing Engine GraphHopper is a fast and memory efficient Java routing engine, released under Apache License 2.0. By default it uses OpenS

GraphHopper 4k Jan 7, 2023
Vector map library and writer - running on Android and Desktop.

Mapsforge See the integration guide and changelog. And read through how to contribute guidelines. If you have any questions or problems, don't hesitat

mapsforge 1k Jan 2, 2023
Epoxy is an Android library for building complex screens in a RecyclerView

Epoxy Epoxy is an Android library for building complex screens in a RecyclerView. Models are automatically generated from custom views or databinding

Airbnb 8.1k Jan 4, 2023
The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...

FastAdapter The FastAdapter is here to simplify creating adapters for RecyclerViews. Don't worry about the adapter anymore. Just write the logic for h

Mike Penz 3.7k Jan 8, 2023
Renderers is an Android library created to avoid all the boilerplate needed to use a RecyclerView/ListView with adapters.

Renderers Renderers is an Android library created to avoid all the RecyclerView/Adapter boilerplate needed to create a list/grid of data in your app a

Pedro Vicente Gómez Sánchez 1.2k Nov 19, 2022
Android library to auto-play/pause videos from url in recyclerview.

AutoplayVideos Show some ❤️ and star the repo to support the project This library is created with the purpose to implement recyclerview with videos ea

Krupen Ghetiya 989 Nov 17, 2022
:page_with_curl: [Android Library] Giving powers to RecyclerView

Android library that provides most common functions around recycler-view like Swipe to dismiss, Drag and Drop, Divider in the ui, events for when item

Nishant Srivastava 644 Nov 20, 2022
[] Easy Adapters library for Android

Deprecated Due to the growing use of the RecyclerView and the RecyclerView.Adapter provided adapter class, Easy-Adapter is now deprecated. Whilst the

ribot 425 Nov 25, 2022
This library provides GridAdapters(ListGridAdapter & CursorGridAdapter) which enable you to bind your data in grid card fashion within android.widget.ListView, Also provides many other features related to GridListView.

GridListViewAdapters This libarary enables you to implement GridView like card layout within ListView with added capabilites like Paginations, Additio

Biraj Patel 270 Nov 25, 2022
This library provides Easy Android ListView Adapters(EasyListAdapter & EasyCursorAdapter) which makes designing Multi-Row-Type ListView very simple & cleaner, It also provides many useful features for ListView.

EasyListViewAdapters Whenever you want to display custom items in listview, then only way to achieve this is to implement your own subclass of BaseAda

Biraj Patel 132 Nov 25, 2022