Class NewsfeedListFragment<A extends NewsfeedListAdapter,V extends NewsfeedListView,P extends NewsfeedListPresenter<V>>
- java.lang.Object
-
- androidx.fragment.app.Fragment
-
- com.cheetahdigital.uikit.architecture.mvp.MvpFragmentView<V,P>
-
- com.cheetahdigital.uikit.architecture.lce.LceFragmentView<V,P>
-
- com.cheetahdigital.uikit.architecture.refreshable.RefreshableFragmentView<V,P>
-
- com.cheetahdigital.uikit.widget.list.ListFragmentView<V,P>
-
- com.cheetahdigital.uikit.widget.list.EndlessListFragmentView<A,V,P>
-
- com.cheetahdigital.newsfeed.ui.list.NewsfeedListFragment<A,V,P>
-
- All Implemented Interfaces:
android.content.ComponentCallbacks
,android.view.View.OnCreateContextMenuListener
,androidx.lifecycle.LifecycleOwner
,androidx.lifecycle.ViewModelStoreOwner
,androidx.savedstate.SavedStateRegistryOwner
,androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener
,AnalyticsManager.AnalyticsScreen
,NewsfeedListView
,PostClickListener
,LceView
,MvpLceView
,MvpView
,RefreshableView
,FacebookHelper.FacebookShareCallBack
,EndlessListView
,ListView
public class NewsfeedListFragment<A extends NewsfeedListAdapter,V extends NewsfeedListView,P extends NewsfeedListPresenter<V>> extends EndlessListFragmentView<A,V,P> implements NewsfeedListView, FacebookHelper.FacebookShareCallBack, PostClickListener
The fragment class for showing a list ofPost
Can receive the following extras:IntentKey.PRIMARY_PARAMS
- use this key to pass any changes in query parameters of list ofPost
IntentKey.SECONDARY_PARAMS
- use this key to pass any changes in query parameters of flagsIntentKey.PRIMARY_ID
- name of the category of the newsfeedPUBLIC_PROFILE_CLICKABLE
- boolean key to allow clicking of member avatar/name in a post to show their profile
onActivityResult(int, int, Intent)
NewsfeedDetailsActivity.KEY_POST_ID
- id of the post to refresh
DETAILS_ACTIVITY_REQUEST
- Request code when usingListFragmentView.startActivityForResult(Intent, int)
forNewsfeedDetailsActivity
.POST_CODE
- Request code when usingListFragmentView.startActivityForResult(Intent, int)
forNewsfeedPostActivity
.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DETAILS_ACTIVITY_REQUEST
static int
POST_CODE
static java.lang.String
PUBLIC_PROFILE_CLICKABLE
-
Fields inherited from class com.cheetahdigital.uikit.widget.list.EndlessListFragmentView
mEndlessRecyclerOnScrollListener
-
Fields inherited from class com.cheetahdigital.uikit.widget.list.ListFragmentView
mLinearLayoutManager, mListView, mSelectedPosition
-
Fields inherited from class com.cheetahdigital.uikit.architecture.refreshable.RefreshableFragmentView
mSwipeRefreshLayout
-
Fields inherited from class com.cheetahdigital.uikit.architecture.lce.LceFragmentView
mContentView, mErrorView, mInitialLoad, mLoadingView
-
-
Constructor Summary
Constructors Constructor Description NewsfeedListFragment()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendNews(Post pinnedPost, java.util.List<Post> newsfeed, int totalEntries, boolean isUserAllowedToPost, boolean isUserAllowedToComment)
Notifies the view to append list ofPost
to the existing post list.protected NewsfeedListAdapter
createAdapter()
Create the adapter used in current RecycleView present.protected androidx.recyclerview.widget.RecyclerView.ItemDecoration
createItemDecoration()
Create the item decoration used in the RecyclerView.protected P
createPresenter()
InstantiateMvpFragmentView.mPresenter
to be used for thisMvpActivityView
void
deletePost(Post post)
Notifies the view to delete the post from the list.protected int
getContentLayoutId()
Provide the Content Layout ID which is of a Layout Resource Reference of Androidint
getScreenName()
void
onActivityResult(int requestCode, int resultCode, android.content.Intent data)
void
onCommentClick(Post post)
Method to handle clicking of comment viewvoid
onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater)
android.view.View
onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)
void
onDeletePost(int postId)
Method to handle deleting of postvoid
onFacebookShareCancelled()
void
onFacebookShareError(com.facebook.FacebookException e)
void
onFacebookShareSuccess(com.facebook.share.Sharer.Result result)
void
onFlagNews(int postId, java.lang.String flag)
Method to handle clicking of flag viewvoid
onLikePost(boolean isAttempToLike, int postId)
Method to handle liking of Postvoid
onLinkPreviewClick(Post post)
Method to handle clicking of link previewvoid
onNewsLaunchProfile(Owner owner)
Method to handle launching of Owner's profileboolean
onOptionsItemSelected(android.view.MenuItem item)
void
onPostClick(Post post)
Method to handle clicking of postvoid
onPrepareOptionsMenu(android.view.Menu menu)
void
onShareUrl(android.net.Uri uri)
Method to handle sharing of urlvoid
onViewUrl(android.net.Uri uri)
Method to handle viewing of urlvoid
revertChanges(int postId)
Notifies the view to revert any changes made to the post.void
showErrorDialog(java.lang.String error)
Notifies the view to show a dialog with the provided error messagevoid
showNewsfeedList(Post pinnedPost, java.util.List<Post> newsfeed, java.util.List<Flag> flags, int totalEntries, boolean isUserAllowedToPost, boolean isUserAllowedToComment)
Notifies the view to show the list ofPost
.void
updatePost(Post post)
Notifies the view to update the Post.-
Methods inherited from class com.cheetahdigital.uikit.widget.list.EndlessListFragmentView
onFinishLoadMore, onFinishRefresh, onLoadMoreFailed, setListTotalEntries
-
Methods inherited from class com.cheetahdigital.uikit.widget.list.ListFragmentView
getLayoutManager, isListAnimationEnabled, onAttach, setExitTransition, showContent, startActivity, startActivityForResult
-
Methods inherited from class com.cheetahdigital.uikit.architecture.refreshable.RefreshableFragmentView
onRefresh, onRefreshFailed, reloadData, showError, showLoading, startRefresh
-
Methods inherited from class com.cheetahdigital.uikit.architecture.lce.LceFragmentView
onLoadFailed, onLoadSuccess, onViewCreated, setErrorViewClickListener
-
Methods inherited from class com.cheetahdigital.uikit.architecture.mvp.MvpFragmentView
captureSharedElementValues, getPresenter, getSharedElementViews, initSharedElementValues, isSharedAnimationEnabled, onDestroyView
-
Methods inherited from class androidx.fragment.app.Fragment
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLayoutInflater, getLifecycle, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSavedStateRegistry, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, getViewLifecycleOwner, getViewLifecycleOwnerLiveData, getViewModelStore, hashCode, hasOptionsMenu, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isMenuVisible, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreate, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onDestroy, onDestroyOptionsMenu, onDetach, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onResume, onSaveInstanceState, onStart, onStop, onViewStateRestored, postponeEnterTransition, postponeEnterTransition, registerForContextMenu, requestPermissions, requireActivity, requireArguments, requireContext, requireFragmentManager, requireHost, requireParentFragment, requireView, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenu
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.cheetahdigital.uikit.widget.list.EndlessListView
onFinishLoadMore, onLoadMoreFailed
-
Methods inherited from interface com.cheetahdigital.uikit.architecture.lce.LceView
onLoadFailed, onLoadSuccess, setErrorViewClickListener
-
Methods inherited from interface com.cheetahdigital.uikit.architecture.lce.MvpLceView
showContent, showError, showLoading
-
Methods inherited from interface com.cheetahdigital.uikit.architecture.refreshable.RefreshableView
onFinishRefresh, onRefreshFailed
-
-
-
-
Field Detail
-
DETAILS_ACTIVITY_REQUEST
public static final int DETAILS_ACTIVITY_REQUEST
- See Also:
- Constant Field Values
-
POST_CODE
public static final int POST_CODE
- See Also:
- Constant Field Values
-
PUBLIC_PROFILE_CLICKABLE
public static final java.lang.String PUBLIC_PROFILE_CLICKABLE
- See Also:
- Constant Field Values
-
-
Method Detail
-
onCreateView
@Nullable public android.view.View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)
- Overrides:
onCreateView
in classEndlessListFragmentView<A extends NewsfeedListAdapter,V extends NewsfeedListView,P extends NewsfeedListPresenter<V>>
-
onActivityResult
public void onActivityResult(int requestCode, int resultCode, android.content.Intent data)
- Overrides:
onActivityResult
in classandroidx.fragment.app.Fragment
-
onCreateOptionsMenu
public void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater)
- Overrides:
onCreateOptionsMenu
in classandroidx.fragment.app.Fragment
-
onPrepareOptionsMenu
public void onPrepareOptionsMenu(@NonNull android.view.Menu menu)
- Overrides:
onPrepareOptionsMenu
in classandroidx.fragment.app.Fragment
-
onOptionsItemSelected
public boolean onOptionsItemSelected(android.view.MenuItem item)
- Overrides:
onOptionsItemSelected
in classandroidx.fragment.app.Fragment
-
getScreenName
public int getScreenName()
- Specified by:
getScreenName
in interfaceAnalyticsManager.AnalyticsScreen
- Overrides:
getScreenName
in classMvpFragmentView<V extends NewsfeedListView,P extends NewsfeedListPresenter<V>>
-
getContentLayoutId
protected int getContentLayoutId()
Description copied from class:MvpFragmentView
Provide the Content Layout ID which is of a Layout Resource Reference of Android- Specified by:
getContentLayoutId
in classMvpFragmentView<V extends NewsfeedListView,P extends NewsfeedListPresenter<V>>
- Returns:
- id of the content layout
-
createPresenter
protected P createPresenter()
Description copied from class:MvpFragmentView
InstantiateMvpFragmentView.mPresenter
to be used for thisMvpActivityView
- Specified by:
createPresenter
in classMvpFragmentView<V extends NewsfeedListView,P extends NewsfeedListPresenter<V>>
- Returns:
- return the
MvpBasePresenter
-
showNewsfeedList
public void showNewsfeedList(Post pinnedPost, java.util.List<Post> newsfeed, java.util.List<Flag> flags, int totalEntries, boolean isUserAllowedToPost, boolean isUserAllowedToComment)
Description copied from interface:NewsfeedListView
Notifies the view to show the list ofPost
. This also means the GET newsfeed API was successful.- Specified by:
showNewsfeedList
in interfaceNewsfeedListView
- Parameters:
pinnedPost
- pinned post in the feednewsfeed
- list ofPost
objectsflags
- list ofFlag
objectstotalEntries
- total number of posts regardless of paginationisUserAllowedToPost
- member posting is allowed or not allowedisUserAllowedToComment
- member commenting is allowed or not allowed
-
appendNews
public void appendNews(Post pinnedPost, java.util.List<Post> newsfeed, int totalEntries, boolean isUserAllowedToPost, boolean isUserAllowedToComment)
Description copied from interface:NewsfeedListView
Notifies the view to append list ofPost
to the existing post list. This also means that the GET newsfeed API with pagination was successful- Specified by:
appendNews
in interfaceNewsfeedListView
- Parameters:
pinnedPost
- pinned post in the feednewsfeed
- list ofPost
objectstotalEntries
- total number of posts regardless of paginationisUserAllowedToPost
- member posting is allowed or not allowedisUserAllowedToComment
- member commenting is allowed or not allowed
-
deletePost
public void deletePost(Post post)
Description copied from interface:NewsfeedListView
Notifies the view to delete the post from the list. This also means delete post API was successful.- Specified by:
deletePost
in interfaceNewsfeedListView
- Parameters:
post
- deletedPost
-
showErrorDialog
public void showErrorDialog(java.lang.String error)
Description copied from interface:NewsfeedListView
Notifies the view to show a dialog with the provided error message- Specified by:
showErrorDialog
in interfaceNewsfeedListView
- Parameters:
error
- error message
-
revertChanges
public void revertChanges(int postId)
Description copied from interface:NewsfeedListView
Notifies the view to revert any changes made to the post. This also means that Like/Unlike and Flag/Unflag of Post API failed- Specified by:
revertChanges
in interfaceNewsfeedListView
- Parameters:
postId
- id of the post to revert
-
updatePost
public void updatePost(Post post)
Description copied from interface:NewsfeedListView
Notifies the view to update the Post. This also means that the GET post API with clearing of cache was successful.- Specified by:
updatePost
in interfaceNewsfeedListView
- Parameters:
post
- updatedPost
-
onFacebookShareSuccess
public void onFacebookShareSuccess(com.facebook.share.Sharer.Result result)
- Specified by:
onFacebookShareSuccess
in interfaceFacebookHelper.FacebookShareCallBack
-
onFacebookShareCancelled
public void onFacebookShareCancelled()
- Specified by:
onFacebookShareCancelled
in interfaceFacebookHelper.FacebookShareCallBack
-
onFacebookShareError
public void onFacebookShareError(com.facebook.FacebookException e)
- Specified by:
onFacebookShareError
in interfaceFacebookHelper.FacebookShareCallBack
-
createAdapter
protected NewsfeedListAdapter createAdapter()
Create the adapter used in current RecycleView present. This is commonly used when overriding theNewsfeedListAdapter
- Returns:
- instance of
NewsfeedListAdapter
-
onDeletePost
public void onDeletePost(int postId)
Description copied from interface:PostClickListener
Method to handle deleting of post- Specified by:
onDeletePost
in interfacePostClickListener
- Parameters:
postId
- id of post
-
onPostClick
public void onPostClick(Post post)
Description copied from interface:PostClickListener
Method to handle clicking of post- Specified by:
onPostClick
in interfacePostClickListener
- Parameters:
post
-Post
-
onLikePost
public void onLikePost(boolean isAttempToLike, int postId)
Description copied from interface:PostClickListener
Method to handle liking of Post- Specified by:
onLikePost
in interfacePostClickListener
- Parameters:
isAttempToLike
- status if post is liked/unlikedpostId
- id of post
-
onCommentClick
public void onCommentClick(Post post)
Description copied from interface:PostClickListener
Method to handle clicking of comment view- Specified by:
onCommentClick
in interfacePostClickListener
- Parameters:
post
-Post
-
onFlagNews
public void onFlagNews(int postId, java.lang.String flag)
Description copied from interface:PostClickListener
Method to handle clicking of flag view- Specified by:
onFlagNews
in interfacePostClickListener
- Parameters:
postId
- id of postflag
- key attribute of the selected flag fromFlag
-
onViewUrl
public void onViewUrl(android.net.Uri uri)
Description copied from interface:PostClickListener
Method to handle viewing of url- Specified by:
onViewUrl
in interfacePostClickListener
- Parameters:
uri
- uri to view
-
onShareUrl
public void onShareUrl(android.net.Uri uri)
Description copied from interface:PostClickListener
Method to handle sharing of url- Specified by:
onShareUrl
in interfacePostClickListener
- Parameters:
uri
- uri for sharing
-
onNewsLaunchProfile
public void onNewsLaunchProfile(Owner owner)
Description copied from interface:PostClickListener
Method to handle launching of Owner's profile- Specified by:
onNewsLaunchProfile
in interfacePostClickListener
- Parameters:
owner
-Owner
-
onLinkPreviewClick
public void onLinkPreviewClick(Post post)
Description copied from interface:PostClickListener
Method to handle clicking of link preview- Specified by:
onLinkPreviewClick
in interfacePostClickListener
- Parameters:
post
-Post
-
createItemDecoration
protected androidx.recyclerview.widget.RecyclerView.ItemDecoration createItemDecoration()
Create the item decoration used in the RecyclerView. This invoked when initializing the list for the first time- Returns:
- instance of
RecyclerView.ItemDecoration
for the RecyclerView
-
-