Package 

Class CarouselModel_

    • Method Detail

      • addTo

         void addTo(EpoxyController controller)

        Add this model to the given controller. Can only be called from inside .

      • buildView

         Carousel buildView(ViewGroup parent)

        Create and return a new instance of a view for this model. By default a view is created byinflating the layout resource.

      • handlePreBind

         void handlePreBind(EpoxyViewHolder holder, Carousel object, int position)

        Called on the generated model immediately before the main model onBind method has been called.This let's the generated model handle binding setup of its own

        The ViewHolder is needed to get the model's adapter position when clicked.

      • bind

         void bind(Carousel object)

        Binds the current data to the given view. You should bind all fields including unset/emptyfields to ensure proper recycling.

      • bind

         void bind(Carousel object, EpoxyModel previousModel)

        Similar to bind, but provides a non null model which was previously bound tothis view. This will only be called if the model is used with an EpoxyController.

      • handlePostBind

         void handlePostBind(Carousel object, int position)

        Called on the generated model immediately after the main model onBind method has been called.This let's the generated model handle binding of its own and dispatch calls to its onBindlistener.

        We don't want to rely on the main onBind method to dispatch the onBind listener call becausethere are two onBind methods (one for payloads and one for no payloads), and one can call intothe other. We don't want to dispatch two onBind listener calls in that case.

      • unbind

         void unbind(Carousel object)

        Called when the view bound to this model is recycled. Subclasses can override this if theirview should release resources when it's recycled.

        Note that bind can be called multiple times without an unbind call in betweenif the view has remained on screen to be reused across item changes. This means that you shouldnot rely on unbind to clear a view or model's state before bind is called again.

      • onVisibilityChanged

         void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, Carousel object)

        TODO link to the wiki

      • numViewsToShowOnScreen

         CarouselModel_ numViewsToShowOnScreen(float numViewsToShowOnScreen)

        Set the number of views to show on screen in this carousel at a time, partial numbers areallowed.

        This is useful where you want to easily control for the number of items on screen,regardless of screen size. For example, you could set this to 1.2f so that one view is shown infull and 20% of the next view "peeks" from the edge to indicate that there is more content toscroll to.

        Another pattern is setting a different view count depending on whether the device is phoneor tablet.

        Additionally, if a LinearLayoutManager is used this value will be forwarded to as a performance optimization.

        If you want to only change the prefetch count without changing the view size you can simplyuse setInitialPrefetchItemCount

        Optional: Default value is 0.0f

      • initialPrefetchItemCount

         CarouselModel_ initialPrefetchItemCount(int initialPrefetchItemCount)

        If you are using a Linear or Grid layout manager you can use this to set the item prefetchcount. Only use this if you are not using setNumViewsToShowOnScreen

      • paddingRes

         CarouselModel_ paddingRes(@DimenRes() int paddingRes)

        Set a dimension resource to specify the padding value to use on each side of the carousel andin between carousel items.

        Optional: Default value is 0

      • paddingDp

         CarouselModel_ paddingDp(@Dimension(unit = 0) int paddingDp)

        Set a DP value to use as the padding on each side of the carousel and in between carouselitems.

        The default as the value returned by getDefaultSpacingBetweenItemsDp

        Optional: Default value is {@value Carousel#NO_VALUE_SET}

      • padding

         CarouselModel_ padding(@Nullable() Carousel.Padding padding)

        Use the Padding class to specify individual padding values for each side of thecarousel, as well as item spacing.

        A value of null will set all padding and item spacing to 0.

        Optional: Default value is (Carousel.Padding) null

      • id

         CarouselModel_ id(long id)

        Override the default id in cases where the data subject naturally has an id, like an objectfrom a database. This id can only be set before the model is added to the adapter, it is anerror to change the id after that.

      • id

         CarouselModel_ id(@Nullable() Array<Number> ids)

        Use multiple numbers as the id for this model. Useful when you don't have a single long thatrepresents a unique id.

        This hashes the numbers, so there is a tiny risk of collision with other ids.

      • id

         CarouselModel_ id(long id1, long id2)

        Use two numbers as the id for this model. Useful when you don't have a single long thatrepresents a unique id.

        This hashes the two numbers, so there is a tiny risk of collision with other ids.

      • id

         CarouselModel_ id(@Nullable() CharSequence key)

        Use a string as the model id. Useful for models that don't clearly map to a numerical id. Thisis preferable to using hashCode because that is a 32 bit hash and this is a 64bit hash, giving better spread and less chance of collision with other ids.

        Since this uses a hashcode method to convert the String to a long there is a very small chancethat you may have a collision with another id. Assuming an even spread of hashcodes, andseveral hundred models in the adapter, there would be roughly 1 in 100 trillion chance of acollision. (http://preshing.com/20110504/hash-collision-probabilities/)

      • id

         CarouselModel_ id(@Nullable() CharSequence key, long id)

        Set an id that is namespaced with a string. This is useful when you need to show models ofmultiple types, side by side and don't want to risk id collisions.

        Since this uses a hashcode method to convert the String to a long there is a very small chancethat you may have a collision with another id. Assuming an even spread of hashcodes, andseveral hundred models in the adapter, there would be roughly 1 in 100 trillion chance of acollision. (http://preshing.com/20110504/hash-collision-probabilities/)

      • shouldSaveViewState

         boolean shouldSaveViewState()

        Whether the adapter should save the state of the view bound to this model.

      • getSpanSize

         int getSpanSize(int totalSpanCount, int position, int itemCount)

        Subclasses can override this if they want their view to take up more than one span in a gridlayout.

        Parameters:
        totalSpanCount - The number of spans in the grid
        position - The position of the model
        itemCount - The total number of items in the adapter