java.lang.Object
com.samsung.android.sdk.samsungpay.v2.payment.sheet.SheetControl
com.samsung.android.sdk.samsungpay.v2.payment.sheet.SpinnerControl
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
  • Constructor Details

    • SpinnerControl

      public SpinnerControl(String controlId, String title, SheetItemType sheetItemType)
      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

      public void setSheetUpdatedListener(SheetUpdatedListener sheetUpdatedListener)
      API to register a callback which is invoked when SpinnerControl is updated.

      SheetUpdatedListener.onResult(String, CustomSheet) is invoked when SpinnerControl is updated.
      Parameters:
      sheetUpdatedListener - The callback that will run.
      Since:
      API Level 1.6
    • getTitle

      public String getTitle()
      API to get spinner title.
      Returns:
      Title for SpinnerControl.
      Since:
      API Level 1.6
    • setTitle

      public void setTitle(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(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(String id, 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, String id, 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(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(String id, 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(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