Class NewsfeedListPresenter<T extends NewsfeedListView>
- 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.newsfeed.ui.list.NewsfeedListPresenter<T>
-
- Type Parameters:
T
- theMvpView
class
- All Implemented Interfaces:
MvpPresenter<T>
public class NewsfeedListPresenter<T extends NewsfeedListView> extends EndlessListPresenter<T>
TheMvpPresenter
class forNewsfeedListFragment
-
-
Constructor Summary
Constructors Constructor Description NewsfeedListPresenter()
Default constructor This creates and instance ofNewsfeedParams
for getting the list of posts and getting the list of flagsNewsfeedListPresenter(NewsfeedParams listParams, NewsfeedParams flagParams)
Constructor the receives customNewsfeedParams
for list of posts and list of flags
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deletePost(int postId)
Delete a postvoid
deletePost(int postId, NewsfeedParams queryParams)
Delete a postvoid
flagPost(int postId, java.lang.String flag)
Flag a postvoid
flagPost(int postId, java.lang.String flag, NewsfeedParams postParams, NewsfeedFields flagParams)
Flag a postprotected ListenerModel<BaseModel<Post>,Post>
getDeletePostListener()
Create a listener forNewsfeedAPI.deletePost(NewsfeedParams, ListenerModel)
.protected Listener<SuccessResponse>
getFlagPostListener(int postId)
Create a listener forNewsfeedAPI.flagPost(NewsfeedParams, NewsfeedFields, Listener)
.protected ListenerModel<BaseModel<java.util.List<Flag>>,java.util.List<Flag>>
getFlagReceivedListener()
Create a listener forNewsfeedAPI.getFlags(NewsfeedParams, boolean, ListenerModel)
.protected Listener<SuccessResponse>
getLikePostListener(int postId)
Create a listener forNewsfeedAPI.likePost(NewsfeedParams, Listener)
.protected NewsfeedAPI
getNewsfeedAPI()
Get current instance ofNewsfeedAPI
protected ListenerModel<BaseModel<Newsfeed>,Newsfeed>
getNewsfeedReceivedListener()
Create a listener forNewsfeedAPI.getNewsfeed(NewsfeedParams, boolean, ListenerModel)
.protected ListenerModel<BaseModel<Post>,Post>
getPostReceivedListener()
Create a listener forNewsfeedAPI.getPost(NewsfeedParams, boolean, ListenerModel)
.protected Listener<SuccessResponse>
getUnlikePostListener(int postId)
Create a listener forNewsfeedAPI.unlikeComment(NewsfeedParams, Listener)
.void
like(int postId)
Like a postvoid
like(int postId, NewsfeedParams queryParams)
Like a postvoid
loadData()
Load initial view data.void
loadMore(int currentPage)
protected void
onDeletePostFailure(java.lang.String error)
Called when deleting a post failsprotected void
onDeletePostSuccess(Post post)
Called when deleting a post is successfulprotected void
onFlagPostFailure(java.lang.String error, int postId)
Called when flagging a post failsprotected void
onFlagPostSuccess(int postId)
Called when flagging a post is successfulprotected void
onLikePostFailure(java.lang.String error, int postId)
Called when liking a post failsprotected void
onLikePostSuccess(int postId)
Called when liking a post is successfulprotected void
onLoadFlagFailed(java.lang.String error)
Called when GET flags failsprotected void
onLoadFlagSuccess(java.util.List<Flag> data)
Called when GET flags is successfulvoid
onLoadMoreSuccess(BaseData data)
End of load more with success requestprotected void
onLoadNewsfeedSuccess(Newsfeed data)
Called when GET newsfeed is successful.protected void
onRefreshPostFailure(java.lang.String error)
Called when GET post API failsprotected void
onRefreshPostSuccess(Post post)
Called when GET post API is successfulvoid
onRefreshSuccess(BaseData data)
End of refresh with success request.protected void
onUnlikePostFailure(java.lang.String error, int postId)
Called when unliking a post failsprotected void
onUnlikePostSuccess(int postId)
Called when unliking a post is successfulvoid
refreshData()
Start the refresh view data.void
refreshPost(int postId)
Calls GET post API and clears the response cachevoid
refreshPost(int postId, NewsfeedParams queryParams)
Calls GET post API and clears the response cachevoid
unflagPost(int postId)
Unflag a postvoid
unflagPost(int postId, NewsfeedParams queryParams)
Unflag a postvoid
unLike(int postId)
Unlike a postvoid
unLike(int postId, NewsfeedParams queryParams)
Unlike a post-
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
-
Methods inherited from class com.cheetahdigital.uikit.architecture.mvp.MvpNullObjectBasePresenter
attachView, detachView, getView
-
-
-
-
Constructor Detail
-
NewsfeedListPresenter
public NewsfeedListPresenter()
Default constructor This creates and instance ofNewsfeedParams
for getting the list of posts and getting the list of flags
-
NewsfeedListPresenter
public NewsfeedListPresenter(NewsfeedParams listParams, NewsfeedParams flagParams)
Constructor the receives customNewsfeedParams
for list of posts and list of flags- Parameters:
listParams
-NewsfeedParams
to retrieveNewsfeed
flagParams
-NewsfeedParams
for retrieve the list ofFlag
-
-
Method Detail
-
getFlagReceivedListener
protected ListenerModel<BaseModel<java.util.List<Flag>>,java.util.List<Flag>> getFlagReceivedListener()
Create a listener forNewsfeedAPI.getFlags(NewsfeedParams, boolean, ListenerModel)
.- Returns:
- listener to handle requests
-
getNewsfeedReceivedListener
protected ListenerModel<BaseModel<Newsfeed>,Newsfeed> getNewsfeedReceivedListener()
Create a listener forNewsfeedAPI.getNewsfeed(NewsfeedParams, boolean, ListenerModel)
.- Returns:
- listener to handle requests
-
getPostReceivedListener
protected ListenerModel<BaseModel<Post>,Post> getPostReceivedListener()
Create a listener forNewsfeedAPI.getPost(NewsfeedParams, boolean, ListenerModel)
.- Returns:
- listener to handle requests
-
getDeletePostListener
protected ListenerModel<BaseModel<Post>,Post> getDeletePostListener()
Create a listener forNewsfeedAPI.deletePost(NewsfeedParams, ListenerModel)
.- Returns:
- listener to handle requests
-
getLikePostListener
protected Listener<SuccessResponse> getLikePostListener(int postId)
Create a listener forNewsfeedAPI.likePost(NewsfeedParams, Listener)
.- Parameters:
postId
- id of the post- Returns:
- listener to handle requests
-
getUnlikePostListener
protected Listener<SuccessResponse> getUnlikePostListener(int postId)
Create a listener forNewsfeedAPI.unlikeComment(NewsfeedParams, Listener)
.- Parameters:
postId
- id of the post- Returns:
- listener to handle requests
-
getFlagPostListener
protected Listener<SuccessResponse> getFlagPostListener(int postId)
Create a listener forNewsfeedAPI.flagPost(NewsfeedParams, NewsfeedFields, Listener)
.- Parameters:
postId
- id of the post- Returns:
- listener to handle requests
-
getNewsfeedAPI
protected NewsfeedAPI getNewsfeedAPI()
Get current instance ofNewsfeedAPI
- Returns:
NewsfeedAPI
used on this presenter
-
loadData
public void loadData()
Description copied from class:LcePresenter
Load initial view data.- Specified by:
loadData
in classLcePresenter<T extends NewsfeedListView>
-
loadMore
public void loadMore(int currentPage)
- Overrides:
loadMore
in classEndlessListPresenter<T extends NewsfeedListView>
-
refreshData
public void refreshData()
Description copied from class:RefreshablePresenter
Start the refresh view data.- Overrides:
refreshData
in classRefreshablePresenter<T extends NewsfeedListView>
-
deletePost
public void deletePost(int postId)
Delete a post- Parameters:
postId
- id of post
-
deletePost
public void deletePost(int postId, NewsfeedParams queryParams)
Delete a post- Parameters:
postId
- id of postqueryParams
- customNewsfeedParams
-
like
public void like(int postId)
Like a post- Parameters:
postId
- id of post
-
like
public void like(int postId, NewsfeedParams queryParams)
Like a post- Parameters:
postId
- id of postqueryParams
- customNewsfeedParams
-
unLike
public void unLike(int postId)
Unlike a post- Parameters:
postId
- id of post
-
unLike
public void unLike(int postId, NewsfeedParams queryParams)
Unlike a post- Parameters:
postId
- id of postqueryParams
- customNewsfeedParams
-
flagPost
public void flagPost(int postId, java.lang.String flag)
Flag a post- Parameters:
postId
- id of the post to flagflag
- selected flag
-
flagPost
public void flagPost(int postId, java.lang.String flag, NewsfeedParams postParams, NewsfeedFields flagParams)
Flag a post- Parameters:
postId
- id of the post to flagflag
- selected flagpostParams
- customNewsfeedParams
flagParams
- customNewsfeedFields
-
unflagPost
public void unflagPost(int postId)
Unflag a post- Parameters:
postId
- id of the post to unflag
-
unflagPost
public void unflagPost(int postId, NewsfeedParams queryParams)
Unflag a post- Parameters:
postId
- id of the post to unflagqueryParams
- customNewsfeedParams
-
onRefreshSuccess
public void onRefreshSuccess(BaseData data)
Description copied from class:RefreshablePresenter
End of refresh with success request.- Overrides:
onRefreshSuccess
in classRefreshablePresenter<T extends NewsfeedListView>
- Parameters:
data
- theBaseData
.
-
onLoadMoreSuccess
public void onLoadMoreSuccess(BaseData data)
Description copied from class:EndlessListPresenter
End of load more with success request- Overrides:
onLoadMoreSuccess
in classEndlessListPresenter<T extends NewsfeedListView>
- Parameters:
data
- instance ofBaseData
passed
-
onLoadNewsfeedSuccess
protected void onLoadNewsfeedSuccess(Newsfeed data)
Called when GET newsfeed is successful. Handles both refreshing and initial load.- Parameters:
data
-Newsfeed
-
onLoadFlagSuccess
protected void onLoadFlagSuccess(java.util.List<Flag> data)
Called when GET flags is successful- Parameters:
data
- List ofFlag
-
onLoadFlagFailed
protected void onLoadFlagFailed(java.lang.String error)
Called when GET flags fails- Parameters:
error
- error message
-
onDeletePostSuccess
protected void onDeletePostSuccess(Post post)
Called when deleting a post is successful- Parameters:
post
- deletedPost
-
onDeletePostFailure
protected void onDeletePostFailure(java.lang.String error)
Called when deleting a post fails- Parameters:
error
- error message
-
onLikePostSuccess
protected void onLikePostSuccess(int postId)
Called when liking a post is successful- Parameters:
postId
- id of liked post
-
onLikePostFailure
protected void onLikePostFailure(java.lang.String error, int postId)
Called when liking a post fails- Parameters:
error
- error messagepostId
- id of post the user attempted to like
-
onUnlikePostSuccess
protected void onUnlikePostSuccess(int postId)
Called when unliking a post is successful- Parameters:
postId
- id of unliked post
-
onUnlikePostFailure
protected void onUnlikePostFailure(java.lang.String error, int postId)
Called when unliking a post fails- Parameters:
error
- error messagepostId
- id of post the user attempted to unlike
-
onFlagPostSuccess
protected void onFlagPostSuccess(int postId)
Called when flagging a post is successful- Parameters:
postId
- id of the flagged post
-
onFlagPostFailure
protected void onFlagPostFailure(java.lang.String error, int postId)
Called when flagging a post fails- Parameters:
error
- error messagepostId
- id of the post the user attempted to flag
-
refreshPost
public void refreshPost(int postId)
Calls GET post API and clears the response cache- Parameters:
postId
- id of the post to refresh
-
refreshPost
public void refreshPost(int postId, NewsfeedParams queryParams)
Calls GET post API and clears the response cache- Parameters:
postId
- id of the post to refreshqueryParams
- customNewsfeedParams
-
onRefreshPostSuccess
protected void onRefreshPostSuccess(Post post)
Called when GET post API is successful- Parameters:
post
- UpdatePost
-
onRefreshPostFailure
protected void onRefreshPostFailure(java.lang.String error)
Called when GET post API fails- Parameters:
error
- error message
-
-