Day view calendar jump back to current date

4 posts, 0 answers
  1. Shalin
    Shalin avatar
    61 posts
    Member since:
    May 2015

    Posted 10 Apr 2019 Link to this post

    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 ?

     

     

  2. Didi
    Admin
    Didi avatar
    384 posts

    Posted 11 Apr 2019 Link to this post

    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
  3. Shalin
    Shalin avatar
    61 posts
    Member since:
    May 2015

    Posted 11 Apr 2019 Link to this post

    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

     

  4. Didi
    Admin
    Didi avatar
    384 posts

    Posted 11 Apr 2019 Link to this post

    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
Back to Top