@@ -85,7 +85,7 @@ public static void AddInterfaceListenerEventsAndProperties (TypeWriter tw, Inter
85
85
86
86
AddInterfaceListenerEventsAndProperties ( tw , iface , target , name , setter ,
87
87
string . Format ( "__v => {0} = __v" , prop . Name ) ,
88
- string . Format ( "__v => {0} = null" , prop . Name ) , opt ) ;
88
+ string . Format ( "__v => {0} = null" , prop . Name ) , opt , prop . Getter ) ;
89
89
} else {
90
90
refs . Add ( method . Name ) ;
91
91
string rm = null ;
@@ -103,7 +103,7 @@ public static void AddInterfaceListenerEventsAndProperties (TypeWriter tw, Inter
103
103
104
104
AddInterfaceListenerEventsAndProperties ( tw , iface , target , name , method . Name ,
105
105
method . Name ,
106
- remove , opt ) ;
106
+ remove , opt , method ) ;
107
107
}
108
108
}
109
109
@@ -113,7 +113,9 @@ public static void AddInterfaceListenerEventsAndProperties (TypeWriter tw, Inter
113
113
tw . Methods . Add ( new CreateImplementorMethod ( iface , opt ) ) ;
114
114
}
115
115
116
- public static void AddInterfaceListenerEventsAndProperties ( TypeWriter tw , InterfaceGen iface , ClassGen target , string name , string connector_fmt , string add , string remove , CodeGenerationOptions opt )
116
+ // Parameter 'setListenerMethod' refers to the method used to set the listener, like 'addOnRoutingChangedListener'/'setOnRoutingChangedListener'.
117
+ // This is used to determine what API level the listener setter is available on.
118
+ public static void AddInterfaceListenerEventsAndProperties ( TypeWriter tw , InterfaceGen iface , ClassGen target , string name , string connector_fmt , string add , string remove , CodeGenerationOptions opt , Method setListenerMethod )
117
119
{
118
120
if ( ! iface . IsValid )
119
121
return ;
@@ -128,11 +130,11 @@ public static void AddInterfaceListenerEventsAndProperties (TypeWriter tw, Inter
128
130
if ( target . ContainsName ( nameUnique ) )
129
131
nameUnique += "Event" ;
130
132
131
- AddInterfaceListenerEventOrProperty ( tw , iface , method , target , nameUnique , connector_fmt , add , remove , opt ) ;
133
+ AddInterfaceListenerEventOrProperty ( tw , iface , method , target , nameUnique , connector_fmt , add , remove , opt , setListenerMethod ) ;
132
134
}
133
135
}
134
136
135
- public static void AddInterfaceListenerEventOrProperty ( TypeWriter tw , InterfaceGen iface , Method method , ClassGen target , string name , string connector_fmt , string add , string remove , CodeGenerationOptions opt )
137
+ public static void AddInterfaceListenerEventOrProperty ( TypeWriter tw , InterfaceGen iface , Method method , ClassGen target , string name , string connector_fmt , string add , string remove , CodeGenerationOptions opt , Method setListenerMethod )
136
138
{
137
139
if ( method . EventName == string . Empty )
138
140
return ;
@@ -157,7 +159,7 @@ public static void AddInterfaceListenerEventOrProperty (TypeWriter tw, Interface
157
159
var mt = target . Methods . Where ( method => string . Compare ( method . Name , connector_fmt , StringComparison . OrdinalIgnoreCase ) == 0 && method . IsListenerConnector ) . FirstOrDefault ( ) ;
158
160
var hasHandlerArgument = mt != null && mt . IsListenerConnector && mt . Parameters . Count == 2 && mt . Parameters [ 1 ] . Type == "Android.OS.Handler" ;
159
161
160
- tw . Events . Add ( new InterfaceListenerEvent ( iface , name , nameSpec , full_delegate_name , connector_fmt , add , remove , hasHandlerArgument , opt ) ) ;
162
+ tw . Events . Add ( new InterfaceListenerEvent ( iface , setListenerMethod , name , nameSpec , full_delegate_name , connector_fmt , add , remove , hasHandlerArgument , opt ) ) ;
161
163
}
162
164
} else {
163
165
if ( opt . GetSafeIdentifier ( name ) != name ) {
0 commit comments