This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"click": [ | |
{ | |
"startActivityFromFragment": { | |
"activity": "MvRxActivity", | |
"calledFrom": "AccountLandingFragment", | |
"extras": "[fragment_class=com.airbnb.android.profile.UserProfileFragment, fragment_args=UserProfileArgs(userId=1)]", | |
"intentFlags": 0, | |
"requestCode": 102 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"fragment_container->coordinator_layout->recycler_view->AccountDocumentMarqueeModel->link_text": { | |
"view": "TextView", | |
"viewId": "link_text", | |
"click": [ | |
{ | |
"startActivityFromFragment": { | |
"activity": "MvRxActivity", | |
"calledFrom": "AccountLandingFragment", | |
"extras": "[fragment_class=com.airbnb.android.profile.UserProfileFragment, fragment_args=UserProfileArgs(userId=1)]", | |
"intentFlags": 0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
args("No dates") { | |
setNull { ::checkInDate } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
state("Not super hosted") { | |
setFalse { ::listingDetails { success { ::isHostedBySuperhost } } } | |
.setFalse { ::listingDetails { success { ::primaryHost { ::isSuperhost } } } } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
state("Show cancellation policy subtitle") { | |
set { ::bookingDetails { success { ::cancellationSection { ::showSubtitle } } } }.with { true } | |
// Can also be written more simply as: | |
setTrue { ::bookingDetails { success { ::cancellationSection { ::showSubtitle } } } } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
state("Empty results") { | |
// Nested copying - gross! | |
copy(request = Success(request.copy(results = emptyList()))) | |
// A cleaner way to specify the same thing | |
set { ::request { success { ::results } } }.with { emptyList() } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun provideMocks() = mockSingleViewModel( | |
viewModelReference = DadJokeFragment::viewModel, | |
defaultState = mockDadJokeState | |
) { | |
state("Loading") { | |
copy(jokes = Loading()) | |
} | |
state("Empty results") { | |
copy(jokes = Success(jokes.copy(results = emptyList()))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val mockDadJokeState = DadJokeState( | |
jokes = Success( | |
value = JokesResponse( | |
nextPage = 3, | |
results = listOf( | |
Joke( | |
id = "0LuXvkq4Muc", | |
joke = "I'm tired of following my dreams. I'm just going to ask them where they are going and meet up with them later." | |
), | |
Joke( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DadJokeFragment : MvRxFragment() { | |
val viewModel: DadJokeViewModel by fragmentViewModel() | |
override fun provideMocks() = mockSingleViewModel( | |
viewModelReference = DadJokeFragment::viewModel, | |
defaultState = mockDadJokeState | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class MyState(val text: String = "Hello World") : MvRxState | |
class MyViewModel(state: MyState) : BaseMvRxViewModel<MyState>(state) | |
class MyFragment : MvRxFragment() { | |
val viewModel: MyViewModel by fragmentViewModel() | |
fun epoxyController() = simpleController(viewModel) { state -> | |
textRow { |