Skip to content

Commit

Permalink
Added delay on Android layer until SDK update is available
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-SD committed Nov 21, 2024
1 parent 4754226 commit 0db23b6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.os.IBinder
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ServiceLifecycleDispatcher
import androidx.lifecycle.lifecycleScope
import com.adyen.checkout.components.core.ActionComponentData
import com.adyen.checkout.components.core.BalanceResult
import com.adyen.checkout.components.core.Order
Expand All @@ -29,6 +30,8 @@ import com.adyen.checkout.flutter.dropIn.model.DropInStoredPaymentMethodDeletion
import com.adyen.checkout.flutter.dropIn.model.DropInType
import com.adyen.checkout.flutter.utils.Constants
import com.adyen.checkout.googlepay.GooglePayComponentState
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.json.JSONObject

class AdvancedDropInService : DropInService(), LifecycleOwner {
Expand Down Expand Up @@ -166,7 +169,10 @@ class AdvancedDropInService : DropInService(), LifecycleOwner {
}

val balanceResult = mapToBalanceDropInServiceResult(message.contentIfNotHandled as String)
sendBalanceResult(balanceResult)
lifecycleScope.launch {
delay(300)
sendBalanceResult(balanceResult)
}
}
}

Expand All @@ -178,7 +184,10 @@ class AdvancedDropInService : DropInService(), LifecycleOwner {
}

val orderResult = mapToOrderDropInServiceResult(message.contentIfNotHandled as String)
sendOrderResult(orderResult)
lifecycleScope.launch {
delay(300)
sendOrderResult(orderResult)
}
}
}

Expand All @@ -190,7 +199,10 @@ class AdvancedDropInService : DropInService(), LifecycleOwner {
}

val orderResult = mapToOrderCancelDropInServiceResult(message.contentIfNotHandled) ?: return@observe
sendResult(orderResult)
lifecycleScope.launch {
delay(300)
sendResult(orderResult)
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import UIKit
RedirectComponent.applicationDidOpen(from: url)
return true
}

private func setDropInStyle() {
var dropInStyle = Adyen.DropInComponent.Style()
dropInStyle.formComponent.mainButtonItem.button.backgroundColor = .black
dropInStyle.formComponent.mainButtonItem.button.title.color = .white
AdyenAppearance.dropInStyle = dropInStyle
}

private func setCardComponentStyle() {
var cardComponentStyle = Adyen.FormComponentStyle()
cardComponentStyle.mainButtonItem.button.backgroundColor = .black
Expand Down
6 changes: 0 additions & 6 deletions lib/src/drop_in/drop_in.dart
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,6 @@ class DropIn {
await partialPayment?.onCheckBalance(balanceCheckRequestBody);
dropInPlatformApi.onBalanceCheckResult(jsonEncode(balanceCheckResponse));
} catch (error) {
// This delay is necessary because Android shows the spinner after a short delay.
await Future.delayed(const Duration(milliseconds: 300));
dropInPlatformApi.onBalanceCheckResult(error.toString());
}
}
Expand All @@ -309,8 +307,6 @@ class DropIn {
final orderRequestResponse = await partialPayment?.onRequestOrder();
dropInPlatformApi.onOrderRequestResult(jsonEncode(orderRequestResponse));
} catch (error) {
// This delay is necessary because Android shows the spinner after a short delay.
await Future.delayed(const Duration(milliseconds: 300));
dropInPlatformApi.onOrderRequestResult(error.toString());
}
}
Expand All @@ -330,8 +326,6 @@ class DropIn {
OrderCancelResultDTO(orderCancelJson: {});
dropInPlatformApi.onOrderCancelResult(orderCancelResponseDTO);
} catch (error) {
// This delay is necessary because Android shows the spinner after a short delay.
await Future.delayed(const Duration(milliseconds: 300));
dropInPlatformApi
.onOrderCancelResult(OrderCancelResultDTO(orderCancelJson: {}));
}
Expand Down

0 comments on commit 0db23b6

Please sign in to comment.