Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ subprojects {
targetVersion = 34
codeVersion = 1

hyperwalletCoreVersion = '1.0.0-beta12'
hyperwalletCoreVersion = '1.0.3'
hyperwalletInsightVersion = '1.0.0-beta02'
//
androidMaterialVersion = '1.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void onChanged(Boolean loading) {
}
});

mReceiptViewModel.errors().observe(this, new Observer<Event<Errors>>() {
mReceiptViewModel.errors().observe(getViewLifecycleOwner(), new Observer<Event<Errors>>() {
@Override
public void onChanged(Event<Errors> errorsEvent) {
if (errorsEvent != null && !errorsEvent.isContentConsumed()) {
Expand All @@ -204,7 +204,7 @@ public void onChanged(Event<Errors> errorsEvent) {
}
});

mReceiptViewModel.getDetailNavigation().observe(this, new Observer<Event<Receipt>>() {
mReceiptViewModel.getDetailNavigation().observe(getViewLifecycleOwner(), new Observer<Event<Receipt>>() {
@Override
public void onChanged(@NonNull final Event<Receipt> event) {
navigate(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private void retryCurrentListFragment() {
}

private void registerObservers() {
mTabbedListReceiptsViewModel.getPrepaidCards().observe(this, new Observer<List<PrepaidCard>>() {
mTabbedListReceiptsViewModel.getPrepaidCards().observe(getViewLifecycleOwner(), new Observer<List<PrepaidCard>>() {
@Override
public void onChanged(List<PrepaidCard> prepaidCards) {
if (!prepaidCards.isEmpty()) {
Expand Down Expand Up @@ -137,7 +137,7 @@ public void onChanged(List<PrepaidCard> prepaidCards) {
}
});

mTabbedListReceiptsViewModel.getRetryListReceipts().observe(this, new Observer<Boolean>() {
mTabbedListReceiptsViewModel.getRetryListReceipts().observe(getViewLifecycleOwner(), new Observer<Boolean>() {
@Override
public void onChanged(Boolean aBoolean) {
retryCurrentListFragment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ public class SelectTransferMethodPresenter implements SelectTransferMethodContra
private final SelectTransferMethodContract.View mView;

public SelectTransferMethodPresenter(SelectTransferMethodContract.View view,
@NonNull final TransferMethodConfigurationRepository transferMethodConfigurationRepository,
@NonNull final UserRepository userRepository) {
@NonNull final TransferMethodConfigurationRepository transferMethodConfigurationRepository,
@NonNull final UserRepository userRepository) {
this.mView = view;
this.mTransferMethodConfigurationRepository = transferMethodConfigurationRepository;
this.mUserRepository = userRepository;
}

@Override
public void loadTransferMethodConfigurationKeys(final boolean forceUpdate, @Nullable final String countryCode,
@Nullable final String currencyCode) {
@Nullable final String currencyCode) {

mView.showProgressBar();

Expand Down Expand Up @@ -146,15 +146,14 @@ public void onKeysLoaded(@Nullable final HyperwalletTransferMethodConfigurationK
if (!mView.isActive()) {
return;
}
List<Currency> currencies = key.getCurrencies(countryCode) != null ?
new ArrayList<>(key.getCurrencies(countryCode)) :
new ArrayList<Currency>();
String selectedCurrencyCode = getDefaultCurrencyCode(key, countryCode);

if (selectedCurrencyCode == null) {
return;
}
mView.showTransferMethodCountry(countryCode);
mView.showTransferMethodCurrency(currencies.get(0).getCode());

loadFeeAndProcessingTimeAndShowTransferMethods(countryCode, currencies.get(0).getCode(),
user);
mView.showTransferMethodCurrency(selectedCurrencyCode);
loadFeeAndProcessingTimeAndShowTransferMethods(countryCode, selectedCurrencyCode, user);
}

@Override
Expand All @@ -180,7 +179,7 @@ private void showErrorLoadCurrency(@NonNull Errors errors) {

@Override
public void loadTransferMethodTypes(final boolean forceUpdate,
@NonNull final String countryCode, @NonNull final String currencyCode) {
@NonNull final String countryCode, @NonNull final String currencyCode) {
mView.showProgressBar();

if (forceUpdate) {
Expand Down Expand Up @@ -226,7 +225,7 @@ public void onError(@NonNull Errors errors) {

@Override
public void openAddTransferMethod(@NonNull final String country, @NonNull final String currency,
@NonNull final String transferMethodType, @NonNull final String profileType) {
@NonNull final String transferMethodType, @NonNull final String profileType) {
mView.showAddTransferMethod(country, currency, transferMethodType, profileType);
}

Expand Down Expand Up @@ -293,6 +292,34 @@ public void onError(@NonNull final Errors errors) {
});
}

// Helper method to get the DefaultCurrencyCode
private String getDefaultCurrencyCode(@NonNull final HyperwalletTransferMethodConfigurationKey keys, @NonNull final String countryCode) {
Country selectedCountry = null;
for (Country country : keys.getCountries()) {
if (country.getCode().equals(countryCode)) {
selectedCountry = country;
break;
}
}
if (selectedCountry == null) {
return null;
}
Set<Currency> currencies = keys.getCurrencies(countryCode);
String defaultCurrencyCode = selectedCountry.getDefaultCurrency();
if (defaultCurrencyCode != null) {
for (Currency currency : currencies) {
if (currency.getCode().equals(defaultCurrencyCode)) {
return currency.getCode();
}
}
}
if (!keys.getCurrencies(countryCode).isEmpty()) {
return keys.getCurrencies(countryCode).iterator().next().getCode();
}
return null;
}


private List<TransferMethodSelectionItem> getTransferMethodSelectionItems(
@NonNull final String countryCode, @NonNull final String currencyCode,
@NonNull final String userProfileType,
Expand All @@ -309,7 +336,7 @@ private List<TransferMethodSelectionItem> getTransferMethodSelectionItems(
}

private void loadFeeAndProcessingTimeAndShowTransferMethods(final String countryCode, final String currencyCode,
final User user) {
final User user) {
mTransferMethodConfigurationRepository.getTransferMethodTypesFeeAndProcessingTime(countryCode, currencyCode,
new TransferMethodConfigurationRepository.LoadKeysCallback() {
@Override
Expand Down