r82 - in trunk: res/values res/values-fr src/fr/ifremer/wlo src/fr/ifremer/wlo/utils
Author: kmorin Date: 2014-03-18 17:15:11 +0100 (Tue, 18 Mar 2014) New Revision: 82 Url: http://forge.codelutin.com/projects/wlo/repository/revisions/82 Log: fixes #4742 [ERGO] ne pas afficher les "Non d?\195?\169fini - Non d?\195?\169fini - Non d?\195?\169fini" ou 'NA, NA" Modified: trunk/res/values-fr/strings.xml trunk/res/values/strings.xml trunk/src/fr/ifremer/wlo/WeightsActivity.java trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java Modified: trunk/res/values/strings.xml =================================================================== --- trunk/res/values/strings.xml 2014-03-17 18:25:25 UTC (rev 81) +++ trunk/res/values/strings.xml 2014-03-18 16:15:11 UTC (rev 82) @@ -232,7 +232,7 @@ <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 (gender / maturity / age)</string> + <string name="scientific_species_categories">Weights per category</string> <!--File chooser--> <string name="file_chooser_location">Location</string> Modified: trunk/res/values-fr/strings.xml =================================================================== --- trunk/res/values-fr/strings.xml 2014-03-17 18:25:25 UTC (rev 81) +++ trunk/res/values-fr/strings.xml 2014-03-18 16:15:11 UTC (rev 82) @@ -224,7 +224,7 @@ <string name="commercial_species_total_unloaded_weight">Poids total débarqué</string> <string name="scientific_species_sorted_weight">Poids trié</string> <string name="scientific_species_sample_weight">Poids d\'échantillon</string> - <string name="scientific_species_categories">Poids par catégorie (Sexe / maturité / age)</string> + <string name="scientific_species_categories">Poids par catégorie</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-03-17 18:25:25 UTC (rev 81) +++ trunk/src/fr/ifremer/wlo/WeightsActivity.java 2014-03-18 16:15:11 UTC (rev 82) @@ -102,17 +102,21 @@ commercialSpeciesModel = (CommercialSpeciesModel) getIntent().getSerializableExtra(INTENT_COMMERCIAL_SPECIES); + List<String> categoryLabels = new ArrayList<>(); CategoryModel category1 = commercialSpeciesModel.getCategory1(); if (category1 != null) { valuesById.putAll(Maps.uniqueIndex(category1.getQualitativeValues(), BaseModel.GET_ID_FUNCTION)); + categoryLabels.add(category1.getLabel()); } CategoryModel category2 = commercialSpeciesModel.getCategory2(); if (category2 != null) { valuesById.putAll(Maps.uniqueIndex(category2.getQualitativeValues(), BaseModel.GET_ID_FUNCTION)); + categoryLabels.add(category2.getLabel()); } CategoryModel category3 = commercialSpeciesModel.getCategory3(); if (category3 != null) { valuesById.putAll(Maps.uniqueIndex(category3.getQualitativeValues(), BaseModel.GET_ID_FUNCTION)); + categoryLabels.add(category3.getLabel()); } getSupportActionBar().setSubtitle(commercialSpeciesModel.toString(this)); @@ -179,50 +183,68 @@ } }); - // weight per category - TextView weightByCategoryView = new TextView(this); - weightByCategoryView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); - weightByCategoryView.setTextAppearance(this, android.R.style.TextAppearance_Medium); - weightByCategoryView.setText(R.string.scientific_species_categories); - container.addView(weightByCategoryView); + if (!categoryLabels.isEmpty()) { + // weight per category + TextView weightByCategoryView = new TextView(this); + weightByCategoryView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); + weightByCategoryView.setTextAppearance(this, android.R.style.TextAppearance_Medium); + String weightByCategoryViewText = getString(R.string.scientific_species_categories) + + " (" + StringUtils.join(categoryLabels, " / ") + ")"; + weightByCategoryView.setText(weightByCategoryViewText); + container.addView(weightByCategoryView); - // get all the category weights - Cursor categoryWeighs = woh.getAllCategoryWeigths(scientificSpecies.getId()); - categoryWeightModels = WloSqlOpenHelper.transformCursorIntoCollection(categoryWeighs, - new Function<Cursor, CategoryWeightModel>() { - @Override - public CategoryWeightModel apply(Cursor input) { - CategoryWeightModel result = new CategoryWeightModel(input); - result.setParent(scientificSpecies); - return result; - } - }); + // get all the category weights + Cursor categoryWeighs = woh.getAllCategoryWeigths(scientificSpecies.getId()); + categoryWeightModels = WloSqlOpenHelper.transformCursorIntoCollection(categoryWeighs, + new Function<Cursor, CategoryWeightModel>() { + @Override + public CategoryWeightModel apply(Cursor input) { + CategoryWeightModel result = new CategoryWeightModel(input); + result.setParent(scientificSpecies); + return result; + } + }); - for (final CategoryWeightModel categoryWeightModel : categoryWeightModels) { - // create the weight field - QualitativeValueModel category1Value = valuesById.get(categoryWeightModel.getCategory1()); - QualitativeValueModel category2Value = valuesById.get(categoryWeightModel.getCategory2()); - QualitativeValueModel category3Value = valuesById.get(categoryWeightModel.getCategory3()); + for (final CategoryWeightModel categoryWeightModel : categoryWeightModels) { + // create the weight field - String category1ValueLabel = category1Value != null ? category1Value.toString() : categoryWeightModel.getCategory1(); - String category2ValueLabel = category2Value != null ? category2Value.toString() : categoryWeightModel.getCategory2(); - String category3ValueLabel = category3Value != null ? category3Value.toString() : categoryWeightModel.getCategory3(); + List<String> labels = new ArrayList<>(); - String label = (category1ValueLabel != null ? category1ValueLabel : "NA") + ", " + - (category2ValueLabel != null ? category2ValueLabel : "NA") + ", " + - (category3ValueLabel != null ? category3ValueLabel : "NA"); + String categoryWeightModelCategory1 = categoryWeightModel.getCategory1(); + if (categoryWeightModelCategory1 != null) { + QualitativeValueModel category1Value = valuesById.get(categoryWeightModelCategory1); + String category1ValueLabel = category1Value != null ? category1Value.toString() : categoryWeightModelCategory1; + labels.add(category1ValueLabel); + } - // add label - createWeightLabel(label); + String categoryWeightModelCategory2 = categoryWeightModel.getCategory2(); + if (categoryWeightModelCategory2 != null) { + QualitativeValueModel category2Value = valuesById.get(categoryWeightModelCategory2); + String category2ValueLabel = category2Value != null ? category2Value.toString() : categoryWeightModelCategory2; + labels.add(category2ValueLabel); + } - createEditText(categoryWeightModel.getWeight(), new Function<Integer, Void>() { - @Override - public Void apply(Integer input) { - categoryWeightModel.setWeight(input); - return null; + String categoryWeightModelCategory3 = categoryWeightModel.getCategory3(); + if (categoryWeightModelCategory3 != null) { + QualitativeValueModel category3Value = valuesById.get(categoryWeightModelCategory3); + String category3ValueLabel = category3Value != null ? category3Value.toString() : categoryWeightModelCategory3; + labels.add(category3ValueLabel); } - }); + + String label = StringUtils.join(labels, " / "); + + // add label + createWeightLabel(label); + + createEditText(categoryWeightModel.getWeight(), new Function<Integer, Void>() { + @Override + public Void apply(Integer input) { + categoryWeightModel.setWeight(input); + return null; + } + }); + } } } woh.close(); Modified: trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java =================================================================== --- trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-03-17 18:25:25 UTC (rev 81) +++ trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-03-18 16:15:11 UTC (rev 82) @@ -120,7 +120,7 @@ break; } TextView textView = (TextView) view; - textView.setText(UIUtils.getStringOrUndefined(ref, context)); + textView.setText(ref != null ? ref.toString(context): ""); return true; } } @@ -128,7 +128,7 @@ String value = cursor.getString(columnIndex); if (value == null) { TextView textView = (TextView) view; - textView.setText(R.string.undefined); + textView.setText(""); return true; }
participants (1)
-
kmorin@users.forge.codelutin.com