Package com.example.qrgo.utilities
Class UserCarouselAdapter
- java.lang.Object
-
- androidx.viewpager.widget.PagerAdapter
-
- com.example.qrgo.utilities.UserCarouselAdapter
-
public class UserCarouselAdapter extends androidx.viewpager.widget.PagerAdapter
This class provides an adapter to display a carousel of user profiles.PlayerActivity
to go to the player profile of the user.BasicPlayerProfile
to display the user's profile information.
-
-
Constructor Summary
Constructors Constructor Description UserCarouselAdapter(android.content.Context context, java.util.List<BasicPlayerProfile> carouselItems)
Constructor for the UserCarouselAdapter.
-
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 adapter is about to destroy the item previously instantiated by the instantiateItem() method.int
getCount()
Returns the number of items in the carousel.java.lang.Object
instantiateItem(android.view.ViewGroup container, int position)
Creates the page view for the given position in the carousel.boolean
isViewFromObject(android.view.View view, java.lang.Object object)
Determines if a page 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
-
-
-
-
Constructor Detail
-
UserCarouselAdapter
public UserCarouselAdapter(android.content.Context context, java.util.List<BasicPlayerProfile> carouselItems)
Constructor for the UserCarouselAdapter.- Parameters:
context
- The context of the activity or fragment using the adapter.carouselItems
- A list of BasicPlayerProfile objects to display in the carousel.
-
-
Method Detail
-
getCount
public int getCount()
Returns the number of items in the carousel.- Specified by:
getCount
in classandroidx.viewpager.widget.PagerAdapter
- Returns:
- The number of items in the carousel.
-
isViewFromObject
public boolean isViewFromObject(android.view.View view, java.lang.Object object)
Determines if a page view is associated with a given object.- Specified by:
isViewFromObject
in classandroidx.viewpager.widget.PagerAdapter
- Parameters:
view
- The page view to check for association.object
- The object to check for association.- 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 the page view for the given position in the carousel.- Overrides:
instantiateItem
in classandroidx.viewpager.widget.PagerAdapter
- Parameters:
container
- The view container for the page view.position
- The position of the page view in the carousel.- Returns:
- The created page view.
-
destroyItem
public void destroyItem(android.view.ViewGroup container, int position, java.lang.Object object)
This method is called when the adapter is about to destroy the item previously instantiated by the instantiateItem() method. It is responsible for removing the view of the item from the container.- Overrides:
destroyItem
in classandroidx.viewpager.widget.PagerAdapter
- Parameters:
container
- the parent view of the itemposition
- the position of the item in the adapterobject
- the object representing the item
-
-