@Test public void isWithinVolumeThreshold() throws Exception { final int baseVolume = 50; final int lowerBoundVolume = baseVolume - SenseVoiceSettings.VOLUME_EQUALS_THRESHOLD; final int upperBoundVolume = baseVolume + SenseVoiceSettings.VOLUME_EQUALS_THRESHOLD; final SenseVoiceSettings baseSetting = new SenseVoiceSettings(baseVolume, false, false); for (int volume = lowerBoundVolume; volume <= upperBoundVolume; volume++) { assertTrue(baseSetting.isWithinVolumeThreshold(volume)); } assertFalse(baseSetting.isWithinVolumeThreshold(lowerBoundVolume - 1)); assertFalse(baseSetting.isWithinVolumeThreshold(upperBoundVolume + 1)); }
public boolean isWithinVolumeThreshold(final int otherVolume) { return Math.abs(volume - otherVolume) <= VOLUME_EQUALS_THRESHOLD; }
SenseVoiceSettings extends ApiResponse { public boolean isWithinVolumeThreshold(final int otherVolume) { return Math.abs(volume - otherVolume) <= VOLUME_EQUALS_THRESHOLD; } }
SenseVoiceSettings extends ApiResponse { public boolean isWithinVolumeThreshold(final int otherVolume) { return Math.abs(volume - otherVolume) <= VOLUME_EQUALS_THRESHOLD; } SenseVoiceSettings(final Integer volume,
                              final Boolean isMuted,
                              final Boolean isPrimaryUser);  SenseVoiceSettings(final int volume,
                              final boolean isMuted,
                              final boolean isPrimaryUser); }
SenseVoiceSettings extends ApiResponse { public boolean isWithinVolumeThreshold(final int otherVolume) { return Math.abs(volume - otherVolume) <= VOLUME_EQUALS_THRESHOLD; } SenseVoiceSettings(final Integer volume,
                              final Boolean isMuted,
                              final Boolean isPrimaryUser);  SenseVoiceSettings(final int volume,
                              final boolean isMuted,
                              final boolean isPrimaryUser); static SenseVoiceSettings newInstance(@NonNull final SenseVoiceSettings latestSettings); @Nullable Integer getVolume(); void setVolume(final int volume); @Nullable Boolean isMuted(); void setMuted(final boolean muted); @Nullable Boolean isPrimaryUser(); void setPrimaryUser(final boolean primaryUser); boolean isWithinVolumeThreshold(final int otherVolume); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); Boolean isPrimaryUserOrDefault(); Boolean isMuteOrDefault(); Integer getVolumeOrDefault(); }
SenseVoiceSettings extends ApiResponse { public boolean isWithinVolumeThreshold(final int otherVolume) { return Math.abs(volume - otherVolume) <= VOLUME_EQUALS_THRESHOLD; } SenseVoiceSettings(final Integer volume,
                              final Boolean isMuted,
                              final Boolean isPrimaryUser);  SenseVoiceSettings(final int volume,
                              final boolean isMuted,
                              final boolean isPrimaryUser); static SenseVoiceSettings newInstance(@NonNull final SenseVoiceSettings latestSettings); @Nullable Integer getVolume(); void setVolume(final int volume); @Nullable Boolean isMuted(); void setMuted(final boolean muted); @Nullable Boolean isPrimaryUser(); void setPrimaryUser(final boolean primaryUser); boolean isWithinVolumeThreshold(final int otherVolume); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); Boolean isPrimaryUserOrDefault(); Boolean isMuteOrDefault(); Integer getVolumeOrDefault(); @VisibleForTesting
    static final int VOLUME_EQUALS_THRESHOLD; static final int TOTAL_VOLUME_LEVELS; static final int DEFAULT_START_VOLUME; }