Code Monkey home page Code Monkey logo

androidbubbles's Introduction

AndroidBubbles

Android bubbles recreates the chat bubbles as implemented by Facebook. It focuses on smooth animations for a smiliar user experience, and extremely easy implementation.

(Higher quality version can be found here)

Usage

You can start using Android Bubbles in 3 simple steps.

1. Add project dependency

First, add Android Bubbles to your project dependencies.

Make sure you have jcenter as one of your repositories...

repositories {
  ...
  jcenter()
}

...and add Android Bubbles to your dependencies.

dependencies {
  ...
  compile 'com.rodrigopontes:android-bubbles:0.1.0'
}

2. Create a BubblesManager

Create a BubblesManager using a Context.

public class MainActivity extends Activity {

  BubblesManager bubblesManager;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);
    
    bubblesManager = BubblesManager.create(this);
  }
}

After you create it, you can also retrieve it with

bubblesManager = BubblesManager.getManager();

3. Add Bubble

Add a bubble to BubblesManager

ImageView imageView = new ImageView(this);
imageView.setImageResource(R.drawable.my_image);
Bubble bubble = new Bubble(imageView);
bubblesManager.addBubble(bubble);

You now have your first Android Bubble!

Other methods

Handle Bubble taps

You can handle Bubble taps just as you would with a Button.

bubble.setBubbleOnTapListener(new BubbleOnTapListener {

  @Override
  public void onTap(Bubble.BubblePosition bubblePosition) {
    Log.d("Bubbles", "Hello World!");
  }
}

The Bubble's position can be retrieved from

bubblePosition.x
bubblePosition.y

You can also implement

public void onTapConfirmed(Bubble.BubblePosition)
public void onDoubleTap(Bubble.BubblePosition)

Remove Bubble

You can remove Bubbles programatically with

bubblesManager.removeBubble(bubble);

Create Bubbles easily

You can save a few lines of code by using Bubble's convenience contructors.

new Bubble(imageBitmap);
new Bubble(drawable);
new Bubble(resourceId);
new Bubble(imageUri);

Set Bubble's image size

You can customize the size of the Bubble by using

bubble.setImageViewSize(width, height);

Check if BubblesManager exists

To avoid problems with activity recreations, you can wrap your BubblesManager creation with

if(BubblesManager.exists()) {
  bubblesManager = BubblesManager.getManager();
} else {
  bubblesManager = BubblesManeger.create(this);
}

Handle screen rotations

Screen rotations must be handled by the Activity that implements BubblesManager. That is made simple with

bubblesManager.updateConfiguration();

Highly customizable

You can easily customize Android Bubble's feel by tweaking the fields in BubblesProperties.

Share your project!

Implemented Android Bubbles for your project? Send it to [email protected] and I'll share it here!

License

Copyright 2016 Rodrigo Pontes

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

androidbubbles's People

Contributors

rodrigodlpontes avatar

Stargazers

Vincent Nagel avatar Nisarg avatar Kҽʋιɳ Sҽɾɾαɳσ avatar Khalid O. Lamptey avatar Pranav Lathigara avatar Marcin Moskała avatar Rahul avatar Vasile2kappa avatar Irshu avatar Harish Uginval avatar Taishi Yamasaki avatar 学海无涯 avatar Arun Karnan avatar

Watchers

James Cloos avatar Arun Karnan 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.