Search in sources :

Example 1 with EnvironmentType

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

the class AssetManager method updateLogos.

/**
 * Update the logos for the given paymentProducts if there is a new version
 *
 * @param region, region determines what baseurl is used for loading images
 * @param environment, environment determines what baseurl is used for loading images
 * @param basicPaymentItems, PaymentProductSelectables for which the logo will be updated if there is a new version
 */
public void updateLogos(Region region, EnvironmentType environment, List<BasicPaymentItem> basicPaymentItems, Size size) {
    // Get the map containg all logos per paymentProductId from the preferences
    Type listType = new TypeToken<Map<String, String>>() {
    }.getType();
    Map<String, String> logoMapping = preferences.getMapFromSharedPreferences(Constants.PREFERENCES_LOGO_MAP, context, listType, new HashMap<String, String>());
    // Store that mapping in the user preferences so it will be cached there.
    if (logoMapping == null) {
        logoMapping = readInitialLogoMapping();
    }
    if (logoMapping != null && basicPaymentItems != null) {
        // Loop trough all BasicPaymentProducts to see if their logo must be updated
        for (BasicPaymentItem product : basicPaymentItems) {
            String url = logoMapping.get(product.getId());
            // Check if the logo url is different for the paymentproduct
            if (url == null || !url.equals(product.getDisplayHints().getLogoUrl())) {
                // Update the image
                getImageFromUrl(region, environment, logoMapping, product, size);
            }
        }
    }
}
Also used : EnvironmentType(com.globalcollect.gateway.sdk.client.android.sdk.model.Environment.EnvironmentType) Type(java.lang.reflect.Type) HashMap(java.util.HashMap) Map(java.util.Map) BasicPaymentItem(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentItem)

Example 2 with EnvironmentType

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

the class StartPageActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_startpage);
    // Get all values for Region spinner
    List<Region> spinnerArrayRegion = new ArrayList<Region>(EnumSet.allOf(Region.class));
    // Make adapters of list and put it inside spinner
    ArrayAdapter<Region> adapterRegion = new ArrayAdapter<Region>(this, android.R.layout.simple_spinner_item, spinnerArrayRegion);
    adapterRegion.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    Spinner spinnerRegion = (Spinner) findViewById(R.id.region);
    spinnerRegion.setAdapter(adapterRegion);
    // Get all values for Environment spinner
    List<EnvironmentType> spinnerArrayEnvironment = new ArrayList<EnvironmentType>(EnumSet.allOf(EnvironmentType.class));
    // Make adapters of list and put it inside spinner
    ArrayAdapter<EnvironmentType> adapterEnvironment = new ArrayAdapter<EnvironmentType>(this, android.R.layout.simple_spinner_item, spinnerArrayEnvironment);
    // adapterRegion.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    Spinner spinnerEnvironment = (Spinner) findViewById(R.id.environment);
    spinnerEnvironment.setAdapter(adapterEnvironment);
    // Get all values for CountryCode spinner
    List<CountryCode> spinnerArrayCountry = new ArrayList<CountryCode>(EnumSet.allOf(CountryCode.class));
    Collections.sort(spinnerArrayCountry);
    // Make adapters of list and put it inside spinner
    ArrayAdapter<CountryCode> adapterCountry = new ArrayAdapter<CountryCode>(this, android.R.layout.simple_spinner_item, spinnerArrayCountry);
    adapterCountry.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    Spinner spinnerCountry = (Spinner) findViewById(R.id.country_code);
    spinnerCountry.setAdapter(adapterCountry);
    spinnerCountry.setSelection(adapterCountry.getPosition(CountryCode.US));
    // Get all values for CurrencyCode spinner
    List<CurrencyCode> spinnerArrayCurrency = new ArrayList<CurrencyCode>(EnumSet.allOf(CurrencyCode.class));
    Collections.sort(spinnerArrayCurrency);
    // Make adapters of list and put it inside spinner
    ArrayAdapter<CurrencyCode> adapterCurrency = new ArrayAdapter<CurrencyCode>(this, android.R.layout.simple_spinner_item, spinnerArrayCurrency);
    adapterCurrency.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    Spinner spinnerCurrency = (Spinner) findViewById(R.id.currency_code);
    spinnerCurrency.setAdapter(adapterCurrency);
    spinnerCurrency.setSelection(adapterCurrency.getPosition(CurrencyCode.EUR));
}
Also used : Spinner(android.widget.Spinner) ArrayList(java.util.ArrayList) CurrencyCode(com.globalcollect.gateway.sdk.client.android.sdk.model.CurrencyCode) EnvironmentType(com.globalcollect.gateway.sdk.client.android.sdk.model.Environment.EnvironmentType) Region(com.globalcollect.gateway.sdk.client.android.sdk.model.Region) CountryCode(com.globalcollect.gateway.sdk.client.android.sdk.model.CountryCode) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

EnvironmentType (com.globalcollect.gateway.sdk.client.android.sdk.model.Environment.EnvironmentType)2 ArrayAdapter (android.widget.ArrayAdapter)1 Spinner (android.widget.Spinner)1 CountryCode (com.globalcollect.gateway.sdk.client.android.sdk.model.CountryCode)1 CurrencyCode (com.globalcollect.gateway.sdk.client.android.sdk.model.CurrencyCode)1 Region (com.globalcollect.gateway.sdk.client.android.sdk.model.Region)1 BasicPaymentItem (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentItem)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1