If the simulation doesn't have data, open the edit dialog instead of issuing a warning.
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Tue, 3 Jul 2012 02:54:54 +0000 (02:54 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Tue, 3 Jul 2012 02:54:54 +0000 (02:54 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@858 180e2498-e6e9-4542-8430-84ac67f01cd8

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

index c621dab23a1b931a941cba1830da3e2dc9366502..2304aa9a6e86a63101321ce8dc9415a303e69b87 100644 (file)
@@ -179,10 +179,7 @@ implements Simulations.OnSimulationSelectedListener, OpenRocketSaverFragment.OnO
                Simulation sim = CurrentRocketHolder.getCurrentRocket().getRocketDocument().getSimulation(simulationId);\r
                // Check if there is data for this simulation.\r
                if ( sim.getSimulatedData() == null || 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
+                       // This shouldn't happen because the Simulations list does the check.\r
                        return;\r
                }\r
 \r
index 61ef2a411bb2350b33a60a3a1564acbf6ba31fea..805792b6583d02778f7ca424b40b9265bf577f97 100644 (file)
@@ -136,7 +136,11 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
                simulationList.setOnItemClickListener( new OnItemClickListener() {\r
                        @Override\r
                        public void onItemClick(AdapterView l, View v, int position, long id) {\r
-                               if (listener != null ) {\r
+                               Simulation sim = CurrentRocketHolder.getCurrentRocket().getRocketDocument().getSimulation(position);\r
+                               // Check if there is data for this simulation.\r
+                               if ( sim.getSimulatedData() == null || sim.getSimulatedData().getBranchCount() == 0 ) {\r
+                                       openEditor(position);\r
+                               } else if (listener != null ) {\r
                                        listener.onSimulationSelected(position);\r
                                }\r
                        }\r
@@ -147,10 +151,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
                        @Override\r
                        public boolean onItemLongClick(AdapterView<?> parent, View view,\r
                                        int position, long id) {\r
-                               final SimulationEditFragment f = SimulationEditFragment.newInstance(position);\r
-                               FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();\r
-                               ft.add(f, wizardFrag);\r
-                               ft.commit();\r
+                               openEditor(position);\r
 \r
                                return true;\r
                        }\r
@@ -159,6 +160,13 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
                simulationList.setAdapter(sims);\r
 \r
        }\r
+       \r
+       private void openEditor( int position ) {\r
+               final SimulationEditFragment f = SimulationEditFragment.newInstance(position);\r
+               FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();\r
+               ft.add(f, wizardFrag);\r
+               ft.commit();\r
+       }\r
 \r
        private void addSimulation() {\r
                CurrentRocketHolder.getCurrentRocket().addNewSimulation();\r