Git Product home page Git Product logo

floating-hearts-view's Introduction

Floating Hearts

Android Arsenal GitHub license

Instagram-like floating hearts view for android.

Demo APK: https://petersamokhin.com/files/projects/fh/fh.apk

Install

  1. Add jitpack repo to your project-level build.gradle:
allprojects {
    repositories {
        // other repos
	    maven { url 'https://jitpack.io' }
    }
}
  1. Add library to your dependencies:
dependencies {
    implementation 'com.github.petersamokhin:floating-hearts-view:$ACTUAL_VERSION'
}

Latest version: https://github.com/petersamokhin/floating-hearts-view/releases

Usage

Configure renderer:

val config = HeartsRenderer.Config(
            5f,                        // The max amplitude of the flight along the X axis
            0.15f,                     // Duration of the flying animation will be multiplied by this value (lower โ€” faster)
            2f                         // Heart size coefficient 
)
heartsView.applyConfig(config)

Or in your XML layout file:

<com.petersamokhin.android.floatinghearts.HeartsView
            android:id="@+id/heartsView"
            android:layout_width="match_parent"
            android:layout_height="330dp"
            app:x_max="3"
            app:size_coeff="2.5"
            app:floating_time_coeff="0.8" />

Make your model:

// Get bitmap from image by URL
// or simply convert from drawable, etc
val image = "https://cdn.shopify.com/s/files/1/1061/1924/products/Thinking_Face_Emoji_large.png"
val byteArray = URL(image).readBytes()
val bitmap = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.size)

val model = HeartsView.Model(
            0,                         // Unique ID of this image, used for Rajawali materials caching
            bitmap                     // Bitmap image
)

Let your image fly!

heartsView.emitHeart(model)

3rd party

Rajawali is the only one dependency. Inspired by Instagram/Snapchat/etc broadcasts.

Known issues

On some devices / on some Android versions NullPointerException may happen after new Material() call in HeartsRenderer. This causes because GLES20.glGetString( GLES20.GL_EXTENSIONS ); is returning null.

To fix this simply do not call emitHeart in first 300-500 ms after activity start.

floating-hearts-view's People

Contributors

petersamokhin avatar

Watchers

James Cloos 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.