CarouselPicker icon indicating copy to clipboard operation
CarouselPicker copied to clipboard

How to set an adapter of FirebaseRecyclerAdapter?

Open joancolmenerodev opened this issue 7 years ago • 1 comments

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.

joancolmenerodev avatar Dec 28 '17 16:12 joancolmenerodev

Hi joan, For now the carousel picker expects a CarouselViewAdapter. CarouselPicker is basically a ViewPager, so you would have to make sure your adapter is a CarouselViewAdapter instead.

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);

Something like above. The pickerItems has two variations, DrawableItem and TextItem. Make sure you prepare the arraylist as shown above. But if you have custom views I don't think it is supported yet. But since we have been planning to do it from a long time, we will work on custom views in the next 3 days and make sure it's there. Are you working with custom views ? If you are, then we will take this as a priority to fix it up around the weekend. On the other hand if you just have text/ drawable items to show you are good to go with our existing pickerItem.

Also I will go through your stackoverflow question in detail and try to guide you in just a bit.

Best, Pavan.

Vatican-Cameos avatar Dec 29 '17 07:12 Vatican-Cameos