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
AbstractFragment
which 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 callsGiftcardManageActivity
which is an abstract class. If the default behavior will be overridden, no need to subclassGiftcardManageActivity
. Use request codeMANAGE_REQUEST_CODE
when launchingGiftcardManageActivity
usingMvpFragmentView.startActivityForResult(Intent, int)
. SeeonManageButtonClicked(String)
. Can receive the following intent extras:IntentKey.PRIMARY_PARAMS
-GiftcardParams
to useIntentKey.SECONDARY_PARAMS
-GiftcardParams
to use for client token
-
-
Field Summary
Fields Modifier and Type Field Description static int
MANAGE_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 GiftcardPagerAdapter
createGiftcardPagerAdapter()
Create an instance ofGiftcardPagerAdapter
.protected P
createPresenter()
InstantiateMvpFragmentView.mPresenter
to be used for thisMvpActivityView
void
dismissAddGiftcardDialog()
This notifies the view to dismiss theAddGiftcardDialogFragment
boolean
getAutoReloadState()
Get the state of auto-reloadprotected int
getContentLayoutId()
Provide the Content Layout ID which is of a Layout Resource Reference of Androidvoid
onActivityResult(int requestCode, int resultCode, android.content.Intent data)
void
onAddGiftcard(java.lang.String cardNumber, java.lang.String pin)
Handles adding of gift cardprotected void
onAddGiftcardTriggered()
Method to launchAddGiftcardDialogFragment
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
onManageButtonClicked(java.lang.String cardNumber)
Handle managing of giftcardboolean
onOptionsItemSelected(android.view.MenuItem item)
void
onPayButtonClicked(java.lang.String cardNumber)
Handle the method of payingabstract void
onPurchaseGiftcard(java.lang.String clientToken, float amount)
Abstract method to launch Braintree Drop-in UI to Purchase a Gift Card.protected void
onPurchaseGiftcardTriggered()
Displays an Amount Dialog w/c allows custom values (from user-input) and pre-defined values frommFixedReloadAmounts
.void
onReloadButtonClicked(java.lang.String cardNumber)
Handle reloading of giftcardabstract 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.void
onResume()
void
refreshDataAndUi()
Gets new data from the server and refreshes the layoutvoid
showAddGiftcardDialog()
This notifies the view to showAddGiftcardDialogFragment
void
showErrorDialog(java.lang.String error)
This notifies the view to show the dialog with error messagevoid
showGiftcards(java.util.List<Giftcard> giftcards, java.util.Date responseReceivedDate)
This notifies the view to show the list ofGiftcard
void
showLinkSuccessMessage()
This notifies the view to show a message informing the user that adding a gift card to the member's account was successful.void
showPurchaseSuccessResponse(PurchaseResponse response)
This notifies the view to show a message informing the user that purchasing a digital gift card was successful.void
showReloadSuccessResponse(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:
onCreateView
in classRefreshableFragmentView<V extends GiftcardsPagerView,P extends GiftcardsPagerPresenter<V>>
-
onAddGiftcard
public void onAddGiftcard(java.lang.String cardNumber, java.lang.String pin)
Description copied from interface:OnAddGiftcardListener
Handles adding of gift card- Specified by:
onAddGiftcard
in interfaceOnAddGiftcardListener
- Parameters:
cardNumber
- code of gift cardpin
- pin of gift card
-
onActivityResult
public void onActivityResult(int requestCode, int resultCode, android.content.Intent data)
- Overrides:
onActivityResult
in classandroidx.fragment.app.Fragment
-
onResume
public void onResume()
- Overrides:
onResume
in classandroidx.fragment.app.Fragment
-
onCreateOptionsMenu
public void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater)
- Overrides:
onCreateOptionsMenu
in classandroidx.fragment.app.Fragment
-
onOptionsItemSelected
public boolean onOptionsItemSelected(android.view.MenuItem item)
- Overrides:
onOptionsItemSelected
in 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:MvpFragmentView
InstantiateMvpFragmentView.mPresenter
to be used for thisMvpActivityView
- Specified by:
createPresenter
in classMvpFragmentView<V extends GiftcardsPagerView,P extends GiftcardsPagerPresenter<V>>
- Returns:
- return the
MvpBasePresenter
-
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 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:GiftcardsPagerView
This notifies the view to show the list ofGiftcard
- Specified by:
showGiftcards
in interfaceGiftcardsPagerView
- Parameters:
giftcards
- list ofGiftcard
responseReceivedDate
- date the response is received
-
showErrorDialog
public void showErrorDialog(java.lang.String error)
Description copied from interface:GiftcardsPagerView
This notifies the view to show the dialog with error message- Specified by:
showErrorDialog
in interfaceGiftcardsPagerView
- Parameters:
error
- error message
-
showReloadSuccessResponse
public void showReloadSuccessResponse(GiftcardReload response)
Description copied from interface:GiftcardsPagerView
This notifies the view to show a message informing the user that reloading a gift card was successful.- Specified by:
showReloadSuccessResponse
in interfaceGiftcardsPagerView
- Parameters:
response
- response inGiftcardReload
format
-
showLinkSuccessMessage
public void showLinkSuccessMessage()
Description copied from interface:GiftcardsPagerView
This notifies the view to show a message informing the user that adding a gift card to the member's account was successful.- Specified by:
showLinkSuccessMessage
in interfaceGiftcardsPagerView
-
showPurchaseSuccessResponse
public void showPurchaseSuccessResponse(PurchaseResponse response)
Description copied from interface:GiftcardsPagerView
This notifies the view to show a message informing the user that purchasing a digital gift card was successful.- Specified by:
showPurchaseSuccessResponse
in interfaceGiftcardsPagerView
- Parameters:
response
- inPurchaseResponse
format
-
dismissAddGiftcardDialog
public void dismissAddGiftcardDialog()
Description copied from interface:GiftcardsPagerView
This notifies the view to dismiss theAddGiftcardDialogFragment
- Specified by:
dismissAddGiftcardDialog
in interfaceGiftcardsPagerView
-
showAddGiftcardDialog
public void showAddGiftcardDialog()
Description copied from interface:GiftcardsPagerView
This notifies the view to showAddGiftcardDialogFragment
- Specified by:
showAddGiftcardDialog
in 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:OnGiftcardClickListener
Handle reloading of giftcard- Specified by:
onReloadButtonClicked
in 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:OnGiftcardClickListener
Handle the method of paying- Specified by:
onPayButtonClicked
in interfaceOnGiftcardClickListener
- Parameters:
cardNumber
- code of giftcard
-
onManageButtonClicked
public void onManageButtonClicked(java.lang.String cardNumber)
Description copied from interface:OnGiftcardClickListener
Handle managing of giftcard- Specified by:
onManageButtonClicked
in interfaceOnGiftcardClickListener
- Parameters:
cardNumber
- code of giftcard
-
refreshDataAndUi
public void refreshDataAndUi()
Description copied from interface:GiftcardsPagerView
Gets new data from the server and refreshes the layout- Specified by:
refreshDataAndUi
in interfaceGiftcardsPagerView
-
createGiftcardPagerAdapter
protected GiftcardPagerAdapter createGiftcardPagerAdapter()
Create an instance ofGiftcardPagerAdapter
. Usually used ifGiftcardPagerAdapter
was subclassed.- Returns:
- instance of
GiftcardPagerAdapter
-
-