Skip to content

Commit

Permalink
Add comment to explain LayoutInflater problem
Browse files Browse the repository at this point in the history
COAND-806
  • Loading branch information
OscarSpruit committed May 22, 2024
1 parent d1ed1a0 commit 604abd9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,4 @@ object StatusResponseUtils {
fun isFinalResult(statusResponse: StatusResponse): Boolean {
return RESULT_PENDING != statusResponse.resultCode
}

fun isPendingResult(statusResponse: StatusResponse): Boolean {
return RESULT_PENDING == statusResponse.resultCode
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ internal class DefaultTwintDelegate(

private fun restoreState() {
adyenLog(AdyenLogLevel.DEBUG) { "Restoring state" }
val action: SdkAction<TwintSdkData>? = action
if (action != null) {
initState(action)
}
action?.let { initState(it) }
}

override fun observe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal class TwintFragment : Fragment() {

private var twint: Twint? = Twint(this, ::onTwintResult)

private var twintResultQueue: TwintPayResult? = null
private var queuedTwintResult: TwintPayResult? = null

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
_binding = FragmentTwintBinding.inflate(inflater, container, false)
Expand All @@ -50,7 +50,7 @@ internal class TwintFragment : Fragment() {
.onEach { twint?.payWithCode(it) }
.launchIn(viewLifecycleOwner.lifecycleScope)

twintResultQueue?.let {
queuedTwintResult?.let {
adyenLog(AdyenLogLevel.DEBUG) { "initialize: executing queue" }
onTwintResult(it)
}
Expand All @@ -62,10 +62,10 @@ internal class TwintFragment : Fragment() {
?.handleTwintResult(result)
?.also {
adyenLog(AdyenLogLevel.DEBUG) { "onTwintResult: clearing queue" }
twintResultQueue = null
queuedTwintResult = null
} ?: run {
adyenLog(AdyenLogLevel.DEBUG) { "onTwintResult: setting queue" }
twintResultQueue = result
queuedTwintResult = result
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ class AdyenComponentView @JvmOverloads constructor(
}
}

/**
* Returns the [LayoutInflater] of the parent activity or fragment. Using `LayoutInflater.from(context)` when the
* view's parent is a fragment will return the [LayoutInflater] of the fragment's activity. This causes issues with
* nested fragment's.
*/
@Suppress("SwallowedException")
private fun getLayoutInflater(): LayoutInflater = try {
findFragment<Fragment>().layoutInflater
Expand Down

0 comments on commit 604abd9

Please sign in to comment.