Class OffersListPresenter<T extends OffersListView>

  • Type Parameters:
    T - the MvpView class
    All Implemented Interfaces:
    com.cheetahdigital.uikit.architecture.mvp.MvpPresenter<T>

    public class OffersListPresenter<T extends OffersListView>
    extends com.cheetahdigital.uikit.widget.list.EndlessListPresenter<T>
    The MvpPresenter class for OffersListFragment and OffersClippedFragment
    • Constructor Detail

      • OffersListPresenter

        public OffersListPresenter()
        Create the presenter using an empty OfferParams
      • OffersListPresenter

        public OffersListPresenter​(OfferParams offerParams)
        Create the presenter with a give OfferParams
        Parameters:
        offerParams - the OfferParams
      • OffersListPresenter

        public OffersListPresenter​(java.util.List<Offer> offersList)
        Create the presenter using an existing Offer list. This will not call any API when loadData() is called.
        Parameters:
        offersList - the Offer list
    • Method Detail

      • loadData

        public void loadData()
        Description copied from class: com.cheetahdigital.uikit.architecture.lce.LcePresenter
        Load initial view data.
        Specified by:
        loadData in class com.cheetahdigital.uikit.architecture.lce.LcePresenter<T extends OffersListView>
      • loadMore

        public void loadMore​(int currentPage)
        Overrides:
        loadMore in class com.cheetahdigital.uikit.widget.list.EndlessListPresenter<T extends OffersListView>
      • refreshData

        public void refreshData()
        Description copied from class: com.cheetahdigital.uikit.architecture.refreshable.RefreshablePresenter
        Start the refresh view data.
        Overrides:
        refreshData in class com.cheetahdigital.uikit.architecture.refreshable.RefreshablePresenter<T extends OffersListView>
      • onOfferPostDeletedFailure

        protected void onOfferPostDeletedFailure​(java.lang.String error)
        Called when any of the following API calls fail: Favorite an offer Unfavorite an offer Clip an offer Unclip an offer
        Parameters:
        error - error message
      • onOfferPostDeletedSuccess

        protected void onOfferPostDeletedSuccess()
        Called when any of the following API calls are successful: Favorite an offer Unfavorite an offer Clip an offer Unclip an offer
      • onOfferCategoriesReceivedSuccess

        protected void onOfferCategoriesReceivedSuccess​(OfferCategories data)
        Called when getting offer categories is successful
        Parameters:
        data - OfferCategories
      • onOfferCategoriesReceivedFailure

        protected void onOfferCategoriesReceivedFailure​(java.lang.String error)
        Called when getting offer categories fails
        Parameters:
        error - error message
      • getFavoriteOffers

        protected void getFavoriteOffers​(int currentPage)
        Method for GET favorite offers API
        Parameters:
        currentPage - page offset
      • refreshFavoriteOffers

        protected void refreshFavoriteOffers()
        Method for GET favorite offers API and clears the responses cache
      • getOffers

        protected void getOffers​(int currentPage)
        Method for GET offers API
        Parameters:
        currentPage - current page of the offer
      • refreshOffers

        protected void refreshOffers()
        Method for GET offers API and clears the responses cache
      • sendClippedOffer

        public void sendClippedOffer​(int id)
        Set Offer as favorite
        Parameters:
        id - offer id to favorite
      • sendClippedOffer

        public void sendClippedOffer​(int id,
                                     OfferParams offerParams)
        Set Offer as favorite
        Parameters:
        id - offer id to favorite
        offerParams - custom OfferParams
      • sendUnclippedOffer

        public void sendUnclippedOffer​(int id)
        Set Offer as unfavorite
        Parameters:
        id - offer id to unfavorite
      • sendUnclippedOffer

        public void sendUnclippedOffer​(int id,
                                       OfferParams offerParams)
        Set Offer as unfavorite
        Parameters:
        id - offer id to unfavorite
        offerParams - custom OfferParams
      • sendOfferResponse

        public void sendOfferResponse​(int id)
        Respond to an Offer
        Parameters:
        id - offer id to be responded
      • sendOfferResponse

        public void sendOfferResponse​(int id,
                                      OfferParams offerParams)
        Respond to an Offer
        Parameters:
        id - offer id to be responded
        offerParams - custom OfferParams
      • getOfferCategories

        protected void getOfferCategories​(OfferParams offerParams,
                                          boolean clearCache)
        Get all Offer categories
        Parameters:
        offerParams - query params for Offers API
        clearCache - flag for clearing the stored cache
      • getCategory

        public java.lang.String getCategory()
        Returns:
        current category used from the list
      • setCategory

        public void setCategory​(java.lang.String category)
        Set the current category used
        Parameters:
        category - category to be used
      • clipOffer

        public void clipOffer​(int id)
        Clip offer
        Parameters:
        id - offer id to set as clipped
      • clipOffer

        public void clipOffer​(int id,
                              OfferParams offerParams)
        Clip offer
        Parameters:
        id - offer id to set as clipped
        offerParams - custom OfferParams
      • unclipOffer

        public void unclipOffer​(int id)
        Unclip offer
        Parameters:
        id - offer id to unclip
      • unclipOffer

        public void unclipOffer​(int id,
                                OfferParams offerParams)
        Unclip offer
        Parameters:
        id - offer id to unclip
        offerParams - custom OfferParams
      • onRefreshSuccess

        public void onRefreshSuccess​(com.cheetahdigital.corekit.models.data.BaseData data)
        Description copied from class: com.cheetahdigital.uikit.architecture.refreshable.RefreshablePresenter
        End of refresh with success request.
        Overrides:
        onRefreshSuccess in class com.cheetahdigital.uikit.architecture.refreshable.RefreshablePresenter<T extends OffersListView>
        Parameters:
        data - the BaseData.
      • onLoadMoreSuccess

        public void onLoadMoreSuccess​(com.cheetahdigital.corekit.models.data.BaseData data)
        Description copied from class: com.cheetahdigital.uikit.widget.list.EndlessListPresenter
        End of load more with success request
        Overrides:
        onLoadMoreSuccess in class com.cheetahdigital.uikit.widget.list.EndlessListPresenter<T extends OffersListView>
        Parameters:
        data - instance of BaseData passed
      • setShouldLoadFavoriteOffers

        public void setShouldLoadFavoriteOffers​(boolean shouldLoadFavoriteOffers)
        Set the flag for loading favorite offers
        Parameters:
        shouldLoadFavoriteOffers - true to load favorite offers