Skip to content

Commit

Permalink
Remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
kirich1409 committed Jan 12, 2025
1 parent 986ef70 commit d545be3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package dev.androidbroadcast.vbpd.sample

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import androidx.fragment.app.DialogFragment
import dev.androidbroadcast.vbpd.sample.databinding.FragmentPersonDetailBinding
import dev.androidbroadcast.vbpd.viewBinding

class PersonFragment : Fragment(R.layout.fragment_person_detail) {
class PersonFragment : DialogFragment(R.layout.fragment_person_detail) {

private val viewBinding by viewBinding(FragmentPersonDetailBinding::bind)
private val person: Person by parcelableArgument(ARG_PERSON)
Expand All @@ -24,6 +24,12 @@ class PersonFragment : Fragment(R.layout.fragment_person_detail) {

private const val ARG_PERSON = "PERSON"

fun newInstance(person: Person): PersonFragment {
return PersonFragment().apply {
arguments = arguments(person)
}
}

fun arguments(person: Person): Bundle {
return Bundle(1).apply {
putParcelable(ARG_PERSON, person)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,12 @@ public fun <T : ViewBinding> Fragment.viewBinding(
viewBindingClass: Class<T>,
createMethod: CreateMethod = CreateMethod.BIND,
): ViewBindingProperty<Fragment, T> = when (createMethod) {
CreateMethod.BIND -> fragmentViewBinding{
CreateMethod.BIND -> fragmentViewBinding {
ViewBindingCache.getBind(viewBindingClass).bind(requireView())
}

CreateMethod.INFLATE -> {
fragmentViewBinding(
viewNeedsInitialization = false,
viewBinder = {
ViewBindingCache.getInflateWithLayoutInflater(viewBindingClass)
.inflate(layoutInflater, null, false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@file:Suppress("RedundantVisibilityModifier", "unused")
@file:JvmName("FragmentViewBindings")

package dev.androidbroadcast.vbpd
Expand All @@ -17,7 +16,6 @@ import dev.androidbroadcast.vbpd.internal.weakReference
import kotlin.reflect.KProperty

private class FragmentViewBindingProperty<F : Fragment, T : ViewBinding>(
private val viewNeedsInitialization: Boolean,
viewBinder: (F) -> T,
) : LazyViewBindingProperty<F, T>(viewBinder) {

Expand Down Expand Up @@ -56,7 +54,7 @@ private class FragmentViewBindingProperty<F : Fragment, T : ViewBinding>(
this.lifecycleCallbacks = null
}

internal inner class VBFragmentLifecycleCallback(
inner class VBFragmentLifecycleCallback(
fragment: Fragment,
) : FragmentManager.FragmentLifecycleCallbacks() {

Expand Down Expand Up @@ -129,8 +127,7 @@ public inline fun <F : Fragment, T : ViewBinding> Fragment.viewBinding(

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public fun <F : Fragment, T : ViewBinding> fragmentViewBinding(
viewNeedsInitialization: Boolean = true,
viewBinder: (F) -> T,
): ViewBindingProperty<F, T> {
return FragmentViewBindingProperty(viewNeedsInitialization, viewBinder)
return FragmentViewBindingProperty(viewBinder)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("unused")

package dev.androidbroadcast.vbpd

import android.view.View
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@file:Suppress("unused")
@file:JvmName("ViewHolderBindings")

package dev.androidbroadcast.vbpd
Expand Down

0 comments on commit d545be3

Please sign in to comment.