xamarin / AndroidX

AndroidX bindings for .NET for Android
MIT License
185 stars 45 forks source link

Improve MaterialDatePicker bindings #105

Closed tipa closed 4 years ago

tipa commented 4 years ago

Support Libraries Version (eg: 23.3.0):

Xamarin.Google.Android.Material 1.1.0-rc3

Describe your Issue:

I am using the MaterialDatePicker class and want to retrieve the selected date(s) after the user closes the picker. In order to do so, one has to use the AddOnPositiveButtonClickListener method.

Currently this makes it difficult to use that class in a Xamarin.Android project, especially when there are mutliple DateRangePickers used in the same Activity.

Steps to Reproduce:

var picker = MaterialDatePicker.Builder.DateRangePicker().Build();
picker.AddOnPositiveButtonClickListener(this);
picker.Show(Activity.SupportFragmentManager, picker.ToString());

public void OnPositiveButtonClick(Java.Lang.Object p0) // no reference to MaterialDatePicker
{
... // p0 can be AndroidX.Core.Util.Pair in case of DateRangePicker and long in case of  DatePicker
}
moljac commented 4 years ago

Servus @tipa Thanks for feedback and suggestions.

Really short:

I would have expected this method to be exposed as C# event that I can assign an event handler to.

Yes we do that in the core Android (Xamarin.Android), but due to the huge amount of artifacts bound in AndroidX, Google.Play.Services+Firebase and old legacy Android.Support I doubt this will be done soon. Unless community (guess who am I thinking of) helps a bit.

The callback parameter is Java.Lang.Object instead of AndroidX.Core.Util.Pair in case of DateRangePicker

Could be. I would need to see why that was changed: tool or us/me.

Namely:

                     java != c#
                    java idioms != c# idioms

Some stuff will be easier in C#9 with return type covariance, but then we need to switch to C#9 and do numerous manual stuff or write a tool that does improve bindings according to users' wishes.

The Java MaterialDatePicker<S> is using Generics, I think the bindings should do too

Again:

                  java generics != c# generics

this means I would need to dig deeper into bindings in order to see what can be done.

I will take a look, but most likely I will close this issue soon, because I don't think I will have time to implement this soon.

tipa commented 4 years ago

Ok, no worries. I am able to use the picker nonetheless with some small adjustments. Completely understand that the numerous Google libraries are overwhelming

moljac commented 4 years ago

@tipa I have finally caught up with GPS-FB. Now we should be on the same cadence with google (maybe few weeks slower, but not months).

And we are working HARD on improving our tooling and improving features you have suggested, but those are quite low priority.

You just keep on feeding issues and we can discuss.

If you want reopen this one in few months.

Grüße