Skip to content

An easy-to-use animation which can be used for content picking for Android

License

Notifications You must be signed in to change notification settings

hantrungkien/Bubble-Picker

Repository files navigation

Bubble-Picker

License Platform

Read how we did it on Medium

Requirements

  • Android SDK 16+

Usage

Add to your root build.gradle:

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

Add the dependency:

dependencies {
	implementation 'com.github.hantrungkien:Bubble-Picker:v1.0.5.2'
}

How to use this library

This library was developed and extended based on https://github.com/igalata/Bubble-Picker

Please review Activity in the Sample for both cases

Now:

  • We can set Picker Item selected always is true
picker.isAlwaysSelected = false

//or

mBubblePicker.setAlwaysSelected(true);

  • We can set swipe move speed value (default = 1.5f)
picker.swipeMoveSpeed = 2f

//or

mBubblePicker.setSwipeMoveSpeed(2f);


pickerItem.setIsUseImgUrl(true);
pickerItem.setImgUrl(...)

//use Drawable
pickerItem.setIsUseImgUrl(false);
pickerItem.setImgDrawable(...)

Add BubblePicker to your xml layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    android:orientation="vertical">

    <com.kienht.bubblepicker.rendering.BubblePicker
        android:id="@+id/picker"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:backgroundColor="@android:color/white" />

</LinearLayout>

Specify the BubblePickerListener to get notified about events

Kotlin

picker.listener = object : BubblePickerListener {
            override fun onBubbleSelected(item: PickerItem) {

            }

            override fun onBubbleDeselected(item: PickerItem) {

            }
}

Java

picker.setListener(new BubblePickerListener() {
            @Override
            public void onBubbleSelected(@NotNull PickerItem item) {
                
            }

            @Override
            public void onBubbleDeselected(@NotNull PickerItem item) {

            }
});

To get all selected items use picker.selectedItems variable in Kotlin or picker.getSelectedItems() method in Java.

For more usage examples please review the sample app

Thanks

A special thanks go to Mr. Lopspower

Known iOS versions of the animation

LICENCE

Copyright 2018 Kien Han Trung

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.