The Gift Cards kit is used to fetch gift card information for the members. The basic functions in this kit includes displaying available gift cards for purchase, displaying purchased gift cards, displaying gift card balances, configuring gift card properties (autoreload), reloading and deleting gift cards.
To include the Gift Cards kit, open the Gradle Scripts | build.gradle (Module: app)
and add the following to the
dependencies section:
implementation 'com.cheetahdigital.android:giftcards:<version>'
On this page:
Overview
The Gift Cards kit is presented using a View Pager.
Launching the Gift Cards Activity
Assuming that the Gift Cards kit will be launched from a MainActivity
, you can follow the succeeding steps to launch the GiftcardsListActivity
from a Button’s OnClickListener
:
- In your
MainActivity
, add a Button to launch the starting Activity -GiftcardsListActivity
.mButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(StellarActions.Giftcards.getGiftCardListAction(MainActivity.this))); } });
- Gift card classes are available to group gift cards. To specify the gift card class to be used to fetch the gift card list, use the following intent extra
intent.putExtra(GiftcardsListFragment.GIFTCARD_CLASS, "class_name");
For the rest of the available pre-made Activity
and Fragment
for Gift Cards, please see Class Reference.
Theme Customization
The Kits leverage on Android’s built-in support for Styles and Themes. Overriding the Styles and Themes of the app will also change the corresponding Views used in this kit.
Layout Customization
Customizing Layouts via XML
You can customize the layouts of the different screens in the Gift Cards Kit by copying the layout XML’s and overriding as desired. To read more about this, please visit the Layout Customization via XML document. The XML’s used are:
fragment_giftcard.xml
- layout for an item in the list of gift cardsfragment_giftcards.xml
- layout for displaying the list of gift cardsactivity_giftcards.xml
- container forstellar_fragment_giftcards
activity_giftcard_details.xml
- layout for displaying the details of a gift cardactivity_giftcard_manage.xml
- layout for managing gift cardsactivity_giftcard_auto_reload.xml
- layout for auto reloading gift cardslist_item_giftcard_transaction.xml
- layout for an item in the list of gift card transactions
Customizing Layouts via Code
There are certain cases that you may want to use a highly-customized layout for an Activity. To read more about this, please visit the Layout Customization via Code document. The classes used for the Gift Cards kit are:
GiftcardsActivity
andGiftcardsFragment
for displaying the list of gift cardsGiftcardFragment
is a single gift card item in the list of gift cardsGiftcardDetailsActivity
for displaying the details of a gift cardGiftcardAutoReloadActivity
used when reloading a gift cardGiftcardHistoryActivity
for displaying the list of gift card transactionsGiftcardManageActivity
for displaying the gift cards manage screen
Customizing Handlers
There are certain cases that you may want to change the default behavior of an Activity. You can achieve this by extending the Activity/Fragment that you want to customize and override as necessary.
Handlers may occur in different places:
- Adapters - for lists
- Member variables inside Activities or Fragments
- Member variables inside custom Widgets - for stand-alone custom Widgets
To start with, you may look at the classes mentioned in Customizing Layouts via Code, along with AddGiftcardDialogFragment
for the dialog shown when adding a new gift card, and GiftcardHistoryAdapter
- the adapter used when displaying the list of past gift card transactions.
Fully Custom UI
If changing the layout does not suffice for your case, you can always do a full customization. The following are the methods you can use from the GiftcardsAPI
class:
Getting Client Token
getGiftcardsClientToken(GiftcardParams queryParams, boolean clearCache,
ListenerModel<BaseModel<ClientToken>, ClientToken> listener)
Querying Gift Cards
getGiftcards(GiftcardParams queryParams, boolean clearCache,
ListenerModel<BaseModel<Giftcards>, Giftcards> listener)
getGiftcard(GiftcardParams queryParams, boolean clearCache,
ListenerModel<BaseModel<Giftcard>, Giftcard> listener)
Reloading a Gift Card
reloadGiftcard(GiftcardParams queryParams, GiftcardFields fieldParams,
ListenerModel<BaseModel<GiftcardReload>, GiftcardReload> listener)
Purchasing a Gift Card
purchaseGiftcard(GiftcardParams queryParams, GiftcardFields fieldParams,
ListenerModel<BaseModel<PurchaseResponse>, PurchaseResponse> listener)
Link/Unlink a Gift Card
linkGiftcard(GiftcardParams queryParams, GiftcardFields fieldParams,
ListenerModel<BaseModel<Giftcard>, Giftcard> listener)
unlinkGiftcard(GiftcardParams queryParams, ListenerModel<BaseModel<Giftcard>, Giftcard> listener)
Querying Transactions
getTransactions(GiftcardParams queryParams, boolean clearCache,
ListenerModel<BaseModel<Transactions>, Transactions> listener)
Updating Gift Card Auto Reload Details
updateGiftcard(GiftcardParams queryParams, GiftcardFields fieldParams,
ListenerModel<BaseModel<Giftcard>, Giftcard> listener)
Fetch Available Gift Card classes
getClasses(GiftcardParams queryParams, boolean clearCache,
ListenerModel<BaseModel<CardClasses>, CardClasses> listener)