Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[WIP] Japan example app #108
base: develop
Are you sure you want to change the base?
[WIP] Japan example app #108
Changes from 1 commit
56f7f02
cdc6247
76500e5
79fcb33
243c209
756ec02
8412a85
f27283a
45765f2
cb20ffd
5ac6be9
ab93f6a
ae9b3b4
f96f29a
ea2b985
820cff2
c8ed8d6
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To init a ViewModel you need to create custom factory and use it with
ViewModelProviders
: https://android.jlelse.eu/android-viewmodel-with-custom-arguments-d0ff0fba29e1There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any thoughts on having
btLimit
andbtMarket
boolean in the ViewModel vs here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they are actually the button itself, here we're make it selected or not. however it can be made more concise or nature if keep the status in viewModel and linked them together. I'll try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using the model turns out a better solution. I've got a
OrderType
in myOrderInfo
already.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!this::orderForm.isInitialized
is needed? since this is the init of the class I assumethis::orderForm.isInitialized
will returnfalse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when screen rotates, Fragment will call init again. however we don't need to init the
ViewModel
since we should reuse the model in this case. I'm still looking if there is a way to call this init only once and when it's needed. (need to dig into how Fragment works for this)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When configuration changes the fragment is destroyed and then recreated by the fragment manager. However the ViewModel survives configuration changes so when the activity is recreated and you call the ViewModelProviders here you actually get the same instance. https://developer.android.com/topic/libraries/architecture/viewmodel#lifecycle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the view model factory works well. removed the init method now.