Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Xamarin Scheduling: OnItemClick, EnsureVisible, ObjectDisposedException (Read 9762 times)
Heli
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 44
Joined: Aug 29th, 2016
Xamarin Scheduling: OnItemClick, EnsureVisible, ObjectDisposedException
Feb 27th, 2017 at 9:30am
Print Post  
Hi,

some issues with Xamarin Scheduling (Timetable view) on Android (not tested with iOS in detail yet):

* ItemClick event fires once at first click, at second click it fires twice, at third click three times, and so on.
Is there something like a handled flag I should set?

* calendar.EnsureVisible(item)
--> scrolls item only partially into view, please ensure it is shown fully.
I.e. appointment of 3 hours at afternoon, it scrolls vertically and shows me the first 30 minutes of this big item.
I have to scroll myself down to see it fully.

* Exceptions/crashes when closing and reopening ContentPage multiple times:
Unhandled Exception: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'MindFusion.Scheduling.Android.CalendarRenderer'.
Does not happen on similar pages without calendar control on it.
Is there something I can do (call) in Xamarin.Forms ContentPage OnAppearing / OnDisappearing / ... events in order to help Scheduling with a proper cleanup/deregistration? I.e. sort of a flag to stop drawing as page is disappearing?

Thank you for your great support!

Regards,
Heli
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Xamarin Scheduling: OnItemClick, EnsureVisible, ObjectDisposedException
Reply #1 - Feb 27th, 2017 at 3:35pm
Print Post  
Hi,

Quote:
* ItemClick event fires once at first click, at second click it fires twice, at third click three times, and so on.
Is there something like a handled flag I should set?

I cannot reproduce this. Are you sure you are not attaching an event handler multiple times?

Quote:
* calendar.EnsureVisible(item)
--> scrolls item only partially into view, please ensure it is shown fully.
I.e. appointment of 3 hours at afternoon, it scrolls vertically and shows me the first 30 minutes of this big item.
I have to scroll myself down to see it fully.

We'll try to fix this.

Quote:
* Exceptions/crashes when closing and reopening ContentPage multiple times:
Unhandled Exception: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'MindFusion.Scheduling.Android.CalendarRenderer'.
Does not happen on similar pages without calendar control on it.
Is there something I can do (call) in Xamarin.Forms ContentPage OnAppearing / OnDisappearing / ... events in order to help Scheduling with a proper cleanup/deregistration? I.e. sort of a flag to stop drawing as page is disappearing?

We'll look into this. Is it happening on a real device or in an emulator?

Regards,
Meppy
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Xamarin Scheduling: OnItemClick, EnsureVisible, ObjectDisposedException
Reply #2 - Feb 27th, 2017 at 3:50pm
Print Post  
As a workaround for point (2), you can try using the other EnsureVisible overload:

Code
Select All
calendar.EnsureVisible(item.StartTime);
calendar.EnsureVisible(item.EndTime); 


If the item is associated with a resource, make sure to use the overload that accepts a Resource as an argument.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Heli
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 44
Joined: Aug 29th, 2016
Re: Xamarin Scheduling: OnItemClick, EnsureVisible, ObjectDisposedException
Reply #3 - Feb 27th, 2017 at 8:26pm
Print Post  
Hi,

I'll try your suggestion for (2) in the next hours (I'm currently on the road).

I always debug with real devices and Visual Studio 2015.

(1) and (3) might be connected - XAML instantiates the Calendar for me, there I defined the ItemClick event mapping to my method in code behind.
So, it looks like that after closing and reopening the ContentPage the same Calendar instance is reused by Xamarin.Forms??? That would explain the multiple event occurrence (one more for each page close/reopen).
Furthermore it would somehow explain the exceptions.
I did not expect such an instance reuse (as it seems to be), but how to get Xamarin.Forms to don't do this and still being able to write XAML?
Or make the calendar "compatible" with such an instance reuse scenario as a second option?

Regards,
Heli
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Xamarin Scheduling: OnItemClick, EnsureVisible, ObjectDisposedException
Reply #4 - Feb 28th, 2017 at 9:08am
Print Post  
Hi,

It appears that both the Calendar and its renderer are getting disposed of when the application is deactivated and recreated once its activated again. However I cannot reproduce the exception. Also, the ItemCreated event is raised only once (as expected) after reactivation. Are you doing anything specific when the exception happens? What is the Xamarin.Forms version of your testing project?

Regards,
Meppy
  
Back to top
 
IP Logged
 
Heli
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 44
Joined: Aug 29th, 2016
Re: Xamarin Scheduling: OnItemClick, EnsureVisible, ObjectDisposedException
Reply #5 - Feb 28th, 2017 at 2:42pm
Print Post  
Hi,

point 1, the multiple events, are solved.
It was my fault, I did not deregister properly. Sorry about the confusion.

I'm using the Scheduling version from here with the exact same Xamarin.Forms version 2.3.3.180.

Workaround with the two dates for point (2) works for me, thanks!

I'll continue investigation on the exceptions.
Just had the one with "Renderer disposed" again although event deregistration is ok now.

Another question:
In the ItemModifying event I'd like to know if there is a collision at the resource I'm dragging onto (or within).
You know that, as the dragged appointment and the existing are drawn side-by-side with half resource column width.
It would be great for me to get this information, too.
Currently I have to do calculations to get this information (a waste of CPU time and error prone).
I don't allow collisions, so I set e.Confirm=false if my calculation reveals that there is a collision.

Regards,
Heli
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Xamarin Scheduling: OnItemClick, EnsureVisible, ObjectDisposedException
Reply #6 - Mar 1st, 2017 at 8:18am
Print Post  
Hi,

You can detect collisions by using one of the Calendar.Schedule.GetAllItems overloads and using the item's start and end times. If the returned collection contains two or more items, than the item collides.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint