Code Monkey home page Code Monkey logo

carouselpicker's Introduction

Carousel Picker

alt downloads

A Carousel picker library for android which supports both text and icons . 😾

Gradle Dependency

Add this in your root build.gradle file at the end of repositories:

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

Add the dependency :

dependencies {
	        implementation 'com.github.GoodieBag:CarouselPicker:v1.2'
		// v1.2 is the latest release with vertical orientation and font styling options. 
		// For the previous stable release use v1.1
	}

Sync the gradle and that's it! 👍

Features :

  • Supports icons and text or a mixture of both as items of the picker.
  • Gives a nice carousel view of the items.
  • Page change listener exists to monitor the current selected item.

Usage

XML :

<in.goodiebag.carouselpicker.CarouselPicker
        android:id="@+id/carousel"
        android:layout_marginTop="20dp"
        android:layout_marginBottom="20dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#CCC"
        app:items_visible="three" />

items_visible represents the number of pages visible on the screen. Three, five and seven are the available options.

Java :

Carousel picker supports both images and text or a mixture of both !

CarouselPicker carouselPicker = (CarouselPicker) findViewById(R.id.carousel);

// Case 1 : To populate the picker with images
List<CarouselPicker.PickerItem> imageItems = new ArrayList<>();
imageItems.add(new CarouselPicker.DrawableItem(R.drawable.i1));
imageItems.add(new CarouselPicker.DrawableItem(R.drawable.i2));
imageItems.add(new CarouselPicker.DrawableItem(R.drawable.i3));
//Create an adapter
CarouselPicker.CarouselViewAdapter imageAdapter = new CarouselPicker.CarouselViewAdapter(this, imageItems, 0);
//Set the adapter
carouselPicker.setAdapter(imageAdapter);

//Case 2 : To populate the picker with text
List<CarouselPicker.PickerItem> textItems = new ArrayList<>();
//20 here represents the textSize in dp, change it to the value you want.
textItems.add(new CarouselPicker.TextItem("hi", 20));
textItems.add(new CarouselPicker.TextItem("hi", 20));
textItems.add(new CarouselPicker.TextItem("hi", 20));
CarouselPicker.CarouselViewAdapter textAdapter = new CarouselPicker.CarouselViewAdapter(this, textItems, 0);
carouselPicker.setAdapter(textAdapter);

//Case 3 : To populate the picker with both images and text
List<CarouselPicker.PickerItem> mixItems = new ArrayList<>();
mixItems.add(new CarouselPicker.DrawableItem(R.drawable.i1));
mixItems.add(new CarouselPicker.TextItem("hi", 20));
mixItems.add(new CarouselPicker.DrawableItem(R.drawable.i2));
mixItems.add(new CarouselPicker.TextItem("hi", 20));
CarouselPicker.CarouselViewAdapter mixAdapter = new CarouselPicker.CarouselViewAdapter(this, mixItems, 0);
carouselPicker.setAdapter(mixAdapter);

Decorations :

  • Text color for text items can be set using adapter.setTextColor(colorInt)

Listeners :

carouselPicker.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                //position of the selected item
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });

LICENSE :

MIT License

Copyright (c) 2017 GoodieBag

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

carouselpicker's People

Contributors

iago-suarez avatar thirstycoda avatar vatican-cameos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

carouselpicker's Issues

method addOnPageChangeListener is not working well

i added this method so i can set value on other widget easily but then it doesnt work well the way i want to. It scrolled randomly and sometimes it gone away from the screen ( i dont know know how to describe it).

Even number items

Is there any way to create a carousel of any number of items? (2,4,6,7,8,9,10, etc.)

dpToPx converter in CarouselPicker.java class

Consider changing your dpToPx conversion to Math.round(dp * (displayMetrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT)). You are using displayMetrics.xdpi inplace of the device true densityDpi. This had big consequences for us across different devices such as Samsung S9+

OnClick() For each item in the carousel??!?!?

Is it possible to have an OnClick() (and therefore a function called) for each item in the carousel. I tried using the code on the GitHub homepage, but this calls the function when the image is in the center. I want the function to be called when I click on the image.

any ideas?!?!?

Similar to this I guess? not sure?
#14

Color

How to change picker items textColor?

Scale the size of CarouselPicker

Hello i have a problem with it. When i put the Carousel Picker beetween two buttons in LinearLayout (horizontal) Picker stops working and look unwell. One text is on another one overlaps. How can I change the size of the carousel picker from screen width to my size?

I need Custom view

I create custom adapter and tried to set image and textview at the same time but i can't ..
Can i custom view to this adapter i need view to contain image and text at the same time ?? what shall i do ?

Text overlapping

Hello
In text and mixed modes all list items overlap each other badly. My words are 5-8 characters long. I've tried different font sizes
Is there a way to remove or reduce overlap?

setItemClickListener

How to setItemClickListener?I set OnClickListener to the ItemView.The current selected one can receive events but the others can not receive events.

code like this

        public Object instantiateItem(@NonNull ViewGroup container, final int position) {
            View view = LayoutInflater.from(SwitchWheelActivity.this).inflate(
                    R.layout.item_text, container, false);
            view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    
                }
            });
            TextView textView = view.findViewById(R.id.tv_type);
            textView.setText(titles[position]);
            container.addView(view);
            return view;
        }

The CarouselPicker does not sync in app module.

When i will sync my project with CarouselPicker this message show for me

Failed to resolve: com.github.GoodieBag:CarouselPicker:v1.1
Show in File
Show in Project Structure dialog

Can you help me?

Thanks for now!

Is it possible to use this lib using external images?

Hello.
I'm using glide but I don't know how to use this lib with it! I've tried to get the image from an stream but the result is a bitmap and I don't know how to apply the results on the carousel, could you help me?

How to set an adapter of FirebaseRecyclerAdapter?

I'm trying to put the adapter of a FirebaseRecyclerAdapter to the Carousel to display the items, but I'm not able to do that because it says :

setAdapter
(android.support.v4.view.PagerAdapter)
in CarouselPicker cannot be applied
to
(com.firebase.ui.database.FirebaseRecyclerAdapter)
 

I've created a question on StackOverflow, feel free to answer if you know the solution to how to do it :
https://stackoverflow.com/questions/48010917/custom-adapter-for-firebaseadapter

Thanks.

Failed to resolve the library

I tried adding the library to my gradle and I face this issue.
Failed to resolve: com.github.Vatican-Cameos:CarouselPicker:v1.0

This is how I added it to my gradle

// carousel
implementation 'com.github.Vatican-Cameos:CarouselPicker:v1.0'

Did anyone else face the same issue?

Is this still active?

I am not using maven. In 2020, Android studio uses gradle, so could you update that? Also is there a kotlin documentation?

Set a custom font to the text in the textAdapter

Is it currently possible to set a custom font to the text shown in the elements of the CarouselPicker?
If it is not then, I hope there are plans to include that feature in future versions, that is the only thing it needs to perfect-fit the project I'm working with.
Thank you in advance.

Resource conflict - orientation - with GridLayout

If project has dependency on GridLayout the widget cannot be used.

Compile error:

gradle/caches/transforms-3/cbd44e2830edce0e72a93d68270588cf/transformed/gridlayout-1.0.0/res/values/values.xml:2:4: Duplicate value for resource 'attr/orientation' with config 'DEFAULT' and product ''. Resource was previously defined here: .gradle/caches/transforms-3/b75751e2fab6a33fd86b9118a3504783/transformed/jetified-CarouselPicker-v1.2/res/values/values.xml:10:4:

Proposed solution: Add prefix to attributes

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.