- Welcome, Guest. Please Login or Register
MindFusion  
  Version 2 of our Xamarin Calendar component adds Resource view and support for Universal Windows Platform. Now beta testing spreadsheet component for Java Swing.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Xamarin Scheduling: OnItemClick, EnsureVisible, ObjectDisposedException
Read 632 times

Heli   Offline
YaBB Newbies
*
Posts: 44
I Love MindFusion!


   
     
 
Xamarin Scheduling: OnItemClick, EnsureVisible, ObjectDisposedException
Feb 27th, 2017 at 9:30am
 
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
 
 
 
IP Logged    
 
     

Meppy   Offline
YaBB Moderator
*****
Posts: 1750
Gender: male
MindFusion support


   
     
 
Re: Xamarin Scheduling: OnItemClick, EnsureVisible, ObjectDisposedException
Reply #1 - Feb 27th, 2017 at 3:35pm
 
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
 
 
 
IP Logged    
 
     

Meppy   Offline
YaBB Moderator
*****
Posts: 1750
Gender: male
MindFusion support


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

Code:
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
 
 
 
IP Logged    
 
     

Heli   Offline
YaBB Newbies
*
Posts: 44
I Love MindFusion!


   
     
 
Re: Xamarin Scheduling: OnItemClick, EnsureVisible, ObjectDisposedException
Reply #3 - Feb 27th, 2017 at 8:26pm
 
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
 
 
 
IP Logged    
 
     

Meppy   Offline
YaBB Moderator
*****
Posts: 1750
Gender: male
MindFusion support


   
     
 
Re: Xamarin Scheduling: OnItemClick, EnsureVisible, ObjectDisposedException
Reply #4 - Feb 28th, 2017 at 9:08am
 
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
 
 
 
IP Logged    
 
     

Heli   Offline
YaBB Newbies
*
Posts: 44
I Love MindFusion!


   
     
 
Re: Xamarin Scheduling: OnItemClick, EnsureVisible, ObjectDisposedException
Reply #5 - Feb 28th, 2017 at 2:42pm
 
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
 
 
 
IP Logged    
 
     

Meppy   Offline
YaBB Moderator
*****
Posts: 1750
Gender: male
MindFusion support


   
     
 
Re: Xamarin Scheduling: OnItemClick, EnsureVisible, ObjectDisposedException
Reply #6 - Mar 1st, 2017 at 8:18am
 
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
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print