GithubHelp home page GithubHelp logo

binaryopsgit / collageimageview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grishinsergey/collageimageview

0.0 0.0 0.0 21.18 MB

Organize your images in beautiful collage with this library!

License: MIT License

Kotlin 100.00%

collageimageview's Introduction

CollageImageView

This app is an example. how to create collages with RecyclerView. See an example, how it's working:

device-2021-04-24-015545.mp4

Installation

1) If you have not added Jitpack to your repositories, add it:

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

2) Then add to your app (or another module, where you will use the lib) this dependency:

implementation 'com.github.GrishinSergey:CollageImageView:<actual-lib-version>'

3) In your layout you should place this:

<com.sagrishin.collageview.CollageView
    android:id="@+id/collageViewId"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

And in your source you should place next code.

One of major changes between v1 and v2 is that now it is necessary to provide previewer. This is the way, how this lib supports different libraries for previewing images. Look to app module to see details

collageViewId.itemPreviewLoader = GlideItemPreviewLoaderImpl.Builder(context).build()

Now it is possible to set radius for images in collage. Just paste value in dp in collage to make it rounded

val radius = TypedValue.applyDimension(
    TypedValue.COMPLEX_UNIT_DIP,
    4F, // the radius value
    context.resources.displayMetrics
)
collageViewId.itemCornerRadius = radius.toInt()

Here is an example, how to fill list of urls to images. Let's say you have list of images from your API, so you can convert them to CollageItemUrlData

val images = photos.map { singlePhoto ->
    CollageItemUrlData(singlePhoto.url).apply {
        this.width = singlePhoto.width
        this.height = singlePhoto.height
    }
}
collageViewId.setItemDatas(images)

Also it is possible to listen, on which image user clicked:

collageViewId.clickListener = OnCollageClickListener { position ->
    Toast.makeText(context, "clicked position is $position", Toast.LENGTH_SHORT).show()
}

Last, which is necessary, call showCollage method:

collageViewId.showCollage()

What should be upgraded:

  1. Make thumbnail and error holders which will be shown, if image still loading or if an error acquired
  2. Create proguard file

collageimageview's People

Contributors

grishinsergey avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.