Class GiftcardsPagerFragment<V extends GiftcardsPagerView,P extends GiftcardsPagerPresenter<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.giftcards.ui.viewpager.GiftcardsPagerFragment<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,OnAddGiftcardListener,GiftcardsPagerView,OnGiftcardClickListener,LceView,MvpLceView,MvpView,RefreshableView
public abstract class GiftcardsPagerFragment<V extends GiftcardsPagerView,P extends GiftcardsPagerPresenter<V>> extends RefreshableFragmentView<V,P> implements GiftcardsPagerView, OnGiftcardClickListener, OnAddGiftcardListener
AbstractFragmentwhich shows a list ofGiftcard. This class needs to be subclassed to add action to:onReloadGiftcard(String, String, float)andonPurchaseGiftcard(String, float). Note thatonManageButtonClicked(String)by default callsGiftcardManageActivitywhich is an abstract class. If the default behavior will be overridden, no need to subclassGiftcardManageActivity. Use request codeMANAGE_REQUEST_CODEwhen launchingGiftcardManageActivityusingMvpFragmentView.startActivityForResult(Intent, int). SeeonManageButtonClicked(String). Can receive the following intent extras:IntentKey.PRIMARY_PARAMS-GiftcardParamsto useIntentKey.SECONDARY_PARAMS-GiftcardParamsto use for client token
-
-
Field Summary
Fields Modifier and Type Field Description static intMANAGE_REQUEST_CODE-
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 GiftcardsPagerFragment()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected GiftcardPagerAdaptercreateGiftcardPagerAdapter()Create an instance ofGiftcardPagerAdapter.protected PcreatePresenter()InstantiateMvpFragmentView.mPresenterto be used for thisMvpActivityViewvoiddismissAddGiftcardDialog()This notifies the view to dismiss theAddGiftcardDialogFragmentbooleangetAutoReloadState()Get the state of auto-reloadprotected intgetContentLayoutId()Provide the Content Layout ID which is of a Layout Resource Reference of AndroidvoidonActivityResult(int requestCode, int resultCode, android.content.Intent data)voidonAddGiftcard(java.lang.String cardNumber, java.lang.String pin)Handles adding of gift cardprotected voidonAddGiftcardTriggered()Method to launchAddGiftcardDialogFragmentvoidonCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater)android.view.ViewonCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)voidonManageButtonClicked(java.lang.String cardNumber)Handle managing of giftcardbooleanonOptionsItemSelected(android.view.MenuItem item)voidonPayButtonClicked(java.lang.String cardNumber)Handle the method of payingabstract voidonPurchaseGiftcard(java.lang.String clientToken, float amount)Abstract method to launch Braintree Drop-in UI to Purchase a Gift Card.protected voidonPurchaseGiftcardTriggered()Displays an Amount Dialog w/c allows custom values (from user-input) and pre-defined values frommFixedReloadAmounts.voidonReloadButtonClicked(java.lang.String cardNumber)Handle reloading of giftcardabstract voidonReloadGiftcard(java.lang.String clientToken, java.lang.String cardNumber, float amount)Abstract method to launch Braintree Drop-in UI to Reload a Gift Card.voidonResume()voidrefreshDataAndUi()Gets new data from the server and refreshes the layoutvoidshowAddGiftcardDialog()This notifies the view to showAddGiftcardDialogFragmentvoidshowErrorDialog(java.lang.String error)This notifies the view to show the dialog with error messagevoidshowGiftcards(java.util.List<Giftcard> giftcards, java.util.Date responseReceivedDate)This notifies the view to show the list ofGiftcardvoidshowLinkSuccessMessage()This notifies the view to show a message informing the user that adding a gift card to the member's account was successful.voidshowPurchaseSuccessResponse(PurchaseResponse response)This notifies the view to show a message informing the user that purchasing a digital gift card was successful.voidshowReloadSuccessResponse(GiftcardReload response)This notifies the view to show a message informing the user that reloading a gift card was successful.-
Methods inherited from class com.cheetahdigital.uikit.architecture.refreshable.RefreshableFragmentView
onFinishRefresh, onRefresh, onRefreshFailed, reloadData, showContent, 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, getScreenName, getSharedElementViews, initSharedElementValues, isSharedAnimationEnabled, onAttach, onDestroyView, startActivity, startActivityForResult
-
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, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, 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.corekit.sdk.analytics.AnalyticsManager.AnalyticsScreen
getScreenName
-
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
-
MANAGE_REQUEST_CODE
public static final int MANAGE_REQUEST_CODE
- 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 classRefreshableFragmentView<V extends GiftcardsPagerView,P extends GiftcardsPagerPresenter<V>>
-
onAddGiftcard
public void onAddGiftcard(java.lang.String cardNumber, java.lang.String pin)Description copied from interface:OnAddGiftcardListenerHandles adding of gift card- Specified by:
onAddGiftcardin interfaceOnAddGiftcardListener- Parameters:
cardNumber- code of gift cardpin- pin of gift card
-
onActivityResult
public void onActivityResult(int requestCode, int resultCode, android.content.Intent data)- Overrides:
onActivityResultin classandroidx.fragment.app.Fragment
-
onResume
public void onResume()
- Overrides:
onResumein classandroidx.fragment.app.Fragment
-
onCreateOptionsMenu
public void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater)- Overrides:
onCreateOptionsMenuin classandroidx.fragment.app.Fragment
-
onOptionsItemSelected
public boolean onOptionsItemSelected(android.view.MenuItem item)
- Overrides:
onOptionsItemSelectedin classandroidx.fragment.app.Fragment
-
getAutoReloadState
public boolean getAutoReloadState()
Get the state of auto-reload- Returns:
- state of auto-reload
-
createPresenter
protected P createPresenter()
Description copied from class:MvpFragmentViewInstantiateMvpFragmentView.mPresenterto be used for thisMvpActivityView- Specified by:
createPresenterin classMvpFragmentView<V extends GiftcardsPagerView,P extends GiftcardsPagerPresenter<V>>- Returns:
- return the
MvpBasePresenter
-
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 GiftcardsPagerView,P extends GiftcardsPagerPresenter<V>>- Returns:
- id of the content layout
-
showGiftcards
public void showGiftcards(java.util.List<Giftcard> giftcards, java.util.Date responseReceivedDate)
Description copied from interface:GiftcardsPagerViewThis notifies the view to show the list ofGiftcard- Specified by:
showGiftcardsin interfaceGiftcardsPagerView- Parameters:
giftcards- list ofGiftcardresponseReceivedDate- date the response is received
-
showErrorDialog
public void showErrorDialog(java.lang.String error)
Description copied from interface:GiftcardsPagerViewThis notifies the view to show the dialog with error message- Specified by:
showErrorDialogin interfaceGiftcardsPagerView- Parameters:
error- error message
-
showReloadSuccessResponse
public void showReloadSuccessResponse(GiftcardReload response)
Description copied from interface:GiftcardsPagerViewThis notifies the view to show a message informing the user that reloading a gift card was successful.- Specified by:
showReloadSuccessResponsein interfaceGiftcardsPagerView- Parameters:
response- response inGiftcardReloadformat
-
showLinkSuccessMessage
public void showLinkSuccessMessage()
Description copied from interface:GiftcardsPagerViewThis notifies the view to show a message informing the user that adding a gift card to the member's account was successful.- Specified by:
showLinkSuccessMessagein interfaceGiftcardsPagerView
-
showPurchaseSuccessResponse
public void showPurchaseSuccessResponse(PurchaseResponse response)
Description copied from interface:GiftcardsPagerViewThis notifies the view to show a message informing the user that purchasing a digital gift card was successful.- Specified by:
showPurchaseSuccessResponsein interfaceGiftcardsPagerView- Parameters:
response- inPurchaseResponseformat
-
dismissAddGiftcardDialog
public void dismissAddGiftcardDialog()
Description copied from interface:GiftcardsPagerViewThis notifies the view to dismiss theAddGiftcardDialogFragment- Specified by:
dismissAddGiftcardDialogin interfaceGiftcardsPagerView
-
showAddGiftcardDialog
public void showAddGiftcardDialog()
Description copied from interface:GiftcardsPagerViewThis notifies the view to showAddGiftcardDialogFragment- Specified by:
showAddGiftcardDialogin interfaceGiftcardsPagerView
-
onReloadGiftcard
public abstract void onReloadGiftcard(java.lang.String clientToken, java.lang.String cardNumber, float amount)Abstract method to launch Braintree Drop-in UI to Reload a Gift Card. See https://developers.braintreepayments.com.Sample code: String currency = getString(R.string.currency); String currencyAndAmount = currency + " " + amount; // Create Braintree Payment Request DropInRequest dropInRequest = new DropInRequest() .clientToken(clientToken) .amount(currencyAndAmount); startActivityForResult(dropInRequest.getIntent(getActivity()), RELOAD_REQUEST_CODE);
- Parameters:
clientToken- the client token required for the Braintree SDKcardNumber- the gift card code needed for doing the Reload API callamount- the amount to be reloaded
-
onPurchaseGiftcard
public abstract void onPurchaseGiftcard(java.lang.String clientToken, float amount)Abstract method to launch Braintree Drop-in UI to Purchase a Gift Card. See https://developers.braintreepayments.com/.Sample code: String currency = getString(R.string.currency); String currencyAndAmount = currency + " " + amount; // Create Braintree Payment Request DropInRequest paymentRequest = createPaymentRequest( clientToken, currencyAndAmount); startActivityForResult(paymentRequest.getIntent(getActivity()), PURCHASE_REQUEST_CODE);
- Parameters:
clientToken- the client token required for the Braintree SDKamount- the amount to be reloaded
-
onReloadButtonClicked
public void onReloadButtonClicked(java.lang.String cardNumber)
Description copied from interface:OnGiftcardClickListenerHandle reloading of giftcard- Specified by:
onReloadButtonClickedin interfaceOnGiftcardClickListener- Parameters:
cardNumber- code of giftcard
-
onAddGiftcardTriggered
protected void onAddGiftcardTriggered()
Method to launchAddGiftcardDialogFragment
-
onPurchaseGiftcardTriggered
protected void onPurchaseGiftcardTriggered()
Displays an Amount Dialog w/c allows custom values (from user-input) and pre-defined values frommFixedReloadAmounts.
-
onPayButtonClicked
public void onPayButtonClicked(java.lang.String cardNumber)
Description copied from interface:OnGiftcardClickListenerHandle the method of paying- Specified by:
onPayButtonClickedin interfaceOnGiftcardClickListener- Parameters:
cardNumber- code of giftcard
-
onManageButtonClicked
public void onManageButtonClicked(java.lang.String cardNumber)
Description copied from interface:OnGiftcardClickListenerHandle managing of giftcard- Specified by:
onManageButtonClickedin interfaceOnGiftcardClickListener- Parameters:
cardNumber- code of giftcard
-
refreshDataAndUi
public void refreshDataAndUi()
Description copied from interface:GiftcardsPagerViewGets new data from the server and refreshes the layout- Specified by:
refreshDataAndUiin interfaceGiftcardsPagerView
-
createGiftcardPagerAdapter
protected GiftcardPagerAdapter createGiftcardPagerAdapter()
Create an instance ofGiftcardPagerAdapter. Usually used ifGiftcardPagerAdapterwas subclassed.- Returns:
- instance of
GiftcardPagerAdapter
-
-