Search in sources :

Example 6 with Translator

use of com.globalcollect.gateway.sdk.client.android.exampleapp.translation.Translator in project connect-sdk-client-android by Ingenico-ePayments.

the class RenderPaymentItem method renderPaymentItem.

@SuppressWarnings("deprecation")
@Override
public void renderPaymentItem(BasicPaymentItem product, ViewGroup parent) {
    if (product == null) {
        throw new InvalidParameterException("Error renderingPaymentProduct, product may not be null");
    }
    if (parent == null) {
        throw new InvalidParameterException("Error renderingPaymentProduct, 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(product);
    // Get the TextView and ImageView which will be filled
    TextView paymentProductNameTextView = (TextView) paymentProductLayout.findViewById(R.id.paymentProductName);
    ImageView paymentProductNameLogoImageView = (ImageView) paymentProductLayout.findViewById(R.id.paymentProductLogo);
    // Set the translated value
    Translator translator = Translator.getInstance(parent.getContext());
    String translatedValue = (product instanceof BasicPaymentProduct) ? translator.getPaymentProductName(product.getId()) : translator.getPaymentProductGroupName(product.getId());
    paymentProductNameTextView.setText(translatedValue);
    if (Build.VERSION.SDK_INT < 16) {
        paymentProductNameLogoImageView.setBackgroundDrawable(product.getDisplayHints().getLogo());
    } else {
        paymentProductNameLogoImageView.setBackground(product.getDisplayHints().getLogo());
    }
    parent.addView(paymentProductLayout);
}
Also used : InvalidParameterException(java.security.InvalidParameterException) Translator(com.globalcollect.gateway.sdk.client.android.exampleapp.translation.Translator) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) ImageView(android.widget.ImageView) BasicPaymentProduct(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentProduct) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View)

Aggregations

Translator (com.globalcollect.gateway.sdk.client.android.exampleapp.translation.Translator)6 TextView (android.widget.TextView)4 InvalidParameterException (java.security.InvalidParameterException)3 InputFilter (android.text.InputFilter)2 LayoutInflater (android.view.LayoutInflater)2 View (android.view.View)2 EditText (android.widget.EditText)2 ImageView (android.widget.ImageView)2 LinearLayout (android.widget.LinearLayout)2 StringFormatter (com.globalcollect.gateway.sdk.client.android.sdk.formatter.StringFormatter)2 KeyValuePair (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.KeyValuePair)2 PaymentItem (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentItem)2 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 ViewGroup (android.view.ViewGroup)1 LayoutParams (android.view.ViewGroup.LayoutParams)1 AccountOnFile (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.AccountOnFile)1 BasicPaymentItem (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentItem)1 BasicPaymentProduct (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentProduct)1