If there is no branch data in a simulation, display a dialog and don't try to show...
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Tue, 21 Feb 2012 02:41:02 +0000 (02:41 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Tue, 21 Feb 2012 02:41:02 +0000 (02:41 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@431 180e2498-e6e9-4542-8430-84ac67f01cd8

android/src/net/sf/openrocket/android/rocket/OpenRocketViewer.java

index 5ea7982743e2fad54bcd3ec24879e456a7f1deb6..8d2c8c0fb79224e820ef9874be8991c8eb99d374 100644 (file)
@@ -10,6 +10,7 @@ import net.sf.openrocket.android.simulation.SimulationFragment;
 import net.sf.openrocket.android.simulation.SimulationViewActivity;\r
 import net.sf.openrocket.android.util.AndroidLogWrapper;\r
 import net.sf.openrocket.document.Simulation;\r
+import android.app.AlertDialog;\r
 import android.content.Intent;\r
 import android.os.Bundle;\r
 import android.support.v4.app.Fragment;\r
@@ -69,9 +70,19 @@ implements Simulations.OnSimulationSelectedListener
 \r
        @Override\r
        public void onSimulationSelected(int simulationId) {\r
+               \r
+               Simulation sim = app.getRocketDocument().getSimulation(simulationId);\r
+               // Check if there is data for this simulation.\r
+               if ( sim.getSimulatedData().getBranchCount() == 0 ) {\r
+                       AlertDialog.Builder builder = new AlertDialog.Builder(this);\r
+                       builder.setMessage("The selected simulation does not have saved data.");\r
+                       builder.setCancelable(true);\r
+                       builder.show();\r
+                       return;\r
+               }\r
+               \r
                View sidepane = findViewById(R.id.sidepane);\r
                if ( /* if multi pane */ sidepane != null ) {\r
-                       Simulation sim = app.getRocketDocument().getSimulation(simulationId);\r
                        SimulationChart chart = new SimulationChart(simulationId);\r
 \r
                        Fragment graph = SimulationFragment.newInstance(chart);\r