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 ofOfferCan 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 ofOfferto be displayedOFFER_IS_CLIPPING_ENABLED- the flag for enabling the clipping/unclipping ofOffer. Default value istrueENABLE_SHOW_BACKGROUND_OFFER_IMAGE- the flag for enabling the showing of background offer image to the container of the list itemOPEN_URL_DETAIL- the flagOffertype URLs,truewill open the detail screen, otherwise an external browser will be openedIntentKey.PRIMARY_PARAMS- list ofOfferto be displayed
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringENABLE_SHOW_BACKGROUND_OFFER_IMAGEstatic java.lang.StringOFFER_IS_CLIPPING_ENABLEDstatic java.lang.StringOFFER_IS_GRID_VIEWstatic java.lang.StringOFFERS_FILTER_ONstatic java.lang.StringOPEN_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 voidappendOffersList(java.util.List<Offer> offers, int totalEntries)Notifies the view to append the existingOfferlist.protected voidcaptureSharedElementValues(android.content.Intent intent)Captures the shared element and passes its values to intent.protected androidx.recyclerview.widget.RecyclerView.ItemDecorationcreateItemDecoration()Create theRecyclerView.ItemDecorationused in the RecyclerView.protected OffersAdaptercreateOffersAdapter(OfferClickListener offerClickListener, OfferClipListener offerClipListener)Create an instance ofOffersAdapter.protected PcreatePresenter()InstantiateMvpFragmentView.mPresenterto be used for thisMvpActivityViewprotected intgetContentLayoutId()Provide the Content Layout ID which is of a Layout Resource Reference of AndroidintgetScreenName()protected android.view.View[]getSharedElementViews()Fetches the shared element views.voidonCreate(android.os.Bundle savedInstanceState)voidonCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater)android.view.ViewonCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)voidonOfferClipped(Offer offer, boolean mustClipped)Callback when an offer was clippedvoidonSaveInstanceState(android.os.Bundle outState)voidrefreshList()Refresh the current list by callingOffersListPresenter.refreshData()voidsetListItemDecoration(androidx.recyclerview.widget.RecyclerView.ItemDecoration itemDecoration)Set a customRecyclerView.ItemDecoration.protected voidsetSelectedOffer(Offer selectedOffer)Set the selectedOfferafterOfferClickListener.onOfferClick(Offer, View, int)protected voidsetSelectedView(android.view.View selectedView)Set the selectedViewafterOfferClickListener.onOfferClick(Offer, View, int)voidshowErrorDialog(java.lang.String error)Callback when clipping an offer failedvoidshowOfferCategoryFilter(java.util.List<OfferCategory> offerCategories)Notifies the view to initialize theOfferCategoryfilter.voidshowOffersList(java.util.List<Offer> offers, int totalEntries)Notifies the view to show theOfferlist.-
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:
onCreateViewin classEndlessListAndGridFragmentView<A extends OffersAdapter,V extends OffersListView,P extends OffersListPresenter<V>>
-
getContentLayoutId
protected int getContentLayoutId()
Description copied from class:MvpFragmentViewProvide the Content Layout ID which is of a Layout Resource Reference of Android- Specified by:
getContentLayoutIdin classMvpFragmentView<V extends OffersListView,P extends OffersListPresenter<V>>- Returns:
- id of the content layout
-
createPresenter
protected P createPresenter()
Description copied from class:MvpFragmentViewInstantiateMvpFragmentView.mPresenterto be used for thisMvpActivityView- Specified by:
createPresenterin 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:
onCreateOptionsMenuin classandroidx.fragment.app.Fragment
-
onSaveInstanceState
public void onSaveInstanceState(android.os.Bundle outState)
- Overrides:
onSaveInstanceStatein classandroidx.fragment.app.Fragment
-
onCreate
public void onCreate(@Nullable android.os.Bundle savedInstanceState)- Overrides:
onCreatein classandroidx.fragment.app.Fragment
-
createItemDecoration
protected androidx.recyclerview.widget.RecyclerView.ItemDecoration createItemDecoration()
Create theRecyclerView.ItemDecorationused in the RecyclerView. This will be invoked when initializing the list for the first time.- Returns:
- instance of
RecyclerView.ItemDecorationfor 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:OffersListViewNotifies the view to show theOfferlist. This also means that the GET offers API was successful- Specified by:
showOffersListin interfaceOffersListView- Parameters:
offers- the list ofOffertotalEntries- the total number of offers
-
appendOffersList
public void appendOffersList(java.util.List<Offer> offers, int totalEntries)
Description copied from interface:OffersListViewNotifies the view to append the existingOfferlist. This also means that the GET offers API with pagination was successful- Specified by:
appendOffersListin interfaceOffersListView- Parameters:
offers- the list ofOffertotalEntries- total number of offers
-
showErrorDialog
public void showErrorDialog(java.lang.String error)
Description copied from interface:OffersListViewCallback when clipping an offer failed- Specified by:
showErrorDialogin interfaceOffersListView- Parameters:
error- error message
-
refreshList
public void refreshList()
Description copied from interface:OffersListViewRefresh the current list by callingOffersListPresenter.refreshData()- Specified by:
refreshListin interfaceOffersListView
-
showOfferCategoryFilter
public void showOfferCategoryFilter(java.util.List<OfferCategory> offerCategories)
Description copied from interface:OffersListViewNotifies the view to initialize theOfferCategoryfilter. This also means that the GET offer categories API was successful- Specified by:
showOfferCategoryFilterin interfaceOffersListView- Parameters:
offerCategories- list ofOfferCategory
-
onOfferClipped
public void onOfferClipped(Offer offer, boolean mustClipped)
Description copied from interface:OfferClipListenerCallback when an offer was clipped- Specified by:
onOfferClippedin interfaceOfferClipListener- Parameters:
offer- theOffermustClipped- the action if the offer was clipped or unclipped
-
createOffersAdapter
protected OffersAdapter createOffersAdapter(OfferClickListener offerClickListener, OfferClipListener offerClipListener)
Create an instance ofOffersAdapter. Usually used ifOffersAdapterwas subclassed.- Parameters:
offerClickListener- handles offer click actionsofferClipListener- handles offer clip actions- Returns:
- instance of
OffersAdapter
-
getScreenName
public int getScreenName()
- Specified by:
getScreenNamein interfaceAnalyticsManager.AnalyticsScreen- Overrides:
getScreenNamein classMvpFragmentView<V extends OffersListView,P extends OffersListPresenter<V>>
-
captureSharedElementValues
protected void captureSharedElementValues(android.content.Intent intent)
Description copied from class:MvpFragmentViewCaptures the shared element and passes its values to intent.- Overrides:
captureSharedElementValuesin classMvpFragmentView<V extends OffersListView,P extends OffersListPresenter<V>>- Parameters:
intent-Intentto store the shared element values
-
getSharedElementViews
protected android.view.View[] getSharedElementViews()
Description copied from class:MvpFragmentViewFetches the shared element views.- Overrides:
getSharedElementViewsin classMvpFragmentView<V extends OffersListView,P extends OffersListPresenter<V>>- Returns:
- list of shared element
View
-
setSelectedOffer
protected void setSelectedOffer(Offer selectedOffer)
Set the selectedOfferafterOfferClickListener.onOfferClick(Offer, View, int)- Parameters:
selectedOffer- the selectedOffer
-
setSelectedView
protected void setSelectedView(android.view.View selectedView)
Set the selectedViewafterOfferClickListener.onOfferClick(Offer, View, int)- Parameters:
selectedView- the selectedView
-
-