-
-
Save hasanmohdkhan/08230354e8475812720e27022bfe6474 to your computer and use it in GitHub Desktop.
Revisions
-
adam-hurwitz revised this gist
Apr 8, 2020 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,5 +11,6 @@ class SomeViewModel(private val someString: String) : ViewModel() { class Fragment: Fragment() { // Create VM in activity/fragment with VM factory. // Don't forget to add 'kotlinOptions { jvmTarget = '1.8' } to build.gradle (:app)' val someViewModel: SomeViewModel by viewModels { SomeViewModelFactory("someString") } } -
adam-hurwitz revised this gist
Feb 8, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ // Override ViewModelProvider.NewInstanceFactory to create the ViewModel (VM). class SomeViewModelFactory(private val someString: String): ViewModelProvider.NewInstanceFactory() { override fun <T : ViewModel?> create(modelClass: Class<T>): T = SomeViewModel(someString) as T } -
adam-hurwitz revised this gist
Feb 8, 2020 . No changes.There are no files selected for viewing
-
adam-hurwitz revised this gist
Feb 8, 2020 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,13 +3,13 @@ class SomeViewModelFactory(private val someString: String): ViewModelProvider.Ne override fun <T : ViewModel?> create(modelClass: Class<T>): T = SomeViewModel(someString) as T } class SomeViewModel(private val someString: String) : ViewModel() { init { //TODO: Use 'someString' to init process when VM is created. i.e. Get data request. } } class Fragment: Fragment() { // Create VM in activity/fragment with VM factory. val someViewModel: SomeViewModel by viewModels { SomeViewModelFactory("someString") } } -
adam-hurwitz revised this gist
Feb 8, 2020 . No changes.There are no files selected for viewing
-
adam-hurwitz revised this gist
Feb 8, 2020 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,15 @@ // Override ViewModelProvider.NewInstanceFactory to create ViewModel (VM) class SomeViewModelFactory(private val someString: String): ViewModelProvider.NewInstanceFactory() { override fun <T : ViewModel?> create(modelClass: Class<T>): T = SomeViewModel(someString) as T } class Fragment: Fragment() { // Create VM in activity/fragment with VM factory. val someViewModel: SomeViewModel by viewModels { SomeViewModelFactory("someString") } } class SomeViewModel(private val someString: String) : ViewModel() { init { //TODO: Use 'someString' to init process when VM is created. i.e. Get data request. } } -
adam-hurwitz revised this gist
Feb 8, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,5 +5,5 @@ class CustomViewModelFactory(private val someString: String): ViewModelProvider. class Fragment: Fragment() { // Create VM in activity/fragment with VM factory. val contentViewModel: ContentViewModel by viewModels { CustomViewModelFactory("someString") } } -
adam-hurwitz revised this gist
Feb 8, 2020 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,5 +3,7 @@ class CustomViewModelFactory(private val someString: String): ViewModelProvider. override fun <T : ViewModel?> create(modelClass: Class<T>): T = SomeViewModel(someString) as T } class Fragment: Fragment() { // Create VM in activity/fragment with VM factory. val feedViewModel: FeedViewModel by viewModels { CustomViewModelFactory("someString") } } -
adam-hurwitz revised this gist
Feb 8, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,5 +3,5 @@ class CustomViewModelFactory(private val someString: String): ViewModelProvider. override fun <T : ViewModel?> create(modelClass: Class<T>): T = SomeViewModel(someString) as T } // Create VM in activity/fragment with VM factory. val feedViewModel: FeedViewModel by viewModels { CustomViewModelFactory("someString") } -
adam-hurwitz created this gist
Feb 8, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ // Override ViewModelProvider.NewInstanceFactory to create ViewModel (VM) class CustomViewModelFactory(private val someString: String): ViewModelProvider.NewInstanceFactory() { override fun <T : ViewModel?> create(modelClass: Class<T>): T = SomeViewModel(someString) as T } // Create ViewModel in Activity/Fragment with VM factory. val feedViewModel: FeedViewModel by viewModels { CustomViewModelFactory("someString") }