Class OffersListFragment<A extends OffersAdapter,V extends OffersListView,P extends OffersListPresenter<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.EndlessListAndGridFragmentView<A,V,P>
-
- com.cheetahdigital.offers.ui.list.OffersListFragment<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
,OfferClipListener
,OffersListView
,LceView
,MvpLceView
,MvpView
,RefreshableView
,EndlessListView
,ListView
- Direct Known Subclasses:
OffersClippedFragment
public class OffersListFragment<A extends OffersAdapter,V extends OffersListView,P extends OffersListPresenter<V>> extends EndlessListAndGridFragmentView<A,V,P> implements OffersListView, OfferClipListener
The fragment class for showing the list ofOffer
Can receive the following intent extras:OFFERS_FILTER_ON
- flag to show the offer categories- OFFER_IS_GRID_VIEW - view type of the offer.
true
- grid view,false
- list view. Default value is false. IntentKey.OFFERS_LIST
- list ofOffer
to be displayedOFFER_IS_CLIPPING_ENABLED
- the flag for enabling the clipping/unclipping ofOffer
. Default value istrue
ENABLE_SHOW_BACKGROUND_OFFER_IMAGE
- the flag for enabling the showing of background offer image to the container of the list itemOPEN_URL_DETAIL
- the flagOffer
type URLs,true
will open the detail screen, otherwise an external browser will be openedIntentKey.PRIMARY_PARAMS
- list ofOffer
to be displayed
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ENABLE_SHOW_BACKGROUND_OFFER_IMAGE
static java.lang.String
OFFER_IS_CLIPPING_ENABLED
static java.lang.String
OFFER_IS_GRID_VIEW
static java.lang.String
OFFERS_FILTER_ON
static java.lang.String
OPEN_URL_DETAIL
-
Fields inherited from class com.cheetahdigital.uikit.widget.list.EndlessListAndGridFragmentView
mEndlessRecyclerOnScrollListener, mGridLayoutManager
-
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 OffersListFragment()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendOffersList(java.util.List<Offer> offers, int totalEntries)
Notifies the view to append the existingOffer
list.protected void
captureSharedElementValues(android.content.Intent intent)
Captures the shared element and passes its values to intent.protected androidx.recyclerview.widget.RecyclerView.ItemDecoration
createItemDecoration()
Create theRecyclerView.ItemDecoration
used in the RecyclerView.protected OffersAdapter
createOffersAdapter(OfferClickListener offerClickListener, OfferClipListener offerClipListener)
Create an instance ofOffersAdapter
.protected P
createPresenter()
InstantiateMvpFragmentView.mPresenter
to be used for thisMvpActivityView
protected int
getContentLayoutId()
Provide the Content Layout ID which is of a Layout Resource Reference of Androidint
getScreenName()
protected android.view.View[]
getSharedElementViews()
Fetches the shared element views.void
onCreate(android.os.Bundle savedInstanceState)
void
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
onOfferClipped(Offer offer, boolean mustClipped)
Callback when an offer was clippedvoid
onSaveInstanceState(android.os.Bundle outState)
void
refreshList()
Refresh the current list by callingOffersListPresenter.refreshData()
void
setListItemDecoration(androidx.recyclerview.widget.RecyclerView.ItemDecoration itemDecoration)
Set a customRecyclerView.ItemDecoration
.protected void
setSelectedOffer(Offer selectedOffer)
Set the selectedOffer
afterOfferClickListener.onOfferClick(Offer, View, int)
protected void
setSelectedView(android.view.View selectedView)
Set the selectedView
afterOfferClickListener.onOfferClick(Offer, View, int)
void
showErrorDialog(java.lang.String error)
Callback when clipping an offer failedvoid
showOfferCategoryFilter(java.util.List<OfferCategory> offerCategories)
Notifies the view to initialize theOfferCategory
filter.void
showOffersList(java.util.List<Offer> offers, int totalEntries)
Notifies the view to show theOffer
list.-
Methods inherited from class com.cheetahdigital.uikit.widget.list.EndlessListAndGridFragmentView
getCurrentPage, getGridViewNumColumns, getListTotalEntries, isGridView, onFinishLoadMore, onFinishRefresh, onLoadMoreFailed, setCurrentPage, setIsGridView, setListTotalEntries, setSpanSizeLookupForGridView
-
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
getPresenter, 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, onActivityResult, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onDestroy, onDestroyOptionsMenu, onDetach, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onResume, 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
-
OFFERS_FILTER_ON
public static final java.lang.String OFFERS_FILTER_ON
- See Also:
- Constant Field Values
-
OFFER_IS_GRID_VIEW
public static final java.lang.String OFFER_IS_GRID_VIEW
- See Also:
- Constant Field Values
-
OFFER_IS_CLIPPING_ENABLED
public static final java.lang.String OFFER_IS_CLIPPING_ENABLED
- See Also:
- Constant Field Values
-
OPEN_URL_DETAIL
public static final java.lang.String OPEN_URL_DETAIL
- See Also:
- Constant Field Values
-
ENABLE_SHOW_BACKGROUND_OFFER_IMAGE
public static final java.lang.String ENABLE_SHOW_BACKGROUND_OFFER_IMAGE
- 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 classEndlessListAndGridFragmentView<A extends OffersAdapter,V extends OffersListView,P extends OffersListPresenter<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 OffersListView,P extends OffersListPresenter<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 OffersListView,P extends OffersListPresenter<V>>
- Returns:
- return the
MvpBasePresenter
-
onCreateOptionsMenu
public void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater)
- Overrides:
onCreateOptionsMenu
in classandroidx.fragment.app.Fragment
-
onSaveInstanceState
public void onSaveInstanceState(android.os.Bundle outState)
- Overrides:
onSaveInstanceState
in classandroidx.fragment.app.Fragment
-
onCreate
public void onCreate(@Nullable android.os.Bundle savedInstanceState)
- Overrides:
onCreate
in classandroidx.fragment.app.Fragment
-
createItemDecoration
protected androidx.recyclerview.widget.RecyclerView.ItemDecoration createItemDecoration()
Create theRecyclerView.ItemDecoration
used in the RecyclerView. This will be invoked when initializing the list for the first time.- Returns:
- instance of
RecyclerView.ItemDecoration
for the RecyclerView
-
setListItemDecoration
public void setListItemDecoration(androidx.recyclerview.widget.RecyclerView.ItemDecoration itemDecoration)
Set a customRecyclerView.ItemDecoration
. The custom item decoration will be set when initializing the list for the first time.- Parameters:
itemDecoration
- theRecyclerView.ItemDecoration
-
showOffersList
public void showOffersList(java.util.List<Offer> offers, int totalEntries)
Description copied from interface:OffersListView
Notifies the view to show theOffer
list. This also means that the GET offers API was successful- Specified by:
showOffersList
in interfaceOffersListView
- Parameters:
offers
- the list ofOffer
totalEntries
- the total number of offers
-
appendOffersList
public void appendOffersList(java.util.List<Offer> offers, int totalEntries)
Description copied from interface:OffersListView
Notifies the view to append the existingOffer
list. This also means that the GET offers API with pagination was successful- Specified by:
appendOffersList
in interfaceOffersListView
- Parameters:
offers
- the list ofOffer
totalEntries
- total number of offers
-
showErrorDialog
public void showErrorDialog(java.lang.String error)
Description copied from interface:OffersListView
Callback when clipping an offer failed- Specified by:
showErrorDialog
in interfaceOffersListView
- Parameters:
error
- error message
-
refreshList
public void refreshList()
Description copied from interface:OffersListView
Refresh the current list by callingOffersListPresenter.refreshData()
- Specified by:
refreshList
in interfaceOffersListView
-
showOfferCategoryFilter
public void showOfferCategoryFilter(java.util.List<OfferCategory> offerCategories)
Description copied from interface:OffersListView
Notifies the view to initialize theOfferCategory
filter. This also means that the GET offer categories API was successful- Specified by:
showOfferCategoryFilter
in interfaceOffersListView
- Parameters:
offerCategories
- list ofOfferCategory
-
onOfferClipped
public void onOfferClipped(Offer offer, boolean mustClipped)
Description copied from interface:OfferClipListener
Callback when an offer was clipped- Specified by:
onOfferClipped
in interfaceOfferClipListener
- Parameters:
offer
- theOffer
mustClipped
- the action if the offer was clipped or unclipped
-
createOffersAdapter
protected OffersAdapter createOffersAdapter(OfferClickListener offerClickListener, OfferClipListener offerClipListener)
Create an instance ofOffersAdapter
. Usually used ifOffersAdapter
was subclassed.- Parameters:
offerClickListener
- handles offer click actionsofferClipListener
- handles offer clip actions- Returns:
- instance of
OffersAdapter
-
getScreenName
public int getScreenName()
- Specified by:
getScreenName
in interfaceAnalyticsManager.AnalyticsScreen
- Overrides:
getScreenName
in classMvpFragmentView<V extends OffersListView,P extends OffersListPresenter<V>>
-
captureSharedElementValues
protected void captureSharedElementValues(android.content.Intent intent)
Description copied from class:MvpFragmentView
Captures the shared element and passes its values to intent.- Overrides:
captureSharedElementValues
in classMvpFragmentView<V extends OffersListView,P extends OffersListPresenter<V>>
- Parameters:
intent
-Intent
to store the shared element values
-
getSharedElementViews
protected android.view.View[] getSharedElementViews()
Description copied from class:MvpFragmentView
Fetches the shared element views.- Overrides:
getSharedElementViews
in classMvpFragmentView<V extends OffersListView,P extends OffersListPresenter<V>>
- Returns:
- list of shared element
View
-
setSelectedOffer
protected void setSelectedOffer(Offer selectedOffer)
Set the selectedOffer
afterOfferClickListener.onOfferClick(Offer, View, int)
- Parameters:
selectedOffer
- the selectedOffer
-
setSelectedView
protected void setSelectedView(android.view.View selectedView)
Set the selectedView
afterOfferClickListener.onOfferClick(Offer, View, int)
- Parameters:
selectedView
- the selectedView
-
-