From ede0971867b2133360b42c94a9d16f0227d2dbf5 Mon Sep 17 00:00:00 2001 From: kruland2607 Date: Tue, 21 Feb 2012 02:41:02 +0000 Subject: [PATCH] If there is no branch data in a simulation, display a dialog and don't try to show anything. git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@431 180e2498-e6e9-4542-8430-84ac67f01cd8 --- .../openrocket/android/rocket/OpenRocketViewer.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/android/src/net/sf/openrocket/android/rocket/OpenRocketViewer.java b/android/src/net/sf/openrocket/android/rocket/OpenRocketViewer.java index 5ea79827..8d2c8c0f 100644 --- a/android/src/net/sf/openrocket/android/rocket/OpenRocketViewer.java +++ b/android/src/net/sf/openrocket/android/rocket/OpenRocketViewer.java @@ -10,6 +10,7 @@ import net.sf.openrocket.android.simulation.SimulationFragment; import net.sf.openrocket.android.simulation.SimulationViewActivity; import net.sf.openrocket.android.util.AndroidLogWrapper; import net.sf.openrocket.document.Simulation; +import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -69,9 +70,19 @@ implements Simulations.OnSimulationSelectedListener @Override public void onSimulationSelected(int simulationId) { + + Simulation sim = app.getRocketDocument().getSimulation(simulationId); + // Check if there is data for this simulation. + if ( sim.getSimulatedData().getBranchCount() == 0 ) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage("The selected simulation does not have saved data."); + builder.setCancelable(true); + builder.show(); + return; + } + View sidepane = findViewById(R.id.sidepane); if ( /* if multi pane */ sidepane != null ) { - Simulation sim = app.getRocketDocument().getSimulation(simulationId); SimulationChart chart = new SimulationChart(simulationId); Fragment graph = SimulationFragment.newInstance(chart); -- 2.47.2