Foursquare-CollectionPicker

Additional

Language
Java
Version
1.0.1 (Mar 4, 2015)
Created
Feb 17, 2015
Updated
Nov 21, 2016 (Retired)
Owner
Anton Nurdin Tuhadiansyah (anton46)
Contributors
Anton Nurdin Tuhadiansyah (anton46)
Huqiu Liao (liaohuqiu)
Vasilis Charalampakis (charbgr)
3
Activity
Badge
Generate
Download
Source code

Forsquare-CollectionPicker

Collection Picker is an Android View library which looks like Foursquare Tastes picker. For more information see the website.

Usage

Gradle

compile 'com.anton46:collection-picker:1.0.2'

Maven

<dependency>
    <groupId>com.anton46</groupId>
    <artifactId>collection-picker</artifactId>
    <version>1.0.2</version>
</dependency>

Declare a CollectionPicker inside your XML layout file

 <com.anton46.collectionitempicker.CollectionPicker
        android:id="@+id/collection_item_picker"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        app:cp_addIcon="@android:drawable/ic_menu_add"
        app:cp_cancelIcon="@android:drawable/ic_menu_close_clear_cancel"
        app:cp_itemBackgroundNormal="@color/blue"
        app:cp_itemBackgroundPressed="@color/red"
        app:cp_itemMargin="5dp"
        app:cp_textPaddingBottom="5dp"
        app:cp_textPaddingLeft="10dp"
        app:cp_textPaddingRight="10dp"
        app:cp_textPaddingTop="5dp" 
        app:cp_simplified="false" />

Add Items

        List<Item> items = new ArrayList<>();
        items.add(new Item("item1", "Items 1"));
        
        CollectionPicker picker = (CollectionPicker) findViewById(R.id.collection_item_picker);
        picker.setItems(items);
        picker.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onClick(Item item, int position) {
            
            }
        });

Configure using xml attributes in code :

        //Layout radius
        <attr name="cp_itemRadius" format="dimension" />
        //Layout background normal
        <attr name="cp_itemBackgroundNormal" format="color" />
        //Layout background pressed/selected
        <attr name="cp_itemBackgroundPressed" format="color" />
        //Add icon indicator
        <attr name="cp_addIcon" format="reference" />
        //Cancel icon indicator
        <attr name="cp_cancelIcon" format="reference" />
        //Margin beetwen items (Horizontal and vertical)
        <attr name="cp_itemMargin" format="dimension" />
        //Text color
        <attr name="cp_itemTextColor" format="color"/>
        //Text paddding to left
        <attr name="cp_textPaddingLeft" format="dimension" />
         //Text paddding to right 
        <attr name="cp_textPaddingRight" format="dimension" />
         //Text paddding to top 
        <attr name="cp_textPaddingTop" format="dimension" />
         //Text paddding to bottom  
        <attr name="cp_textPaddingBottom" format="dimension" />
        //Simplify tags (No icons)
        <attr name="cp_simplified" format="boolean" />

Developed by

License

Copyright 2015 Anton Nurdin Tuhadiansyah

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.