Skip to content

Commit b6f0236

Browse files
change coroutine context for image repo (#11635)
* change coroutine context for image repo * Fix checks. --------- Co-authored-by: Jay Newstrom <jaynewstrom@stripe.com>
1 parent bb1c623 commit b6f0236

File tree

6 files changed

+1
-21
lines changed

6 files changed

+1
-21
lines changed

3ds2sdk/src/main/kotlin/com/stripe/android/stripe3ds2/views/ChallengeActivity.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class ChallengeActivity : AppCompatActivity() {
7777
challengeActionHandler,
7878
transactionTimer,
7979
errorReporter,
80-
WORK_CONTEXT
8180
)
8281
}
8382

@@ -108,7 +107,6 @@ class ChallengeActivity : AppCompatActivity() {
108107
challengeActionHandler = challengeActionHandler,
109108
intentData = viewArgs.intentData,
110109
initialUiType = viewArgs.cresData.uiType,
111-
workContext = WORK_CONTEXT
112110
)
113111

114112
super.onCreate(savedInstanceState)

3ds2sdk/src/main/kotlin/com/stripe/android/stripe3ds2/views/ChallengeActivityViewModel.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ import com.stripe.android.stripe3ds2.utils.ImageCache
1717
import kotlinx.coroutines.Job
1818
import kotlinx.coroutines.flow.firstOrNull
1919
import kotlinx.coroutines.launch
20-
import kotlin.coroutines.CoroutineContext
2120

2221
internal class ChallengeActivityViewModel(
2322
private val challengeActionHandler: ChallengeActionHandler,
2423
private val transactionTimer: TransactionTimer,
2524
errorReporter: ErrorReporter,
2625
private val imageCache: ImageCache = ImageCache.Default,
27-
workContext: CoroutineContext
2826
) : ViewModel() {
29-
private val imageRepository = ImageRepository(errorReporter, workContext)
27+
private val imageRepository = ImageRepository(errorReporter, viewModelScope.coroutineContext)
3028

3129
private val _refreshUi = MutableLiveData<Unit>()
3230
val refreshUi: LiveData<Unit> = _refreshUi
@@ -124,7 +122,6 @@ internal class ChallengeActivityViewModel(
124122
private val challengeActionHandler: ChallengeActionHandler,
125123
private val transactionTimer: TransactionTimer,
126124
private val errorReporter: ErrorReporter,
127-
private val workContext: CoroutineContext
128125
) : ViewModelProvider.Factory {
129126

130127
@Suppress("UNCHECKED_CAST")
@@ -133,7 +130,6 @@ internal class ChallengeActivityViewModel(
133130
challengeActionHandler,
134131
transactionTimer,
135132
errorReporter,
136-
workContext = workContext
137133
) as T
138134
}
139135
}

3ds2sdk/src/main/kotlin/com/stripe/android/stripe3ds2/views/ChallengeFragment.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import com.stripe.android.stripe3ds2.transactions.ChallengeResponseData
2626
import com.stripe.android.stripe3ds2.transactions.ErrorData
2727
import com.stripe.android.stripe3ds2.transactions.UiType
2828
import com.stripe.android.stripe3ds2.utils.AnalyticsDelegate
29-
import kotlin.coroutines.CoroutineContext
3029

3130
internal class ChallengeFragment(
3231
private val uiCustomization: StripeUiCustomization,
@@ -37,7 +36,6 @@ internal class ChallengeFragment(
3736
private val challengeActionHandler: ChallengeActionHandler,
3837
private val initialUiType: UiType?,
3938
private val intentData: IntentData,
40-
private val workContext: CoroutineContext
4139
) : Fragment(R.layout.stripe_challenge_fragment) {
4240

4341
private lateinit var cresData: ChallengeResponseData
@@ -49,7 +47,6 @@ internal class ChallengeFragment(
4947
challengeActionHandler,
5048
transactionTimer,
5149
errorReporter,
52-
workContext
5350
)
5451
}
5552

3ds2sdk/src/main/kotlin/com/stripe/android/stripe3ds2/views/ChallengeFragmentFactory.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import com.stripe.android.stripe3ds2.transaction.IntentData
1010
import com.stripe.android.stripe3ds2.transaction.TransactionTimer
1111
import com.stripe.android.stripe3ds2.transactions.UiType
1212
import com.stripe.android.stripe3ds2.utils.AnalyticsDelegate
13-
import kotlin.coroutines.CoroutineContext
1413

1514
internal class ChallengeFragmentFactory(
1615
private val uiCustomization: StripeUiCustomization,
@@ -21,7 +20,6 @@ internal class ChallengeFragmentFactory(
2120
private val challengeActionHandler: ChallengeActionHandler,
2221
private val initialUiType: UiType?,
2322
private val intentData: IntentData,
24-
private val workContext: CoroutineContext
2523
) : FragmentFactory() {
2624
override fun instantiate(classLoader: ClassLoader, className: String): Fragment {
2725
return when (className) {
@@ -35,7 +33,6 @@ internal class ChallengeFragmentFactory(
3533
challengeActionHandler,
3634
initialUiType,
3735
intentData,
38-
workContext
3936
)
4037
}
4138
else -> {

3ds2sdk/src/test/kotlin/com/stripe/android/stripe3ds2/views/ChallengeActivityViewModelTest.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import com.stripe.android.stripe3ds2.transaction.ChallengeRequestResultFixures
1111
import com.stripe.android.stripe3ds2.transaction.FakeTransactionTimer
1212
import com.stripe.android.stripe3ds2.transaction.TransactionTimer
1313
import kotlinx.coroutines.cancel
14-
import kotlinx.coroutines.test.StandardTestDispatcher
1514
import org.junit.Rule
1615
import org.junit.runner.RunWith
1716
import org.robolectric.RobolectricTestRunner
@@ -22,8 +21,6 @@ class ChallengeActivityViewModelTest {
2221
@get:Rule
2322
val rule = InstantTaskExecutorRule()
2423

25-
private val testDispatcher = StandardTestDispatcher()
26-
2724
private val actionHandler = object : ChallengeActionHandler {
2825
override suspend fun submit(action: ChallengeAction): ChallengeRequestResult {
2926
return ChallengeRequestResultFixures.SUCCESS
@@ -72,7 +69,6 @@ class ChallengeActivityViewModelTest {
7269
actionHandler,
7370
transactionTimer,
7471
FakeErrorReporter(),
75-
workContext = testDispatcher
7672
)
7773
}
7874
}

3ds2sdk/src/test/kotlin/com/stripe/android/stripe3ds2/views/ChallengeFragmentTest.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import com.stripe.android.stripe3ds2.transaction.TransactionTimer
2121
import com.stripe.android.stripe3ds2.transactions.ChallengeResponseData
2222
import com.stripe.android.stripe3ds2.transactions.UiType
2323
import com.stripe.android.stripe3ds2.utils.FakeAnalyticsDelegate
24-
import kotlinx.coroutines.test.StandardTestDispatcher
2524
import org.junit.Rule
2625
import org.junit.runner.RunWith
2726
import org.mockito.kotlin.mock
@@ -38,8 +37,6 @@ class ChallengeFragmentTest {
3837
@get:Rule
3938
val rule = InstantTaskExecutorRule()
4039

41-
private val testDispatcher = StandardTestDispatcher()
42-
4340
private val transactionTimer: TransactionTimer = FakeTransactionTimer(false)
4441
private val errorReporter: ErrorReporter = FakeErrorReporter()
4542
private val challengeActionHandler = FakeChallengeActionHandler()
@@ -373,7 +370,6 @@ class ChallengeFragmentTest {
373370
challengeActionHandler = challengeActionHandler,
374371
intentData = IntentDataFixtures.DEFAULT,
375372
initialUiType = UiType.Text,
376-
workContext = testDispatcher
377373
)
378374
).onFragment(onFragment)
379375
}

0 commit comments

Comments
 (0)