-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sample with inflate for DialogFragment
- Loading branch information
1 parent
8274d6c
commit e13eff3
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...ava/by/kirich1409/viewbindingdelegate/sample/reflection/inflate/ProfileDialogFragment1.kt
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@file:Suppress("unused") | ||
|
||
package by.kirich1409.viewbindingdelegate.sample.reflection.inflate | ||
|
||
import android.app.Dialog | ||
import android.os.Bundle | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.fragment.app.DialogFragment | ||
import by.kirich1409.viewbindingdelegate.CreateMethod | ||
import by.kirich1409.viewbindingdelegate.dialogViewBinding | ||
import by.kirich1409.viewbindingdelegate.sample.R | ||
import by.kirich1409.viewbindingdelegate.sample.databinding.FragmentProfileBinding | ||
import by.kirich1409.viewbindingdelegate.viewBinding | ||
|
||
class ProfileDialogFragment1 : DialogFragment() { | ||
|
||
private val viewBinding: FragmentProfileBinding by viewBinding(createMethod = CreateMethod.INFLATE) | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
return AlertDialog.Builder(requireContext()) | ||
.setView(viewBinding.root) | ||
.create() | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ava/by/kirich1409/viewbindingdelegate/sample/reflection/inflate/ProfileDialogFragment2.kt
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@file:Suppress("unused") | ||
|
||
package by.kirich1409.viewbindingdelegate.sample.reflection.inflate | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.DialogFragment | ||
import by.kirich1409.viewbindingdelegate.CreateMethod | ||
import by.kirich1409.viewbindingdelegate.viewBinding | ||
import by.kirich1409.viewbindingdelegate.dialogViewBinding | ||
import by.kirich1409.viewbindingdelegate.sample.R | ||
import by.kirich1409.viewbindingdelegate.sample.databinding.FragmentProfileBinding | ||
|
||
class ProfileDialogFragment2 : DialogFragment() { | ||
|
||
private val viewBindingUsingReflection: FragmentProfileBinding by viewBinding(createMethod = CreateMethod.INFLATE) | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
return viewBindingUsingReflection.root | ||
} | ||
} |