This is a migrated thread and some comments may be shown as answers.
Day view calendar jump back to current date
3 Answers 27 Views
This is a migrated thread and some comments may be shown as answers.
Shalin
Top achievements
Rank 1
Shalin asked on 10 Apr 2019, 10:58 AM

hi,

when user swipe day calendar, i am fetching appointments from server in calendar DisplayDateChanged event, those server calls are under "await". This take some time to complete and then use those data to set calendar appointment source, then DisplayDateChanged event automatically fires and setting date to previously where it was. so calendar can not scroll to where user wants. This may be because of time taken to fetch data or again setting appointment source of calendar.

can reproduce using following code.

private async void daycalendar_DisplayDateChanged (object sender, Telerik.XamarinForms.Common.ValueChangedEventArgs<object> e)
       {
          
 
           await longrun();
       }

 

private async Task longrun()
      {
          ObservableCollection<testmodel> items = new ObservableCollection<testmodel>();
          for (int i = 0; i < 10; i++)
          {
              var item = new testmodel
              {
                  Title = "Meeting with Tom" + i,
                  Detail = "Sea Garden",
                  StartDate = DateTime.Now,
                  EndDate = DateTime.Now.AddHours(1),
                  Color = Color.Tomato
              };
              items.Add(item);
               
          }
       
          weekcalendar.AppointmentsSource = items;
      }
  }

 

testmodel as is this 

public class testmodel : IAppointment, INotifyPropertyChanged

 

tested only in Android. Any solution ?

 

 

3 Answers, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 11 Apr 2019, 09:52 AM
Hello Shalin,

We are aware with this issue and we have it logged in our Feedback portal at the following link:

https://feedback.telerik.com/xamarin/1400314-calendar-android-selectionchanged-is-triggered-twice-when-changing-the-appointments-collection-at-runtime

This issue occurs in scenarios when DayView, MultiDayView are used. 

Workaround: 

The workaround I could suggest is replace the ObservableCollection with List. After that implement a custom renderer for Android, override the OnElementPropertyChanged method and inside it call the UpdateCalendar method. 

I have attached a sample that shows how the workaround is implemented. Also note that when new event is added it is not displayed in the Calendar timeline. This issue is related to the issue with the Calendar Appointments collection.

Let me know if I can assist with anything else.

Regards,
Didi
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Shalin
Top achievements
Rank 1
answered on 11 Apr 2019, 10:22 AM

hi,

thank you for the provided workaround. But after lot of effort i make it working using Task.Run.

server calls or time consuming codes in Task.Run

Task.Run(async () =>
                       {
                           await longrun();
 
                       });

 

if you want to notify UI or any changes happen in Binded properties which are binded to UI (ex: AppointmentSource), those will run in 

Device.BeginInvokeOnMainThread(() =>
               {
                  //UI notify or changes happen in binded properties
               });

 

Thank you, but these bugs are really annoying.

Fixes must come faster than this speed

 

0
Didi
Telerik team
answered on 11 Apr 2019, 10:33 AM
Hello Shalin,

I am glad to hear you have managed to find a different workaround.

The severity of the issue comes from the native Android calendar and it makes it more complex. I can assure you that I have escalated this issue to the developer team, still at this point I could not commit a time-frame when a possible fix for the issue could be provided. 

Please follow the Feedback item in order to receive an email notification as soon as there is any progress on it.  

Regards,
Didi
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Asked by
Shalin
Top achievements
Rank 1
Answers by
Didi
Telerik team
Shalin
Top achievements
Rank 1
Share this question
or