Class OffersListPresenter<T extends OffersListView>
- java.lang.Object
-
- com.cheetahdigital.uikit.architecture.mvp.MvpNullObjectBasePresenter<V>
-
- com.cheetahdigital.uikit.architecture.mvp.Presenter<V>
-
- com.cheetahdigital.uikit.architecture.lce.LcePresenter<V>
-
- com.cheetahdigital.uikit.architecture.refreshable.RefreshablePresenter<V>
-
- com.cheetahdigital.uikit.widget.list.ListPresenter<V>
-
- com.cheetahdigital.uikit.widget.list.EndlessListPresenter<T>
-
- com.cheetahdigital.offers.ui.list.OffersListPresenter<T>
-
- Type Parameters:
T
- theMvpView
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>
-
-
Constructor Summary
Constructors Constructor Description OffersListPresenter()
Create the presenter using an emptyOfferParams
OffersListPresenter(OfferParams offerParams)
Create the presenter with a giveOfferParams
OffersListPresenter(java.util.List<Offer> offersList)
Create the presenter using an existingOffer
list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clipOffer(int id)
Clip offervoid
clipOffer(int id, OfferParams offerParams)
Clip offerjava.lang.String
getCategory()
protected void
getFavoriteOffers(int currentPage)
Method for GET favorite offers APIprotected void
getOfferCategories(OfferParams offerParams, boolean clearCache)
Get all Offer categoriesprotected com.cheetahdigital.corekit.models.module.ListenerModel<com.cheetahdigital.corekit.models.BaseModel<OfferCategories>,OfferCategories>
getOfferCategoriesReceivedListener()
Create a listener forOffersAPI.getOfferCategories(OfferParams, boolean, ListenerModel)
protected com.cheetahdigital.corekit.models.module.Listener<com.cheetahdigital.corekit.models.responses.SuccessResponse>
getOfferPostDeleteListener()
Create a listener for the following:OffersAPI.setOfferAsFavorited(OfferParams, Listener)
OffersAPI.setOfferAsUnfavorited(OfferParams, Listener)
(OfferParams, Listener)}OffersAPI.clipOffer(OfferParams, Listener)
(OfferParams, Listener)}OffersAPI.unclipOffer(OfferParams, Listener)
(OfferParams, Listener)}protected void
getOffers(int currentPage)
Method for GET offers APIprotected OffersAPI
getOffersAPI()
Get current instance ofOffersAPI
protected java.util.List<Offer>
getOffersList()
protected com.cheetahdigital.corekit.models.module.ListenerModel<com.cheetahdigital.corekit.models.BaseModel<Offers>,Offers>
getOffersReceivedListener()
protected com.cheetahdigital.corekit.models.module.ListenerModel<com.cheetahdigital.corekit.models.BaseModel<OfferResponse>,OfferResponse>
getRespondToOfferListener()
Create a listener forOffersAPI.respondToOffer(OfferParams, ListenerModel)
void
loadData()
Load initial view data.void
loadMore(int currentPage)
void
onLoadMoreSuccess(com.cheetahdigital.corekit.models.data.BaseData data)
End of load more with success requestprotected void
onOfferCategoriesReceivedFailure(java.lang.String error)
Called when getting offer categories failsprotected void
onOfferCategoriesReceivedSuccess(OfferCategories data)
Called when getting offer categories is successfulprotected 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 offerprotected void
onOfferPostDeletedSuccess()
Called when any of the following API calls are successful: Favorite an offer Unfavorite an offer Clip an offer Unclip an offervoid
onRefreshSuccess(com.cheetahdigital.corekit.models.data.BaseData data)
End of refresh with success request.void
refreshData()
Start the refresh view data.protected void
refreshFavoriteOffers()
Method for GET favorite offers API and clears the responses cacheprotected void
refreshOffers()
Method for GET offers API and clears the responses cachevoid
sendClippedOffer(int id)
Set Offer as favoritevoid
sendClippedOffer(int id, OfferParams offerParams)
Set Offer as favoritevoid
sendOfferResponse(int id)
Respond to an Offervoid
sendOfferResponse(int id, OfferParams offerParams)
Respond to an Offervoid
sendUnclippedOffer(int id)
Set Offer as unfavoritevoid
sendUnclippedOffer(int id, OfferParams offerParams)
Set Offer as unfavoritevoid
setCategory(java.lang.String category)
Set the current category usedvoid
setShouldLoadFavoriteOffers(boolean shouldLoadFavoriteOffers)
Set the flag for loading favorite offersprotected boolean
shouldLoadFavoriteOffers()
void
unclipOffer(int id)
Unclip offervoid
unclipOffer(int id, OfferParams offerParams)
Unclip offer-
Methods inherited from class com.cheetahdigital.uikit.widget.list.EndlessListPresenter
isAppending, onLoadMoreFailed
-
Methods inherited from class com.cheetahdigital.uikit.architecture.refreshable.RefreshablePresenter
isRefreshing, onRefreshFailed
-
Methods inherited from class com.cheetahdigital.uikit.architecture.lce.LcePresenter
onLoadFailed, onLoadSuccess
-
-
-
-
Constructor Detail
-
OffersListPresenter
public OffersListPresenter()
Create the presenter using an emptyOfferParams
-
OffersListPresenter
public OffersListPresenter(OfferParams offerParams)
Create the presenter with a giveOfferParams
- Parameters:
offerParams
- theOfferParams
-
OffersListPresenter
public OffersListPresenter(java.util.List<Offer> offersList)
Create the presenter using an existingOffer
list. This will not call any API whenloadData()
is called.- Parameters:
offersList
- theOffer
list
-
-
Method Detail
-
getOfferPostDeleteListener
protected com.cheetahdigital.corekit.models.module.Listener<com.cheetahdigital.corekit.models.responses.SuccessResponse> getOfferPostDeleteListener()
Create a listener for the following:OffersAPI.setOfferAsFavorited(OfferParams, Listener)
OffersAPI.setOfferAsUnfavorited(OfferParams, Listener)
(OfferParams, Listener)}OffersAPI.clipOffer(OfferParams, Listener)
(OfferParams, Listener)}OffersAPI.unclipOffer(OfferParams, Listener)
(OfferParams, Listener)}- Returns:
- listener to handle requests
-
getOfferCategoriesReceivedListener
protected com.cheetahdigital.corekit.models.module.ListenerModel<com.cheetahdigital.corekit.models.BaseModel<OfferCategories>,OfferCategories> getOfferCategoriesReceivedListener()
Create a listener forOffersAPI.getOfferCategories(OfferParams, boolean, ListenerModel)
- Returns:
- listener to handle requests
-
getOffersReceivedListener
protected com.cheetahdigital.corekit.models.module.ListenerModel<com.cheetahdigital.corekit.models.BaseModel<Offers>,Offers> getOffersReceivedListener()
Create a listener forOffersAPI.getOffers(OfferParams, boolean, ListenerModel)
andOffersAPI.getFavoriteOffers(OfferParams, boolean, ListenerModel)
- Returns:
- listener to handle requests
-
getRespondToOfferListener
protected com.cheetahdigital.corekit.models.module.ListenerModel<com.cheetahdigital.corekit.models.BaseModel<OfferResponse>,OfferResponse> getRespondToOfferListener()
Create a listener forOffersAPI.respondToOffer(OfferParams, ListenerModel)
- Returns:
- listener to handle requests
-
getOffersAPI
protected OffersAPI getOffersAPI()
Get current instance ofOffersAPI
- Returns:
OffersAPI
used on this presenter
-
loadData
public void loadData()
Description copied from class:com.cheetahdigital.uikit.architecture.lce.LcePresenter
Load initial view data.- Specified by:
loadData
in classcom.cheetahdigital.uikit.architecture.lce.LcePresenter<T extends OffersListView>
-
loadMore
public void loadMore(int currentPage)
- Overrides:
loadMore
in classcom.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 classcom.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 favoriteofferParams
- customOfferParams
-
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 unfavoriteofferParams
- customOfferParams
-
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 respondedofferParams
- customOfferParams
-
getOfferCategories
protected void getOfferCategories(OfferParams offerParams, boolean clearCache)
Get all Offer categories- Parameters:
offerParams
- query params for Offers APIclearCache
- 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 clippedofferParams
- customOfferParams
-
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 unclipofferParams
- customOfferParams
-
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 classcom.cheetahdigital.uikit.architecture.refreshable.RefreshablePresenter<T extends OffersListView>
- Parameters:
data
- theBaseData
.
-
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 classcom.cheetahdigital.uikit.widget.list.EndlessListPresenter<T extends OffersListView>
- Parameters:
data
- instance ofBaseData
passed
-
shouldLoadFavoriteOffers
protected boolean shouldLoadFavoriteOffers()
- Returns:
- the boolean passed in
setShouldLoadFavoriteOffers(boolean)
-
setShouldLoadFavoriteOffers
public void setShouldLoadFavoriteOffers(boolean shouldLoadFavoriteOffers)
Set the flag for loading favorite offers- Parameters:
shouldLoadFavoriteOffers
-true
to load favorite offers
-
getOffersList
protected java.util.List<Offer> getOffersList()
- Returns:
- the list of
Offer
passed inOffersListPresenter(List)
-
-