Skip to content

Commit

Permalink
防止重复注册
Browse files Browse the repository at this point in the history
  • Loading branch information
yizems authored May 9, 2020
1 parent eef3f8d commit d15902a
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,14 @@ object SavedDelegateHelper {
savedStateRegistry: SavedStateRegistry,
obj: Any
) {
if (isRegisted(obj)) {
return
}
val provider = getOrCreateSavedProvider(obj)
savedStateRegistry.registerSavedStateProvider(KEY, provider)
}
/** 是否已经注册 */
fun isRegisted(obj: Any) = providers.containsKey(obj.hashCode())

/**
* 注册
Expand Down Expand Up @@ -139,4 +144,4 @@ object SavedDelegateHelper {
}
return bundle
}
}
}

0 comments on commit d15902a

Please sign in to comment.