Open tipa opened 3 years ago
Binding issue:
13> BINDINGSGENERATOR : warning BG8800: Unknown parameter type L in method AddOnChangeListener in managed type Google.Android.Material.Slider.RangeSlider.
13> C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.Core.targets(61,5): message BG0000: warning BG8800: Unknown parameter type L in method AddOnChangeListener in managed type Google.Android.Material.Slider.RangeSlider.
13> BINDINGSGENERATOR : warning BG8800: Unknown parameter type T in method AddOnSliderTouchListener in managed type Google.Android.Material.Slider.RangeSlider.
13> C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.Core.targets(61,5): message BG0000: warning BG8800: Unknown parameter type T in method AddOnSliderTouchListener in managed type Google.Android.Material.Slider.RangeSlider.
13> BINDINGSGENERATOR : warning BG8800: Unknown parameter type L in method RemoveOnChangeListener in managed type Google.Android.Material.Slider.RangeSlider.
13> C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.Core.targets(61,5): message BG0000: warning BG8800: Unknown parameter type L in method RemoveOnChangeListener in managed type Google.Android.Material.Slider.RangeSlider.
13> BINDINGSGENERATOR : warning BG8800: Unknown parameter type T in method RemoveOnSliderTouchListener in managed type Google.Android.Material.Slider.RangeSlider.
13> C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.Core.targets(61,5): message BG0000: warning BG8800: Unknown parameter type T in method RemoveOnSliderTouchListener in managed type Google.Android.Material.Slider.RangeSlider.
13> BINDINGSGENERATOR : warning BG8800: Unknown parameter type L in method AddOnChangeListener in managed type Google.Android.Material.Slider.Slider.
13> C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.Core.targets(61,5): message BG0000: warning BG8800: Unknown parameter type L in method AddOnChangeListener in managed type Google.Android.Material.Slider.Slider.
13> BINDINGSGENERATOR : warning BG8800: Unknown parameter type T in method AddOnSliderTouchListener in managed type Google.Android.Material.Slider.Slider.
13> C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.Core.targets(61,5): message BG0000: warning BG8800: Unknown parameter type T in method AddOnSliderTouchListener in managed type Google.Android.Material.Slider.Slider.
13> BINDINGSGENERATOR : warning BG8800: Unknown parameter type L in method RemoveOnChangeListener in managed type Google.Android.Material.Slider.Slider.
13> C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.Core.targets(61,5): message BG0000: warning BG8800: Unknown parameter type L in method RemoveOnChangeListener in managed type Google.Android.Material.Slider.Slider.
13> BINDINGSGENERATOR : warning BG8800: Unknown parameter type T in method RemoveOnSliderTouchListener in managed type Google.Android.Material.Slider.Slider.
13> C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.Core.targets(61,5): message BG0000: warning BG8800: Unknown parameter type T in method RemoveOnSliderTouchListener in managed type Google.Android.Material.Slider.Slider.
13> BINDINGSGENERATOR : warning BG8700: Unknown return type P in method GetPrimaryAnimatorProvider in managed type Google.Android.Material.Transition.MaterialElevationScale.
Reproduced for RangeSlider too. Or maybe I should use other API ?
Although have the same issue
Any updates?
workaround:
var method = Class.ForName("com.google.android.material.slider.BaseSlider").GetDeclaredMethods().FirstOrDefault(x => x.Name == "addOnChangeListener");
method?.Invoke(slider, this); // this is implementing IBaseOnChangeListener
Please try 1.3.0 and provide feedback here.
If it is not fixed automagically I will dive in next week
@moljac thanks for the new bindings - great stuff! 🥳 Unfortunately no magic fix for this issue :(
@tipa
Thanks.
OK. I will need to dig in. Hopefully soon
Friendly ping :) Would be great if this could be fixed so no workaround is necessary
Sadly, this issue is still present with 1.4.0
This is a workaround until they fix binding issue:
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState, Resource.Layout.my_activity);
slider = FindViewById<Slider>(Resource.Id.slider);
slider.Touch += Slider_Touch;
}
private void Slider_Touch(object sender, View.TouchEventArgs e)
{
switch (e.Event.Action)
{
case MotionEventActions.Move:
case MotionEventActions.Up:
OnValueChange(slider, slider.Value, true); //(Slider slider, float value, boolean fromUser)
break;
}
e.Handled = false;
}
//This footprint matches native library callback
private void OnValueChange(Java.Lang.Object sender, float value, bool fromUser)
{
//Do what you want to do as if you are listening to ValueChanged event (or at least very near to actual event)
}
1.4.0.5 still not work
Moving my comment from #450 here:
Ugh, this one is a mess. According to the public documentation Slider
is defined like this:
public class Slider extends View {
public void addOnChangeListener (L listener) { ... }
}
One may be wondering what L
is because it isn't specified anywhere. That's because decompiling the .jar
shows that the public documentation is lying:
public class Slider extends BaseSlider<Slider, Slider.OnChangeListener, Slider.OnSliderTouchListener>
{
...
}
abstract class BaseSlider<S extends BaseSlider<S, L, T>, L extends BaseOnChangeListener<S>, T extends BaseOnSliderTouchListener<S>> extends View
{
public void addOnChangeListener(@NonNull L listener) { ... }
}
That is, the public
Slider
class inherits from the private
BaseSlider
class, which isn't allowed in C#. Our tooling attempts to fix this and have Slider
inherit from the public View
instead, and copy all the methods that it can from the BaseSlider
class directly into the Slider
class.
However, due to the lack of generics support in our tooling, it is unable to copy the addOnChangeListener
method which requires a generic parameter. Thus this method is dropped from the binding:
warning BG8800: Unknown parameter type 'L' for member 'Google.Android.Material.Slider.Slider.AddOnChangeListener (L)'.
I would suggest continuing to use the workaround listed above.
Is there no progress with this. Right now it's not very convenient to use these controls
Still same with "1.8.0" version. Any progress ?
I'm also affected by this.
I understand that updating the tooling to support this edge case would be hard, but is it not possible to add the required code manually in the bindings? I believe something like this is done, for instance, to add method overloads that accept .NET classes like System.Text.StringBuilder to improve interoperability between .NET and Java.
Just me being nosy here, what's the tooling issue? Is it to do with all generic methods like this?
var method = Class.ForName("com.google.android.material.slider.BaseSlider").GetDeclaredMethods().FirstOrDefault(x => x.Name == "addOnChangeListener"); method?.Invoke(slider, this); // this is implementing IBaseOnChangeListener
With the latest Nuget packages, this warning now also shows the deprecation warning:
While this type is 'public', Google considers it internal API and reserves the right to modify or delete it in the future. Use at your own risk
When trying to use the non-deprecated Slider.IOnChangeListener
class (which inherits from IBaseOnChangeListener
) it leads to other errors:
1>obj\Debug\net8.0-android\android\src\crc64cd18cf298694e84d\Dialog.java(4,8): javac.exe error JAVAC0000: error: BaseOnChangeListener cannot be inherited with different arguments: <com.google.android.material.slider.Slider> and <>
1>obj\Debug\net8.0-android\android\src\crc64cd18cf298694e84d\Dialog.java(4,8): javac.exe error JAVAC0000: public class Dialog
1>obj\Debug\net8.0-android\android\src\crc64cd18cf298694e84d\Dialog.java(4,8): javac.exe error JAVAC0000:
1>obj\Debug\net8.0-android\android\src\crc64cd18cf298694e84d\Dialog.java(59,14): javac.exe error JAVAC0000: error: name clash: class Dialog has two methods with the same erasure, yet neither overrides the other
1>obj\Debug\net8.0-android\android\src\crc64cd18cf298694e84d\Dialog.java(59,14): javac.exe error JAVAC0000: public void onValueChange (com.google.android.material.slider.Slider p0, float p1, boolean p2)
1>obj\Debug\net8.0-android\android\src\crc64cd18cf298694e84d\Dialog.java(59,14): javac.exe error JAVAC0000: first method: onValueChange(Slider,float,boolean) in BaseOnChangeListener
1>obj\Debug\net8.0-android\android\src\crc64cd18cf298694e84d\Dialog.java(59,14): javac.exe error JAVAC0000: second method: onValueChange(Object,float,boolean) in Dialog
1>obj\Debug\net8.0-android\android\src\crc64cd18cf298694e84d\Dialog.java(59,14): javac.exe error JAVAC0000:
1>obj\Debug\net8.0-android\android\src\crc64cd18cf298694e84d\Dialog.java(67,14): javac.exe error JAVAC0000: error: name clash: onValueChange(Object,float,boolean) in Dialog and onValueChange(Slider,float,boolean) in BaseOnChangeListener have the same erasure, yet neither overrides the other
1>obj\Debug\net8.0-android\android\src\crc64cd18cf298694e84d\Dialog.java(67,14): javac.exe error JAVAC0000: public void onValueChange (java.lang.Object p0, float p1, boolean p2)
1>obj\Debug\net8.0-android\android\src\crc64cd18cf298694e84d\Dialog.java(67,14): javac.exe error JAVAC0000:
It really would be appreciated if some working workaround could be provided by the bindings, without having to implement it by ourselves that causes build warnings
Version Information
Describe your Issue:
Slider.IOnChangeListener
is bound, but there is no way to add it to the Slider class, theaddOnChangeListener
method hasn't been boundSteps to Reproduce (with link to sample solution if possible):