All Implemented Interfaces:
android.os.Parcelable
public class SpinnerControl
extends SheetControl
implements android.os.Parcelable
This class provides SpinnerControl on custom payment sheet.
SpinnerControl is used for displaying spinner option on custom payment sheet.
Since:
API Level 1.6
Nested Class Summary
Nested classes/interfaces inherited from interface android.os.Parcelable
android.os.Parcelable.ClassLoaderCreator<T extends Object >, android.os.Parcelable.Creator<T extends Object >
Field Summary
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
Constructor Summary
Constructors
Constructor to create SpinnerControl.
Method Summary
All Methods Instance Methods Concrete Methods
void
API to add item in specific location.
void
boolean
API to check the item is existing or not.
API to get the ID of selected item.
API to get spinner title.
void
void
API to set selected item with ID.
void
void
API to set spinner title.
void
Constructor Details
SpinnerControl
Constructor to create SpinnerControl.
// Construct SpinnerControl.
SpinnerControl spinnerControl = new SpinnerControl("spinner", "Shipping method", SheetItemType
.SHIPPING_METHOD_SPINNER);
spinnerControl.addItem("id_item1", "item1 option");
spinnerControl.addItem("id_item2", "item2 option");
spinnerControl.setSelectedItemId("id_item1");
// Register {@link SheetUpdatedListener} to get result from Samsung Pay App.
spinnerControl.setSheetUpdatedListener(new SheetUpdatedListener() {
@Override
public void onResult(String updatedControlId, CustomSheet sheet) {
SpinnerControl spinnerControl = (SpinnerControl) sheet.getSheetControl(updatedControlId);
Log.d(TAG, "SELECTED ID : " + spinnerControl.getSelectedItemId());
// Merchant can calculate total amount with selected option.
sheet.updateControl(amountBoxControl);
// Call updateSheet() API method with AmountBoxControl. This is mandatory.
paymentManager.updateSheet(sheet);
}
}
Parameters:
controlId - Unique ID to represent the SpinnerControl. This ID is used to compare with other SheetControls.
title - Spinner title to display.
sheetItemType - sheetItemType to display.
The possible values are:
SheetItemType.SHIPPING_METHOD_SPINNER
SheetItemType.INSTALLMENT_SPINNER
Throws:
NullPointerException - Thrown if title is null.
IllegalArgumentException - Thrown if controlId is null or empty.
Thrown if sheetItemType is not SheetItemType.SHIPPING_METHOD_SPINNER or
SheetItemType.INSTALLMENT_SPINNER .
Since:
API Level 1.6
Method Details
setSheetUpdatedListener
Parameters:
sheetUpdatedListener - The callback that will run.
Since:
API Level 1.6
getTitle
API to get spinner title.
Returns:
Title for SpinnerControl.
Since:
API Level 1.6
setTitle
public void setTitle (@NonNull
String title)
API to set spinner title.
Parameters:
title - Spinner title for SpinnerControl.
Throws:
NullPointerException - Thrown if spinnerTitle is null.
Since:
API Level 1.6
getSelectedItemId
public String getSelectedItemId ()
API to get the ID of selected item.
Returns:
Selected item ID.
Since:
API Level 1.6
setSelectedItemId
public void setSelectedItemId (@NonNull
String id)
API to set selected item with ID.
Throws:
NullPointerException - Thrown if the ID is null.
IllegalArgumentException - Thrown if there is no item associated with the ID.
Since:
API Level 1.6
addItem
public void addItem (@NonNull
String id,
@NonNull
String itemText)
API to add item.
Parameters:
id - Unique ID to be set.
itemText - String to be set.
Throws:
NullPointerException - Thrown if the ID or value is null.
IllegalArgumentException - Thrown if the same ID is used in Items.
Since:
API Level 1.6
addItem
public void addItem (int location,
@NonNull
String id,
@NonNull
String itemText)
API to add item in specific location.
Parameters:
id - Unique ID to add.
itemText - String value to be set.
Throws:
NullPointerException - Thrown if the ID or value is null.
IllegalArgumentException - Thrown if the location is abnormal.
IllegalArgumentException - Thrown if the same ID is used in Items.
Since:
API Level 1.6
removeItem
public void removeItem (@NonNull
String id)
API to remove item.
Parameters:
id - ID to be removed.
Throws:
NullPointerException - Thrown if the ID is null.
IllegalArgumentException - Thrown if there is no item associated with the ID.
Since:
API Level 1.6
updateItem
public void updateItem (@NonNull
String id,
@NonNull
String text)
API to update item text.
Parameters:
id - ID to update.
text - Item String to update.
Throws:
NullPointerException - Thrown if the ID is null.
IllegalArgumentException - Thrown if there is no item associated with the ID.
Since:
API Level 1.6
existItem
public boolean existItem (@NonNull
String id)
API to check the item is existing or not.
Parameters:
id - ID to be checked item.
Returns:
True, if there is item.
Throws:
NullPointerException - Thrown if the ID is null.
Since:
API Level 1.6
Samsung Electronics . Samsung Pay SDK 2.22.00 - Nov 19 2024