Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2658, #299: Replace builder() with Factory in SingleTypeBuilder and MultiTypeBuilder #4412

Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3162713
Replace builder() with Factory in SingleTypeBuilder and MultiTypeBuil…
KevinGitonga Jul 1, 2022
33dba86
Fix failing tests after refactor, Create Fragment for DragDropTestAct…
KevinGitonga Jul 5, 2022
0a1a5b3
Inject the BindableAdapter.kt factory into the fragment and listview …
KevinGitonga Jul 5, 2022
ee9f243
Inject the BindableAdapter.kt factory into the fragment and listview …
KevinGitonga Jul 5, 2022
955557c
Inject the BindableAdapter.kt factory into the fragment and listview …
KevinGitonga Jul 5, 2022
455f673
Inject the BindableAdapter.kt factory into the fragment and listview …
KevinGitonga Jul 5, 2022
8a5d74f
Add 'androidx.work:work-testing:2.4.0' in androidTestImplementation t…
KevinGitonga Jul 6, 2022
e75cf57
Fix lint formatting issue in updated files.
KevinGitonga Jul 6, 2022
6d72ea9
Fix some of the failing tests after fixing #2658.
KevinGitonga Jul 12, 2022
e92b113
Fix some of the failing tests after fixing #2658.
KevinGitonga Jul 13, 2022
9e1bec0
Fix more failing tests for #2658.
KevinGitonga Jul 13, 2022
e270424
Refactor StatePlayerRecyclerViewAssembler.kt to inject MultiTypeAdapt…
KevinGitonga Jul 14, 2022
459a9a5
Fix failing tests due to missed refactor of QuestionPlayerFragmentPre…
KevinGitonga Jul 14, 2022
f9105ac
Merge branch 'oppia:develop' into enable_dagger_graph_access_for_bind…
KevinGitonga Jul 15, 2022
20c1ff3
More updates as part of refactoring for issue #2658.
KevinGitonga Jul 18, 2022
dfed2cb
Refactor PromotedStoryListView.kt BindableAdapterTest.kt classes to p…
KevinGitonga Jul 19, 2022
6fb1198
Fix issues as advised by code review.
KevinGitonga Jul 21, 2022
8699b2b
Fix issue causing some of failing tests.
KevinGitonga Jul 21, 2022
912bdcd
Fix issue causing some of failing tests.
KevinGitonga Jul 22, 2022
816d626
Revert unused resources, to fix Static check test failure.
KevinGitonga Jul 25, 2022
2d4652a
Add KDocs to implemented public functions, to fix KDocs Static check …
KevinGitonga Jul 25, 2022
be4d3b9
Add exemption for test to DragDropTestFragmentPresenter and DragDropT…
KevinGitonga Jul 25, 2022
4ef20fa
Fix nits and updates as advised during code review.
KevinGitonga Jul 26, 2022
cea5a19
Fix nits and updates as advised during code review.
KevinGitonga Jul 27, 2022
89418ac
Fix nits and updates as advised during code review.
KevinGitonga Jul 27, 2022
7b5e7fe
Updates issues as advised on code review, fix some of the failing tests.
KevinGitonga Jul 28, 2022
d026b12
Fix failing tests.
KevinGitonga Aug 1, 2022
d4d1127
Merge branch 'oppia:develop' into enable_dagger_graph_access_for_bind…
KevinGitonga Aug 1, 2022
b784db5
Fix more failing tests by reverting DragDropSortInteractionView.kt an…
KevinGitonga Aug 1, 2022
86cdf12
Update multiple field namings for consistency as advised by code revi…
KevinGitonga Aug 1, 2022
6c9a6c4
Fix failing tests and revert from previous fix, which could not be us…
KevinGitonga Aug 11, 2022
6432c23
Fix out-of-order binding for selection, drop/drop.
BenHenning Sep 22, 2022
9f838d6
Merge branch 'develop' into update-pr-4412
BenHenning Sep 22, 2022
5a8d7cf
Post-merge fixes.
BenHenning Sep 22, 2022
28df931
Merge branch 'develop' into update-to-latest-develop
BenHenning Sep 22, 2022
af07301
Merge pull request #2 from BenHenning/update-to-latest-develop
KevinGitonga Sep 23, 2022
1e93378
Merge branch 'update-to-latest-develop' into update-pr-4412
BenHenning Sep 24, 2022
1b1f0a5
Merge branch 'enable_dagger_graph_access_for_bindable_adapter' of htt…
BenHenning Sep 24, 2022
a4d482d
Merge branch 'develop' into enable_dagger_graph_access_for_bindable_a…
KevinGitonga Sep 26, 2022
414bf8a
Merge pull request #1 from BenHenning/update-pr-4412
KevinGitonga Sep 26, 2022
8ff532b
Fix lint issues after resolving merge conflicts on CI and add lessons…
KevinGitonga Sep 26, 2022
69603ff
Revert deleted deltas.
KevinGitonga Sep 29, 2022
c8eb1d6
Remove lessons_chapter_view.xml since it is no longer required.
KevinGitonga Oct 3, 2022
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
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ dependencies {
'androidx.test.ext:junit:1.1.1',
'com.github.bumptech.glide:mocks:4.11.0',
'com.google.truth:truth:1.1.3',
'androidx.work:work-testing:2.4.0',
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
'com.google.truth.extensions:truth-liteproto-extension:1.1.3',
'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2',
'org.mockito:mockito-android:2.7.22',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class AdministratorControlsFragmentPresenter @Inject constructor(
private fun createRecyclerViewAdapter(isMultipane: Boolean):
BindableAdapter<AdministratorControlsItemViewModel> {
return BindableAdapter.MultiTypeBuilder
.newBuilder<AdministratorControlsItemViewModel, ViewType> { viewModel ->
.Factory(fragment).create<AdministratorControlsItemViewModel, ViewType> { viewModel ->
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
viewModel.isMultipane.set(isMultipane)
when (viewModel) {
is AdministratorControlsGeneralViewModel -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import javax.inject.Inject
/** Presenter for arranging [ProfileAndDeviceIdFragment]'s UI. */
class ProfileAndDeviceIdFragmentPresenter @Inject constructor(
private val fragment: Fragment,
private val profileListViewModelFactory: ProfileListViewModel.Factory
private val profileListViewModelFactory: ProfileListViewModel.Factory,
private val multiTypeBuilderFactory: BindableAdapter.MultiTypeBuilder.Factory
) {

private lateinit var binding: ProfileAndDeviceIdFragmentBinding

/** Handles [ProfileAndDeviceIdFragment]'s creation flow. */
Expand All @@ -38,16 +40,15 @@ class ProfileAndDeviceIdFragmentPresenter @Inject constructor(
}

private fun createRecyclerViewAdapter(): BindableAdapter<ProfileListItemViewModel> {
return BindableAdapter.MultiTypeBuilder
.newBuilder<ProfileListItemViewModel, ProfileListItemViewType> { viewModel ->
when (viewModel) {
is DeviceIdItemViewModel -> ProfileListItemViewType.DEVICE_ID
is ProfileLearnerIdItemViewModel -> ProfileListItemViewType.LEARNER_ID
is SyncStatusItemViewModel -> ProfileListItemViewType.SYNC_STATUS
else -> error("Encountered unexpected view model: $viewModel")
}
return multiTypeBuilderFactory.create<ProfileListItemViewModel,
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
ProfileListItemViewType> { viewModel ->
when (viewModel) {
is DeviceIdItemViewModel -> ProfileListItemViewType.DEVICE_ID
is ProfileLearnerIdItemViewModel -> ProfileListItemViewType.LEARNER_ID
is SyncStatusItemViewModel -> ProfileListItemViewType.SYNC_STATUS
else -> error("Encountered unexpected view model: $viewModel")
}
.setLifecycleOwner(fragment)
}.setLifecycleOwner(fragment)
.registerViewDataBinder(
viewType = ProfileListItemViewType.DEVICE_ID,
inflateDataBinding = ProfileListDeviceIdItemBinding::inflate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import javax.inject.Inject
class CompletedStoryListFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val fragment: Fragment,
private val viewModelProvider: ViewModelProvider<CompletedStoryListViewModel>
private val viewModelProvider: ViewModelProvider<CompletedStoryListViewModel>,
private val singleTypeBuilderFactory: BindableAdapter.SingleTypeBuilder.Factory
) {

private lateinit var binding: CompletedStoryListFragmentBinding
Expand Down Expand Up @@ -52,8 +53,7 @@ class CompletedStoryListFragmentPresenter @Inject constructor(
}

private fun createRecyclerViewAdapter(): BindableAdapter<CompletedStoryItemViewModel> {
return BindableAdapter.SingleTypeBuilder
.newBuilder<CompletedStoryItemViewModel>()
return singleTypeBuilderFactory.create<CompletedStoryItemViewModel>()
.registerViewDataBinderWithSameModelType(
inflateDataBinding = CompletedStoryItemBinding::inflate,
setViewModel = CompletedStoryItemBinding::setViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import javax.inject.Inject
@FragmentScope
class DeveloperOptionsFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val fragment: Fragment
private val fragment: Fragment,
private val multiTypeBuilderFactory: BindableAdapter.MultiTypeBuilder.Factory

rt4914 marked this conversation as resolved.
Show resolved Hide resolved
) {

private lateinit var binding: DeveloperOptionsFragmentBinding
Expand Down Expand Up @@ -59,28 +61,27 @@ class DeveloperOptionsFragmentPresenter @Inject constructor(
}

private fun createRecyclerViewAdapter(): BindableAdapter<DeveloperOptionsItemViewModel> {
return BindableAdapter.MultiTypeBuilder
.newBuilder<DeveloperOptionsItemViewModel, ViewType> { viewModel ->
when (viewModel) {
is DeveloperOptionsModifyLessonProgressViewModel -> {
viewModel.itemIndex.set(0)
ViewType.VIEW_TYPE_MODIFY_LESSON_PROGRESS
}
is DeveloperOptionsViewLogsViewModel -> {
viewModel.itemIndex.set(1)
ViewType.VIEW_TYPE_VIEW_LOGS
}
is DeveloperOptionsOverrideAppBehaviorsViewModel -> {
viewModel.itemIndex.set(2)
ViewType.VIEW_TYPE_OVERRIDE_APP_BEHAVIORS
}
is DeveloperOptionsTestParsersViewModel -> {
viewModel.itemIndex.set(3)
ViewType.VIEW_TYPE_TEST_PARSERS
}
else -> throw IllegalArgumentException("Encountered unexpected view model: $viewModel")
return multiTypeBuilderFactory.create<DeveloperOptionsItemViewModel, ViewType> { viewModel ->
when (viewModel) {
is DeveloperOptionsModifyLessonProgressViewModel -> {
viewModel.itemIndex.set(0)
ViewType.VIEW_TYPE_MODIFY_LESSON_PROGRESS
}
is DeveloperOptionsViewLogsViewModel -> {
viewModel.itemIndex.set(1)
ViewType.VIEW_TYPE_VIEW_LOGS
}
is DeveloperOptionsOverrideAppBehaviorsViewModel -> {
viewModel.itemIndex.set(2)
ViewType.VIEW_TYPE_OVERRIDE_APP_BEHAVIORS
}
is DeveloperOptionsTestParsersViewModel -> {
viewModel.itemIndex.set(3)
ViewType.VIEW_TYPE_TEST_PARSERS
}
else -> throw IllegalArgumentException("Encountered unexpected view model: $viewModel")
}
}
.registerViewDataBinder(
viewType = ViewType.VIEW_TYPE_MODIFY_LESSON_PROGRESS,
inflateDataBinding = DeveloperOptionsModifyLessonProgressViewBinding::inflate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class ForceNetworkTypeFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val fragment: Fragment,
private val networkConnectionUtil: Optional<NetworkConnectionDebugUtil>,
private val viewModelProvider: ViewModelProvider<ForceNetworkTypeViewModel>
private val viewModelProvider: ViewModelProvider<ForceNetworkTypeViewModel>,
private val singleTypeBuilderFactory: BindableAdapter.SingleTypeBuilder.Factory
) {

private lateinit var binding: ForceNetworkTypeFragmentBinding
Expand Down Expand Up @@ -60,8 +61,7 @@ class ForceNetworkTypeFragmentPresenter @Inject constructor(
}

private fun createRecyclerViewAdapter(): BindableAdapter<NetworkTypeItemViewModel> {
return BindableAdapter.SingleTypeBuilder
.newBuilder<NetworkTypeItemViewModel>()
return singleTypeBuilderFactory.create<NetworkTypeItemViewModel>()
.registerViewDataBinderWithSameModelType(
inflateDataBinding = ForceNetworkTypeNetworkItemViewBinding::inflate,
setViewModel = this::bindNetworkItemView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class MarkChaptersCompletedFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val fragment: Fragment,
private val viewModelProvider: ViewModelProvider<MarkChaptersCompletedViewModel>,
private val modifyLessonProgressController: ModifyLessonProgressController
private val modifyLessonProgressController: ModifyLessonProgressController,
private val multiTypeBuilderFactory: BindableAdapter.MultiTypeBuilder.Factory
) : ChapterSelector {
private lateinit var binding: MarkChaptersCompletedFragmentBinding
private lateinit var linearLayoutManager: LinearLayoutManager
Expand Down Expand Up @@ -94,14 +95,14 @@ class MarkChaptersCompletedFragmentPresenter @Inject constructor(
}

private fun createRecyclerViewAdapter(): BindableAdapter<MarkChaptersCompletedItemViewModel> {
return BindableAdapter.MultiTypeBuilder
.newBuilder<MarkChaptersCompletedItemViewModel, ViewType> { viewModel ->
when (viewModel) {
is StorySummaryViewModel -> ViewType.VIEW_TYPE_STORY
is ChapterSummaryViewModel -> ViewType.VIEW_TYPE_CHAPTER
else -> throw IllegalArgumentException("Encountered unexpected view model: $viewModel")
}
return multiTypeBuilderFactory.create<MarkChaptersCompletedItemViewModel,
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
ViewType> { viewModel ->
when (viewModel) {
is StorySummaryViewModel -> ViewType.VIEW_TYPE_STORY
is ChapterSummaryViewModel -> ViewType.VIEW_TYPE_CHAPTER
else -> throw IllegalArgumentException("Encountered unexpected view model: $viewModel")
}
}
.registerViewDataBinder(
viewType = ViewType.VIEW_TYPE_STORY,
inflateDataBinding = MarkChaptersCompletedStorySummaryViewBinding::inflate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class MarkStoriesCompletedFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val fragment: Fragment,
private val viewModelProvider: ViewModelProvider<MarkStoriesCompletedViewModel>,
private val modifyLessonProgressController: ModifyLessonProgressController
private val modifyLessonProgressController: ModifyLessonProgressController,
private val singleTypeBuilderFactory: BindableAdapter.SingleTypeBuilder.Factory
) : StorySelector {
private lateinit var binding: MarkStoriesCompletedFragmentBinding
private lateinit var linearLayoutManager: LinearLayoutManager
Expand Down Expand Up @@ -91,8 +92,7 @@ class MarkStoriesCompletedFragmentPresenter @Inject constructor(
}

private fun createRecyclerViewAdapter(): BindableAdapter<StorySummaryViewModel> {
return BindableAdapter.SingleTypeBuilder
.newBuilder<StorySummaryViewModel>()
return singleTypeBuilderFactory.create<StorySummaryViewModel>()
.registerViewDataBinderWithSameModelType(
inflateDataBinding = MarkStoriesCompletedStorySummaryViewBinding::inflate,
setViewModel = this::bindStorySummaryView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class MarkTopicsCompletedFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val fragment: Fragment,
private val viewModelProvider: ViewModelProvider<MarkTopicsCompletedViewModel>,
private val modifyLessonProgressController: ModifyLessonProgressController
private val modifyLessonProgressController: ModifyLessonProgressController,
private val singleTypeAdapterFactory: BindableAdapter.SingleTypeBuilder.Factory
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
) : TopicSelector {
private lateinit var binding: MarkTopicsCompletedFragmentBinding
private lateinit var linearLayoutManager: LinearLayoutManager
Expand Down Expand Up @@ -89,8 +90,7 @@ class MarkTopicsCompletedFragmentPresenter @Inject constructor(
}

private fun createRecyclerViewAdapter(): BindableAdapter<TopicViewModel> {
return BindableAdapter.SingleTypeBuilder
.newBuilder<TopicViewModel>()
return singleTypeAdapterFactory.create<TopicViewModel>()
.registerViewDataBinderWithSameModelType(
inflateDataBinding = MarkTopicsCompletedTopicViewBinding::inflate,
setViewModel = this::bindTopicSummaryView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import javax.inject.Inject
class ViewEventLogsFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val fragment: Fragment,
private val viewModelProvider: ViewModelProvider<ViewEventLogsViewModel>
private val viewModelProvider: ViewModelProvider<ViewEventLogsViewModel>,
private val singleTypeAdapterFactory: BindableAdapter.SingleTypeBuilder.Factory
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
) {

private lateinit var binding: ViewEventLogsFragmentBinding
Expand Down Expand Up @@ -56,8 +57,7 @@ class ViewEventLogsFragmentPresenter @Inject constructor(
}

private fun createRecyclerViewAdapter(): BindableAdapter<EventLogItemViewModel> {
return BindableAdapter.SingleTypeBuilder
.newBuilder<EventLogItemViewModel>()
return singleTypeAdapterFactory.create<EventLogItemViewModel>()
.registerViewDataBinderWithSameModelType(
inflateDataBinding = ViewEventLogsEventLogItemViewBinding::inflate,
setViewModel = ViewEventLogsEventLogItemViewBinding::setViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import javax.inject.Inject
class HelpFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val fragment: Fragment,
private val viewModelProvider: ViewModelProvider<HelpListViewModel>
private val viewModelProvider: ViewModelProvider<HelpListViewModel>,
private val singleTypeBuilderFactory: BindableAdapter.SingleTypeBuilder.Factory
) {
private lateinit var binding: HelpFragmentBinding

Expand Down Expand Up @@ -48,8 +49,7 @@ class HelpFragmentPresenter @Inject constructor(
}

private fun createRecyclerViewAdapter(): BindableAdapter<HelpItemViewModel> {
return BindableAdapter.SingleTypeBuilder
.newBuilder<HelpItemViewModel>()
return singleTypeBuilderFactory.create<HelpItemViewModel>()
.registerViewDataBinderWithSameModelType(
inflateDataBinding = HelpItemBinding::inflate,
setViewModel = HelpItemBinding::setViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import javax.inject.Inject
class FAQListFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val fragment: Fragment,
private val viewModelProvider: ViewModelProvider<FAQListViewModel>
private val viewModelProvider: ViewModelProvider<FAQListViewModel>,
private val multiTypeBuilderFactory: BindableAdapter.MultiTypeBuilder.Factory
) {
private lateinit var binding: FaqListFragmentBinding

Expand All @@ -48,14 +49,13 @@ class FAQListFragmentPresenter @Inject constructor(
}

private fun createRecyclerViewAdapter(): BindableAdapter<FAQItemViewModel> {
return BindableAdapter.MultiTypeBuilder
.newBuilder<FAQItemViewModel, ViewType> { viewModel ->
when (viewModel) {
is FAQHeaderViewModel -> ViewType.VIEW_TYPE_HEADER
is FAQContentViewModel -> ViewType.VIEW_TYPE_CONTENT
else -> throw IllegalArgumentException("Encountered unexpected view model: $viewModel")
}
return multiTypeBuilderFactory.create<FAQItemViewModel, ViewType> { viewModel ->
when (viewModel) {
is FAQHeaderViewModel -> ViewType.VIEW_TYPE_HEADER
is FAQContentViewModel -> ViewType.VIEW_TYPE_CONTENT
else -> throw IllegalArgumentException("Encountered unexpected view model: $viewModel")
}
}
.registerViewDataBinder(
viewType = ViewType.VIEW_TYPE_HEADER,
inflateDataBinding = FaqItemHeaderBinding::inflate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import javax.inject.Inject
class LicenseListFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val fragment: Fragment,
private val resourceHandler: AppLanguageResourceHandler
private val resourceHandler: AppLanguageResourceHandler,
private val singleTypeBuilderFactory: BindableAdapter.SingleTypeBuilder.Factory
) {
private lateinit var binding: LicenseListFragmentBinding

Expand Down Expand Up @@ -51,8 +52,7 @@ class LicenseListFragmentPresenter @Inject constructor(
}

private fun createRecyclerViewAdapter(): BindableAdapter<LicenseItemViewModel> {
return BindableAdapter.SingleTypeBuilder
.newBuilder<LicenseItemViewModel>()
return singleTypeBuilderFactory.create<LicenseItemViewModel>()
.registerViewDataBinderWithSameModelType(
inflateDataBinding = LicenseItemBinding::inflate,
setViewModel = LicenseItemBinding::setViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import javax.inject.Inject
class ThirdPartyDependencyListFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val fragment: Fragment,
private val viewModelProvider: ViewModelProvider<ThirdPartyDependencyListViewModel>
private val viewModelProvider: ViewModelProvider<ThirdPartyDependencyListViewModel>,
private val singleTypeBuilderFactory: BindableAdapter.SingleTypeBuilder.Factory
) {
private lateinit var binding: ThirdPartyDependencyListFragmentBinding

Expand Down Expand Up @@ -50,8 +51,7 @@ class ThirdPartyDependencyListFragmentPresenter @Inject constructor(
}

private fun createRecyclerViewAdapter(): BindableAdapter<ThirdPartyDependencyItemViewModel> {
return BindableAdapter.SingleTypeBuilder
.newBuilder<ThirdPartyDependencyItemViewModel>()
return singleTypeBuilderFactory.create<ThirdPartyDependencyItemViewModel>()
.registerViewDataBinderWithSameModelType(
inflateDataBinding = ThirdPartyDependencyItemBinding::inflate,
setViewModel = ThirdPartyDependencyItemBinding::setViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class HintsAndSolutionDialogFragmentPresenter @Inject constructor(
private val htmlParserFactory: HtmlParser.Factory,
@DefaultResourceBucketName private val resourceBucketName: String,
@ExplorationHtmlParserEntityType private val entityType: String,
private val resourceHandler: AppLanguageResourceHandler
private val resourceHandler: AppLanguageResourceHandler,
private val multiTypeAdapterFactory: BindableAdapter.MultiTypeBuilder.Factory
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
) {

private var currentExpandedHintListIndex: Int? = null
Expand Down Expand Up @@ -167,15 +168,14 @@ class HintsAndSolutionDialogFragmentPresenter @Inject constructor(
}

private fun createRecyclerViewAdapter(): BindableAdapter<HintsAndSolutionItemViewModel> {
return BindableAdapter.MultiTypeBuilder
.newBuilder<HintsAndSolutionItemViewModel, ViewType> { viewModel ->
when (viewModel) {
is HintsViewModel -> ViewType.VIEW_TYPE_HINT_ITEM
is SolutionViewModel -> ViewType.VIEW_TYPE_SOLUTION_ITEM
is HintsDividerViewModel -> ViewType.VIEW_TYPE_HINTS_DIVIDER_ITEM
else -> throw IllegalArgumentException("Encountered unexpected view model: $viewModel")
}
return multiTypeAdapterFactory.create<HintsAndSolutionItemViewModel, ViewType> { viewModel ->
when (viewModel) {
is HintsViewModel -> ViewType.VIEW_TYPE_HINT_ITEM
is SolutionViewModel -> ViewType.VIEW_TYPE_SOLUTION_ITEM
is HintsDividerViewModel -> ViewType.VIEW_TYPE_HINTS_DIVIDER_ITEM
else -> throw IllegalArgumentException("Encountered unexpected view model: $viewModel")
}
}
.registerViewDataBinder(
viewType = ViewType.VIEW_TYPE_HINT_ITEM,
inflateDataBinding = HintsSummaryBinding::inflate,
Expand Down
Loading