/** * Returns whether or not BottomSheetLayout will assume it's being shown on a tablet. * * @param context Context instance to retrieve resources * @return True if BottomSheetLayout will assume it's being shown on a tablet, false if not */ public static boolean isTablet(Context context) { return context.getResources().getBoolean(R.bool.bottomsheet_is_tablet); }
private static boolean isPortrait(@NonNull Context context) { Resources res = context.getResources(); return res.getBoolean(R.bool.bb_bottom_bar_is_portrait_mode); }
/** * Check if layout is RTL * * @return true if RTL, false if not */ public boolean isRtl() { return builder.context.getResources().getBoolean(R.bool.wel_is_rtl); }
/** * Creates a ForecastAdapter. * * @param context Used to talk to the UI and app resources * @param clickHandler The on-click handler for this adapter. This single handler is called * when an item is clicked. */ public ForecastAdapter(@NonNull Context context, ForecastAdapterOnClickHandler clickHandler) { mContext = context; mClickHandler = clickHandler; mUseTodayLayout = mContext.getResources().getBoolean(R.bool.use_today_layout); }
/** * Creates a ForecastAdapter. * * @param context Used to talk to the UI and app resources * @param clickHandler The on-click handler for this adapter. This single handler is called * when an item is clicked. */ public ForecastAdapter(@NonNull Context context, ForecastAdapterOnClickHandler clickHandler) { mContext = context; mClickHandler = clickHandler; mUseTodayLayout = mContext.getResources().getBoolean(R.bool.use_today_layout); }
/** * Creates a ForecastAdapter. * * @param context Used to talk to the UI and app resources * @param clickHandler The on-click handler for this adapter. This single handler is called * when an item is clicked. */ public ForecastAdapter(@NonNull Context context, ForecastAdapterOnClickHandler clickHandler) { mContext = context; mClickHandler = clickHandler; mUseTodayLayout = mContext.getResources().getBoolean(R.bool.use_today_layout); }
private static @Nullable Unbinder parseBindBool(Object target, Field field, View source) { BindBool bindBool = field.getAnnotation(BindBool.class); if (bindBool == null) { return null; } validateMember(field); int id = bindBool.value(); Resources resources = source.getContext().getResources(); Object value; Class<?> fieldType = field.getType(); if (fieldType == boolean.class) { value = resources.getBoolean(id); } else { throw new IllegalStateException(); // TODO } trySet(field, target, value); return Unbinder.EMPTY; }
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals(getString(R.string.pref_show_bass_key))) { mVisualizerView.setShowBass(sharedPreferences.getBoolean(key, getResources().getBoolean(R.bool.pref_show_bass_default))); } else if (key.equals(getString(R.string.pref_show_mid_range_key))) { mVisualizerView.setShowMid(sharedPreferences.getBoolean(key, getResources().getBoolean(R.bool.pref_show_mid_range_default))); } else if (key.equals(getString(R.string.pref_show_treble_key))) { mVisualizerView.setShowTreble(sharedPreferences.getBoolean(key, getResources().getBoolean(R.bool.pref_show_treble_default))); } }
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals(getString(R.string.pref_show_bass_key))) { mVisualizerView.setShowBass(sharedPreferences.getBoolean(key, getResources().getBoolean(R.bool.pref_show_bass_default))); } else if (key.equals(getString(R.string.pref_show_mid_range_key))) { mVisualizerView.setShowMid(sharedPreferences.getBoolean(key, getResources().getBoolean(R.bool.pref_show_mid_range_default))); } else if (key.equals(getString(R.string.pref_show_treble_key))) { mVisualizerView.setShowTreble(sharedPreferences.getBoolean(key, getResources().getBoolean(R.bool.pref_show_treble_default))); } else if (key.equals(getString(R.string.pref_color_key))) { loadColorFromPreferences(sharedPreferences); } }
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals(getString(R.string.pref_show_bass_key))) { mVisualizerView.setShowBass(sharedPreferences.getBoolean(key, getResources().getBoolean(R.bool.pref_show_bass_default))); } else if (key.equals(getString(R.string.pref_show_mid_range_key))) { mVisualizerView.setShowMid(sharedPreferences.getBoolean(key, getResources().getBoolean(R.bool.pref_show_mid_range_default))); } else if (key.equals(getString(R.string.pref_show_treble_key))) { mVisualizerView.setShowTreble(sharedPreferences.getBoolean(key, getResources().getBoolean(R.bool.pref_show_treble_default))); } else if (key.equals(getString(R.string.pref_color_key))) { loadColorFromPreferences(sharedPreferences); } }
public boolean resolveBoolRes(@BoolRes int resId) { if (resId != 0) { Boolean cached = mResourceCache.get(resId); if (cached != null) { return cached; } boolean result = mResources.getBoolean(resId); mResourceCache.put(resId, result); return result; } return false; }
@Override public boolean isMultiPane() { return getResources().getBoolean(R.bool.multi_pane); } }
@Test public void getBoolean() throws Exception { assertThat(resources.getBoolean(R.bool.false_bool_value)).isEqualTo(false); assertThat(resources.getBoolean(R.bool.true_as_item)).isEqualTo(true); }
@Test @Config(qualifiers="w820dp") public void checkQualifiedBooleanValue() throws Exception { assertThat( ApplicationProvider.getApplicationContext() .getResources() .getBoolean(R.bool.different_resource_boolean)) .isEqualTo(true); }
@Test public void defaultScreenWidth() { assertThat(resources.getBoolean(R.bool.value_only_present_in_w320dp)).isTrue(); assertThat(resources.getConfiguration().screenWidthDp).isEqualTo(320); }
@Test @Config(qualifiers="w0dp") public void checkDefaultBooleanValue() throws Exception { assertThat( ApplicationProvider.getApplicationContext() .getResources() .getBoolean(R.bool.different_resource_boolean)) .isEqualTo(false); }
@Test public void asBoolean() { Target target = new Target(); boolean expected = context.getResources().getBoolean(R.bool.just_true); Unbinder unbinder = new BindBoolTest$Target_ViewBinding(target, context); assertThat(target.actual).isEqualTo(expected); unbinder.unbind(); assertThat(target.actual).isEqualTo(expected); } }
@Test public void getBoolean_withReference() throws Exception { assertThat(resources.getBoolean(R.bool.reference_to_true)).isEqualTo(true); }
@Test public void getDimension_withReference() { assertThat(resources.getBoolean(R.bool.reference_to_true)).isEqualTo(true); }
private void setupSharedPreferences() { // Get all of the values from shared preferences to set it up SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); // COMPLETED (4) Use resources here instead of the hard coded string and boolean mVisualizerView.setShowBass(sharedPreferences.getBoolean(getString(R.string.pref_show_bass_key), getResources().getBoolean(R.bool.pref_show_bass_default))); mVisualizerView.setShowMid(true); mVisualizerView.setShowTreble(true); mVisualizerView.setMinSizeScale(1); mVisualizerView.setColor(getString(R.string.pref_color_red_value)); }