Refactor the RocketDocument and corresponding data and methods out of Application and into CurrentRocketHolder and CurrentRocket.
This commit is contained in:
parent
192637f189
commit
d103ac1d05
@ -1,30 +1,17 @@
|
||||
package net.sf.openrocket.android;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
||||
import net.sf.openrocket.database.ComponentPresetDatabase;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.document.Simulation;
|
||||
import net.sf.openrocket.file.openrocket.OpenRocketSaver;
|
||||
import net.sf.openrocket.l10n.DebugTranslator;
|
||||
import net.sf.openrocket.l10n.ResourceBundleTranslator;
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.net.Uri;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
public class Application extends android.app.Application {
|
||||
|
||||
private OpenRocketDocument rocketDocument;
|
||||
private Uri fileUri;
|
||||
|
||||
private WarningSet warnings;
|
||||
|
||||
// Big B boolean so I can synchronize on it.
|
||||
private static Boolean initialized = false;
|
||||
|
||||
@ -74,69 +61,4 @@ public class Application extends android.app.Application {
|
||||
PreferencesActivity.initializePreferences(this, PreferenceManager.getDefaultSharedPreferences(this));
|
||||
}
|
||||
|
||||
private RocketChangedEventHandler handler;
|
||||
|
||||
public void setHandler( RocketChangedEventHandler handler ) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rocketDocument
|
||||
*/
|
||||
public OpenRocketDocument getRocketDocument() {
|
||||
return rocketDocument;
|
||||
}
|
||||
|
||||
public void addNewSimulation() {
|
||||
Rocket rocket = rocketDocument.getRocket();
|
||||
Simulation newSim = new Simulation(rocket);
|
||||
newSim.setName(rocketDocument.getNextSimulationName());
|
||||
rocketDocument.addSimulation(newSim);
|
||||
if ( handler != null ) {
|
||||
handler.simsChangedMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteSimulation( int simulationPos ) {
|
||||
rocketDocument.removeSimulation( simulationPos );
|
||||
if ( handler != null ) {
|
||||
handler.simsChangedMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public String addNewMotorConfig() {
|
||||
String configId = rocketDocument.getRocket().newMotorConfigurationID();
|
||||
if ( handler != null ) {
|
||||
handler.configsChangedMessage();
|
||||
}
|
||||
return configId;
|
||||
}
|
||||
/**
|
||||
* @param rocketDocument the rocketDocument to set
|
||||
*/
|
||||
public void setRocketDocument(OpenRocketDocument rocketDocument) {
|
||||
this.rocketDocument = rocketDocument;
|
||||
}
|
||||
|
||||
public WarningSet getWarnings() {
|
||||
return warnings;
|
||||
}
|
||||
|
||||
public void setWarnings(WarningSet warnings) {
|
||||
this.warnings = warnings;
|
||||
}
|
||||
|
||||
public Uri getFileUri() {
|
||||
return fileUri;
|
||||
}
|
||||
|
||||
public void setFileUri(Uri fileUri) {
|
||||
this.fileUri = fileUri;
|
||||
}
|
||||
|
||||
public void saveOpenRocketDocument() throws IOException {
|
||||
OpenRocketSaver saver = new OpenRocketSaver();
|
||||
saver.save(new File(fileUri.getPath()),rocketDocument);
|
||||
|
||||
}
|
||||
}
|
||||
|
87
android/src/net/sf/openrocket/android/CurrentRocket.java
Normal file
87
android/src/net/sf/openrocket/android/CurrentRocket.java
Normal file
@ -0,0 +1,87 @@
|
||||
package net.sf.openrocket.android;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.document.Simulation;
|
||||
import net.sf.openrocket.file.openrocket.OpenRocketSaver;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
import android.net.Uri;
|
||||
|
||||
public class CurrentRocket {
|
||||
|
||||
private Uri fileUri;
|
||||
|
||||
private OpenRocketDocument rocketDocument;
|
||||
private WarningSet warnings;
|
||||
|
||||
private RocketChangedEventHandler handler;
|
||||
|
||||
public void setHandler( RocketChangedEventHandler handler ) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rocketDocument
|
||||
*/
|
||||
public OpenRocketDocument getRocketDocument() {
|
||||
return rocketDocument;
|
||||
}
|
||||
|
||||
public void addNewSimulation() {
|
||||
Rocket rocket = rocketDocument.getRocket();
|
||||
Simulation newSim = new Simulation(rocket);
|
||||
newSim.setName(rocketDocument.getNextSimulationName());
|
||||
rocketDocument.addSimulation(newSim);
|
||||
if ( handler != null ) {
|
||||
handler.simsChangedMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteSimulation( int simulationPos ) {
|
||||
rocketDocument.removeSimulation( simulationPos );
|
||||
if ( handler != null ) {
|
||||
handler.simsChangedMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public String addNewMotorConfig() {
|
||||
String configId = rocketDocument.getRocket().newMotorConfigurationID();
|
||||
if ( handler != null ) {
|
||||
handler.configsChangedMessage();
|
||||
}
|
||||
return configId;
|
||||
}
|
||||
/**
|
||||
* @param rocketDocument the rocketDocument to set
|
||||
*/
|
||||
public void setRocketDocument(OpenRocketDocument rocketDocument) {
|
||||
this.rocketDocument = rocketDocument;
|
||||
}
|
||||
|
||||
public WarningSet getWarnings() {
|
||||
return warnings;
|
||||
}
|
||||
|
||||
public void setWarnings(WarningSet warnings) {
|
||||
this.warnings = warnings;
|
||||
}
|
||||
|
||||
public Uri getFileUri() {
|
||||
return fileUri;
|
||||
}
|
||||
|
||||
public void setFileUri(Uri fileUri) {
|
||||
this.fileUri = fileUri;
|
||||
}
|
||||
|
||||
public void saveOpenRocketDocument() throws IOException {
|
||||
OpenRocketSaver saver = new OpenRocketSaver();
|
||||
saver.save(new File(fileUri.getPath()),rocketDocument);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.sf.openrocket.android;
|
||||
|
||||
|
||||
public abstract class CurrentRocketHolder {
|
||||
|
||||
private static CurrentRocket currentRocket = new CurrentRocket();
|
||||
|
||||
public static CurrentRocket getCurrentRocket() {
|
||||
return currentRocket;
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package net.sf.openrocket.android.rocket;
|
||||
|
||||
import net.sf.openrocket.R;
|
||||
import net.sf.openrocket.android.Application;
|
||||
import net.sf.openrocket.android.CurrentRocketHolder;
|
||||
import net.sf.openrocket.android.rocket.RocketComponentTreeAdapter.RocketComponentWithId;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
@ -34,7 +34,7 @@ public class Component extends Fragment {
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
final OpenRocketDocument rocketDocument = ((Application)getActivity().getApplication()).getRocketDocument();
|
||||
final OpenRocketDocument rocketDocument = CurrentRocketHolder.getCurrentRocket().getRocketDocument();
|
||||
componentTree.setAdapter( buildAdapter( rocketDocument.getRocket() ) );
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package net.sf.openrocket.android.rocket;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.openrocket.R;
|
||||
import net.sf.openrocket.android.Application;
|
||||
import net.sf.openrocket.android.CurrentRocketHolder;
|
||||
import net.sf.openrocket.android.db.DbAdapter;
|
||||
import net.sf.openrocket.android.motor.ExtendedThrustCurveMotor;
|
||||
import net.sf.openrocket.android.motor.MotorDelayDialogFragment;
|
||||
@ -72,7 +72,7 @@ public class Configurations extends ExpandableListFragment {
|
||||
}
|
||||
|
||||
private void addConfiguration() {
|
||||
((Application)getActivity().getApplication()).addNewMotorConfig();
|
||||
CurrentRocketHolder.getCurrentRocket().addNewMotorConfig();
|
||||
}
|
||||
|
||||
private static class MotorMountInfo {
|
||||
@ -110,7 +110,7 @@ public class Configurations extends ExpandableListFragment {
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
final OpenRocketDocument rocketDocument = ((Application)getActivity().getApplication()).getRocketDocument();
|
||||
final OpenRocketDocument rocketDocument = CurrentRocketHolder.getCurrentRocket().getRocketDocument();
|
||||
|
||||
ExpandableListAdapter configurationAdapter = new BaseExpandableListAdapter() {
|
||||
|
||||
|
@ -5,7 +5,7 @@ import java.util.Set;
|
||||
|
||||
import net.sf.openrocket.R;
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.android.Application;
|
||||
import net.sf.openrocket.android.CurrentRocketHolder;
|
||||
import net.sf.openrocket.android.thrustcurve.TCMissingMotorDownloadAction;
|
||||
import net.sf.openrocket.android.thrustcurve.TCQueryAction;
|
||||
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
||||
@ -47,7 +47,7 @@ implements TCQueryAction.OnTCQueryCompleteListener, OpenRocketLoaderFragment.OnO
|
||||
}
|
||||
|
||||
private void loadOrkFile( Uri file ) {
|
||||
((Application)getApplication()).setFileUri( file );
|
||||
CurrentRocketHolder.getCurrentRocket().setFileUri( file );
|
||||
AndroidLogWrapper.d(OpenRocketLoaderActivity.class,"Use ork file: " + file);
|
||||
String path = file.getPath();
|
||||
File orkFile = new File(path);
|
||||
@ -77,15 +77,15 @@ implements TCQueryAction.OnTCQueryCompleteListener, OpenRocketLoaderFragment.OnO
|
||||
dialogBuilder.create().show();
|
||||
|
||||
} else {
|
||||
((Application)OpenRocketLoaderActivity.this.getApplication()).setRocketDocument( result.rocket );
|
||||
((Application)OpenRocketLoaderActivity.this.getApplication()).setWarnings( result.warnings );
|
||||
CurrentRocketHolder.getCurrentRocket().setRocketDocument( result.rocket );
|
||||
CurrentRocketHolder.getCurrentRocket().setWarnings( result.warnings );
|
||||
|
||||
updateMissingMotors();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMissingMotors() {
|
||||
Rocket rocket = ((Application)OpenRocketLoaderActivity.this.getApplication()).getRocketDocument().getRocket();
|
||||
Rocket rocket = CurrentRocketHolder.getCurrentRocket().getRocketDocument().getRocket();
|
||||
Set<ThrustCurveMotorPlaceholder> missingMotors = MissingMotorHelpers.findMissingMotors(rocket);
|
||||
|
||||
if ( missingMotors.size() > 0 ) {
|
||||
@ -103,8 +103,8 @@ implements TCQueryAction.OnTCQueryCompleteListener, OpenRocketLoaderFragment.OnO
|
||||
@Override
|
||||
public void onTCQueryComplete(String message) {
|
||||
|
||||
Rocket rocket = ((Application)OpenRocketLoaderActivity.this.getApplication()).getRocketDocument().getRocket();
|
||||
WarningSet warnings = ((Application)OpenRocketLoaderActivity.this.getApplication()).getWarnings();
|
||||
Rocket rocket = CurrentRocketHolder.getCurrentRocket().getRocketDocument().getRocket();
|
||||
WarningSet warnings = CurrentRocketHolder.getCurrentRocket().getWarnings();
|
||||
// Need to update the motor references.
|
||||
MissingMotorHelpers.updateMissingMotors(rocket, warnings);
|
||||
|
||||
@ -112,7 +112,7 @@ implements TCQueryAction.OnTCQueryCompleteListener, OpenRocketLoaderFragment.OnO
|
||||
}
|
||||
|
||||
private void displayWarningDialog() {
|
||||
WarningSet warnings = ((Application)OpenRocketLoaderActivity.this.getApplication()).getWarnings();
|
||||
WarningSet warnings = CurrentRocketHolder.getCurrentRocket().getWarnings();
|
||||
if (warnings == null || warnings.isEmpty()) {
|
||||
} else {
|
||||
DialogFragment newFragment = WarningDialogFragment.newInstance();
|
||||
@ -124,7 +124,7 @@ implements TCQueryAction.OnTCQueryCompleteListener, OpenRocketLoaderFragment.OnO
|
||||
}
|
||||
|
||||
public void doFixMissingMotors() {
|
||||
Rocket rocket = ((Application)OpenRocketLoaderActivity.this.getApplication()).getRocketDocument().getRocket();
|
||||
Rocket rocket = CurrentRocketHolder.getCurrentRocket().getRocketDocument().getRocket();
|
||||
Set<ThrustCurveMotorPlaceholder> missingMotors = MissingMotorHelpers.findMissingMotors(rocket);
|
||||
|
||||
TCMissingMotorDownloadAction motorfrag = TCMissingMotorDownloadAction.newInstance( missingMotors );
|
||||
|
@ -5,7 +5,7 @@ import java.io.IOException;
|
||||
|
||||
import net.sf.openrocket.R;
|
||||
import net.sf.openrocket.android.ActivityHelpers;
|
||||
import net.sf.openrocket.android.Application;
|
||||
import net.sf.openrocket.android.CurrentRocketHolder;
|
||||
import net.sf.openrocket.android.simulation.SimulationChart;
|
||||
import net.sf.openrocket.android.simulation.SimulationViewActivity;
|
||||
import net.sf.openrocket.android.simulation.SimulationViewFragment;
|
||||
@ -30,8 +30,6 @@ public class OpenRocketViewer extends SherlockFragmentActivity
|
||||
implements Simulations.OnSimulationSelectedListener
|
||||
{
|
||||
|
||||
private Application app;
|
||||
|
||||
private final static int OVERVIEW_POS = 0;
|
||||
private final static int COMPONENT_POS = 1;
|
||||
private final static int SIMS_POS = 2;
|
||||
@ -44,9 +42,7 @@ implements Simulations.OnSimulationSelectedListener
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
app = (Application) this.getApplication();
|
||||
|
||||
setTitle(app.getRocketDocument().getRocket().getName());
|
||||
setTitle(CurrentRocketHolder.getCurrentRocket().getRocketDocument().getRocket().getName());
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
setContentView(R.layout.openrocketviewer);
|
||||
@ -54,12 +50,12 @@ implements Simulations.OnSimulationSelectedListener
|
||||
viewPagerAdapter = new OpenRocketViewerPagerAdapter( this.getSupportFragmentManager() );
|
||||
viewPager.setAdapter( viewPagerAdapter );
|
||||
|
||||
app.setHandler( new RocketChangedEventHandler( ) );
|
||||
CurrentRocketHolder.getCurrentRocket().setHandler( new RocketChangedEventHandler( ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
app.setHandler(null);
|
||||
CurrentRocketHolder.getCurrentRocket().setHandler(null);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@ -77,7 +73,7 @@ implements Simulations.OnSimulationSelectedListener
|
||||
case R.id.menu_save:
|
||||
// FIXME - Probably want to open a dialog here.
|
||||
try {
|
||||
((Application)getApplication()).saveOpenRocketDocument();
|
||||
CurrentRocketHolder.getCurrentRocket().saveOpenRocketDocument();
|
||||
} catch ( IOException iex ) {
|
||||
AndroidLogWrapper.d(OpenRocketViewer.class, iex.getMessage());
|
||||
}
|
||||
@ -101,7 +97,7 @@ implements Simulations.OnSimulationSelectedListener
|
||||
@Override
|
||||
public void onSimulationSelected(int simulationId) {
|
||||
|
||||
Simulation sim = app.getRocketDocument().getSimulation(simulationId);
|
||||
Simulation sim = CurrentRocketHolder.getCurrentRocket().getRocketDocument().getSimulation(simulationId);
|
||||
// Check if there is data for this simulation.
|
||||
if ( sim.getSimulatedData() == null || sim.getSimulatedData().getBranchCount() == 0 ) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
|
@ -5,7 +5,7 @@ import net.sf.openrocket.aerodynamics.AerodynamicCalculator;
|
||||
import net.sf.openrocket.aerodynamics.BarrowmanCalculator;
|
||||
import net.sf.openrocket.aerodynamics.FlightConditions;
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.android.Application;
|
||||
import net.sf.openrocket.android.CurrentRocketHolder;
|
||||
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.masscalc.BasicMassCalculator;
|
||||
@ -75,7 +75,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
final OpenRocketDocument rocketDocument = ((Application)getActivity().getApplication()).getRocketDocument();
|
||||
final OpenRocketDocument rocketDocument = CurrentRocketHolder.getCurrentRocket().getRocketDocument();
|
||||
Rocket rocket = rocketDocument.getRocket();
|
||||
|
||||
// Find the index of the default configuration so we can preselect it.
|
||||
|
@ -2,7 +2,7 @@
|
||||
package net.sf.openrocket.android.rocket;
|
||||
|
||||
import net.sf.openrocket.R;
|
||||
import net.sf.openrocket.android.Application;
|
||||
import net.sf.openrocket.android.CurrentRocketHolder;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.document.Simulation;
|
||||
import net.sf.openrocket.simulation.SimulationOptions;
|
||||
@ -73,7 +73,7 @@ public class SimulationEditFragment extends SherlockDialogFragment {
|
||||
|
||||
motorSpinner = (MotorConfigSpinner) v.findViewById(R.id.simulationConditionConfigurationSpinner);
|
||||
|
||||
OpenRocketDocument rocketDocument = ((Application)getActivity().getApplication()).getRocketDocument();
|
||||
OpenRocketDocument rocketDocument = CurrentRocketHolder.getCurrentRocket().getRocketDocument();
|
||||
|
||||
motorSpinner.createAdapter(rocketDocument.getRocket());
|
||||
|
||||
@ -99,7 +99,7 @@ public class SimulationEditFragment extends SherlockDialogFragment {
|
||||
}
|
||||
|
||||
public void onDelete( ) {
|
||||
((Application)getActivity().getApplication()).deleteSimulation(simulationId);
|
||||
CurrentRocketHolder.getCurrentRocket().deleteSimulation(simulationId);
|
||||
getDialog().dismiss();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.sf.openrocket.android.rocket;
|
||||
|
||||
import net.sf.openrocket.R;
|
||||
import net.sf.openrocket.android.Application;
|
||||
import net.sf.openrocket.android.CurrentRocketHolder;
|
||||
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.document.Simulation;
|
||||
@ -112,7 +112,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
final OpenRocketDocument rocketDocument = ((Application)getActivity().getApplication()).getRocketDocument();
|
||||
final OpenRocketDocument rocketDocument = CurrentRocketHolder.getCurrentRocket().getRocketDocument();
|
||||
AndroidLogWrapper.d(Simulations.class,"activity = {0}", this.getActivity());
|
||||
|
||||
ArrayAdapter<Simulation> sims = new ArrayAdapter<Simulation>(this.getActivity(),android.R.layout.simple_list_item_2,rocketDocument.getSimulations()) {
|
||||
@ -169,7 +169,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||
}
|
||||
|
||||
private void addSimulation() {
|
||||
((Application)getActivity().getApplication()).addNewSimulation();
|
||||
CurrentRocketHolder.getCurrentRocket().addNewSimulation();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package net.sf.openrocket.android.rocket;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.Warning;
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.android.Application;
|
||||
import net.sf.openrocket.android.CurrentRocketHolder;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
@ -24,7 +24,7 @@ public class WarningDialogFragment extends DialogFragment {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
// .setIcon(android.R.drawable.alert_dialog_icon)
|
||||
builder.setTitle("Warnings");
|
||||
WarningSet warnings = ((Application)(getActivity().getApplication())).getWarnings();
|
||||
WarningSet warnings = CurrentRocketHolder.getCurrentRocket().getWarnings();
|
||||
StringBuilder message = new StringBuilder();
|
||||
for ( Warning w : warnings ) {
|
||||
message.append(w.toString()).append("\n");
|
||||
|
@ -3,7 +3,7 @@ package net.sf.openrocket.android.simulation;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.openrocket.R;
|
||||
import net.sf.openrocket.android.Application;
|
||||
import net.sf.openrocket.android.CurrentRocketHolder;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.simulation.FlightDataBranch;
|
||||
import net.sf.openrocket.simulation.FlightDataType;
|
||||
@ -37,7 +37,7 @@ public class SimulationEventsDialog extends DialogFragment {
|
||||
eventList = (TableLayout) v.findViewById(R.id.simulationEventsList);
|
||||
eventList.setColumnShrinkable(0, true);
|
||||
|
||||
final OpenRocketDocument rocketDocument = ((Application)getActivity().getApplication()).getRocketDocument();
|
||||
final OpenRocketDocument rocketDocument = CurrentRocketHolder.getCurrentRocket().getRocketDocument();
|
||||
|
||||
List<FlightEvent> events = chart.getFlightDataBranch(rocketDocument).getEvents();
|
||||
|
||||
|
@ -4,10 +4,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.openrocket.R;
|
||||
import net.sf.openrocket.android.Application;
|
||||
import net.sf.openrocket.android.CurrentRocketHolder;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.simulation.FlightDataType;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
@ -59,7 +58,7 @@ public class SimulationSeriesDialog extends DialogFragment {
|
||||
|
||||
View v = inflater.inflate(R.layout.simulation_series_dialog, container, false);
|
||||
|
||||
OpenRocketDocument rocketDocument = ((Application)getActivity().getApplication()).getRocketDocument();
|
||||
OpenRocketDocument rocketDocument = CurrentRocketHolder.getCurrentRocket().getRocketDocument();
|
||||
|
||||
Button okButton = (Button) v.findViewById(R.id.simulationOkButton);
|
||||
okButton.setOnClickListener( new View.OnClickListener() {
|
||||
|
@ -2,7 +2,7 @@ package net.sf.openrocket.android.simulation;
|
||||
|
||||
import net.sf.openrocket.R;
|
||||
import net.sf.openrocket.android.ActivityHelpers;
|
||||
import net.sf.openrocket.android.Application;
|
||||
import net.sf.openrocket.android.CurrentRocketHolder;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.document.Simulation;
|
||||
import android.os.Bundle;
|
||||
@ -23,7 +23,7 @@ public class SimulationViewActivity extends FragmentActivity {
|
||||
//setContentView(R.layout.simulation_graph_activity);
|
||||
int simulationNumber = getIntent().getIntExtra("Simulation", 0);
|
||||
|
||||
final OpenRocketDocument rocketDocument = ((Application)getApplication()).getRocketDocument();
|
||||
final OpenRocketDocument rocketDocument = CurrentRocketHolder.getCurrentRocket().getRocketDocument();
|
||||
|
||||
Simulation sim = rocketDocument.getSimulation(simulationNumber);
|
||||
|
||||
|
@ -3,6 +3,7 @@ package net.sf.openrocket.android.simulation;
|
||||
|
||||
import net.sf.openrocket.R;
|
||||
import net.sf.openrocket.android.Application;
|
||||
import net.sf.openrocket.android.CurrentRocketHolder;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
|
||||
import org.achartengine.GraphicalView;
|
||||
@ -41,7 +42,7 @@ public class SimulationViewFragment extends Fragment implements SimulationSeries
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
setRetainInstance(true);
|
||||
setHasOptionsMenu(true);
|
||||
OpenRocketDocument rocketDocument = ((Application)getActivity().getApplication()).getRocketDocument();
|
||||
OpenRocketDocument rocketDocument = CurrentRocketHolder.getCurrentRocket().getRocketDocument();
|
||||
|
||||
this.container = container;
|
||||
if (savedInstanceState != null ) {
|
||||
@ -77,7 +78,7 @@ public class SimulationViewFragment extends Fragment implements SimulationSeries
|
||||
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
OpenRocketDocument rocketDocument = ((Application)getActivity().getApplication()).getRocketDocument();
|
||||
OpenRocketDocument rocketDocument = CurrentRocketHolder.getCurrentRocket().getRocketDocument();
|
||||
|
||||
mChart = chart.buildChart(rocketDocument);
|
||||
ViewGroup parent = (ViewGroup) mView.getParent();
|
||||
|
Loading…
x
Reference in New Issue
Block a user