motor updates
This commit is contained in:
parent
7eca17a372
commit
bd8e82c1d2
@ -7,7 +7,6 @@ import net.sf.openrocket.motor.ThrustCurveMotor;
|
|||||||
import net.sf.openrocket.util.Coordinate;
|
import net.sf.openrocket.util.Coordinate;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.SQLException;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@ -47,7 +46,9 @@ public class MotorDao {
|
|||||||
this.mDb = mDb;
|
this.mDb = mDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String[] create() { return new String[] {CREATE_TABLE}; }
|
static String[] create() {
|
||||||
|
return new String[] { CREATE_TABLE };
|
||||||
|
}
|
||||||
|
|
||||||
static String[] update(int oldVer, int newVer) {
|
static String[] update(int oldVer, int newVer) {
|
||||||
return new String[] { DROP_TABLE, CREATE_TABLE };
|
return new String[] { DROP_TABLE, CREATE_TABLE };
|
||||||
@ -107,7 +108,7 @@ public class MotorDao {
|
|||||||
initialValues.put(BURN_TIME, tcm.getBurnTimeEstimate());
|
initialValues.put(BURN_TIME, tcm.getBurnTimeEstimate());
|
||||||
initialValues.put(LENGTH, tcm.getLength());
|
initialValues.put(LENGTH, tcm.getLength());
|
||||||
initialValues.put(CASE_INFO, mi.getCaseInfo());
|
initialValues.put(CASE_INFO, mi.getCaseInfo());
|
||||||
initialValues.put(TYPE, tcm.getMotorType().getName());
|
initialValues.put(TYPE, tcm.getMotorType().name());
|
||||||
initialValues.put(IMPULSE_CLASS, mi.getImpulseClass());
|
initialValues.put(IMPULSE_CLASS, mi.getImpulseClass());
|
||||||
initialValues.put(MANUFACTURER, tcm.getManufacturer().getSimpleName());
|
initialValues.put(MANUFACTURER, tcm.getManufacturer().getSimpleName());
|
||||||
initialValues.put(THRUST_DATA, ConversionUtils.serializeArrayOfDouble(tcm.getThrustPoints()));
|
initialValues.put(THRUST_DATA, ConversionUtils.serializeArrayOfDouble(tcm.getThrustPoints()));
|
||||||
@ -200,7 +201,12 @@ public class MotorDao {
|
|||||||
double avgImpulse = mCursor.getDouble(mCursor.getColumnIndex(AVG_THRUST));
|
double avgImpulse = mCursor.getDouble(mCursor.getColumnIndex(AVG_THRUST));
|
||||||
double maxThrust = mCursor.getDouble(mCursor.getColumnIndex(MAX_THRUST));
|
double maxThrust = mCursor.getDouble(mCursor.getColumnIndex(MAX_THRUST));
|
||||||
double length = mCursor.getDouble(mCursor.getColumnIndex(LENGTH));
|
double length = mCursor.getDouble(mCursor.getColumnIndex(LENGTH));
|
||||||
Motor.Type type = Motor.Type.fromName( mCursor.getString(mCursor.getColumnIndex(TYPE)));
|
Motor.Type type;
|
||||||
|
try {
|
||||||
|
type = Enum.valueOf(Motor.Type.class, mCursor.getString(mCursor.getColumnIndex(TYPE)));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
type = Motor.Type.UNKNOWN;
|
||||||
|
}
|
||||||
Manufacturer manufacturer = Manufacturer.getManufacturer(mCursor.getString(mCursor.getColumnIndex(MANUFACTURER)));
|
Manufacturer manufacturer = Manufacturer.getManufacturer(mCursor.getString(mCursor.getColumnIndex(MANUFACTURER)));
|
||||||
double[] thrustData = ConversionUtils.deserializeArrayOfDouble(mCursor.getBlob(mCursor.getColumnIndex(THRUST_DATA)));
|
double[] thrustData = ConversionUtils.deserializeArrayOfDouble(mCursor.getBlob(mCursor.getColumnIndex(THRUST_DATA)));
|
||||||
double[] timeData = ConversionUtils.deserializeArrayOfDouble(mCursor.getBlob(mCursor.getColumnIndex(TIME_DATA)));
|
double[] timeData = ConversionUtils.deserializeArrayOfDouble(mCursor.getBlob(mCursor.getColumnIndex(TIME_DATA)));
|
||||||
@ -241,8 +247,7 @@ public class MotorDao {
|
|||||||
}
|
}
|
||||||
mCursor.moveToFirst();
|
mCursor.moveToFirst();
|
||||||
return hydrateMotor(mCursor);
|
return hydrateMotor(mCursor);
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
mCursor.close();
|
mCursor.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,8 +270,7 @@ public class MotorDao {
|
|||||||
}
|
}
|
||||||
mCursor.moveToFirst();
|
mCursor.moveToFirst();
|
||||||
return hydrateMotor(mCursor);
|
return hydrateMotor(mCursor);
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
mCursor.close();
|
mCursor.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user