Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package Google.Android.Material.Slider missing AddOnChangeListener() #450

Closed
luraze opened this issue Dec 17, 2021 · 2 comments
Closed

Package Google.Android.Material.Slider missing AddOnChangeListener() #450

luraze opened this issue Dec 17, 2021 · 2 comments

Comments

@luraze
Copy link

luraze commented Dec 17, 2021

Using latest package of Xamarin.Google.Android.Material (1.4.0.4). Slider has ClearOnChangeListener(), but missing AddOnChangeListener(). Maybe mapping needs to be based on newer version of material package?

Thanks.

Edit:
Ok, I found this post that seems to work: https://stackoverflow.com/questions/67723339/how-to-implement-google-android-material-slider-changelistener-or-addonchangelis

@jpobst
Copy link
Contributor

jpobst commented Mar 10, 2022

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 in the issue description.

@jpobst
Copy link
Contributor

jpobst commented May 24, 2022

Closing as duplicate of #230.

@jpobst jpobst closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants