Example usage for android.content.res Resources getBoolean

List of usage examples for android.content.res Resources getBoolean

Introduction

In this page you can find the example usage for android.content.res Resources getBoolean.

Prototype

public boolean getBoolean(@BoolRes int id) throws NotFoundException 

Source Link

Document

Return a boolean associated with a particular resource ID.

Usage

From source file:com.afayear.android.client.activity.DualPaneActivity.java

@Override
protected void onStart() {
    final FragmentManager fm = getSupportFragmentManager();
    if (!isDualPaneMode() && !FragmentManagerTrojan.isStateSaved(fm)) {
        for (int i = 0, count = fm.getBackStackEntryCount(); i < count; i++) {
            fm.popBackStackImmediate();/*from   w  w  w  . j a  v a  2s  .c  o m*/
        }
    }
    super.onStart();
    final Resources res = getResources();
    final boolean is_large_screen = res.getBoolean(R.bool.is_large_screen);
    final boolean dual_pane_in_portrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT,
            is_large_screen);
    final boolean dual_pane_in_landscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE,
            is_large_screen);
    final int orientation = res.getConfiguration().orientation;
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        if (mDualPaneInLandscape != dual_pane_in_landscape) {
            restart();
        }
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        if (mDualPaneInPortrait != dual_pane_in_portrait) {
            restart();
        }
        break;
    }
}

From source file:com.android.contacts.interactions.ImportDialogFragment.java

private void addItems(ArrayAdapter<AdapterEntry> adapter) {
    final Resources res = getActivity().getResources();
    if (res.getBoolean(R.bool.config_allow_import_from_vcf_file) && !mSimOnly) {
        adapter.add(new AdapterEntry(getString(R.string.import_from_vcf_file), R.string.import_from_vcf_file));
    }//from w  w  w .ja v a  2  s  . co m
    final List<SimCard> sims = mSimDao.getSimCards();

    if (sims.size() == 1) {
        adapter.add(
                new AdapterEntry(getString(R.string.import_from_sim), R.string.import_from_sim, sims.get(0)));
        return;
    }
    for (int i = 0; i < sims.size(); i++) {
        final SimCard sim = sims.get(i);
        adapter.add(new AdapterEntry(getSimDescription(sim, i), R.string.import_from_sim, sim));
    }
}

From source file:com.schedjoules.eventdiscovery.framework.eventlist.EventListHeaderFragment.java

private void setupToolbar(SchedjoulesFragmentEventListHeaderBinding views) {
    Toolbar toolbar = views.schedjoulesEventListToolbar;
    toolbar.setTitle(""); // Need to set it to empty, otherwise the activity label is set automatically

    mToolbarTitle = views.schedjoulesEventListToolbarTitle;
    mToolbarTitle.setOnClickListener(new View.OnClickListener() {
        @Override// w ww .j  a  v  a2 s .c om
        public void onClick(View v) {
            new LocationPickerPlaceSelection().start(EventListHeaderFragment.this);
        }
    });

    BaseActivity activity = (BaseActivity) getActivity();
    activity.setSupportActionBar(toolbar);

    Resources res = activity.getResources();
    toolbar.setContentInsetsAbsolute(
            res.getDimensionPixelSize(R.dimen.schedjoules_list_item_padding_horizontal),
            toolbar.getContentInsetRight());

    if (res.getBoolean(R.bool.schedjoules_enableBackArrowOnEventListScreen)) {
        //noinspection ConstantConditions
        activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    updateToolbarTitle();
}

From source file:org.mariotaku.twidere.activity.support.DualPaneActivity.java

@Override
protected void onStart() {
    final FragmentManager fm = getSupportFragmentManager();
    if (!isDualPaneMode() && !FragmentManagerTrojan.isStateSaved(fm)) {
        // for (int i = 0, count = fm.getBackStackEntryCount(); i < count;
        // i++) {
        // fm.popBackStackImmediate();
        // }/*  w w  w.  ja v a2s . co  m*/
        fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }
    super.onStart();
    final Resources res = getResources();
    final boolean is_large_screen = res.getBoolean(R.bool.is_large_screen);
    final boolean dual_pane_in_portrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT,
            is_large_screen);
    final boolean dual_pane_in_landscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE,
            is_large_screen);
    final int orientation = res.getConfiguration().orientation;
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        if (mDualPaneInLandscape != dual_pane_in_landscape) {
            restart();
        }
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        if (mDualPaneInPortrait != dual_pane_in_portrait) {
            restart();
        }
        break;
    }
}

From source file:android.support.v7.internal.view.menu.ActionMenuItemView.java

public ActionMenuItemView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    final Resources res = context.getResources();
    mAllowTextWithIcon = res.getBoolean(R.bool.abc_config_allowActionMenuItemTextWithIcon);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ActionMenuItemView, defStyle, 0);
    mMinWidth = a.getDimensionPixelSize(R.styleable.ActionMenuItemView_android_minWidth, 0);
    a.recycle();// www  .  j ava 2s.  c o  m

    final float density = res.getDisplayMetrics().density;
    mMaxIconSize = (int) (MAX_ICON_SIZE * density + 0.5f);

    setOnClickListener(this);
    setOnLongClickListener(this);

    mSavedPaddingLeft = -1;
}

From source file:org.jraf.android.bikey.app.ride.map.RideMapActivity.java

private boolean hasNavigationBar() {
    Resources res = getResources();
    int resourceId = res.getIdentifier("config_showNavigationBar", "bool", "android");
    if (resourceId != 0) {
        boolean hasNav = res.getBoolean(resourceId);

        return hasNav;
    }/*from  ww  w . j  a  v  a 2 s.  c o m*/
    // Fallback
    return !ViewConfiguration.get(this).hasPermanentMenuKey();
}

From source file:com.afayear.android.client.activity.DualPaneActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    super.onCreate(savedInstanceState);
    final Resources res = getResources();
    final int orientation = res.getConfiguration().orientation;
    final int layout;
    final boolean is_large_screen = res.getBoolean(R.bool.is_large_screen);
    mDualPaneInPortrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT, is_large_screen);
    mDualPaneInLandscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE, is_large_screen);
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        layout = mDualPaneInLandscape || shouldForceEnableDualPaneMode() ? getDualPaneLayoutRes()
                : getNormalLayoutRes();/*www  . java2 s . c  om*/
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        layout = mDualPaneInPortrait || shouldForceEnableDualPaneMode() ? getDualPaneLayoutRes()
                : getNormalLayoutRes();
        break;
    default:
        layout = getNormalLayoutRes();
        break;
    }
    setContentView(layout);
    if (mSlidingPane != null) {
        mSlidingPane.setRightPaneBackground(getPaneBackground());
    }
    final FragmentManager fm = getSupportFragmentManager();
    fm.addOnBackStackChangedListener(this);
    if (savedInstanceState != null) {
        final Fragment left_pane_fragment = fm.findFragmentById(PANE_LEFT);
        final View main_view = findViewById(R.id.main);
        final boolean left_pane_used = left_pane_fragment != null && left_pane_fragment.isAdded();
        if (main_view != null) {
            final int visibility = left_pane_used ? View.GONE : View.VISIBLE;
            main_view.setVisibility(visibility);
        }
    }
}

From source file:org.mariotaku.twidere.activity.support.DualPaneActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    super.onCreate(savedInstanceState);
    final Resources res = getResources();
    final int orientation = res.getConfiguration().orientation;
    final int layout;
    final boolean is_large_screen = res.getBoolean(R.bool.is_large_screen);
    mDualPaneInPortrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT, is_large_screen);
    mDualPaneInLandscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE, is_large_screen);
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        layout = mDualPaneInLandscape || shouldForceEnableDualPaneMode() ? getDualPaneLayoutRes()
                : getNormalLayoutRes();//  w  w  w.  j a  va2  s  .  c o m
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        layout = mDualPaneInPortrait || shouldForceEnableDualPaneMode() ? getDualPaneLayoutRes()
                : getNormalLayoutRes();
        break;
    default:
        layout = getNormalLayoutRes();
        break;
    }
    setContentView(layout);
    if (mSlidingPane != null) {
        mSlidingPane.setRightPaneBackground(getPaneBackground());
    }
    final FragmentManager fm = getSupportFragmentManager();
    fm.addOnBackStackChangedListener(this);
    if (savedInstanceState != null) {
        updateMainViewVisibility();
    }
}

From source file:co.paulburke.android.textviewpager.TextViewPagerIndicator.java

public TextViewPagerIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;// w  ww  .  j  av  a 2  s. c  om

    final Resources res = getResources();

    // Load defaults from resources
    final boolean defaultFades = res.getBoolean(R.bool.scroll_indicator_fades);
    final int defaultFadeDelay = res.getInteger(R.integer.scroll_indicator_fade_delay);
    final int defaultFadeLength = res.getInteger(R.integer.scroll_indicator_fade_length);
    final int defaultSelectedColor = res.getColor(R.color.scroll_indicator_selected_color);

    // Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextViewPagerIndicator, defStyle, 0);

    setFades(a.getBoolean(R.styleable.TextViewPagerIndicator_fades, defaultFades));
    setSelectedColor(a.getColor(R.styleable.TextViewPagerIndicator_selectedColor, defaultSelectedColor));
    setFadeDelay(a.getInteger(R.styleable.TextViewPagerIndicator_fadeDelay, defaultFadeDelay));
    setFadeLength(a.getInteger(R.styleable.TextViewPagerIndicator_fadeLength, defaultFadeLength));

    Drawable background = a.getDrawable(R.styleable.TextViewPagerIndicator_android_background);
    if (background != null)
        setBackgroundDrawable(background);

    a.recycle();
}

From source file:com.lovebridge.library.view.viewpagerindicator.UnderlinePageIndicator.java

public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from w w  w. java  2s . c o m*/
    final Resources res = getResources();
    // Load defaults from resources
    final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades);
    final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay);
    final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length);
    final int defaultSelectedColor = res.getColor(R.color.default_underline_indicator_selected_color);
    // Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UnderlinePageIndicator, defStyle, 0);
    setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades));
    setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor));
    setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay));
    setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength));
    Drawable background = a.getDrawable(R.styleable.UnderlinePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }
    a.recycle();
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}