Class PlacesListPresenter<T extends PlacesListView>
- 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.locations.ui.places.list.PlacesListPresenter<T>
-
- Type Parameters:
T
- theMvpView
class
- All Implemented Interfaces:
MvpPresenter<T>
public class PlacesListPresenter<T extends PlacesListView> extends EndlessListPresenter<T>
TheMvpPresenter
class forPlacesListFragment
-
-
Constructor Summary
Constructors Constructor Description PlacesListPresenter()
Constructor of this presenter.PlacesListPresenter(PlacesParams placesParams)
Constructor of this presenter.PlacesListPresenter(PlacesParams placesParams, boolean useDefaultServer, java.lang.Integer customDistance, java.lang.String customUnit)
Constructor of this presenter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ListenerModel<BaseModel<Places>,Places>
getDistanceUnitReceivedListener()
Get the default distance unit from the server and gets the nearby places Create a listener forPlacesAPI
void
getNearbyPlaces(double radius, double latitude, double longitude)
Get the nearby places.protected void
getNearbyPlaces(int distance, java.lang.String unit)
Called after receiving distance data to compute the correct distance for nearby placesprotected ListenerModel<BaseModel<Places>,Places>
getNearbyPlacesReceivedListener()
Create a listener forPlacesAPI
protected PlacesAPI
getPlacesAPI()
Get current instance ofPlacesAPI
void
loadData()
Load initial view data.void
loadMore(int currentPage)
protected void
onDistanceDataReceivedFailure(java.lang.String error)
Called whengetNearbyPlaces(double, double, double)
failedprotected void
onDistanceDataReceivedSuccess(Places data)
Called whengetNearbyPlaces(double, double, double)
was successfulvoid
onLoadFailed(java.lang.String error)
Show the error viewvoid
onLoadMoreFailed(java.lang.String error)
End of load more with failed requestvoid
onLoadMoreSuccess(BaseData data)
End of load more with success requestvoid
onRefreshFailed(java.lang.String error)
End of refresh with failed attemptvoid
onRefreshSuccess(BaseData data)
End of refresh with success request.void
refreshData()
Start the refresh view data.void
search(double latitude, double longitude)
-
Methods inherited from class com.cheetahdigital.uikit.widget.list.EndlessListPresenter
isAppending
-
Methods inherited from class com.cheetahdigital.uikit.architecture.refreshable.RefreshablePresenter
isRefreshing
-
Methods inherited from class com.cheetahdigital.uikit.architecture.lce.LcePresenter
onLoadSuccess
-
Methods inherited from class com.cheetahdigital.uikit.architecture.mvp.MvpNullObjectBasePresenter
attachView, detachView, getView
-
-
-
-
Constructor Detail
-
PlacesListPresenter
public PlacesListPresenter()
Constructor of this presenter. Creates the defaultPlacesParams
for Places API calls.
-
PlacesListPresenter
public PlacesListPresenter(PlacesParams placesParams)
Constructor of this presenter. Creates the defaultPlacesParams
for Places API calls with default server value set to true.- Parameters:
placesParams
- contains the query params for place API
-
PlacesListPresenter
public PlacesListPresenter(PlacesParams placesParams, boolean useDefaultServer, java.lang.Integer customDistance, java.lang.String customUnit)
Constructor of this presenter. Creates the defaultPlacesParams
for Places API calls.- Parameters:
placesParams
- places parameter for api callsuseDefaultServer
- true if to use the default server search radius and unit provided in the Program Settings - Location - Search Radius and Program Settings - Location - Search Radius UnitcustomDistance
- distance to be search in IntegercustomUnit
- unit of the customDistance. It is limited to theCustomUnit
-
-
Method Detail
-
getNearbyPlacesReceivedListener
protected ListenerModel<BaseModel<Places>,Places> getNearbyPlacesReceivedListener()
Create a listener forPlacesAPI
- Returns:
- listener to handle
PlacesAPI
requests
-
getDistanceUnitReceivedListener
protected ListenerModel<BaseModel<Places>,Places> getDistanceUnitReceivedListener()
Get the default distance unit from the server and gets the nearby places Create a listener forPlacesAPI
- Returns:
- listener to handle
PlacesAPI
requests
-
getPlacesAPI
protected PlacesAPI getPlacesAPI()
Get current instance ofPlacesAPI
- Returns:
PlacesAPI
used on this presenter
-
loadData
public void loadData()
Description copied from class:LcePresenter
Load initial view data.- Specified by:
loadData
in classLcePresenter<T extends PlacesListView>
-
loadMore
public void loadMore(int currentPage)
- Overrides:
loadMore
in classEndlessListPresenter<T extends PlacesListView>
-
refreshData
public void refreshData()
Description copied from class:RefreshablePresenter
Start the refresh view data.- Overrides:
refreshData
in classRefreshablePresenter<T extends PlacesListView>
-
search
public void search(double latitude, double longitude)
-
getNearbyPlaces
public void getNearbyPlaces(double radius, double latitude, double longitude)
Get the nearby places. Radius is based on the configured style. Can be via- Parameters:
radius
- range of radiuslatitude
- point for latitudelongitude
- point for longitude
-
onRefreshFailed
public void onRefreshFailed(java.lang.String error)
Description copied from class:RefreshablePresenter
End of refresh with failed attempt- Overrides:
onRefreshFailed
in classRefreshablePresenter<T extends PlacesListView>
- Parameters:
error
- short description on reason of failure
-
onRefreshSuccess
public void onRefreshSuccess(BaseData data)
Description copied from class:RefreshablePresenter
End of refresh with success request.- Overrides:
onRefreshSuccess
in classRefreshablePresenter<T extends PlacesListView>
- Parameters:
data
- theBaseData
.
-
onLoadFailed
public void onLoadFailed(java.lang.String error)
Description copied from class:LcePresenter
Show the error view- Overrides:
onLoadFailed
in classLcePresenter<T extends PlacesListView>
- Parameters:
error
- message detailing the error
-
onLoadMoreFailed
public void onLoadMoreFailed(java.lang.String error)
Description copied from class:EndlessListPresenter
End of load more with failed request- Overrides:
onLoadMoreFailed
in classEndlessListPresenter<T extends PlacesListView>
- Parameters:
error
- message used for failed cases
-
onLoadMoreSuccess
public void onLoadMoreSuccess(BaseData data)
Description copied from class:EndlessListPresenter
End of load more with success request- Overrides:
onLoadMoreSuccess
in classEndlessListPresenter<T extends PlacesListView>
- Parameters:
data
- instance ofBaseData
passed
-
onDistanceDataReceivedSuccess
protected void onDistanceDataReceivedSuccess(Places data)
Called whengetNearbyPlaces(double, double, double)
was successful- Parameters:
data
-Places
-
getNearbyPlaces
@CallSuper protected void getNearbyPlaces(int distance, java.lang.String unit)
Called after receiving distance data to compute the correct distance for nearby places- Parameters:
distance
- distance to cover in search of nearby placesunit
- unit to use for the distance
-
onDistanceDataReceivedFailure
protected void onDistanceDataReceivedFailure(java.lang.String error)
Called whengetNearbyPlaces(double, double, double)
failed- Parameters:
error
- error message
-
-