@Test public void hasCorrectIdealValues() throws Exception { ExpansionValueRange expansionValueRange = new ExpansionValueRange(9, 32); assertEquals(new ExpansionValueRange(15, 19), expansionCategoryFormatter.getIdealValueRange(Category.TEMPERATURE, expansionValueRange)); expansionValueRange = new ExpansionValueRange(1, 100); assertEquals(new ExpansionValueRange(20, 20), expansionCategoryFormatter.getIdealValueRange(Category.LIGHT, expansionValueRange)); }
public ExpansionValueRange getIdealValueRange(@NonNull final Category category, @NonNull final ExpansionValueRange valueRange) { final float mid = valueRange.max - valueRange.min; final float min; switch (category) { case TEMPERATURE: min = valueRange.min + (int) (mid * DEFAULT_TEMP_MULTIPLIER); return new ExpansionValueRange(min, min + 4); case LIGHT: min = valueRange.min + (int) (mid * DEFAULT_LIGHT_MULTIPLIER); return new ExpansionValueRange(min, min); } return new ExpansionValueRange(mid, mid); }
ExpansionCategoryFormatter { public ExpansionValueRange getIdealValueRange(@NonNull final Category category, @NonNull final ExpansionValueRange valueRange) { final float mid = valueRange.max - valueRange.min; final float min; switch (category) { case TEMPERATURE: min = valueRange.min + (int) (mid * DEFAULT_TEMP_MULTIPLIER); return new ExpansionValueRange(min, min + 4); case LIGHT: min = valueRange.min + (int) (mid * DEFAULT_LIGHT_MULTIPLIER); return new ExpansionValueRange(min, min); } return new ExpansionValueRange(mid, mid); } }
ExpansionCategoryFormatter { public ExpansionValueRange getIdealValueRange(@NonNull final Category category, @NonNull final ExpansionValueRange valueRange) { final float mid = valueRange.max - valueRange.min; final float min; switch (category) { case TEMPERATURE: min = valueRange.min + (int) (mid * DEFAULT_TEMP_MULTIPLIER); return new ExpansionValueRange(min, min + 4); case LIGHT: min = valueRange.min + (int) (mid * DEFAULT_LIGHT_MULTIPLIER); return new ExpansionValueRange(min, min); } return new ExpansionValueRange(mid, mid); } @Inject  ExpansionCategoryFormatter(@NonNull final UnitFormatter unitFormatter); }
ExpansionCategoryFormatter { public ExpansionValueRange getIdealValueRange(@NonNull final Category category, @NonNull final ExpansionValueRange valueRange) { final float mid = valueRange.max - valueRange.min; final float min; switch (category) { case TEMPERATURE: min = valueRange.min + (int) (mid * DEFAULT_TEMP_MULTIPLIER); return new ExpansionValueRange(min, min + 4); case LIGHT: min = valueRange.min + (int) (mid * DEFAULT_LIGHT_MULTIPLIER); return new ExpansionValueRange(min, min); } return new ExpansionValueRange(mid, mid); } @Inject  ExpansionCategoryFormatter(@NonNull final UnitFormatter unitFormatter); String getFormattedValueRange(@NonNull final Category category,
                                         @NonNull final ExpansionValueRange valueRange,
                                         @NonNull final Context context); Pair<Integer,Integer> getInitialValuePair(@NonNull final Category category,
                                     @NonNull final List<Capability> capabilities,
                                     @NonNull final ExpansionValueRange valueRange); ExpansionValueRange getIdealValueRange(@NonNull final Category category,
                                                  @NonNull final ExpansionValueRange valueRange); UnitConverter getUnitConverter(@NonNull final Category category); UnitConverter getReverseUnitConverter(@NonNull final Category category); String getFormattedAttributionValueRange(@NonNull final Category category,
                                                    @NonNull final ExpansionValueRange expansionRange,
                                                    @NonNull final Context context); String getSuffix(@NonNull final Category category); @DrawableRes int getDisplayIconRes(@NonNull final Category category); @StringRes int getDisplayValueResFromState(@NonNull final State expansionState); @XmlRes int getExpansionInfoDialogXmlRes(@NonNull final Category category); @XmlRes int getExpansionAlarmInfoDialogXmlRes(@NonNull final Category category); }
ExpansionCategoryFormatter { public ExpansionValueRange getIdealValueRange(@NonNull final Category category, @NonNull final ExpansionValueRange valueRange) { final float mid = valueRange.max - valueRange.min; final float min; switch (category) { case TEMPERATURE: min = valueRange.min + (int) (mid * DEFAULT_TEMP_MULTIPLIER); return new ExpansionValueRange(min, min + 4); case LIGHT: min = valueRange.min + (int) (mid * DEFAULT_LIGHT_MULTIPLIER); return new ExpansionValueRange(min, min); } return new ExpansionValueRange(mid, mid); } @Inject  ExpansionCategoryFormatter(@NonNull final UnitFormatter unitFormatter); String getFormattedValueRange(@NonNull final Category category,
                                         @NonNull final ExpansionValueRange valueRange,
                                         @NonNull final Context context); Pair<Integer,Integer> getInitialValuePair(@NonNull final Category category,
                                     @NonNull final List<Capability> capabilities,
                                     @NonNull final ExpansionValueRange valueRange); ExpansionValueRange getIdealValueRange(@NonNull final Category category,
                                                  @NonNull final ExpansionValueRange valueRange); UnitConverter getUnitConverter(@NonNull final Category category); UnitConverter getReverseUnitConverter(@NonNull final Category category); String getFormattedAttributionValueRange(@NonNull final Category category,
                                                    @NonNull final ExpansionValueRange expansionRange,
                                                    @NonNull final Context context); String getSuffix(@NonNull final Category category); @DrawableRes int getDisplayIconRes(@NonNull final Category category); @StringRes int getDisplayValueResFromState(@NonNull final State expansionState); @XmlRes int getExpansionInfoDialogXmlRes(@NonNull final Category category); @XmlRes int getExpansionAlarmInfoDialogXmlRes(@NonNull final Category category);  }