Rework the motor browser functionality to make it more tablet friendly.
This commit is contained in:
parent
ad86008f28
commit
3f37586278
@ -72,7 +72,7 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".android.motor.MotorBrowserActivity" />
|
||||
<activity android:name=".android.motor.MotorDetailsActivity" />
|
||||
<activity android:name=".android.motor.BurnPlotActivity" />
|
||||
<activity android:name=".android.thrustcurve.TCQueryActivity" />
|
||||
<activity android:name=".android.simulation.SimulationViewActivity" />
|
||||
<activity android:name=".android.filebrowser.SimpleFileBrowser" />
|
||||
|
20
android/res/layout-xlarge-land/motorbrowser.xml
Normal file
20
android/res/layout-xlarge-land/motorbrowser.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/motorBrowserList"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="4"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/sidepane"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical" />
|
||||
|
||||
</LinearLayout>
|
20
android/res/layout-xlarge-port/motorbrowser.xml
Normal file
20
android/res/layout-xlarge-port/motorbrowser.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/motorBrowserList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="3" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/sidepane"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical" />
|
||||
|
||||
</LinearLayout>
|
@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<fragment
|
||||
android:id="@+id/burnPlotFragment"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginLeft="0px"
|
||||
android:layout_marginRight="0px"
|
||||
android:layout_marginTop="5px"
|
||||
class="net.sf.openrocket.android.motor.BurnPlotFragment"
|
||||
title="Burn Plot" />
|
||||
|
||||
<SlidingDrawer
|
||||
android:id="@+id/drawer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.4"
|
||||
android:content="@+id/motorDetailForm"
|
||||
android:handle="@+id/handle" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/handle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30px"
|
||||
android:src="@drawable/arrow_up_float"
|
||||
android:text="" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/motorDetailForm"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
class="net.sf.openrocket.android.motor.MotorDetailsFragment" />
|
||||
</SlidingDrawer>
|
||||
|
||||
</FrameLayout>
|
@ -1,16 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<TableLayout
|
||||
android:id="@+id/motorDetailForm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/black"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="10px" >
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<TableRow >
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:paddingRight="10px"
|
||||
android:paddingRight="10dp"
|
||||
android:text="Manufacturer" />
|
||||
|
||||
<EditText
|
||||
@ -18,13 +20,14 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.04"
|
||||
android:editable="false" />
|
||||
android:editable="false"
|
||||
android:inputType="text" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow >
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:paddingRight="10px"
|
||||
android:paddingRight="10dp"
|
||||
android:text="Name" />
|
||||
|
||||
<EditText
|
||||
@ -32,13 +35,14 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.04"
|
||||
android:editable="false" />
|
||||
android:editable="false"
|
||||
android:inputType="text" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow >
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:paddingRight="10px"
|
||||
android:paddingRight="10dp"
|
||||
android:text="Delays" />
|
||||
|
||||
<EditText
|
||||
@ -46,13 +50,14 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.04"
|
||||
android:editable="false" />
|
||||
android:editable="false"
|
||||
android:inputType="number" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow >
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:paddingRight="10px"
|
||||
android:paddingRight="10dp"
|
||||
android:text="Case Info" />
|
||||
|
||||
<EditText
|
||||
@ -60,13 +65,14 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.04"
|
||||
android:editable="false" />
|
||||
android:editable="false"
|
||||
android:inputType="text" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow >
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:paddingRight="10px"
|
||||
android:paddingRight="10dp"
|
||||
android:text="Impulse Class" />
|
||||
|
||||
<EditText
|
||||
@ -74,13 +80,14 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.04"
|
||||
android:editable="false" />
|
||||
android:editable="false"
|
||||
android:inputType="text" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow >
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:paddingRight="10px"
|
||||
android:paddingRight="10dp"
|
||||
android:text="Diameter" />
|
||||
|
||||
<EditText
|
||||
@ -88,13 +95,14 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.04"
|
||||
android:editable="false" />
|
||||
android:editable="false"
|
||||
android:inputType="text" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow >
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:paddingRight="10px"
|
||||
android:paddingRight="10dp"
|
||||
android:text="Length" />
|
||||
|
||||
<EditText
|
||||
@ -102,7 +110,16 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.04"
|
||||
android:editable="false" />
|
||||
android:editable="false"
|
||||
android:inputType="text" />
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
<!--
|
||||
<Button
|
||||
android:id="@+id/motorDetailsSaveButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/save" />
|
||||
-->
|
||||
|
||||
</TableLayout>
|
||||
</ScrollView>
|
12
android/res/layout/motorbrowser.xml
Normal file
12
android/res/layout/motorbrowser.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/motorBrowserList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:enabled="true" android:id="@+id/save" android:visible="true" android:title="@string/save"/>
|
||||
|
||||
</menu>
|
@ -0,0 +1,23 @@
|
||||
package net.sf.openrocket.android.motor;
|
||||
|
||||
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
public class BurnPlotActivity extends FragmentActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
AndroidLogWrapper.d(BurnPlotActivity.class,"onCreate Bundle = "+ String.valueOf(savedInstanceState));
|
||||
|
||||
Intent i = getIntent();
|
||||
long motorId = i.getLongExtra("Motor",-1);
|
||||
|
||||
BurnPlotFragment burnPlot = BurnPlotFragment.newInstance(motorId);
|
||||
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, burnPlot).commit();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import net.sf.openrocket.R;
|
||||
import net.sf.openrocket.android.db.DbAdapter;
|
||||
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PointF;
|
||||
@ -27,6 +28,7 @@ import com.androidplot.xy.YValueMarker;
|
||||
public class BurnPlotFragment extends Fragment implements OnTouchListener {
|
||||
|
||||
private ExtendedThrustCurveMotor motor;
|
||||
private long motorId;
|
||||
|
||||
private XYPlot mySimpleXYPlot;
|
||||
private SimpleXYSeries mySeries;
|
||||
@ -39,12 +41,44 @@ public class BurnPlotFragment extends Fragment implements OnTouchListener {
|
||||
private ScaleGestureDetector mScaleDetector;
|
||||
private float mScaleFactor = 1.f;
|
||||
|
||||
public static BurnPlotFragment newInstance( long motorId ) {
|
||||
BurnPlotFragment frag = new BurnPlotFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong("motorId", motorId);
|
||||
frag.setArguments(bundle);
|
||||
return frag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
AndroidLogWrapper.d(BurnPlotFragment.class,"onCreate");
|
||||
|
||||
if ( savedInstanceState!= null) {
|
||||
motorId = savedInstanceState.getLong("motorId",-1);
|
||||
} else {
|
||||
Bundle b = getArguments();
|
||||
motorId = b.getLong("motorId");
|
||||
}
|
||||
|
||||
DbAdapter mDbHelper = new DbAdapter(getActivity());
|
||||
mDbHelper.open();
|
||||
|
||||
try {
|
||||
motor = mDbHelper.getMotorDao().fetchMotor(motorId);
|
||||
} catch ( Exception e ) {
|
||||
|
||||
}
|
||||
|
||||
mDbHelper.close();
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putLong("motorId", motorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
@ -53,6 +87,7 @@ public class BurnPlotFragment extends Fragment implements OnTouchListener {
|
||||
mySimpleXYPlot = (XYPlot) v.findViewById(R.id.xyplot);
|
||||
mySimpleXYPlot.setOnTouchListener(this);
|
||||
mScaleDetector = new ScaleGestureDetector(v.getContext(), new ScaleListener());
|
||||
init(motor);
|
||||
return v;
|
||||
}
|
||||
|
||||
@ -63,7 +98,8 @@ public class BurnPlotFragment extends Fragment implements OnTouchListener {
|
||||
}
|
||||
return l;
|
||||
}
|
||||
void init( ExtendedThrustCurveMotor motor ) {
|
||||
|
||||
private void init( ExtendedThrustCurveMotor motor ) {
|
||||
|
||||
mySimpleXYPlot.setUserDomainOrigin(0);
|
||||
mySimpleXYPlot.setUserRangeOrigin(0);
|
||||
|
@ -6,6 +6,7 @@ import net.sf.openrocket.android.PreferencesActivity;
|
||||
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.view.Menu;
|
||||
@ -23,13 +24,8 @@ implements MotorListFragment.OnMotorSelectedListener
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (getSupportFragmentManager().findFragmentById(android.R.id.content) == null) {
|
||||
motorList = MotorListFragment.newInstance();
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
ft.add(android.R.id.content, motorList);
|
||||
ft.commit();
|
||||
}
|
||||
setContentView(R.layout.motorbrowser);
|
||||
getSupportFragmentManager().beginTransaction().add( R.id.motorBrowserList, new MotorListFragment()).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,23 +55,19 @@ implements MotorListFragment.OnMotorSelectedListener
|
||||
|
||||
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);
|
||||
Fragment graph = BurnPlotFragment.newInstance(motorId);
|
||||
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
|
||||
// probably only want to update back stack for first time.
|
||||
ft.addToBackStack("simulationplot");
|
||||
ft.addToBackStack("burnplot");
|
||||
ft.replace(R.id.sidepane, graph);
|
||||
ft.show(graph);
|
||||
ft.commit();
|
||||
*/
|
||||
|
||||
} else {
|
||||
Intent i = new Intent(this,MotorDetailsActivity.class);
|
||||
Intent i = new Intent(this,BurnPlotActivity.class);
|
||||
i.putExtra("Motor", motorId);
|
||||
startActivity(i);
|
||||
}
|
||||
|
@ -1,87 +0,0 @@
|
||||
package net.sf.openrocket.android.motor;
|
||||
|
||||
import net.sf.openrocket.R;
|
||||
import net.sf.openrocket.android.db.DbAdapter;
|
||||
import net.sf.openrocket.android.util.AndroidLogWrapper;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.SlidingDrawer;
|
||||
|
||||
public class MotorDetailsActivity extends FragmentActivity
|
||||
implements SlidingDrawer.OnDrawerCloseListener, SlidingDrawer.OnDrawerOpenListener {
|
||||
|
||||
private SlidingDrawer slidingDrawer;
|
||||
private ImageView handle;
|
||||
|
||||
private ExtendedThrustCurveMotor motor;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
AndroidLogWrapper.d(MotorDetailsActivity.class,"onCreate Bundle = "+ String.valueOf(savedInstanceState));
|
||||
setContentView(R.layout.motor_detail);
|
||||
|
||||
Intent i = getIntent();
|
||||
long motorId = i.getLongExtra("Motor",-1);
|
||||
|
||||
DbAdapter mDbHelper = new DbAdapter(this);
|
||||
mDbHelper.open();
|
||||
|
||||
try {
|
||||
motor = mDbHelper.getMotorDao().fetchMotor(motorId);
|
||||
} catch ( Exception e ) {
|
||||
|
||||
}
|
||||
|
||||
mDbHelper.close();
|
||||
|
||||
BurnPlotFragment burnPlot = (BurnPlotFragment) getSupportFragmentManager().findFragmentById(R.id.burnPlotFragment);
|
||||
burnPlot.init(motor);
|
||||
|
||||
MotorDetailsFragment motorDetails = (MotorDetailsFragment) getSupportFragmentManager().findFragmentById(R.id.motorDetailForm);
|
||||
motorDetails.init(motor);
|
||||
|
||||
slidingDrawer = (SlidingDrawer) findViewById(R.id.drawer);
|
||||
|
||||
slidingDrawer.setOnDrawerOpenListener(this);
|
||||
slidingDrawer.setOnDrawerCloseListener(this);
|
||||
|
||||
handle = (ImageView) findViewById(R.id.handle);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerOpened() {
|
||||
handle.setImageResource(R.drawable.arrow_down_float);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerClosed() {
|
||||
handle.setImageResource(R.drawable.arrow_up_float);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.motor_details_option_menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
||||
switch(item.getItemId()) {
|
||||
case R.id.save:
|
||||
// Extract form data to Motor.
|
||||
// Save motor.
|
||||
return true;
|
||||
}
|
||||
return super.onMenuItemSelected(featureId, item);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -2,15 +2,17 @@ package net.sf.openrocket.android.motor;
|
||||
|
||||
import net.sf.openrocket.R;
|
||||
import net.sf.openrocket.android.db.ConversionUtils;
|
||||
import net.sf.openrocket.android.db.DbAdapter;
|
||||
import net.sf.openrocket.motor.ThrustCurveMotor;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
public class MotorDetailsFragment extends Fragment {
|
||||
public class MotorDetailsFragment extends DialogFragment {
|
||||
|
||||
EditText manuField;
|
||||
EditText nameField;
|
||||
@ -20,6 +22,43 @@ public class MotorDetailsFragment extends Fragment {
|
||||
EditText diameterField;
|
||||
EditText lengthField;
|
||||
|
||||
ExtendedThrustCurveMotor motor;
|
||||
|
||||
public static MotorDetailsFragment newInstance( long motorId ) {
|
||||
MotorDetailsFragment fragment = new MotorDetailsFragment();
|
||||
Bundle b = new Bundle();
|
||||
b.putLong("motorId", motorId);
|
||||
fragment.setArguments(b);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setStyle(DialogFragment.STYLE_NO_TITLE,getTheme());
|
||||
|
||||
Long motorId;
|
||||
if ( savedInstanceState != null ) {
|
||||
motorId = savedInstanceState.getLong("motorId");
|
||||
} else {
|
||||
Bundle b = getArguments();
|
||||
motorId = b.getLong("motorId");
|
||||
}
|
||||
DbAdapter mDbHelper = new DbAdapter(getActivity());
|
||||
mDbHelper.open();
|
||||
try {
|
||||
motor = mDbHelper.getMotorDao().fetchMotor(motorId);
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
mDbHelper.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle arg0) {
|
||||
super.onSaveInstanceState(arg0);
|
||||
arg0.putLong("motorId", motor.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
@ -31,19 +70,37 @@ public class MotorDetailsFragment extends Fragment {
|
||||
impulseClassField = (EditText) v.findViewById(R.id.motorDetailsImpuseClass);
|
||||
diameterField = (EditText) v.findViewById(R.id.motorDetailsDiameter);
|
||||
lengthField = (EditText) v.findViewById(R.id.motorDetailsLength);
|
||||
init();
|
||||
/* TODO - enable saving.
|
||||
((Button) v.findViewById(R.id.motorDetailsSaveButton)).setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MotorDetailsFragment.this.saveChanges();
|
||||
}
|
||||
});
|
||||
*/
|
||||
return v;
|
||||
}
|
||||
|
||||
public void init( ExtendedThrustCurveMotor m ) {
|
||||
ThrustCurveMotor tcm = m.getThrustCurveMotor();
|
||||
private void init( ) {
|
||||
ThrustCurveMotor tcm = motor.getThrustCurveMotor();
|
||||
manuField.setText( tcm.getManufacturer().getDisplayName());
|
||||
nameField.setText( tcm.getDesignation() );
|
||||
delaysField.setText( ConversionUtils.delaysToString(tcm.getStandardDelays()) );
|
||||
caseField.setText( m.getCaseInfo());
|
||||
impulseClassField.setText( m.getImpulseClass());
|
||||
caseField.setText( motor.getCaseInfo());
|
||||
impulseClassField.setText( motor.getImpulseClass());
|
||||
diameterField.setText( String.valueOf(tcm.getDiameter()*1000.0) );
|
||||
lengthField.setText( String.valueOf(tcm.getLength()*1000.0) );
|
||||
|
||||
}
|
||||
|
||||
private void saveChanges() {
|
||||
DbAdapter mDbHelper = new DbAdapter(getActivity());
|
||||
mDbHelper.open();
|
||||
try {
|
||||
mDbHelper.getMotorDao().insertOrUpdateMotor(motor);
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,9 @@ import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.Menu;
|
||||
@ -35,12 +38,12 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||
}
|
||||
|
||||
public static MotorListFragment newInstance( ) {
|
||||
|
||||
MotorListFragment frag = new MotorListFragment();
|
||||
return frag;
|
||||
}
|
||||
|
||||
private static final int CONTEXTMENU_DELETE = Menu.FIRST+1;
|
||||
private static final int CONTEXTMENU_EDIT = Menu.FIRST+2;
|
||||
|
||||
private String groupColumnPreferenceKey;
|
||||
private String groupColumn = MotorDao.CASE_INFO;
|
||||
@ -165,6 +168,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
menu.setHeaderTitle("Motor Operations");
|
||||
menu.add(Menu.NONE,CONTEXTMENU_DELETE,CONTEXTMENU_DELETE,"Delete");
|
||||
menu.add(Menu.NONE,CONTEXTMENU_EDIT,CONTEXTMENU_EDIT,"Edit");
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
}
|
||||
|
||||
@ -178,6 +182,21 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||
mDbHelper.getMotorDao().deleteMotor(motorId);
|
||||
refreshData();
|
||||
return true;
|
||||
case CONTEXTMENU_EDIT:
|
||||
// DialogFragment.show() will take care of adding the fragment
|
||||
// in a transaction. We also want to remove any currently showing
|
||||
// dialog, so make our own transaction and take care of that here.
|
||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||
Fragment prev = getFragmentManager().findFragmentByTag("dialog");
|
||||
if (prev != null) {
|
||||
ft.remove(prev);
|
||||
}
|
||||
ft.addToBackStack(null);
|
||||
|
||||
// Create and show the dialog.
|
||||
DialogFragment newFragment = MotorDetailsFragment.newInstance(motorId);
|
||||
newFragment.show(ft, "dialog");
|
||||
return true;
|
||||
}
|
||||
return super.onContextItemSelected(item);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user