r50 - in trunk: res/values res/values-fr src/fr/ifremer/wlo src/fr/ifremer/wlo/models src/fr/ifremer/wlo/storage src/fr/ifremer/wlo/utils
Author: kmorin Date: 2014-02-19 11:17:11 +0100 (Wed, 19 Feb 2014) New Revision: 50 Url: http://forge.codelutin.com/projects/wlo/repository/revisions/50 Log: fixes #4192 [SAISIE] ?\195?\137cran des poids [niveau 5 ?\195?\160 7] Modified: trunk/res/values-fr/strings.xml trunk/res/values/strings.xml trunk/src/fr/ifremer/wlo/WeightsActivity.java trunk/src/fr/ifremer/wlo/models/CategoryWeightModel.java trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java trunk/src/fr/ifremer/wlo/utils/BigFinFeedReaderRecord.java Modified: trunk/res/values/strings.xml =================================================================== --- trunk/res/values/strings.xml 2014-02-17 13:32:31 UTC (rev 49) +++ trunk/res/values/strings.xml 2014-02-19 10:17:11 UTC (rev 50) @@ -171,8 +171,9 @@ <!-- Weights --> <string name="weights_title">Weights</string> <string name="commercial_species_total_unloaded_weight">Total unloaded weight</string> + <string name="scientific_species_sorted_weight">Sorted weight</string> <string name="scientific_species_sample_weight">Sample weight</string> - <string name="scientific_species_categories">Weights per category</string> + <string name="scientific_species_categories">Weights per category (gender / maturity / age)</string> <!--File chooser--> <string name="file_chooser_location">Location</string> Modified: trunk/res/values-fr/strings.xml =================================================================== --- trunk/res/values-fr/strings.xml 2014-02-17 13:32:31 UTC (rev 49) +++ trunk/res/values-fr/strings.xml 2014-02-19 10:17:11 UTC (rev 50) @@ -164,8 +164,9 @@ <!-- Weights --> <string name="weights_title">Poids</string> <string name="commercial_species_total_unloaded_weight">Poids total débarqué</string> + <string name="scientific_species_sample_weight">Poids trié</string> <string name="scientific_species_sample_weight">Poids d\'échantillon</string> - <string name="scientific_species_categories">Poids par catégorie</string> + <string name="scientific_species_categories">Poids par catégorie (Sexe / maturité / age)</string> <!--File chooser--> <string name="file_chooser_location">Emplacement</string> Modified: trunk/src/fr/ifremer/wlo/WeightsActivity.java =================================================================== --- trunk/src/fr/ifremer/wlo/WeightsActivity.java 2014-02-17 13:32:31 UTC (rev 49) +++ trunk/src/fr/ifremer/wlo/WeightsActivity.java 2014-02-19 10:17:11 UTC (rev 50) @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Locale; /** * @author Kevin Morin (Code Lutin) @@ -109,6 +110,18 @@ container.addView(labelView); // add label + createWeightLabel(getString(R.string.scientific_species_sorted_weight)); + + // create the sorted weight field + createEditText(scientificSpecies.getSortedWeight(), new Function<Integer, Void>() { + @Override + public Void apply(Integer input) { + scientificSpecies.setSortedWeight(input); + return null; + } + }); + + // add label createWeightLabel(getString(R.string.scientific_species_sample_weight)); // create the sample weight field @@ -201,7 +214,12 @@ public void onTextChanged(CharSequence s, int start, int before, int count) { Integer newValue = null; if (StringUtils.isNotEmpty(s)) { - newValue = Integer.parseInt(s.toString()); + if (weightUnit > 1) { + newValue = (int) (Float.parseFloat(s.toString()) * weightUnit); + + } else { + newValue = Integer.parseInt(s.toString()); + } } setWeightFunction.apply(newValue); editText.setSelection(start + count); @@ -213,18 +231,20 @@ final EditText editText = new EditText(this); int inputType = InputType.TYPE_CLASS_NUMBER; - String textValue; + String textValue = null; - if (weightUnit > 1) { - inputType |= InputType.TYPE_NUMBER_FLAG_DECIMAL; - } + if (value != null) { + if (weightUnit > 1) { + inputType |= InputType.TYPE_NUMBER_FLAG_DECIMAL; + } - if (weightUnit > 1 && value != null) { - float floatValue = (float) value / weightUnit; - textValue = String.format("%.3f", floatValue); + if (weightUnit > 1 && value != null) { + float floatValue = (float) value / weightUnit; + textValue = String.format(Locale.US, "%.3f", floatValue); - } else { - textValue = String.valueOf(value); + } else { + textValue = String.valueOf(value); + } } editText.setInputType(inputType); editText.setText(textValue); Modified: trunk/src/fr/ifremer/wlo/models/CategoryWeightModel.java =================================================================== --- trunk/src/fr/ifremer/wlo/models/CategoryWeightModel.java 2014-02-17 13:32:31 UTC (rev 49) +++ trunk/src/fr/ifremer/wlo/models/CategoryWeightModel.java 2014-02-19 10:17:11 UTC (rev 50) @@ -46,7 +46,9 @@ category1 = cursor.getString(1); category2 = cursor.getString(2); category3 = cursor.getString(3); - weight = cursor.getInt(4); + if (!cursor.isNull(4)) { + weight = cursor.getInt(4); + } } public String getCategory1() { return category1; Modified: trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java =================================================================== --- trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java 2014-02-17 13:32:31 UTC (rev 49) +++ trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java 2014-02-19 10:17:11 UTC (rev 50) @@ -99,7 +99,9 @@ String presentationId = cursor.getString(7); presentation = DataCache.getPresentationById(context, presentationId); comment = cursor.getString(8); - totalUnloadedWeight = cursor.getInt(9); + if (!cursor.isNull(9)) { + totalUnloadedWeight = cursor.getInt(9); + } } public CommercialSpecies getFaoCode() { Modified: trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java =================================================================== --- trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java 2014-02-17 13:32:31 UTC (rev 49) +++ trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java 2014-02-19 10:17:11 UTC (rev 50) @@ -44,6 +44,7 @@ public static final String COLUMN_NAME = "name"; public static final String COLUMN_TAKING_ACTIVATION = "takingActivation"; public static final String COLUMN_COMMENT = "comment"; + public static final String COLUMN_SORTED_WEIGHT = "sortedWeight"; public static final String COLUMN_SAMPLE_WEIGHT = "sampleWeight"; public static final String COLUMN_COMMERCIAL_SPECIES_ID = "commercialSpeciesId"; public static final String[] ALL_COLUMNS = new String[] { @@ -51,6 +52,7 @@ COLUMN_NAME, COLUMN_TAKING_ACTIVATION, COLUMN_COMMENT, + COLUMN_SORTED_WEIGHT, COLUMN_SAMPLE_WEIGHT, COLUMN_COMMERCIAL_SPECIES_ID }; @@ -58,6 +60,7 @@ protected ScientificSpecies name; protected boolean takingActivation; protected String comment; + protected Integer sortedWeight; protected Integer sampleWeight; public ScientificSpeciesModel() { @@ -69,7 +72,12 @@ name = DataCache.getScientificSpeciesById(context, nameId); takingActivation = cursor.getShort(2) > 0; comment = cursor.getString(3); - sampleWeight = cursor.getInt(4); + if (!cursor.isNull(4)) { + sortedWeight = cursor.getInt(4); + } + if (!cursor.isNull(5)) { + sampleWeight = cursor.getInt(5); + } } public ScientificSpecies getName() { @@ -102,6 +110,16 @@ firePropertyChange(COLUMN_COMMENT, oldValue, comment); } + public Integer getSortedWeight() { + return sortedWeight; + } + + public void setSortedWeight(Integer sortedWeight) { + Object oldValue = this.sortedWeight; + this.sortedWeight = sortedWeight; + firePropertyChange(COLUMN_SORTED_WEIGHT, oldValue, sortedWeight); + } + public Integer getSampleWeight() { return sampleWeight; } @@ -128,6 +146,7 @@ putValue(value, COLUMN_NAME, name != null ? name.getId() : null); putValue(value, COLUMN_TAKING_ACTIVATION, takingActivation ? 1 : 0); putValue(value, COLUMN_COMMENT, comment); + putValue(value, COLUMN_SORTED_WEIGHT, sortedWeight); putValue(value, COLUMN_SAMPLE_WEIGHT, sampleWeight); putValue(value, COLUMN_COMMERCIAL_SPECIES_ID, getParentId()); return value; Modified: trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java =================================================================== --- trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-02-17 13:32:31 UTC (rev 49) +++ trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-02-19 10:17:11 UTC (rev 50) @@ -67,7 +67,7 @@ private static final String TAG = "WloOpenHelper"; public static final String DATABASE_NAME = "wlo.db"; - public static final int DATABASE_VERSION = 16; + public static final int DATABASE_VERSION = 17; public static final String TEXT_TYPE = " TEXT"; public static final String BIGINT_TYPE = " BIGINT"; @@ -179,6 +179,7 @@ ScientificSpeciesModel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP + ScientificSpeciesModel.COLUMN_TAKING_ACTIVATION + BYTE_TYPE + COMMA_SEP + ScientificSpeciesModel.COLUMN_COMMENT + TEXT_TYPE + COMMA_SEP + + ScientificSpeciesModel.COLUMN_SORTED_WEIGHT + BIGINT_TYPE + COMMA_SEP + ScientificSpeciesModel.COLUMN_SAMPLE_WEIGHT + BIGINT_TYPE + COMMA_SEP + ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP + "FOREIGN KEY(" + ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + ") REFERENCES " + Modified: trunk/src/fr/ifremer/wlo/utils/BigFinFeedReaderRecord.java =================================================================== --- trunk/src/fr/ifremer/wlo/utils/BigFinFeedReaderRecord.java 2014-02-17 13:32:31 UTC (rev 49) +++ trunk/src/fr/ifremer/wlo/utils/BigFinFeedReaderRecord.java 2014-02-19 10:17:11 UTC (rev 50) @@ -155,7 +155,7 @@ // remove any starting 0 lengthCell = lengthCell.replaceAll("^0*", ""); - length = Float.valueOf(lengthCell) * 10; + length = Float.valueOf(lengthCell); } catch (Exception e) { Log.e(TAG, "Could not get length from " + record, e);
participants (1)
-
kmorin@users.forge.codelutin.com