Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Commit c1d391d

Browse files
author
Ira
committed
Merge remote-tracking branch 'origin/develop' into develop
2 parents f87a82e + fe8a04a commit c1d391d

File tree

2 files changed

+180
-1
lines changed

2 files changed

+180
-1
lines changed

README.md

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# Bubble-Picker
2+
3+
[![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)]()
4+
[![](https://jitpack.io/v/igalata/Bubble-Picker.svg)](https://jitpack.io/#igalata/Bubble-Picker)
5+
6+
<a href='https://play.google.com/store/apps/details?id=com.igalata.bubblepickerdemo&pcampaignid=MKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1'><img alt='Get it on Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png' height="70" width="180"/></a>
7+
8+
[Live DEMO on appetize.io](https://appetize.io/app/eem5172h1pvn1wzxf8uq35xqbg?device=nexus5&scale=75&orientation=portrait&osVersion=7.0)
9+
10+
Check this [project on dribbble](https://dribbble.com/shots/3349372-Bubble-Picker-Open-Source-Component)
11+
12+
Read how we did it [on Medium](https://medium.com/@igalata13/how-to-create-a-bubble-selection-animation-on-android-627044da4854#.ajonc010b)
13+
14+
<img src="shot.gif"/>
15+
16+
##Requirements
17+
- Android SDK 16+
18+
19+
##Usage
20+
21+
Add to your root build.gradle:
22+
```Groovy
23+
allprojects {
24+
repositories {
25+
...
26+
maven { url "https://jitpack.io" }
27+
}
28+
}
29+
```
30+
31+
Add the dependency:
32+
```Groovy
33+
dependencies {
34+
compile 'com.github.igalata:Bubble-Picker:v0.1.1'
35+
}
36+
```
37+
38+
## How to use this library
39+
40+
Add `BubblePicker` to your xml layout
41+
42+
```xml
43+
<?xml version="1.0" encoding="utf-8"?>
44+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
45+
xmlns:app="http://schemas.android.com/apk/res-auto"
46+
android:layout_width="match_parent"
47+
android:layout_height="match_parent">
48+
49+
<com.igalata.bubblepicker.rendering.BubblePicker
50+
android:id="@+id/picker"
51+
android:layout_width="match_parent"
52+
android:layout_height="match_parent"
53+
app:backgroundColor="@android:color/white" />
54+
55+
</FrameLayout>
56+
```
57+
58+
Override onResume() and onPause() methods to call the same methods from the `BubblePicker`
59+
60+
Kotlin
61+
```kotlin
62+
override fun onResume() {
63+
super.onResume()
64+
picker.onResume()
65+
}
66+
67+
override fun onPause() {
68+
super.onPause()
69+
picker.onPause()
70+
}
71+
```
72+
73+
Java
74+
```java
75+
@Override
76+
protected void onResume() {
77+
super.onResume();
78+
picker.onResume();
79+
}
80+
81+
@Override
82+
protected void onPause() {
83+
super.onPause();
84+
picker.onPause();
85+
}
86+
```
87+
88+
Pass the `PickerItem` list to the `BubblePicker`
89+
90+
Kotlin
91+
```kotlin
92+
val titles = resources.getStringArray(R.array.countries)
93+
val colors = resources.obtainTypedArray(R.array.colors)
94+
val images = resources.obtainTypedArray(R.array.images)
95+
96+
picker.items = ArrayList()
97+
98+
titles.forEachIndexed { i, country ->
99+
picker.items?.add(PickerItem(country,
100+
gradient = BubbleGradient(colors.getColor((i * 2) % 8, 0), colors.getColor((i * 2) % 8 + 1, 0),
101+
BubbleGradient.VERTICAL),
102+
typeface = mediumTypeface,
103+
textColor = ContextCompat.getColor(this, android.R.color.white),
104+
image = ContextCompat.getDrawable(this, images.getResourceId(i, 0))))
105+
}
106+
```
107+
108+
Java
109+
```java
110+
final String[] titles = getResources().getStringArray(R.array.countries);
111+
final TypedArray colors = getResources().obtainTypedArray(R.array.colors);
112+
final TypedArray images = getResources().obtainTypedArray(R.array.images);
113+
114+
picker.setItems(new ArrayList<PickerItem>() {{
115+
for (int i = 0; i < titles.length; ++i) {
116+
add(new PickerItem(titles[i], colors.getColor((i * 2) % 8, 0),
117+
ContextCompat.getColor(TestActivity.this, android.R.color.white),
118+
ContextCompat.getDrawable(TestActivity.this, images.getResourceId(i, 0))));
119+
}
120+
}});
121+
```
122+
123+
Specify the `BubblePickerListener` to get notified about events
124+
125+
Kotlin
126+
```kotlin
127+
picker.listener = object : BubblePickerListener {
128+
override fun onBubbleSelected(item: PickerItem) {
129+
130+
}
131+
132+
override fun onBubbleDeselected(item: PickerItem) {
133+
134+
}
135+
}
136+
```
137+
138+
Java
139+
```java
140+
picker.setListener(new BubblePickerListener() {
141+
@Override
142+
public void onBubbleSelected(@NotNull PickerItem item) {
143+
144+
}
145+
146+
@Override
147+
public void onBubbleDeselected(@NotNull PickerItem item) {
148+
149+
}
150+
});
151+
```
152+
153+
To get all selected items use `picker.selectedItems` variable in Kotlin or `picker.getSelectedItems()` method in Java.
154+
155+
For more usage examples please review the sample app
156+
157+
## License
158+
159+
MIT License
160+
161+
Copyright (c) 2017 Irina Galata
162+
163+
Permission is hereby granted, free of charge, to any person obtaining a copy
164+
of this software and associated documentation files (the "Software"), to deal
165+
in the Software without restriction, including without limitation the rights
166+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
167+
copies of the Software, and to permit persons to whom the Software is
168+
furnished to do so, subject to the following conditions:
169+
170+
The above copyright notice and this permission notice shall be included in all
171+
copies or substantial portions of the Software.
172+
173+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
174+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
175+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
176+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
177+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
178+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
179+
SOFTWARE.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.0.6'
4+
ext.kotlin_version = '1.1.0'
55
repositories {
66
jcenter()
77
}

0 commit comments

Comments
 (0)