Skip to content

Commit

Permalink
[Feature] Update dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghai committed Jun 30, 2022
1 parent e8406f7 commit 29e7002
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.exifinterface:exifinterface:1.3.3'
implementation 'androidx.fragment:fragment-ktx:1.4.1'
def androidx_lifecycle_version = '2.4.1'
implementation 'androidx.fragment:fragment-ktx:1.5.0'
def androidx_lifecycle_version = '2.5.0'
implementation "androidx.lifecycle:lifecycle-common-java8:$androidx_lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$androidx_lifecycle_version"
implementation "androidx.lifecycle:lifecycle-process:$androidx_lifecycle_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ import androidx.fragment.app.viewModels
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStoreOwner
import androidx.lifecycle.viewmodel.CreationExtras

inline fun <reified VM : ViewModel> Fragment.viewModels(
noinline ownerProducer: () -> ViewModelStoreOwner = { this },
noinline extrasProducer: (() -> CreationExtras)? = null,
noinline factoryProducer: (() -> () -> VM)? = null
) = viewModels<VM>(
ownerProducer,
extrasProducer,
factoryProducer?.let {
{
val factory = it()
Expand All @@ -28,5 +31,6 @@ inline fun <reified VM : ViewModel> Fragment.viewModels(
)

inline fun <reified VM : ViewModel> Fragment.activityViewModels(
noinline extrasProducer: (() -> CreationExtras)? = null,
noinline factoryProducer: (() -> () -> VM)? = null
) = viewModels(::requireActivity, factoryProducer)
) = viewModels(::requireActivity, extrasProducer, factoryProducer)

0 comments on commit 29e7002

Please sign in to comment.