File tree Expand file tree Collapse file tree 2 files changed +14
-15
lines changed
java/com/pureswift/swiftandroid Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -16,16 +16,9 @@ class Fragment(val swiftObject: SwiftObject): android.app.Fragment() {
1616 ): View ? {
1717 val context = this .context
1818 checkNotNull(context)
19- val view = this .onCreateViewSwift(inflater, container, savedInstanceState)
20- checkNotNull(view)
2119 val linearLayout = LinearLayout (context)
22- linearLayout.addView(view)
23- return view
20+ return linearLayout
2421 }
2522
26- external fun onCreateViewSwift (
27- inflater : LayoutInflater ,
28- container : ViewGroup ? ,
29- savedInstanceState : Bundle ?
30- ): View
23+ external override fun onViewCreated (view : View , savedInstanceState : Bundle ? )
3124}
Original file line number Diff line number Diff line change @@ -21,21 +21,27 @@ public extension Fragment {
2121
2222 struct Callback {
2323
24- var onCreateView : ( ( AndroidView . LayoutInflater ? , AndroidView . ViewGroup ? , AndroidOS . Bundle ? ) -> ( AndroidView . View ) )
24+ var onViewCreated : ( ( AndroidView . View , AndroidOS . Bundle ? ) -> ( ) ) ?
2525 }
2626}
2727
2828@JavaImplementation ( " com.pureswift.swiftandroid.Fragment " )
2929extension Fragment {
3030
3131 @JavaMethod
32- func onCreateViewSwift(
33- inflater: AndroidView . LayoutInflater ? ,
34- container: AndroidView . ViewGroup ? ,
32+ func onViewCreated(
33+ view: AndroidView . View ? ,
3534 savedInstanceState: AndroidOS . Bundle ?
36- ) -> AndroidView . View ? {
35+ ) {
3736 log ( " \( self ) . \( #function) " )
38- return callback. onCreateView ( inflater, container, savedInstanceState)
37+ guard let onViewCreated = callback. onViewCreated else {
38+ return
39+ }
40+ guard let view else {
41+ assertionFailure ( " Missing view " )
42+ return
43+ }
44+ onViewCreated ( view, savedInstanceState)
3945 }
4046}
4147
You can’t perform that action at this time.
0 commit comments