Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic DiagramView (Read 5988 times)
Silvia88
Full Member
***
Offline


I Love MindFusion!

Posts: 121
Joined: Aug 31st, 2015
DiagramView
Oct 13th, 2015 at 1:58pm
Print Post  
Hi,
I have a problem, when I close the app and then reopen it, if it has some items drawn of the previous time, if I use diagramView.getDiagram(); and then I make a print log of diagram.getItems().size(), it has 0 items but it's not true, how can I get the items or the diagram? Or how can I cancel the items present?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: DiagramView
Reply #1 - Oct 13th, 2015 at 6:42pm
Print Post  
Hi,

What do you mean by closing the app? If you switch to another Activity (including home-screen one) and return back to yours, it might not start anew if the system had enough memory for both activities, but simply resume with all data intact.

The list returned by getItems() is what the view loops over to draw diagram's contents, so you can't both get zero size and see items on screen. You are either checking incorrect line in the log, or have managed to create a new DiagramView instance but still seeing old one in the UI.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Silvia88
Full Member
***
Offline


I Love MindFusion!

Posts: 121
Joined: Aug 31st, 2015
Re: DiagramView
Reply #2 - Oct 13th, 2015 at 6:54pm
Print Post  
I mean closing the app by swapping out, then when I reopen it, it has some items but I don't want them, I want to start a with a free DiagramView, so I call diagram.clearAll but it doesn't work.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: DiagramView
Reply #3 - Oct 14th, 2015 at 7:56am
Print Post  
There's nothing that can go wrong in clearAll really. First make sure it does get called by logging or tracing through the code. If it's called and you are still seeing items, add breakpoints to all loadFrom calls you can find in the code to verify you aren't loading the diagram again at some point after clearing. Also make sure you haven't shown a new DiagramView but calling methods on the old (now hidden) one.
  
Back to top
 
IP Logged
 
Silvia88
Full Member
***
Offline


I Love MindFusion!

Posts: 121
Joined: Aug 31st, 2015
Re: DiagramView
Reply #4 - Oct 14th, 2015 at 8:22am
Print Post  
Thank you very much, I solved  Smiley
  
Back to top
 
IP Logged
 
Silvia88
Full Member
***
Offline


I Love MindFusion!

Posts: 121
Joined: Aug 31st, 2015
Re: DiagramView
Reply #5 - Oct 16th, 2015 at 4:08pm
Print Post  
Hi, I need a diagramView in an adapter for a ListView, is it possible? What I must put in the tag : tools:context="."? The name of the activity or of the adapter?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: DiagramView
Reply #6 - Oct 19th, 2015 at 12:33pm
Print Post  
Hi,

If you need nothing else but a DiagramView shown in a list row, you can return a DiagramView instance from the list adapter:

Code
Select All
class MyListAdapter
	extends BaseAdapter
	implements ListAdapter
{
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		DiagramView view = convertView != null ?
			(DiagramView)convertView : new DiagramView(parent.getContext());
		view.setDiagram(diagrams[position]);
		view.setLayoutParams(new LayoutParams(600, 400));
		return view;
	}

	Diagram[] diagrams = new Diagram[] { new Diagram(), new Diagram(), new Diagram() };

	public MyListAdapter()
	{
		for (int i = 0; i < diagrams.length; i++)
		{
			Diagram d = diagrams[i];
			d.setBackBrush(new SolidBrush(Color.red));
			d.getFactory().createShapeNode(10, 10, 30, 30).setText(Integer.toString(i));
		}
	}

	@Override
	public int getCount() {
	    return diagrams.length;
	}

	@Override
	public Object getItem(int pos) {
	    return diagrams[pos];
	}

	@Override
	public long getItemId(int pos) {
	    return 0;
	}
} 



You must limit the DiagramView size, or otherwise Android just outputs warning that view size is too large to be cached and draws nothing in the list, at least when using the default diagram size.

Additionally, the ListView intercepts drag gestures (to scroll) and prevents you from drawing in the diagram view. It might be possible to override that, e.g. check if this will work if you need interactivity:
https://mobiarch.wordpress.com/2013/11/21/prevent-touch-event-theft-in-android/

I hope that helps,
Stoyan
« Last Edit: Oct 19th, 2015 at 3:31pm by Stoyo »  
Back to top
 
IP Logged
 
Silvia88
Full Member
***
Offline


I Love MindFusion!

Posts: 121
Joined: Aug 31st, 2015
Re: DiagramView
Reply #7 - Oct 19th, 2015 at 7:16pm
Print Post  
ok, thank you very much  Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint