Class CarouselAdapter


  • public class CarouselAdapter
    extends androidx.viewpager.widget.PagerAdapter
    An adapter class for displaying a list of QR codes in a carousel format using a ViewPager.

    This adapter extends PagerAdapter to handle the swipe functionality.

    • Field Summary

      • Fields inherited from class androidx.viewpager.widget.PagerAdapter

        POSITION_NONE, POSITION_UNCHANGED
    • Constructor Summary

      Constructors 
      Constructor Description
      CarouselAdapter​(android.content.Context context, java.util.List<BasicQRCode> carouselItems)
      Constructs a new CarouselAdapter object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void destroyItem​(android.view.ViewGroup container, int position, java.lang.Object object)
      This method is called when the item instantiated by instantiateItem(ViewGroup, int) is no longer needed and should be removed from the container.
      int getCount()
      Returns the number of QR codes in the carousel.
      java.lang.Object instantiateItem​(android.view.ViewGroup container, int position)
      Creates a new view for a QR code in the carousel.
      boolean isViewFromObject​(android.view.View view, java.lang.Object object)
      Determines if a given view is associated with a given object.
      • Methods inherited from class androidx.viewpager.widget.PagerAdapter

        destroyItem, finishUpdate, finishUpdate, getItemPosition, getPageTitle, getPageWidth, instantiateItem, notifyDataSetChanged, registerDataSetObserver, restoreState, saveState, setPrimaryItem, setPrimaryItem, startUpdate, startUpdate, unregisterDataSetObserver
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CarouselAdapter

        public CarouselAdapter​(android.content.Context context,
                               java.util.List<BasicQRCode> carouselItems)
        Constructs a new CarouselAdapter object.
        Parameters:
        context - The context of the current state of the application.
        carouselItems - The list of BasicQRCode objects to be displayed in the carousel.
    • Method Detail

      • getCount

        public int getCount()
        Returns the number of QR codes in the carousel.
        Specified by:
        getCount in class androidx.viewpager.widget.PagerAdapter
        Returns:
        The number of QR codes in the carousel.
      • isViewFromObject

        public boolean isViewFromObject​(android.view.View view,
                                        java.lang.Object object)
        Determines if a given view is associated with a given object.
        Specified by:
        isViewFromObject in class androidx.viewpager.widget.PagerAdapter
        Parameters:
        view - The view to be compared with the object.
        object - The object to be compared with the view.
        Returns:
        True if the view is associated with the object, false otherwise.
      • instantiateItem

        public java.lang.Object instantiateItem​(android.view.ViewGroup container,
                                                int position)
        Creates a new view for a QR code in the carousel.
        Overrides:
        instantiateItem in class androidx.viewpager.widget.PagerAdapter
        Parameters:
        container - The parent view where the new view will be attached.
        position - The position of the QR code in the carousel.
        Returns:
        The new view for the QR code.
      • destroyItem

        public void destroyItem​(android.view.ViewGroup container,
                                int position,
                                java.lang.Object object)
        This method is called when the item instantiated by instantiateItem(ViewGroup, int) is no longer needed and should be removed from the container. In this case, it removes the view associated with the specified position.
        Overrides:
        destroyItem in class androidx.viewpager.widget.PagerAdapter
        Parameters:
        container - The containing ViewGroup from which the item will be removed.
        position - The position of the item within the adapter's data set that is being removed.
        object - The Object representing the view to be removed.