Search in sources :

Example 6 with KeyValuePair

use of com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.KeyValuePair in project connect-sdk-client-android by Ingenico-ePayments.

the class RenderAccountOnFile method renderAccountOnFile.

@SuppressWarnings("deprecation")
@Override
public void renderAccountOnFile(AccountOnFile accountOnFile, String productId, ViewGroup parent) {
    if (accountOnFile == null) {
        throw new InvalidParameterException("Error renderingAccountOnFile, accountOnFile may not be null");
    }
    if (productId == null) {
        throw new InvalidParameterException("Error renderingAccountOnFile, productId may not be null");
    }
    if (parent == null) {
        throw new InvalidParameterException("Error renderingAccountOnFile, parent may not be null");
    }
    // Inflate the activity_select_payment_product_render layout
    LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View paymentProductLayout = inflater.inflate(R.layout.activity_render_payment_product, parent, false);
    // Set the belonging accountOnFile on the tag of the row so we can retrieve it when clicked
    paymentProductLayout.findViewById(R.id.paymentProductRow).setTag(accountOnFile);
    // Get the TextView and ImageView which will be filled
    TextView accountOnFileTextView = (TextView) paymentProductLayout.findViewById(R.id.paymentProductName);
    ImageView accountOnFileLogoImageView = (ImageView) paymentProductLayout.findViewById(R.id.paymentProductLogo);
    // Set the correct value
    String formattedValue = null;
    for (KeyValuePair attribute : accountOnFile.getAttributes()) {
        for (AccountOnFileDisplay displayEntry : accountOnFile.getDisplayHints().getLabelTemplate()) {
            if (attribute.getKey().equals(displayEntry.getKey())) {
                // Format the value if there is a mask in the accountonfile text
                if (displayEntry.getMask() != null) {
                    StringFormatter stringFormatter = new StringFormatter();
                    String maskedValue = stringFormatter.applyMask(displayEntry.getMask().replace("9", "*"), attribute.getValue());
                    formattedValue = maskedValue;
                } else {
                    formattedValue = attribute.getValue();
                }
            }
        }
    }
    accountOnFileTextView.setText(formattedValue);
    // Set the logo via the AssetManager
    AssetManager logoManager = AssetManager.getInstance(parent.getContext());
    Drawable logo = logoManager.getLogo(productId);
    if (Build.VERSION.SDK_INT < 16) {
        accountOnFileLogoImageView.setBackgroundDrawable(logo);
    } else {
        accountOnFileLogoImageView.setBackground(logo);
    }
    parent.addView(paymentProductLayout);
}
Also used : InvalidParameterException(java.security.InvalidParameterException) AssetManager(com.globalcollect.gateway.sdk.client.android.sdk.manager.AssetManager) KeyValuePair(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.KeyValuePair) LayoutInflater(android.view.LayoutInflater) AccountOnFileDisplay(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.AccountOnFileDisplay) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) StringFormatter(com.globalcollect.gateway.sdk.client.android.sdk.formatter.StringFormatter)

Example 7 with KeyValuePair

use of com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.KeyValuePair in project connect-sdk-client-android by Ingenico-ePayments.

the class DetailInputActivityAfterpay method retrieveValuesFromSearchFields.

private List<KeyValuePair> retrieveValuesFromSearchFields() {
    ArrayList<KeyValuePair> values = new ArrayList<>(3);
    for (PaymentProductField searchField : paymentProductFieldsUsedForLookup) {
        String value = inputDataPersister.getValue(searchField.getId());
        KeyValuePair kvp = new KeyValuePair();
        kvp.setKey(searchField.getId());
        kvp.setValue(value);
        values.add(kvp);
    }
    return values;
}
Also used : KeyValuePair(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.KeyValuePair) PaymentProductField(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductField) ArrayList(java.util.ArrayList)

Aggregations

KeyValuePair (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.KeyValuePair)7 InvalidParameterException (java.security.InvalidParameterException)5 StringFormatter (com.globalcollect.gateway.sdk.client.android.sdk.formatter.StringFormatter)3 InputFilter (android.text.InputFilter)2 EditText (android.widget.EditText)2 TextView (android.widget.TextView)2 Translator (com.globalcollect.gateway.sdk.client.android.exampleapp.translation.Translator)2 AccountOnFile (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.AccountOnFile)2 PaymentItem (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentItem)2 ArrayList (java.util.ArrayList)2 Drawable (android.graphics.drawable.Drawable)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 LayoutParams (android.view.ViewGroup.LayoutParams)1 ArrayAdapter (android.widget.ArrayAdapter)1 DatePicker (android.widget.DatePicker)1 OnDateChangedListener (android.widget.DatePicker.OnDateChangedListener)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 LayoutParams (android.widget.LinearLayout.LayoutParams)1