Skip to content

Commit

Permalink
Merge pull request #479 from skydoves/refactor/newinstance
Browse files Browse the repository at this point in the history
Migrate to getDeclaredConstructor from newInstance
  • Loading branch information
skydoves authored Aug 28, 2023
2 parents 9c97e77 + 4169f25 commit a9c6577
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ internal class ActivityBalloonLazy<out T : Balloon.Factory>(
get() {
var instance = cached
if (instance === null) {
val factory = factory::java.get().newInstance()
val factory = factory::java.get().getDeclaredConstructor().newInstance()
instance = factory.create(context, lifecycleOwner)
cached = instance
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal class FragmentBalloonLazy<out T : Balloon.Factory>(
)
}

val factory = factory::java.get().newInstance()
val factory = factory::java.get().getDeclaredConstructor().newInstance()
val lifecycle = if (fragment.view !== null) {
fragment.viewLifecycleOwner
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal class ViewBalloonLazy<out T : Balloon.Factory>(
var instance = cached
if (instance === null) {
val context = view.context
val factory = factory::java.get().newInstance()
val factory = factory::java.get().getDeclaredConstructor().newInstance()
val viewTreeLifecycle = view.findViewTreeLifecycleOwner()
when {
viewTreeLifecycle != null -> {
Expand Down

0 comments on commit a9c6577

Please sign in to comment.